Skip to content

Commit 6795371

Browse files
committed
Add silver golem and tweak trout texture
Also change TomatoBlock.java
1 parent 65b6c84 commit 6795371

File tree

17 files changed

+440
-31
lines changed

17 files changed

+440
-31
lines changed

src/client/java/barch/mc_extended/Lost.java src/client/java/barch/mc_extended/Entities/Lost.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package barch.mc_extended;
1+
package barch.mc_extended.Entities;
22

33
import barch.mc_extended.render.entity.model.LostEntityModel;
44
import barch.mc_extended.render.entity.renderer.LostEntityRenderer;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package barch.mc_extended.Entities;
2+
3+
4+
import barch.mc_extended.render.entity.model.SilverGolemEntityModel;
5+
import barch.mc_extended.render.entity.renderer.SilverGolemEntityRenderer;
6+
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
7+
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
8+
import net.minecraft.client.render.entity.model.EntityModelLayer;
9+
import net.minecraft.util.Identifier;
10+
11+
import static barch.mc_extended.Entities.Entities.SILVER_GOLEM;
12+
import static barch.mc_extended.MCExtended.NAMESPACE;
13+
14+
public class SilverGolem {
15+
16+
public static final SilverGolem INSTANCE = new SilverGolem();
17+
18+
public static final EntityModelLayer MODEL_SILVER_GOLEM_LAYER = new EntityModelLayer(new Identifier(NAMESPACE, "silver_golem"), "main");
19+
20+
public static void registerClient() {
21+
22+
EntityRendererRegistry.register(SILVER_GOLEM, SilverGolemEntityRenderer::new);
23+
24+
EntityModelLayerRegistry.registerModelLayer(MODEL_SILVER_GOLEM_LAYER, SilverGolemEntityModel::getTexturedModelData);
25+
26+
}
27+
28+
}

src/client/java/barch/mc_extended/TroutFish.java src/client/java/barch/mc_extended/Entities/TroutFish.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
package barch.mc_extended;
1+
package barch.mc_extended.Entities;
22

33
import barch.mc_extended.render.entity.model.TroutFishEntityModel;
4-
import barch.mc_extended.render.entity.renderer.LostEntityRenderer;
54
import barch.mc_extended.render.entity.renderer.TroutFishEntityRenderer;
65
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
76
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
87
import net.minecraft.client.render.entity.model.EntityModelLayer;
98
import net.minecraft.util.Identifier;
109

11-
import static barch.mc_extended.Entities.Entities.LOST;
1210
import static barch.mc_extended.Entities.Entities.TROUT_FISH;
1311
import static barch.mc_extended.MCExtended.NAMESPACE;
1412

src/client/java/barch/mc_extended/EntitiesClient.java

+6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
package barch.mc_extended;
22

3+
import barch.mc_extended.Entities.Lost;
4+
import barch.mc_extended.Entities.SilverGolem;
5+
import barch.mc_extended.Entities.TroutFish;
6+
37
public class EntitiesClient {
48

59
public static final EntitiesClient INSTANCE = new EntitiesClient();
610

711
public static final Lost LOST = Lost.INSTANCE;
812
public static final TroutFish TROUT_FISH = TroutFish.INSTANCE;
13+
public static final SilverGolem SILVER_GOLEM = SilverGolem.INSTANCE;
914

1015
public static void registerClient() {
1116

1217
LOST.registerClient();
1318
TROUT_FISH.registerClient();
19+
SILVER_GOLEM.registerClient();
1420

1521
}
1622

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package barch.mc_extended.render.entity.model;
2+
3+
import barch.mc_extended.Entities.SilverGolemEntity;
4+
import net.minecraft.client.model.*;
5+
import net.minecraft.client.render.entity.model.IronGolemEntityModel;
6+
import net.minecraft.util.math.MathHelper;
7+
8+
public class SilverGolemEntityModel<T extends SilverGolemEntity> extends IronGolemEntityModel<T> {
9+
private final ModelPart root;
10+
private final ModelPart head;
11+
private final ModelPart rightArm;
12+
private final ModelPart leftArm;
13+
private final ModelPart rightLeg;
14+
private final ModelPart leftLeg;
15+
16+
public SilverGolemEntityModel(ModelPart root) {
17+
super(root);
18+
this.root = root;
19+
this.head = root.getChild("head");
20+
this.rightArm = root.getChild("right_arm");
21+
this.leftArm = root.getChild("left_arm");
22+
this.rightLeg = root.getChild("right_leg");
23+
this.leftLeg = root.getChild("left_leg");
24+
}
25+
26+
public static TexturedModelData getTexturedModelData() {
27+
ModelData modelData = new ModelData();
28+
ModelPartData modelPartData = modelData.getRoot();
29+
// head
30+
modelPartData.addChild("head", ModelPartBuilder.create()
31+
.uv(0,20)
32+
.cuboid(-5,-11,-5,10,11,10) // head
33+
.uv(0,0)
34+
.cuboid(-1,-3,-7,2,4,2), // nose
35+
ModelTransform.pivot(0,5,0));
36+
37+
// body
38+
modelPartData.addChild("body", ModelPartBuilder.create()
39+
.uv(0,0)
40+
.cuboid(-8,5,-5,16,10,10) // body
41+
.uv(0,41)
42+
.cuboid(-10,2,0,2,10,6) // support 1
43+
.uv(16,41)
44+
.cuboid(8,2,0,2,10,6) // support 0
45+
.uv(44,54)
46+
.cuboid(-2,5,4,4,6,3), // lump
47+
ModelTransform.pivot(0,0,0));
48+
49+
// right_arm
50+
modelPartData.addChild("right_arm", ModelPartBuilder.create()
51+
.uv(32,45)
52+
.cuboid(0f,0,-3,3,15,3),
53+
ModelTransform.pivot(8.0f,5,-2));
54+
55+
// left_arm
56+
modelPartData.addChild("left_arm", ModelPartBuilder.create()
57+
.uv(32,45)
58+
.cuboid(-3f,0,-3,3,15,3),
59+
ModelTransform.pivot(-8.0f,5,-2));
60+
61+
// right_leg
62+
modelPartData.addChild("right_leg", ModelPartBuilder.create()
63+
.uv(30,20)
64+
.cuboid(-3,-1,-3,6,4,6) // leg
65+
.uv(44,46)
66+
.cuboid(-2,3,-2,4,4,4), // foot
67+
ModelTransform.pivot(4,16,0));
68+
69+
// left_leg
70+
modelPartData.addChild("left_leg", ModelPartBuilder.create()
71+
.uv(34,35)
72+
.cuboid(-3,-1,-3,6,4,6) // leg
73+
.uv(42,0)
74+
.cuboid(-2,3,-2,4,4,4), // foot
75+
ModelTransform.pivot(-4,16,0));
76+
77+
78+
79+
80+
return TexturedModelData.of(modelData, 66,63);
81+
}
82+
@Override
83+
public ModelPart getPart() {
84+
return this.root;
85+
}
86+
87+
@Override
88+
public void setAngles(T silverGolemEntity, float f, float g, float h, float i, float j) {
89+
this.head.yaw = i * 0.017453292F;
90+
this.head.pitch = j * 0.017453292F;
91+
this.rightLeg.pitch = -1.5F * MathHelper.wrap(f, 13.0F) * g;
92+
this.leftLeg.pitch = 1.5F * MathHelper.wrap(f, 13.0F) * g;
93+
this.rightLeg.yaw = 0.0F;
94+
this.leftLeg.yaw = 0.0F;
95+
}
96+
97+
public ModelPart getRightArm() {
98+
return this.rightArm;
99+
}
100+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package barch.mc_extended.render.entity.renderer;
2+
3+
import barch.mc_extended.Entities.SilverGolemEntity;
4+
import barch.mc_extended.render.entity.model.SilverGolemEntityModel;
5+
import net.minecraft.client.render.entity.EntityRendererFactory;
6+
import net.minecraft.client.render.entity.MobEntityRenderer;
7+
import net.minecraft.client.util.math.MatrixStack;
8+
import net.minecraft.util.Identifier;
9+
import net.minecraft.util.math.RotationAxis;
10+
11+
import static barch.mc_extended.Entities.SilverGolem.MODEL_SILVER_GOLEM_LAYER;
12+
import static barch.mc_extended.MCExtended.NAMESPACE;
13+
14+
public class SilverGolemEntityRenderer extends MobEntityRenderer<SilverGolemEntity, SilverGolemEntityModel<SilverGolemEntity>> {
15+
private static final Identifier TEXTURE = new Identifier(NAMESPACE,"textures/entity/golems/silver_golem.png");
16+
17+
public SilverGolemEntityRenderer(EntityRendererFactory.Context context) {
18+
super(context, new SilverGolemEntityModel<>(context.getPart(MODEL_SILVER_GOLEM_LAYER)), 0.7F);
19+
// this.addFeature(new IronGolemCrackFeatureRenderer(this));
20+
// this.addFeature(new IronGolemFlowerFeatureRenderer(this, context.getBlockRenderManager()));
21+
}
22+
23+
@Override
24+
public Identifier getTexture(SilverGolemEntity entity) {
25+
return TEXTURE;
26+
}
27+
28+
protected void setupTransforms(SilverGolemEntity silverGolemEntity, MatrixStack matrixStack, float f, float g, float h) {
29+
super.setupTransforms(silverGolemEntity, matrixStack, f, g, h);
30+
if (!((double)silverGolemEntity.limbAnimator.getSpeed() < 0.01)) {
31+
float i = 13.0F;
32+
float j = silverGolemEntity.limbAnimator.getPos(h) + 6.0F;
33+
float k = (Math.abs(j % 13.0F - 6.5F) - 3.25F) / 3.25F;
34+
matrixStack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(6.5F * k));
35+
}
36+
}
37+
}

src/client/java/barch/mc_extended/render/entity/renderer/TroutFishEntityRenderer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import net.minecraft.util.math.RotationAxis;
1111

1212
import static barch.mc_extended.MCExtended.NAMESPACE;
13-
import static barch.mc_extended.TroutFish.MODEL_TROUT_FISH_LAYER;
13+
import static barch.mc_extended.Entities.TroutFish.MODEL_TROUT_FISH_LAYER;
1414

1515
public class TroutFishEntityRenderer extends MobEntityRenderer<TroutFishEntity, TroutFishEntityModel<TroutFishEntity>> {
1616
private static final Identifier TEXTURE = new Identifier(NAMESPACE,"textures/entity/fish/trout_fish.png");

src/main/java/barch/mc_extended/Entities/Entities.java

+32-6
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,35 @@ public class Entities {
2525

2626
public static final Entities INSTANCE = new Entities();
2727

28-
// lost entity and spawn egg
28+
// entities
29+
// lost entity
2930
public static final EntityType<LostEntity> LOST = Registry.register(
3031
Registries.ENTITY_TYPE,
3132
new Identifier(NAMESPACE, "lost"),
3233
FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, LostEntity::new).dimensions(EntityDimensions.fixed(0.6f,1.99f)).build()
3334
);
34-
public static final Item LOST_SPAWN_EGG = new SpawnEggItem(LOST, 0x839f7D, 0x9f9f9f, new FabricItemSettings());
35-
36-
// trout_fish entity and spawn egg
35+
// trout_fish entity
3736
public static final EntityType<TroutFishEntity> TROUT_FISH = Registry.register(
3837
Registries.ENTITY_TYPE,
3938
new Identifier(NAMESPACE, "trout_fish"),
40-
FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, TroutFishEntity::new).dimensions(EntityDimensions.fixed(.4f, .7f)).trackRangeBlocks(10).build()
39+
FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, TroutFishEntity::new).dimensions(EntityDimensions.fixed(.7f, .4f)).trackRangeBlocks(10).build()
40+
);
41+
// silver_golem entity
42+
public static final EntityType<SilverGolemEntity> SILVER_GOLEM = Registry.register(
43+
Registries.ENTITY_TYPE,
44+
new Identifier(NAMESPACE, "silver_golem"),
45+
FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, SilverGolemEntity::new).dimensions(EntityDimensions.fixed(1.5f, 1.8f)).trackRangeBlocks(10).build()
4146
);
47+
48+
// spawn eggs
49+
50+
// lost
51+
public static final Item LOST_SPAWN_EGG = new SpawnEggItem(LOST, 0x839f7D, 0x9f9f9f, new FabricItemSettings());
52+
// trout_fish
4253
public static final Item TROUT_FISH_SPAWN_EGG = new SpawnEggItem(TROUT_FISH, 0x835e50, 0xeac17c, new FabricItemSettings());
54+
// silver_golem
55+
public static final Item SILVER_GOLEM_SPAWN_EGG = new SpawnEggItem(SILVER_GOLEM, 0xd0d0fa, 0x7c7da2, new FabricItemSettings());
56+
4357

4458
public static void RegisterAll() {
4559

@@ -51,7 +65,11 @@ public static void RegisterAll() {
5165
// trout_fish entity
5266
FabricDefaultAttributeRegistry.register(TROUT_FISH, TroutFishEntity.createFishAttributes());
5367
Registry.register(Registries.ITEM, new Identifier(NAMESPACE, "trout_fish_spawn_egg"), TROUT_FISH_SPAWN_EGG);
54-
BiomeModifications.addSpawn(BiomeSelectors.spawnsOneOf(EntityType.SALMON), SpawnGroup.WATER_AMBIENT, TROUT_FISH, 5, 1, 5);
68+
BiomeModifications.addSpawn(BiomeSelectors.spawnsOneOf(EntityType.SALMON), SpawnGroup.WATER_AMBIENT, TROUT_FISH, 1, 1, 5);
69+
70+
// silver_golem entity
71+
FabricDefaultAttributeRegistry.register(SILVER_GOLEM, SilverGolemEntity.createSilverGolemAttributes());
72+
Registry.register(Registries.ITEM, new Identifier(NAMESPACE, "silver_golem_spawn_egg"), SILVER_GOLEM_SPAWN_EGG);
5573

5674
GroupAll();
5775

@@ -76,5 +94,13 @@ public static void GroupAll() {
7694
content.addAfter(Items.SALMON_SPAWN_EGG, TROUT_FISH_SPAWN_EGG);
7795
});
7896

97+
// silver golem spawn egg
98+
ItemGroupEvents.modifyEntriesEvent(MC_EXTENDED_GROUP).register(content -> {
99+
content.add(SILVER_GOLEM_SPAWN_EGG);
100+
});
101+
ItemGroupEvents.modifyEntriesEvent(ItemGroups.SPAWN_EGGS).register(content -> {
102+
content.addAfter(Items.IRON_GOLEM_SPAWN_EGG, SILVER_GOLEM_SPAWN_EGG);
103+
});
104+
79105
}
80106
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package barch.mc_extended.Entities;
2+
3+
import net.minecraft.entity.EntityType;
4+
import net.minecraft.entity.attribute.DefaultAttributeContainer;
5+
import net.minecraft.entity.attribute.EntityAttributes;
6+
import net.minecraft.entity.mob.MobEntity;
7+
import net.minecraft.entity.passive.IronGolemEntity;
8+
import net.minecraft.entity.player.PlayerEntity;
9+
import net.minecraft.item.ItemStack;
10+
import net.minecraft.item.Items;
11+
import net.minecraft.sound.SoundEvents;
12+
import net.minecraft.util.ActionResult;
13+
import net.minecraft.util.Hand;
14+
import net.minecraft.world.World;
15+
16+
import static barch.mc_extended.Minerals.Silver.SILVER_INGOT;
17+
18+
public class SilverGolemEntity extends IronGolemEntity {
19+
public SilverGolemEntity(EntityType<? extends IronGolemEntity> entityType, World world) {
20+
super(entityType, world);
21+
}
22+
23+
24+
public static DefaultAttributeContainer.Builder createSilverGolemAttributes() {
25+
return MobEntity.createMobAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 30).add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.4).add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 1.0).add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 30.0);
26+
}
27+
28+
@Override
29+
public boolean canTarget(EntityType<?> type) {
30+
if (this.isPlayerCreated() && type == EntityType.PLAYER) {
31+
return false;
32+
}
33+
if (type == EntityType.CREEPER) {
34+
return false;
35+
}
36+
return super.canTarget(type);
37+
}
38+
39+
@Override
40+
protected ActionResult interactMob(PlayerEntity player, Hand hand) {
41+
ItemStack itemStack = player.getStackInHand(hand);
42+
if (!itemStack.isOf(SILVER_INGOT)) {
43+
return ActionResult.PASS;
44+
}
45+
float f = this.getHealth();
46+
this.heal(10.0f);
47+
if (this.getHealth() == f) {
48+
return ActionResult.PASS;
49+
}
50+
float g = 1.0f + (this.random.nextFloat() - this.random.nextFloat()) * 0.2f;
51+
this.playSound(SoundEvents.ENTITY_IRON_GOLEM_REPAIR, 1.0f, g);
52+
if (!player.getAbilities().creativeMode) {
53+
itemStack.decrement(1);
54+
}
55+
return ActionResult.success(this.getWorld().isClient);
56+
}
57+
}

src/main/java/barch/mc_extended/Foods/Tomato.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package barch.mc_extended.Foods;
22

3+
import barch.mc_extended.Foods.blocks.TomatoBlock;
34
import barch.mc_extended.Glue.BlockBuilder;
45
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
56
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;

src/main/java/barch/mc_extended/Foods/TomatoBlock.java

-19
This file was deleted.

0 commit comments

Comments
 (0)