Skip to content

Commit cd24247

Browse files
committed
152v3
1 parent a749acf commit cd24247

25 files changed

Lines changed: 1234 additions & 0 deletions

README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
EntityModeSugarBiome(砂糖バイオーム)
2+
====================
3+
4+
メイドさんのお給料に困ったらここ来ればいいね。地盤が弱いので滑落や生き埋めには注意。
5+
6+
7+
## 概要
8+
9+
1. 砂糖4個からクラフトできる「砂糖ブロック」が追加されます
10+
2. 砂糖ブロックで表面が覆われた "SugarLand" バイオームが追加されます
11+
3. メイドさんに、アクティブモード "SugarHunter" が追加されます
12+
13+
14+
## スクリーンショット
15+
![スクリーンショット](README_SugarBiome.png "スクリーンショット")
16+
17+
18+
## 前提
19+
20+
- Minecraft 1.5.2
21+
- ModLoader 1.5.2
22+
- YMTLib 152v1
23+
24+
前提MODではありませんが、MMM氏製作の「littleMaidMob」が導入済みならば、メイドさんがサトウキビ農業に目覚めます。
25+
26+
27+
## 導入
28+
29+
mods に zip のまま放り込んでください。
30+
導入前にバックアップを取るのも忘れずに。".minecraft" 自体をバックアップするのがお手軽です。
31+
32+
33+
## 利用条件
34+
35+
この MOD は Apache License(ver2.0) の下で配布されます。
36+
37+
http://www.apache.org/licenses/LICENSE-2.0
38+
39+
- この MOD を使用したことにより発生したいかなる結果についても、製作者は一切の責任を負いません。
40+
- この MOD は変更の有無にかかわらず再頒布が可能です。Apache License を確認してください。
41+
42+
この MOD または派生成果物は、それが minecraft を前提としている場合に、
43+
minecraft 自体の利用条件に縛られることに注意してください。
44+
利用条件の詳細は minecraft の利用規約を確認してください。
45+
46+
47+
## レシピ
48+
49+
### 砂糖4個 → 砂糖ブロック
50+
▲▲
51+
▲▲
52+
53+
### 砂糖ブロック → 砂糖4個
54+
55+
56+
### 羊毛5個 → スポンジ
57+
■ ■
58+
 ■ 
59+
■ ■
60+
61+
62+
## Tips
63+
64+
- メイドさんにサトウキビを持たせてアクティブ状態にすると「SugarHunter」モードになります。
65+
- 天然の砂糖ブロックには幸運付きツールが有効です。
66+
- [おまけ機能] ケーキがシルクタッチ付きツールで回収できるようになります。
67+
- [おまけ機能] スポンジが水を吸うようになります。
68+
69+
70+
## Config(mod_SugarBiome.cfg)
71+
72+
sugarBlockId=203 # 砂糖ブロックのID
73+
sugarBiomeId=55 # 砂糖バイオームのID
74+
replaceCake=false # 既存ケーキの挙動変更を有効化/無効化
75+
replaceSponge=false # 既存スポンジの挙動変更を有効化/無効化
76+
77+
78+
## Copyright 2013 Yamato
79+
80+
Licensed under the Apache License, Version 2.0 (the "License");
81+
you may not use this file except in compliance with the License.
82+
You may obtain a copy of the License at
83+
84+
http://www.apache.org/licenses/LICENSE-2.0
85+
86+
Unless required by applicable law or agreed to in writing, software
87+
distributed under the License is distributed on an "AS IS" BASIS,
88+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89+
See the License for the specific language governing permissions and
90+
limitations under the License.
91+
92+
93+
## History
94+
95+
- 152v3: 幾つかのバグ修正
96+
- 152v2: 幾つかのバグ修正
97+
- 152v1: Minecraft1.5.2 に対応
98+
- 151v2: 幾つかのバグ修正
99+
- 151v1: Minecraft1.5.1 に対応
100+
- 147v2: 既存ケーキを回収可能に / 既存スポンジが水を吸うように / その他いくつかのバグ修正
101+
- 147v1: 砂糖ブロック / 砂糖バイオーム / メイドさんキビ農家モード

README_SugarBiome.png

155 KB
Loading

WacoEntityMode_SugarHunter.class

7.21 KB
Binary file not shown.

WacoEntityMode_SugarHunter.java

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
/**
2+
* Copyright 2013 Yamato
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package net.minecraft.src;
17+
18+
import java.util.Random;
19+
import mod.ymt.sugar.SugarBiomeCore;
20+
21+
/**
22+
* @author Yamato
23+
*
24+
*/
25+
public class WacoEntityMode_SugarHunter extends LMM_EntityMode_Basic {
26+
public final int mmode_SugarHunter = 0x3201;
27+
private final Random rand = new Random();
28+
private boolean modeSearchChest = false;
29+
private int coolTime = 0;
30+
private boolean speedUp = false;
31+
private double lastdistance = 0;
32+
private int moveRetryCount = 0;
33+
34+
static {
35+
System.out.println("initializing WacoEntityMode_SugarHunter");
36+
}
37+
38+
public WacoEntityMode_SugarHunter(LMM_EntityLittleMaid owner) {
39+
super(owner);
40+
}
41+
42+
@Override
43+
public void addEntityMode(EntityAITasks pDefaultMove, EntityAITasks pDefaultTargeting) {
44+
if (isModeEnable()) {
45+
EntityAITasks[] ltasks = new EntityAITasks[2];
46+
ltasks[0] = pDefaultMove;
47+
ltasks[1] = pDefaultTargeting;
48+
owner.addMaidMode(ltasks, "SugarHunter", mmode_SugarHunter);
49+
}
50+
}
51+
52+
@Override
53+
public boolean changeMode(EntityPlayer pentityplayer) {
54+
if (isModeEnable()) {
55+
ItemStack litemstack = owner.maidInventory.getStackInSlot(0);
56+
if (litemstack != null) {
57+
if (litemstack.itemID == Item.reed.itemID) {
58+
owner.setMaidMode("SugarHunter");
59+
return true;
60+
}
61+
}
62+
}
63+
return false;
64+
}
65+
66+
@Override
67+
public boolean checkBlock(int pMode, int px, int py, int pz) {
68+
if (modeSearchChest) {
69+
if (isFullInventory()) {
70+
return super.checkBlock(pMode, px, py, pz);
71+
}
72+
else {
73+
clearMy();
74+
return false;
75+
}
76+
}
77+
// サトウキビの探索
78+
World w = owner.worldObj;
79+
int blockId = w.getBlockId(px, py, pz);
80+
if (blockId == Block.reed.blockID) {
81+
if (w.getBlockId(px, py - 1, pz) == Block.reed.blockID) {
82+
speedUp = true;
83+
SugarBiomeCore.getInstance().debugPrint("find reed %d, %d, %d", px, py, pz);
84+
return true;
85+
}
86+
// 伸びていなければ離れた場所に移動してみる
87+
if (rand.nextInt(800) == 0 && 5 * 5 < owner.getDistanceSq(px + 0.5, py + 0.5, pz + 0.5)) {
88+
SugarBiomeCore.getInstance().debugPrint("move far %d, %d, %d", px, py, pz);
89+
return true;
90+
}
91+
}
92+
// 植え付け可能場所の探索
93+
else if (blockId == Block.dirt.blockID || blockId == Block.grass.blockID || blockId == Block.sand.blockID) {
94+
Material mm = w.getBlockMaterial(px, py + 1, pz);
95+
if (mm == null || (mm.isReplaceable() && !mm.isLiquid())) {
96+
if (Block.reed.canPlaceBlockAt(w, px, py + 1, pz) && owner.maidInventory.hasItem(Item.reed.itemID)) {
97+
speedUp = 2 * 2 < owner.getDistanceSq(px + 0.5, py + 0.5, pz + 0.5);
98+
SugarBiomeCore.getInstance().debugPrint("find point %d, %d, %d", px, py, pz);
99+
return true;
100+
}
101+
}
102+
}
103+
return false;
104+
}
105+
106+
@Override
107+
public boolean checkItemStack(ItemStack pItemStack) {
108+
return true; // インベントリに空きがあればアイテムは拾いに行く。けど AICollectItem 内でも判定しているみたい
109+
}
110+
111+
@Override
112+
public boolean executeBlock(int pMode, int px, int py, int pz) {
113+
if (modeSearchChest) {
114+
boolean result = super.executeBlock(pMode, px, py, pz);
115+
if (!result) {
116+
SugarBiomeCore.getInstance().debugPrint("SearchChest finish");
117+
modeSearchChest = false;
118+
}
119+
return result;
120+
}
121+
World w = owner.worldObj;
122+
int blockId = w.getBlockId(px, py, pz);
123+
124+
// さとうきびの刈り取り
125+
if (blockId == Block.reed.blockID && w.getBlockId(px, py - 1, pz) == Block.reed.blockID) {
126+
owner.setSwing(10, LMM_EnumSound.Null);
127+
Block.blocksList[blockId].dropBlockAsItem(w, px, py, pz, 0, 0);
128+
w.setBlockToAir(px, py, pz);
129+
w.playSoundEffect(px + 0.5F, py + 0.5F, pz + 0.5F, Block.reed.stepSound.getPlaceSound(), (Block.reed.stepSound.getVolume() + 1.0F) / 2.0F,
130+
Block.reed.stepSound.getPitch() * 0.8F);
131+
coolTime = 10;
132+
speedUp = false;
133+
}
134+
// 植え付け
135+
else if (blockId == Block.dirt.blockID || blockId == Block.grass.blockID || blockId == Block.sand.blockID) {
136+
Material mm = w.getBlockMaterial(px, py + 1, pz);
137+
if (mm == null || mm.isReplaceable()) {
138+
if (Block.reed.canPlaceBlockAt(w, px, py + 1, pz) && owner.maidInventory.consumeInventoryItem(Item.reed.itemID)) {
139+
w.setBlock(px, py + 1, pz, Block.reed.blockID);
140+
owner.setSwing(10, LMM_EnumSound.Null);
141+
w.playSoundEffect(px + 0.5F, py + 0.5F, pz + 0.5F, Block.reed.stepSound.getPlaceSound(), (Block.reed.stepSound.getVolume() + 1.0F) / 2.0F,
142+
Block.reed.stepSound.getPitch() * 0.8F);
143+
}
144+
}
145+
}
146+
return false;
147+
}
148+
149+
@Override
150+
public int getNextEquipItem(int pMode) {
151+
if (pMode == mmode_SugarHunter) {
152+
for (int i = 0; i < owner.maidInventory.maxInventorySize; i++) {
153+
ItemStack item = owner.maidInventory.getStackInSlot(i);
154+
if (item != null && item.itemID == Item.reed.itemID) {
155+
return i;
156+
}
157+
}
158+
}
159+
return -1;
160+
}
161+
162+
@Override
163+
public void init() {
164+
if (isModeEnable()) {
165+
// 登録モードの名称追加
166+
ModLoader.addLocalization("littleMaidMob.mode.SugarHunter", "SugarHunter");
167+
ModLoader.addLocalization("littleMaidMob.mode.SugarHunter", "ja_JP", "シュガーハンター");
168+
ModLoader.addLocalization("littleMaidMob.mode.F-SugarHunter", "F-SugarHunter");
169+
ModLoader.addLocalization("littleMaidMob.mode.T-SugarHunter", "T-SugarHunter");
170+
ModLoader.addLocalization("littleMaidMob.mode.D-SugarHunter", "D-SugarHunter");
171+
}
172+
}
173+
174+
@Override
175+
public boolean isSearchBlock() {
176+
if (isFullInventory()) {
177+
SugarBiomeCore.getInstance().debugPrint("SearchChest start");
178+
modeSearchChest = true; // アイテムいっぱいならチェスト探索モード
179+
fDistance = 100F; // チェストまでの最大距離
180+
return !super.shouldBlock(mmode_Escorter); // ほんとは mytile == null したいけど代用として
181+
}
182+
if (0 < coolTime) {
183+
return false; // クールタイム中は立ち止まる
184+
}
185+
return true; // サトウキビ探索
186+
}
187+
188+
@Override
189+
public void onUpdate(int pMode) {
190+
super.onUpdate(pMode);
191+
if (0 < coolTime) {
192+
coolTime--;
193+
}
194+
}
195+
196+
@Override
197+
public boolean outrangeBlock(int pMode, int pX, int pY, int pZ) {
198+
if (modeSearchChest) {
199+
return super.outrangeBlock(pMode, pX, pY, pZ);
200+
}
201+
boolean result = false;
202+
if (!owner.isMaidWaitEx()) {
203+
double distance = owner.getDistanceSq(pX + 0.5, pY + 0.5, pZ + 0.5);
204+
if (distance == lastdistance) {
205+
owner.updateWanderPath();
206+
SugarBiomeCore.getInstance().debugPrint("updateWanderPath(%s)", ++moveRetryCount);
207+
result = moveRetryCount < 40; // 40回までリトライ可能
208+
}
209+
else {
210+
result = owner.getNavigator().tryMoveToXYZ(pX, pY, pZ, speedUp ? 0.3F : 0.23F);
211+
}
212+
lastdistance = distance;
213+
}
214+
return result;
215+
}
216+
217+
@Override
218+
public int priority() {
219+
return 5999; // IC2だとサトウキビが燃えるようになるので、LMM_EntityMode_Cooking より優先度を上げる
220+
}
221+
222+
@Override
223+
public void resetBlock(int pMode) {
224+
super.resetBlock(pMode);
225+
speedUp = false;
226+
moveRetryCount = 0;
227+
}
228+
229+
@Override
230+
public boolean setMode(int pMode) {
231+
switch (pMode) {
232+
case mmode_SugarHunter:
233+
owner.setBloodsuck(false);
234+
owner.aiWander.setEnable(true);
235+
owner.aiJumpTo.setEnable(false);
236+
owner.aiFollow.setEnable(false);
237+
owner.aiAvoidPlayer.setEnable(false);
238+
return true;
239+
}
240+
return false;
241+
}
242+
243+
@Override
244+
public boolean shouldBlock(int pMode) {
245+
if (modeSearchChest) {
246+
return super.shouldBlock(pMode);
247+
}
248+
return false;
249+
}
250+
251+
private boolean isFullInventory() {
252+
return owner.maidInventory.getFirstEmptyStack() == -1;
253+
}
254+
255+
@Override
256+
protected void clearMy() {
257+
super.clearMy();
258+
SugarBiomeCore.getInstance().debugPrint("SearchChest clear");
259+
modeSearchChest = false; // リセット
260+
}
261+
262+
private static boolean isModeEnable() {
263+
return SugarBiomeCore.getInstance().isRunning();
264+
}
265+
}
2.82 KB
Binary file not shown.

0 commit comments

Comments
 (0)