Skip to content

Commit

Permalink
Finished Snow Golem scarf implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Nov 30, 2024
1 parent 7a98d0b commit 6036c83
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import net.fabricmc.api.Environment;
import net.minecraft.Util;
import net.minecraft.client.model.SnowGolemModel;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.RenderLayerParent;
Expand All @@ -24,15 +21,13 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.animal.SnowGolem;
import net.minecraft.world.entity.animal.horse.Markings;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.WoolCarpetBlock;
import org.jetbrains.annotations.Nullable;

import java.util.EnumMap;
import java.util.Map;

@Environment(EnvType.CLIENT)
public class SnowGolemDecorLayer extends RenderLayer<SnowGolem, SnowGolemModel<SnowGolem>> {
Expand All @@ -56,11 +51,8 @@ public class SnowGolemDecorLayer extends RenderLayer<SnowGolem, SnowGolemModel<S

});

private final SnowGolemModel<SnowGolem> model;

public SnowGolemDecorLayer(RenderLayerParent<SnowGolem, SnowGolemModel<SnowGolem>> renderLayerParent, EntityModelSet entityModelSet) {
public SnowGolemDecorLayer(RenderLayerParent<SnowGolem, SnowGolemModel<SnowGolem>> renderLayerParent) {
super(renderLayerParent);
this.model = new SnowGolemModel<>(entityModelSet.bakeLayer(ModelLayers.SNOW_GOLEM));
}

private static DyeColor getDyeColor(ItemStack itemStack) {
Expand All @@ -69,12 +61,10 @@ private static DyeColor getDyeColor(ItemStack itemStack) {
}

public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, SnowGolem snowGolem, float f, float g, float h, float j, float k, float l) {
DyeColor dyeColor = getDyeColor(snowGolem.getItemBySlot(EquipmentSlot.CHEST));

this.getParentModel().copyPropertiesTo(this.model);
this.model.setupAnim(snowGolem, f, g, j, k, l);
assert dyeColor != null;
VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderType.entityCutoutNoCull((ResourceLocation)TEXTURE_LOCATION.get(dyeColor)));
this.model.renderToBuffer(poseStack, vertexConsumer, i, OverlayTexture.NO_OVERLAY);
DyeColor dyeColor = getDyeColor(snowGolem.getItemBySlot(EquipmentSlot.BODY));
if (dyeColor != null) {
VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderType.entityCutout((ResourceLocation)TEXTURE_LOCATION.get(dyeColor)));
this.getParentModel().renderToBuffer(poseStack, vertexConsumer, i, OverlayTexture.NO_OVERLAY);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
package com.starfish_studios.seasons_greetings.mixin;

import com.starfish_studios.seasons_greetings.client.SeasonsGreetingsClient;
import com.starfish_studios.seasons_greetings.client.render.layers.HappyGolemLayer;
import com.starfish_studios.seasons_greetings.client.render.layers.SnowGolemDecorLayer;
import net.minecraft.client.model.SnowGolemModel;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.SnowGolemRenderer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.animal.SnowGolem;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(SnowGolemRenderer.class)
public class SnowGolemRendererMixin extends MobRenderer<SnowGolem, SnowGolemModel<SnowGolem>> {
public SnowGolemRendererMixin(EntityRendererProvider.Context context, SnowGolemModel<SnowGolem> entityModel, float f) {
super(context, entityModel, f);
this.addLayer(new SnowGolemDecorLayer(this, context.getModelSet()));
}

@Inject(method = "<init>", at = @At("TAIL"))
private void addDecorLayer(EntityRendererProvider.Context context, CallbackInfo ci) {
// this.addLayer(new HappyGolemLayer(this));
this.addLayer(new SnowGolemDecorLayer(this));
}

@Override
public @NotNull ResourceLocation getTextureLocation(SnowGolem entity) {
return ResourceLocation.fromNamespaceAndPath("minecraft", "textures/entity/snow_golem.png");
return ResourceLocation.withDefaultNamespace("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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/main/resources/seasonsgreetings.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"package": "com.starfish_studios.seasons_greetings.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"ExampleMixin",
"SnowGolemMixin"
],
"injectors": {
Expand Down

0 comments on commit 6036c83

Please sign in to comment.