Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @OnlyIn(Dist.CLIENT)
- public class BeeLayer extends LayerRenderer<CustomBeeEntity, CustomBeeModel<CustomBeeEntity>> {
- private final boolean isEmissive;
- private final int glowingPulse;
- private final boolean isEnchanted;
- private final CustomBeeModel<CustomBeeEntity> additionModel;
- private final ResourceLocation layerTexture;
- private final ResourceLocation angerLayerTexture;
- private float[] color;
- private final boolean isRainbowBee;
- public BeeLayer(IEntityRenderer<CustomBeeEntity, CustomBeeModel<CustomBeeEntity>> renderer, CustomBeeRenderer.LayerType layerType, ModelTypes addition, ColorData colorData) {
- super(renderer);
- this.additionModel = addition == ModelTypes.DEFAULT ? null : new CustomBeeModel<>(addition);
- this.isRainbowBee = colorData.isRainbowBee();
- this.isEnchanted = colorData.isEnchanted();
- this.glowingPulse = colorData.getGlowingPulse();
- switch (layerType) {
- case PRIMARY:
- this.isEmissive = false;
- this.layerTexture = ResourceLocation.tryCreate(ResourcefulBees.MOD_ID + ":" + BeeConstants.ENTITY_TEXTURES_DIR + colorData.getPrimaryLayerTexture() + ".png");
- this.angerLayerTexture = ResourceLocation.tryCreate(ResourcefulBees.MOD_ID + ":" + BeeConstants.ENTITY_TEXTURES_DIR + colorData.getPrimaryLayerTexture() + "_angry.png");
- this.color = isRainbowBee ? RainbowColor.getColorFloats() : colorData.getPrimaryColorFloats();
- break;
- case SECONDARY:
- this.isEmissive = false;
- this.layerTexture = ResourceLocation.tryCreate(ResourcefulBees.MOD_ID + ":" + BeeConstants.ENTITY_TEXTURES_DIR + colorData.getSecondaryLayerTexture() + ".png");
- this.angerLayerTexture = ResourceLocation.tryCreate(ResourcefulBees.MOD_ID + ":" + BeeConstants.ENTITY_TEXTURES_DIR + colorData.getSecondaryLayerTexture() + "_angry.png");
- this.color = isRainbowBee ? RainbowColor.getColorFloats() : colorData.getSecondaryColorFloats();
- break;
- case EMISSIVE:
- this.isEmissive = true;
- this.layerTexture = ResourceLocation.tryCreate(ResourcefulBees.MOD_ID + ":" + BeeConstants.ENTITY_TEXTURES_DIR + colorData.getEmissiveLayerTexture() + ".png");
- this.angerLayerTexture = ResourceLocation.tryCreate(ResourcefulBees.MOD_ID + ":" + BeeConstants.ENTITY_TEXTURES_DIR + colorData.getEmissiveLayerTexture() + "_angry.png");
- this.color = isRainbowBee ? RainbowColor.getColorFloats() : colorData.getGlowColorFloats();
- break;
- default:
- throw new IllegalStateException("You dun screwed up, did you add a new layer?");
- }
- }
- @Override
- public void render(@Nonnull MatrixStack matrixStackIn, @Nonnull IRenderTypeBuffer bufferIn, int packedLightIn, @Nonnull CustomBeeEntity customBeeEntity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
- if (isRainbowBee) color = RainbowColor.getColorFloats();
- ResourceLocation texture = customBeeEntity.hasAngerTime() && angerLayerTexture != null ? angerLayerTexture : layerTexture;
- if (texture == null) texture = BeeConstants.MISSING_TEXTURE;
- if (additionModel != null) {
- this.getEntityModel().setModelAttributes(additionModel);
- additionModel.setLivingAnimations(customBeeEntity, limbSwing, limbSwingAmount, partialTicks);
- additionModel.setAngles(customBeeEntity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
- }
- if (isEmissive) {
- if (isEnchanted) {
- this.getEntityModel().render(matrixStackIn, bufferIn.getBuffer(RenderType.getEntityGlint()), packedLightIn, OverlayTexture.DEFAULT_UV, 0.0F, 0.0F, 0.0F, 0.0F);
- if (additionModel != null) {
- additionModel.render(matrixStackIn, bufferIn.getBuffer(RenderType.getEntityGlint()), packedLightIn, LivingRenderer.getOverlay(customBeeEntity, 0.0F), 0.0F, 0.0F, 0.0F, 0.0F);
- }
- } else {
- IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RenderType.getEyes(texture));
- if (glowingPulse == 0 || customBeeEntity.ticksExisted / 5 % glowingPulse == 0) {
- this.getEntityModel().render(matrixStackIn, ivertexbuilder, 15728640, OverlayTexture.DEFAULT_UV, color[0], color[1], color[2], 1.0F);
- if (additionModel != null) {
- additionModel.render(matrixStackIn, ivertexbuilder, 15728640, LivingRenderer.getOverlay(customBeeEntity, 0.0F), color[0], color[1], color[2], 1.0F);
- }
- }
- }
- } else {
- if (!Files.exists(Paths.get("resources/assets/" + texture.getPath()))) {
- System.out.println("ANGERY");
- }
- renderModel(this.getEntityModel(), texture, matrixStackIn, bufferIn, packedLightIn, customBeeEntity, color[0], color[1], color[2]);
- if (additionModel != null) {
- IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RenderType.getEntityTranslucent(texture));
- additionModel.render(matrixStackIn, ivertexbuilder, packedLightIn, LivingRenderer.getOverlay(customBeeEntity, 0.0F), color[0], color[1], color[2], 1.0F);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement