-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished Snow Golem head item placement
- Loading branch information
1 parent
6036c83
commit f70e2ab
Showing
13 changed files
with
180 additions
and
17 deletions.
There are no files selected for viewing
5 changes: 0 additions & 5 deletions
5
...java/com/starfish_studios/seasons_greetings/client/render/layers/SnowGolemDecorLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...java/com/starfish_studios/seasons_greetings/client/render/layers/SnowGolemNosesLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.starfish_studios.seasons_greetings.client.render.layers; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.starfish_studios.seasons_greetings.SeasonsGreetings; | ||
import com.starfish_studios.seasons_greetings.registry.SGTags; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.Util; | ||
import net.minecraft.client.model.SnowGolemModel; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.RenderLayerParent; | ||
import net.minecraft.client.renderer.entity.layers.RenderLayer; | ||
import net.minecraft.client.renderer.texture.OverlayTexture; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.entity.animal.SnowGolem; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.level.block.Blocks; | ||
|
||
import java.util.HashMap; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public class SnowGolemNosesLayer extends RenderLayer<SnowGolem, SnowGolemModel<SnowGolem>> { | ||
public static final HashMap<Item, ResourceLocation> TEXTURE_LOCATION = Util.make(new HashMap<>(), (hashMap) -> { | ||
hashMap.put(Items.CARROT, SeasonsGreetings.id("textures/entity/snow_golem/nose/carrot.png")); | ||
hashMap.put(Items.POTATO, SeasonsGreetings.id("textures/entity/snow_golem/nose/potato.png")); | ||
hashMap.put(Items.BEETROOT, SeasonsGreetings.id("textures/entity/snow_golem/nose/beetroot.png")); | ||
hashMap.put(Items.WHEAT, SeasonsGreetings.id("textures/entity/snow_golem/nose/wheat.png")); | ||
}); | ||
|
||
public SnowGolemNosesLayer(RenderLayerParent<SnowGolem, SnowGolemModel<SnowGolem>> renderLayerParent) { | ||
super(renderLayerParent); | ||
} | ||
|
||
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, SnowGolem snowGolem, float f, float g, float h, float j, float k, float l) { | ||
ItemStack itemStack = snowGolem.getItemBySlot(EquipmentSlot.HEAD); | ||
if (TEXTURE_LOCATION.containsKey(itemStack.getItem())) { | ||
VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderType.entityCutout(TEXTURE_LOCATION.get(itemStack.getItem()))); | ||
this.getParentModel().renderToBuffer(poseStack, vertexConsumer, i, OverlayTexture.NO_OVERLAY); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/com/starfish_studios/seasons_greetings/mixin/SnowGolemModelMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.starfish_studios.seasons_greetings.mixin; | ||
|
||
import net.minecraft.client.model.AnimationUtils; | ||
import net.minecraft.client.model.HierarchicalModel; | ||
import net.minecraft.client.model.SnowGolemModel; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.client.model.geom.PartPose; | ||
import net.minecraft.client.model.geom.builders.*; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.HumanoidArm; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.Mob; | ||
import net.minecraft.world.entity.animal.SnowGolem; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(SnowGolemModel.class) | ||
public abstract class SnowGolemModelMixin<T extends Entity> extends HierarchicalModel<T> { | ||
@Unique | ||
private final ModelPart upperBody; | ||
@Unique | ||
private final ModelPart head; | ||
@Unique | ||
private final ModelPart leftArm; | ||
@Unique | ||
private final ModelPart rightArm; | ||
@Unique | ||
private final ModelPart nose; | ||
|
||
public SnowGolemModelMixin(ModelPart modelPart) { | ||
this.head = modelPart.getChild("head"); | ||
this.leftArm = modelPart.getChild("left_arm"); | ||
this.rightArm = modelPart.getChild("right_arm"); | ||
this.upperBody = modelPart.getChild("upper_body"); | ||
this.nose = modelPart.getChild("carrot_nose"); | ||
} | ||
|
||
|
||
@Inject(method = "createBodyLayer", at = @At(value = "RETURN"), cancellable = true) | ||
private static void sg$createBodyLayer(CallbackInfoReturnable<LayerDefinition> cir) { | ||
MeshDefinition meshDefinition = new MeshDefinition(); | ||
PartDefinition partDefinition = meshDefinition.getRoot(); | ||
CubeDeformation cubeDeformation = new CubeDeformation(-0.5F); | ||
partDefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, cubeDeformation), PartPose.offset(0.0F, 4.0F, 0.0F)); | ||
CubeListBuilder cubeListBuilder = CubeListBuilder.create().texOffs(32, 0).addBox(-1.0F, 0.0F, -1.0F, 12.0F, 2.0F, 2.0F, cubeDeformation); | ||
partDefinition.addOrReplaceChild("left_arm", cubeListBuilder, PartPose.offsetAndRotation(5.0F, 6.0F, 1.0F, 0.0F, 0.0F, 1.0F)); | ||
partDefinition.addOrReplaceChild("right_arm", cubeListBuilder, PartPose.offsetAndRotation(-5.0F, 6.0F, -1.0F, 0.0F, 3.1415927F, -1.0F)); | ||
partDefinition.addOrReplaceChild("upper_body", CubeListBuilder.create().texOffs(0, 16).addBox(-5.0F, -10.0F, -5.0F, 10.0F, 10.0F, 10.0F, cubeDeformation), PartPose.offset(0.0F, 13.0F, 0.0F)); | ||
partDefinition.addOrReplaceChild("lower_body", CubeListBuilder.create().texOffs(0, 36).addBox(-6.0F, -12.0F, -6.0F, 12.0F, 12.0F, 12.0F, cubeDeformation), PartPose.offset(0.0F, 24.0F, 0.0F)); | ||
|
||
PartDefinition head = partDefinition.getChild("head"); | ||
|
||
head.addOrReplaceChild("carrot_nose", CubeListBuilder.create().texOffs(33, 16).addBox(0.0F, -24.0F, 0.0F, 1.0F, 1.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(-0.5F, 19.0F, -7.5F)); | ||
head.addOrReplaceChild("potato_nose", CubeListBuilder.create().texOffs(44, 12).addBox(-2.0F, -27.0F, 1.0F, 4.0F, 6.0F, 3.0F, new CubeDeformation(-0.5F)), PartPose.offset(0.0F, 20.75F, -7.0F)); | ||
|
||
head.addOrReplaceChild("wheat_hair", CubeListBuilder.create().texOffs(41, 31).addBox(-4.0F, -4.0F, 0.0F, 8.0F, 8.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -11.0F, 0.0F, 0.0F, 0.7854F, 0.0F)); | ||
head.addOrReplaceChild("wheat_hair_2", CubeListBuilder.create().texOffs(41, 31).addBox(-4.0F, -4.0F, 0.0F, 8.0F, 8.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -11.0F, 0.0F, 0.0F, 2.3562F, 0.0F)); | ||
|
||
head.addOrReplaceChild("beetroot_nose", CubeListBuilder.create().texOffs(41, 22).addBox(-2.0F, -26.0F, 0.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(-0.5F)), PartPose.offset(0.0F, 19.75F, -6.25F)); | ||
|
||
|
||
cir.setReturnValue(LayerDefinition.create(meshDefinition, 64, 64)); | ||
} | ||
|
||
@Inject(method = "setupAnim", at = @At(value = "HEAD")) | ||
private void sg$setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, CallbackInfo ci) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.05 KB
src/main/resources/assets/seasonsgreetings/textures/entity/snow_golem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+298 Bytes
.../resources/assets/seasonsgreetings/textures/entity/snow_golem/nose/beetroot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+191 Bytes
...in/resources/assets/seasonsgreetings/textures/entity/snow_golem/nose/carrot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+366 Bytes
...in/resources/assets/seasonsgreetings/textures/entity/snow_golem/nose/potato.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+355 Bytes
...ain/resources/assets/seasonsgreetings/textures/entity/snow_golem/nose/wheat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions
8
src/main/resources/data/seasonsgreetings/tags/item/snow_golem_noses.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"values": [ | ||
"minecraft:carrot", | ||
"minecraft:potato", | ||
"minecraft:wheat", | ||
"minecraft:beetroot" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
"defaultRequire": 1 | ||
}, | ||
"client": [ | ||
"SnowGolemModelMixin", | ||
"SnowGolemRendererMixin" | ||
] | ||
} |