Skip to content

Commit d226355

Browse files
committed
147v6
1 parent a749acf commit d226355

25 files changed

Lines changed: 1210 additions & 0 deletions

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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.4.7
21+
- ModLoader 1.4.7
22+
- YMTLib 147v4
23+
24+
前提MODではありませんが、MMM氏製作の「littleMaidMob 1.4.7-4」が導入済みならば、メイドさんがサトウキビ農業に目覚めます。
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 (0で砂糖ブロック無効化)
73+
sugarBiomeId=55 # 砂糖バイオームのID (0で砂糖バイオーム無効化)
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+
- 147v6: 幾つかのバグ修正
96+
- 147v5: 幾つかのバグ修正
97+
- 147v4: 幾つかのバグ修正
98+
- 147v3: 幾つかのバグ修正
99+
- 147v2: 既存ケーキを回収可能に / 既存スポンジが水を吸うように / その他いくつかのバグ修正
100+
- 147v1: 砂糖ブロック / 砂糖バイオーム / メイドさんキビ農家モード

README_SugarBiome.png

155 KB
Loading

SBLMMEntityMode_SugarHunter.class

6.69 KB
Binary file not shown.

SBLMMEntityMode_SugarHunter.java

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
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 SBLMMEntityMode_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+
SugarBiomeCore.getInstance().debugPrint("initializing SBLMMEntityMode_SugarHunter");
36+
}
37+
38+
public SBLMMEntityMode_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+
return super.checkBlock(pMode, px, py, pz);
70+
}
71+
// サトウキビの探索
72+
World w = owner.worldObj;
73+
int blockId = w.getBlockId(px, py, pz);
74+
if (blockId == Block.reed.blockID) {
75+
if (w.getBlockId(px, py - 1, pz) == Block.reed.blockID) {
76+
speedUp = true;
77+
SugarBiomeCore.getInstance().debugPrint("find reed %d, %d, %d", px, py, pz);
78+
return true;
79+
}
80+
// 伸びていなければ離れた場所に移動してみる
81+
if (rand.nextInt(800) == 0 && 5 * 5 < owner.getDistanceSq(px + 0.5, py + 0.5, pz + 0.5)) {
82+
SugarBiomeCore.getInstance().debugPrint("move far %d, %d, %d", px, py, pz);
83+
return true;
84+
}
85+
}
86+
// 植え付け可能場所の探索
87+
else if (blockId == Block.dirt.blockID || blockId == Block.grass.blockID || blockId == Block.sand.blockID) {
88+
Material mm = w.getBlockMaterial(px, py + 1, pz);
89+
if (mm == null || (mm.isReplaceable() && !mm.isLiquid())) {
90+
if (Block.reed.canPlaceBlockAt(w, px, py + 1, pz) && owner.maidInventory.hasItem(Item.reed.itemID)) {
91+
speedUp = 2 * 2 < owner.getDistanceSq(px + 0.5, py + 0.5, pz + 0.5);
92+
SugarBiomeCore.getInstance().debugPrint("find point %d, %d, %d", px, py, pz);
93+
return true;
94+
}
95+
}
96+
}
97+
return false;
98+
}
99+
100+
@Override
101+
public boolean checkItemStack(ItemStack pItemStack) {
102+
return true; // インベントリに空きがあればアイテムは拾いに行く。けど AICollectItem 内でも判定しているみたい
103+
}
104+
105+
@Override
106+
public boolean executeBlock(int pMode, int px, int py, int pz) {
107+
if (modeSearchChest) {
108+
boolean result = super.executeBlock(pMode, px, py, pz);
109+
if (!result) {
110+
modeSearchChest = false;
111+
}
112+
return result;
113+
}
114+
World w = owner.worldObj;
115+
int blockId = w.getBlockId(px, py, pz);
116+
117+
// さとうきびの刈り取り
118+
if (blockId == Block.reed.blockID && w.getBlockId(px, py - 1, pz) == Block.reed.blockID) {
119+
owner.setSwing(10, LMM_EnumSound.Null);
120+
Block.blocksList[blockId].dropBlockAsItem(w, px, py, pz, 0, 0);
121+
w.setBlockWithNotify(px, py, pz, 0);
122+
w.playSoundEffect(px + 0.5F, py + 0.5F, pz + 0.5F, Block.reed.stepSound.getPlaceSound(), (Block.reed.stepSound.getVolume() + 1.0F) / 2.0F,
123+
Block.reed.stepSound.getPitch() * 0.8F);
124+
coolTime = 10;
125+
speedUp = false;
126+
}
127+
// 植え付け
128+
else if (blockId == Block.dirt.blockID || blockId == Block.grass.blockID || blockId == Block.sand.blockID) {
129+
Material mm = w.getBlockMaterial(px, py + 1, pz);
130+
if (mm == null || mm.isReplaceable()) {
131+
if (Block.reed.canPlaceBlockAt(w, px, py + 1, pz) && owner.maidInventory.consumeInventoryItem(Item.reed.itemID)) {
132+
w.setBlockWithNotify(px, py + 1, pz, Block.reed.blockID);
133+
owner.setSwing(10, LMM_EnumSound.Null);
134+
w.playSoundEffect(px + 0.5F, py + 0.5F, pz + 0.5F, Block.reed.stepSound.getPlaceSound(), (Block.reed.stepSound.getVolume() + 1.0F) / 2.0F,
135+
Block.reed.stepSound.getPitch() * 0.8F);
136+
}
137+
}
138+
}
139+
return false;
140+
}
141+
142+
@Override
143+
public int getNextEquipItem(int pMode) {
144+
if (pMode == mmode_SugarHunter) {
145+
for (int i = 0; i < owner.maidInventory.maxInventorySize; i++) {
146+
ItemStack item = owner.maidInventory.getStackInSlot(i);
147+
if (item != null && item.itemID == Item.reed.itemID) {
148+
return i;
149+
}
150+
}
151+
}
152+
return -1;
153+
}
154+
155+
@Override
156+
public void init() {
157+
if (isModeEnable()) {
158+
// 登録モードの名称追加
159+
ModLoader.addLocalization("littleMaidMob.mode.SugarHunter", "SugarHunter");
160+
ModLoader.addLocalization("littleMaidMob.mode.SugarHunter", "ja_JP", "シュガーハンター");
161+
ModLoader.addLocalization("littleMaidMob.mode.F-SugarHunter", "F-SugarHunter");
162+
ModLoader.addLocalization("littleMaidMob.mode.T-SugarHunter", "T-SugarHunter");
163+
ModLoader.addLocalization("littleMaidMob.mode.D-SugarHunter", "D-SugarHunter");
164+
}
165+
}
166+
167+
@Override
168+
public boolean isSearchBlock() {
169+
if (owner.maidInventory.getFirstEmptyStack() == -1) {
170+
modeSearchChest = true; // アイテムいっぱいならチェスト探索モード
171+
return !super.shouldBlock(mmode_Escorter); // ほんとは mytile == null したいけど代用として
172+
}
173+
if (0 < coolTime) {
174+
return false; // クールタイム中は立ち止まる
175+
}
176+
return true; // サトウキビ探索
177+
}
178+
179+
@Override
180+
public void onUpdate(int pMode) {
181+
super.onUpdate(pMode);
182+
if (0 < coolTime) {
183+
coolTime--;
184+
}
185+
}
186+
187+
@Override
188+
public boolean outrangeBlock(int pMode, int pX, int pY, int pZ) {
189+
if (modeSearchChest) {
190+
return super.outrangeBlock(pMode, pX, pY, pZ);
191+
}
192+
boolean result = false;
193+
if (!owner.isMaidWaitEx()) {
194+
double distance = owner.getDistanceSq(pX + 0.5, pY + 0.5, pZ + 0.5);
195+
if (distance == lastdistance) {
196+
owner.updateWanderPath();
197+
SugarBiomeCore.getInstance().debugPrint("updateWanderPath(%s)", ++moveRetryCount);
198+
result = moveRetryCount < 40; // 40回までリトライ可能
199+
}
200+
else {
201+
result = owner.getNavigator().tryMoveToXYZ(pX, pY, pZ, speedUp ? 0.3F : 0.23F);
202+
}
203+
lastdistance = distance;
204+
}
205+
return result;
206+
}
207+
208+
@Override
209+
public int priority() {
210+
return 5999; // IC2だとサトウキビが燃えるようになるので、LMM_EntityMode_Cooking より優先度を上げる
211+
}
212+
213+
@Override
214+
public void resetBlock(int pMode) {
215+
super.resetBlock(pMode);
216+
speedUp = false;
217+
moveRetryCount = 0;
218+
}
219+
220+
@Override
221+
public boolean setMode(int pMode) {
222+
switch (pMode) {
223+
case mmode_SugarHunter:
224+
owner.setBloodsuck(false);
225+
owner.aiWander.setEnable(true);
226+
owner.aiJumpTo.setEnable(false);
227+
owner.aiFollow.setEnable(false);
228+
owner.aiAvoidPlayer.setEnable(false);
229+
return true;
230+
}
231+
return false;
232+
}
233+
234+
@Override
235+
public boolean shouldBlock(int pMode) {
236+
if (modeSearchChest) {
237+
return super.shouldBlock(pMode);
238+
}
239+
return false;
240+
}
241+
242+
private static boolean isModeEnable() {
243+
return SugarBiomeCore.getInstance().isRunning();
244+
}
245+
}
2.81 KB
Binary file not shown.

0 commit comments

Comments
 (0)