Skip to content

Commit b57b550

Browse files
committed
more golem
1 parent 41721b5 commit b57b550

26 files changed

Lines changed: 413 additions & 43 deletions

src/main/java/com/adccadc/rust/Rust.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void onInitialize() {
155155
List.of(Items.IRON_SWORD, Items.IRON_AXE, Items.IRON_PICKAXE, Items.IRON_SHOVEL, Items.IRON_HOE, Items.IRON_HELMET, Items.IRON_CHESTPLATE, Items.IRON_LEGGINGS, Items.IRON_BOOTS),
156156
List.of(Moditems.RUSTY_IRON_SWORD, Moditems.RUSTY_IRON_AXE, Moditems.RUSTY_IRON_PICKAXE, Moditems.RUSTY_IRON_SHOVEL, Moditems.RUSTY_IRON_HOE, Moditems.RUSTY_IRON_HELMET, Moditems.RUSTY_IRON_CHESTPLATE, Moditems.RUSTY_IRON_LEGGINGS, Moditems.RUSTY_IRON_BOOTS),
157157
player);
158-
EntityReplace.ReplaceRustyEntityWithAttribute(serverWorld, box);
158+
//EntityReplace.ReplaceRustyEntityWithAttribute(serverWorld, box);
159159
if(RustConfig.useLegacyOxidizeLogic()) {
160160
// 旧版方块氧化机制
161161
for (BlockPos pos : BlockPos.iterate((int) box.minX, (int) box.minY, (int) box.minZ, (int) box.maxX, (int) box.maxY, (int) box.maxZ)) {
@@ -244,11 +244,11 @@ public void onInitialize() {
244244
}
245245
return ActionResult.PASS;
246246
});
247-
247+
/*
248248
UseEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
249249
if (world.isClient) return ActionResult.PASS;
250250
251-
if (entity.getType() == ModEntity.RUSTY_IRON_GOLEM || entity.getType() == ModEntity.WAXED_IRON_GOLEM || entity.getType() == EntityType.IRON_GOLEM) {
251+
if (entity.getType() == ModEntity.EXPOSED_IRON_GOLEM || entity.getType() == ModEntity.WAXED_IRON_GOLEM || entity.getType() == EntityType.IRON_GOLEM) {
252252
ItemStack stack = player.getStackInHand(hand);
253253
if(world instanceof ServerWorld serverWorld) {
254254
if (stack.getItem() instanceof HoneycombItem && entity.getType() == EntityType.IRON_GOLEM) {
@@ -259,7 +259,7 @@ public void onInitialize() {
259259
}
260260
if (stack.getItem() instanceof AxeItem && entity.getType() != EntityType.IRON_GOLEM) {
261261
EntityReplace.ReplaceIronGolemWithAttribute(serverWorld, (IronGolemEntity) entity, null);
262-
if (entity.getType() == ModEntity.RUSTY_IRON_GOLEM) {
262+
if (entity.getType() == ModEntity.EXPOSED_IRON_GOLEM) {
263263
UseLater(stack, player, 4, null, null, serverWorld, entity.getPos(), null, ParticleTypes.WAX_OFF, Moditems.IRON_RUST, 4);
264264
world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.ITEM_AXE_SCRAPE, SoundCategory.PLAYERS, 1.0F, 1.0F);
265265
} else {
@@ -273,5 +273,6 @@ public void onInitialize() {
273273
274274
return ActionResult.PASS;
275275
});
276+
*/
276277
}
277278
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.adccadc.rust;
22

3+
import com.adccadc.rust.entity.GolemEntityRenderer.*;
34
import com.adccadc.rust.entity.ModEntity;
4-
import com.adccadc.rust.entity.RustyIronGolemEntityRenderer;
5-
import com.adccadc.rust.entity.WaxedIronGolemEntityRenderer;
65
import net.fabricmc.api.ClientModInitializer;
76
import net.fabricmc.api.EnvType;
87
import net.fabricmc.api.Environment;
@@ -12,7 +11,12 @@
1211
public class RustClient implements ClientModInitializer {
1312
@Override
1413
public void onInitializeClient() {
15-
EntityRendererRegistry.register(ModEntity.RUSTY_IRON_GOLEM, (context) -> new RustyIronGolemEntityRenderer(context));
14+
EntityRendererRegistry.register(ModEntity.EXPOSED_IRON_GOLEM, (context) -> new ExposedIronGolemEntityRenderer(context));
15+
EntityRendererRegistry.register(ModEntity.WEATHERED_IRON_GOLEM, (context) -> new WeatheredIronGolemEntityRenderer(context));
16+
EntityRendererRegistry.register(ModEntity.OXIDIZED_IRON_GOLEM, (context) -> new OxidizedIronGolemEntityRenderer(context));
1617
EntityRendererRegistry.register(ModEntity.WAXED_IRON_GOLEM, (context) -> new WaxedIronGolemEntityRenderer(context));
18+
EntityRendererRegistry.register(ModEntity.WAXED_EXPOSED_IRON_GOLEM, (context) -> new WaxedExposedIronGolemEntityRenderer(context));
19+
EntityRendererRegistry.register(ModEntity.WAXED_WEATHERED_IRON_GOLEM, (context) -> new WaxedWeatheredIronGolemEntityRenderer(context));
20+
EntityRendererRegistry.register(ModEntity.WAXED_OXIDIZED_IRON_GOLEM, (context) -> new WaxedOxidizedIronGolemEntityRenderer(context));
1721
}
1822
}

src/main/java/com/adccadc/rust/RustConfig.java

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
package com.adccadc.rust;
22

33
import java.io.*;
4+
import java.lang.ref.WeakReference;
5+
import java.util.ArrayList;
6+
import java.util.Arrays;
7+
import java.util.List;
48
import java.util.Properties;
9+
import java.util.regex.Matcher;
10+
import java.util.regex.Pattern;
511

612
public class RustConfig {
713
private static final String CONFIG_FILE_PATH = "./config/rust.properties";
814

915
private static final String USE_LEGACY_KEY = "use_legacy_oxidize_logic";
1016
private static final String AFFECT_REDSTONE = "affect_redstone";
17+
private static final String AFFECT_ENTITY = "effect_entity";
1118

1219
private static final String EXPOSED_WPPB = "exposed_weighted_pressure_plate";
1320
private static final String WEATHERED_WPPB = "weathered_weighted_pressure_plate";
@@ -17,18 +24,56 @@ public class RustConfig {
1724
private static final String WAXED_WEATHERED_WPPB = "waxed_weathered_weighted_pressure_plate";
1825
private static final String WAXED_OXIDIZED_WPPB = "waxed_oxidized_weighted_pressure_plate";
1926

27+
private static final String EXPOSED_IG = "exposed_iron_golem";
28+
private static final String WEATHERED_IG = "weathered_iron_golem";
29+
private static final String OXIDIZED_IG = "oxidized_iron_golem";
30+
private static final String WAXED_IG = "waxed_iron_golem";
31+
private static final String WAXED_EXPOSED_IG = "waxed_exposed_iron_golem";
32+
private static final String WAXED_WEATHERED_IG = "waxed_weathered_iron_golem";
33+
private static final String WAXED_OXIDIZED_IG = "waxed_oxidized_iron_golem";
34+
2035
private static boolean useLegacyLogic = false; // 是否采用旧版氧化逻辑
36+
2137
private static boolean affectRedstone = true; // 是否影响红石
22-
private static Integer exposed_WPPB = 170; // 斑驳的测重压力板每增加一格信号所需实体量
23-
private static Integer weathered_WPPB = 190; // 锈蚀的测重压力板每增加一格信号所需实体量
24-
private static Integer oxidized_WPPB = 210; // 氧化的测重压力板每增加一格信号所需实体量
25-
private static Integer waxed_WPPB = 160; // 涂蜡的测重压力板每增加一格信号所需实体量
26-
private static Integer waxed_exposed_WPPB = 180; // 涂蜡的斑驳测重压力板每增加一格信号所需实体量
27-
private static Integer waxed_weathered_WPPB = 200; // 涂蜡的锈蚀测重压力板每增加一格信号所需实体量
28-
private static Integer waxed_oxidized_WPPB = 220; // 涂蜡的氧化测重压力板每增加一格信号所需实体量
38+
// 各种测重压力板每一级信号所需实体重量
39+
private static Integer exposed_WPPB = 170;
40+
private static Integer weathered_WPPB = 190;
41+
private static Integer oxidized_WPPB = 210;
42+
private static Integer waxed_WPPB = 160;
43+
private static Integer waxed_exposed_WPPB = 180;
44+
private static Integer waxed_weathered_WPPB = 200;
45+
private static Integer waxed_oxidized_WPPB = 220;
46+
47+
private static boolean affectEntity = true; // 是否影响实体
48+
// 各种铁傀儡的生物属性
49+
private static List<?> default_IG = new ArrayList<>(Arrays.asList((double) 100.0F, (double) 0.25F, (double) 1.0F, (double) 15.0F, (double) 1.0F, (double) 16.0F)); //原版铁傀儡属性
50+
private static List<?> exposed_IG = new ArrayList<>(Arrays.asList((double) 90.0F, (double) 0.22F, (double) 0.95F, (double) 14.0F, (double) 1.0F, (double) 15.0F));
51+
private static List<?> weathered_IG = new ArrayList<>(Arrays.asList((double) 80.0F, (double) 0.19F, (double) 0.90F, (double) 13.0F, (double) 1.0F, (double) 14.0F));
52+
private static List<?> oxidized_IG = new ArrayList<>(Arrays.asList((double) 70.0F, (double) 0.16F, (double) 0.85F, (double) 12.0F, (double) 1.0F, (double) 13.0F));
53+
private static List<?> waxed_IG = new ArrayList<>(Arrays.asList((double) 110.0F, (double) 0.23F, (double) 1.0F, (double) 14.5F, (double) 0.9F, (double) 16.0F));
54+
private static List<?> waxed_exposed_IG = new ArrayList<>(Arrays.asList((double) 100.0F, (double) 0.20F, (double) 0.98F, (double) 13.5F, (double) 0.9F, (double) 15.0F));
55+
private static List<?> waxed_weathered_IG = new ArrayList<>(Arrays.asList((double) 90.0F, (double) 0.17F, (double) 0.93F, (double) 12.5F, (double) 0.9F, (double) 14.0F));
56+
private static List<?> waxed_oxidized_IG = new ArrayList<>(Arrays.asList((double) 80.0F, (double) 0.14F, (double) 0.88F, (double) 11.5F, (double) 0.9F, (double) 13.0F));
2957

3058
private RustConfig() {}
3159

60+
protected static List<Double> convertWithRegex(String input) {
61+
List<Double> result = new ArrayList<>();
62+
63+
Pattern pattern = Pattern.compile("\\d+(?:\\.\\d+)?(?:F|f)?");
64+
Matcher matcher = pattern.matcher(input);
65+
66+
while (matcher.find()) {
67+
String match = matcher.group();
68+
69+
if (match.toUpperCase().endsWith("F")) {
70+
match = match.substring(0, match.length() - 1);
71+
}
72+
result.add(Double.parseDouble(match));
73+
}
74+
return result;
75+
}
76+
3277
public static void loadConfig() {
3378
File configFile = new File(CONFIG_FILE_PATH);
3479

@@ -41,15 +86,25 @@ public static void loadConfig() {
4186
try (InputStream input = new FileInputStream(configFile)) {
4287
props.load(input);
4388
useLegacyLogic = Boolean.parseBoolean(props.getProperty(USE_LEGACY_KEY, "false").trim());
44-
affectRedstone = Boolean.parseBoolean(props.getProperty(AFFECT_REDSTONE, "false").trim());
89+
affectRedstone = Boolean.parseBoolean(props.getProperty(AFFECT_REDSTONE, "true").trim());
90+
affectEntity = Boolean.parseBoolean(props.getProperty(AFFECT_ENTITY, "true"));
4591
exposed_WPPB = Integer.parseUnsignedInt(props.getProperty(EXPOSED_WPPB, "150").trim());
4692
weathered_WPPB = Integer.parseUnsignedInt(props.getProperty(WEATHERED_WPPB, "150").trim());
4793
oxidized_WPPB = Integer.parseUnsignedInt(props.getProperty(OXIDIZED_WPPB, "150").trim());
4894
waxed_WPPB = Integer.parseUnsignedInt(props.getProperty(WAXED_WPPB, "150").trim());
4995
waxed_exposed_WPPB = Integer.parseUnsignedInt(props.getProperty(WAXED_EXPOSED_WPPB, "150").trim());
5096
waxed_weathered_WPPB = Integer.parseUnsignedInt(props.getProperty(WAXED_WEATHERED_WPPB, "150").trim());
5197
waxed_oxidized_WPPB = Integer.parseUnsignedInt(props.getProperty(WAXED_OXIDIZED_WPPB, "150").trim());
52-
System.out.println("Loaded oxidize config: use_legacy_logic = " + useLegacyLogic);
98+
exposed_IG = convertWithRegex(props.getProperty(EXPOSED_IG, "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]").trim());
99+
weathered_IG = convertWithRegex(props.getProperty(WEATHERED_IG, "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]").trim());
100+
oxidized_IG = convertWithRegex(props.getProperty(OXIDIZED_IG, "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]").trim());
101+
waxed_IG = convertWithRegex(props.getProperty(WAXED_IG, "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]"));
102+
waxed_exposed_IG = convertWithRegex(props.getProperty(WAXED_EXPOSED_IG, "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]").trim());
103+
waxed_weathered_IG = convertWithRegex(props.getProperty(WAXED_WEATHERED_IG, "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]").trim());
104+
waxed_oxidized_IG = convertWithRegex(props.getProperty(WAXED_OXIDIZED_IG, "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]").trim());
105+
System.out.println("Loaded rust config: use_legacy_logic = " + useLegacyLogic);
106+
System.out.println("Loaded rust config: affect_redstone = " + affectRedstone);
107+
System.out.println("Loaded rust config: affect_entity = " + affectEntity);
53108
} catch (IOException e) {
54109
System.err.println("Failed to load config file, using default settings: " + e.getMessage());
55110
createDefaultConfig(configFile);
@@ -77,7 +132,7 @@ private static void createDefaultConfig(File configFile) {
77132
writer.println("# if the value is false, rust will not use subsequent config, use original block state and logic");
78133
writer.println(AFFECT_REDSTONE + "= true");
79134
writer.println();
80-
writer.println("# - number");
135+
writer.println("# - number(int)");
81136
writer.println("# How much weight is required for each level of signal (original version is 150)");
82137
writer.println(EXPOSED_WPPB + "= 170");
83138
writer.println(WEATHERED_WPPB + "= 190");
@@ -86,6 +141,22 @@ private static void createDefaultConfig(File configFile) {
86141
writer.println(WAXED_EXPOSED_WPPB + "= 180");
87142
writer.println(WAXED_WEATHERED_WPPB + "= 200");
88143
writer.println(WAXED_OXIDIZED_WPPB + "= 220");
144+
writer.println();
145+
writer.println("# - true: Rust can affect entity");
146+
writer.println("# - false: Rust can't affect entity");
147+
writer.println("# if the value is false, rust will not use subsequent config, use original entity attributes");
148+
writer.println(AFFECT_ENTITY + "= true");
149+
writer.println();
150+
writer.println("# - [decimal(float),decimal(float),decimal(float),decimal(float),decimal(float),decimal(float)]");
151+
writer.println("# - [max health,movement speed,knockback resistance,attack damage,step height,follow range] *Please add F at the end of each float value");
152+
writer.println("# This will change the attributes of the golem, some of which may not be effective for existing golem");
153+
writer.println(EXPOSED_IG + "= [90.0F,0.22F,0.95F,14.0F,1.0F,15.0F]");
154+
writer.println(WEATHERED_IG + "= [80.0F,0.19F,0.90F,13.0F,1.0F,14.0F]");
155+
writer.println(OXIDIZED_IG + "= [70.0F,0.16F,0.85F,12.0F,1.0F,13.0F]");
156+
writer.println(WAXED_IG + "= [110.0F,0.23F,1.0F,14.5F,0.9F,16.0F]");
157+
writer.println(WAXED_EXPOSED_IG + "= [100.0F,0.20F,0.98F,13.5F,0.9F,15.0F]");
158+
writer.println(WAXED_WEATHERED_IG + "= [90.0F,0.17F,0.93F,12.5F,0.9F,14.0F]");
159+
writer.println(WAXED_OXIDIZED_IG + "= [80.0F,0.16F,0.88F,11.5F,0.9F,13.0F]");
89160

90161
System.out.println("Created default config file: " + configFile.getAbsolutePath());
91162
System.out.println("Please edit the file and restart Minecraft to apply changes.");
@@ -104,4 +175,12 @@ private static void createDefaultConfig(File configFile) {
104175
public static Integer getWaxed_exposed_WPPB() {return affectRedstone ? waxed_exposed_WPPB : 150;}
105176
public static Integer getWaxed_weathered_WPPB() {return affectRedstone ? waxed_weathered_WPPB : 150;}
106177
public static Integer getWaxed_oxidized_WPPB() {return affectRedstone ? waxed_oxidized_WPPB : 150;}
178+
179+
public static List<?> getExposed_IG() {return affectEntity ? exposed_IG : default_IG;}
180+
public static List<?> getWeathered_IG() {return affectEntity ? weathered_IG : default_IG;}
181+
public static List<?> getOxidized_IG() {return affectEntity ? oxidized_IG : default_IG;}
182+
public static List<?> getWaxed_IG() {return affectEntity ? waxed_IG : default_IG;}
183+
public static List<?> getWaxed_exposed_IG() {return affectEntity ? waxed_exposed_IG : default_IG;}
184+
public static List<?> getWaxed_weathered_IG() {return affectEntity ? waxed_weathered_IG : default_IG;}
185+
public static List<?> getWaxed_oxidized_IG() {return affectEntity ? waxed_oxidized_IG : default_IG;}
107186
}

src/main/java/com/adccadc/rust/entity/EntityReplace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static void ReplaceIronGolemWithAttribute(ServerWorld serverWorld, IronGo
1717
if (isRusty == null) {
1818
ChangedIronGolem = EntityType.IRON_GOLEM.create(serverWorld,CONVERSION);
1919
} else if (isRusty) {
20-
ChangedIronGolem = ModEntity.RUSTY_IRON_GOLEM.create(serverWorld,CONVERSION);
20+
ChangedIronGolem = ModEntity.EXPOSED_IRON_GOLEM.create(serverWorld,CONVERSION);
2121
} else {
2222
ChangedIronGolem = ModEntity.WAXED_IRON_GOLEM.create(serverWorld,CONVERSION);
2323
}

src/main/java/com/adccadc/rust/entity/RustyIronGolemEntityRenderer.java renamed to src/main/java/com/adccadc/rust/entity/GolemEntityRenderer/ExposedIronGolemEntityRenderer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.adccadc.rust.entity;
1+
package com.adccadc.rust.entity.GolemEntityRenderer;
22

33
import net.fabricmc.api.EnvType;
44
import net.fabricmc.api.Environment;
@@ -15,10 +15,10 @@
1515
import net.minecraft.util.math.RotationAxis;
1616

1717
@Environment(EnvType.CLIENT)
18-
public class RustyIronGolemEntityRenderer extends MobEntityRenderer<IronGolemEntity, IronGolemEntityRenderState, IronGolemEntityModel> {
19-
private static final Identifier TEXTURE = Identifier.of("rust", "textures/entity/rusty_iron_golem.png");
18+
public class ExposedIronGolemEntityRenderer extends MobEntityRenderer<IronGolemEntity, IronGolemEntityRenderState, IronGolemEntityModel> {
19+
private static final Identifier TEXTURE = Identifier.of("rust", "textures/entity/exposed_iron_golem.png");
2020

21-
public RustyIronGolemEntityRenderer(EntityRendererFactory.Context context) {
21+
public ExposedIronGolemEntityRenderer(EntityRendererFactory.Context context) {
2222
super(context, new IronGolemEntityModel(context.getPart(EntityModelLayers.IRON_GOLEM)), 0.7F);
2323
this.addFeature(new IronGolemCrackFeatureRenderer(this));
2424
this.addFeature(new IronGolemFlowerFeatureRenderer(this, context.getBlockRenderManager()));

0 commit comments

Comments
 (0)