2016-07-22 20:23:51 +02:00
|
|
|
/*
|
|
|
|
* This file ("RenderWorm.java") is part of the Actually Additions mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-07-22 20:23:51 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.entity;
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
2024-03-03 01:20:53 +01:00
|
|
|
import com.mojang.math.Axis;
|
2021-03-01 21:23:52 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.Util;
|
2016-08-07 13:09:44 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
2021-11-13 20:09:55 +01:00
|
|
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
2021-11-13 20:09:55 +01:00
|
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
2024-03-03 01:20:53 +01:00
|
|
|
import net.minecraft.network.chat.Component;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.resources.ResourceLocation;
|
|
|
|
import net.minecraft.world.inventory.InventoryMenu;
|
2024-03-03 01:20:53 +01:00
|
|
|
import net.minecraft.world.item.ItemDisplayContext;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.world.item.ItemStack;
|
2024-03-04 20:21:48 +01:00
|
|
|
import net.neoforged.api.distmarker.Dist;
|
|
|
|
import net.neoforged.api.distmarker.OnlyIn;
|
2021-03-01 18:11:34 +01:00
|
|
|
|
2016-07-22 20:23:51 +02:00
|
|
|
|
2021-02-26 22:15:48 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2021-11-13 20:09:55 +01:00
|
|
|
public class RenderWorm extends EntityRenderer<EntityWorm> {
|
2016-07-22 20:23:51 +02:00
|
|
|
|
2023-01-16 22:47:31 +01:00
|
|
|
private ItemStack stack;
|
|
|
|
private ItemStack snailStack;
|
2017-07-07 22:09:56 +02:00
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
public RenderWorm(EntityRendererProvider.Context context) {
|
|
|
|
super(context);
|
2016-07-22 20:23:51 +02:00
|
|
|
|
2021-11-13 20:09:55 +01:00
|
|
|
stack = new ItemStack(ActuallyItems.WORM.get());
|
2023-01-16 22:47:31 +01:00
|
|
|
snailStack = new ItemStack(ActuallyItems.WORM.get());
|
2024-03-03 01:20:53 +01:00
|
|
|
snailStack.setHoverName(Component.literal("Snail Mail"));
|
2016-07-22 20:23:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-03-02 21:23:08 +01:00
|
|
|
public void render(EntityWorm entity, float partialTicks, float p_225623_3_, PoseStack matrix, MultiBufferSource buffer, int light) {
|
2023-01-16 22:47:31 +01:00
|
|
|
boolean isSnail = entity.getCustomName().getString().equalsIgnoreCase("snail mail");
|
2021-11-13 20:09:55 +01:00
|
|
|
matrix.pushPose();
|
2024-04-03 12:37:28 +02:00
|
|
|
matrix.translate(0, 0.75F, 0);
|
2021-11-13 20:09:55 +01:00
|
|
|
double boop = Util.getMillis() / 70D;
|
2024-03-03 01:20:53 +01:00
|
|
|
matrix.mulPose(Axis.YP.rotationDegrees(-(float) (boop % 360)));
|
2023-01-16 00:47:13 +01:00
|
|
|
matrix.translate(0,0,0.4);
|
2021-11-13 20:09:55 +01:00
|
|
|
Minecraft.getInstance().getItemRenderer().renderStatic(
|
2024-03-03 01:20:53 +01:00
|
|
|
isSnail? snailStack:stack, ItemDisplayContext.FIXED, light, OverlayTexture.NO_OVERLAY, matrix, buffer, null, 0
|
2021-11-13 20:09:55 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
matrix.popPose();
|
2016-07-22 20:23:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-11-13 20:09:55 +01:00
|
|
|
public ResourceLocation getTextureLocation(EntityWorm pEntity) {
|
2024-03-02 21:23:08 +01:00
|
|
|
return InventoryMenu.BLOCK_ATLAS;
|
2016-07-22 20:23:51 +02:00
|
|
|
}
|
|
|
|
}
|