I've run into a bit of a weird issue. Currently making a thorn whip entity that functions similar to the fishing rod (minus the fishing). The entity functions as intended, right clicking the test item and pulling the first entity it hits. Only problem is, nothing renders visually when casting even though entity creation shows up in the logs and captured entities are pulled. I've used this post as a guide, but nothing in it has solved my problem. I have the written code below (Linking ThornWhipEntity through github as file is a bit long).
ThornWhipRenderer
package com.lordxemnas23.natureswill.client.render;
import com.lordxemnas23.natureswill.NaturesWill;
import com.lordxemnas23.natureswill.client.model.ThornWhipTipModel;
import com.lordxemnas23.natureswill.entities.spells.ThornWhipEntity;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Matrix3f;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation;
public class RenderThornWhipTip extends EntityRenderer<ThornWhipEntity>{
protected static final ResourceLocation TEXTURE = new ResourceLocation(NaturesWill.MOD_ID, "textures/entity/thorn_whip_tip.png");
protected static final RenderType CUTOUT = RenderType.getEntityCutout(TEXTURE);
final ThornWhipTipModel model = new ThornWhipTipModel();
public RenderThornWhipTip(EntityRendererManager renderManager) {
super(renderManager);
}
@Override
public void render(ThornWhipEntity whip, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) {
LivingEntity caster = whip.getCaster();
if (caster != null) {
matrixStackIn.push();
matrixStackIn.push();
matrixStackIn.scale(0.5F, 0.5F, 0.5F);
matrixStackIn.rotate(this.renderManager.getCameraOrientation());
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(180.0F));
MatrixStack.Entry matrixstack$entry = matrixStackIn.getLast();
Matrix4f matrix4f = matrixstack$entry.getMatrix();
Matrix3f matrix3f = matrixstack$entry.getNormal();
IVertexBuilder ivertexbuilder = bufferIn.getBuffer(CUTOUT);
model.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
matrixStackIn.pop();
super.render(whip, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
}
}
@Override
public ResourceLocation getEntityTexture(ThornWhipEntity entity) {
return new ResourceLocation(NaturesWill.MOD_ID, "textures/entity/thorn_whip_tip.png");
}
}
ThornWhipModel
package com.lordxemnas23.natureswill.client.model;
import com.lordxemnas23.natureswill.entities.spells.ThornWhipEntity;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
public class ThornWhipTipModel extends EntityModel<ThornWhipEntity> {
private final ModelRenderer Stem;
private final ModelRenderer StemNeck;
private final ModelRenderer StemTip;
public ThornWhipTipModel() {
super(RenderType::getEntitySolid);
textureWidth = 32;
textureHeight = 32;
Stem = new ModelRenderer(this);
Stem.setRotationPoint(0.0F, 24.0F, 0.0F);
StemNeck = new ModelRenderer(this);
StemNeck.setRotationPoint(0.0F, 0.0F, 0.0F);
Stem.addChild(StemNeck);
StemNeck.setTextureOffset(0, 0).addBox(-1.0F, -6.0F, -8.0F, 2.0F, 2.0F, 8.0F, 0.0F, false);
StemNeck.setTextureOffset(0, 10).addBox(0.0F, -6.0F, 0.0F, 2.0F, 2.0F, 3.0F, 0.0F, false);
StemNeck.setTextureOffset(11, 10).addBox(-1.0F, -7.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
StemNeck.setTextureOffset(4, 6).addBox(-2.0F, -6.0F, -2.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
StemNeck.setTextureOffset(0, 6).addBox(1.0F, -5.0F, -7.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
StemNeck.setTextureOffset(4, 3).addBox(-1.0F, -4.0F, -6.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
StemTip = new ModelRenderer(this);
StemTip.setRotationPoint(0.0F, 0.0F, 0.0F);
Stem.addChild(StemTip);
StemTip.setTextureOffset(0, 0).addBox(-1.0F, -6.0F, 3.0F, 2.0F, 1.0F, 2.0F, 0.0F, false);
StemTip.setTextureOffset(7, 10).addBox(0.0F, -5.0F, 3.0F, 1.0F, 1.0F, 2.0F, 0.0F, false);
StemTip.setTextureOffset(0, 3).addBox(0.0F, -6.0F, 5.0F, 1.0F, 1.0F, 2.0F, 0.0F, false);
}
@Override
public void setRotationAngles(ThornWhipEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
}
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
Stem.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
Entity Register
package com.lordxemnas23.natureswill.core;
import com.lordxemnas23.natureswill.NaturesWill;
import com.lordxemnas23.natureswill.entities.spells.ThornWhipEntity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
public class ModEntityTypes {
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = new DeferredRegister<>(ForgeRegistries.ENTITIES, NaturesWill.MOD_ID);
public static final RegistryObject<EntityType<ThornWhipEntity>> THORN_WHIP = ENTITY_TYPES.register("thorn_whip",
() -> EntityType.Builder.<ThornWhipEntity>create(ThornWhipEntity::new, EntityClassification.MISC).disableSerialization()
.disableSummoning().size(0.5F, 0.5F).build(new ResourceLocation(NaturesWill.MOD_ID, "thorn_whip").toString()));
}
ThornWhipEntity
ClientEventBusSubscriber
package com.lordxemnas23.natureswill.util;
import com.lordxemnas23.natureswill.NaturesWill;
import com.lordxemnas23.natureswill.client.render.RenderThornWhipTip;
import com.lordxemnas23.natureswill.core.ModBlocks;
import com.lordxemnas23.natureswill.core.ModEntityTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
@Mod.EventBusSubscriber(modid = NaturesWill.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEventBusSubscriber {
@SubscribeEvent
public static void clientSetup(FMLClientSetupEvent event) {
RenderTypeLookup.setRenderLayer(ModBlocks.THORNY_VINE.get(), RenderType.getCutout());
RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.THORN_WHIP.get(), RenderThornWhipTip::new);
}
}
And here's the item I'm using to spawn the entity
package com.lordxemnas23.natureswill.objects.items;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.lordxemnas23.natureswill.entities.spells.ThornWhipEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
public class NaturesEssence extends Item {
private static final Logger LOGGER = LogManager.getLogger();
public NaturesEssence(Properties properties) {
super(properties);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
worldIn.addEntity(new ThornWhipEntity(playerIn, worldIn));
LOGGER.info("ThornWhip created");
return super.onItemRightClick(worldIn, playerIn, handIn);
}
}
Any ideas would be appreciated. Thanks.