Jump to content

Recommended Posts

Posted

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.

Posted

I'm not so sure but it seems like you are only rendering a part of your model

	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 render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
		Stem.render(matrixStack, buffer, packedLight, packedOverlay);
	}

 

Posted

what I mean is you are only rendering your "stem" part, which has nothing in it

		Stem = new ModelRenderer(this);
		Stem.setRotationPoint(0.0F, 24.0F, 0.0F);

which all your other stuff are in 

	private final ModelRenderer StemNeck;
	private final ModelRenderer StemTip;

but you only render the stem part

	@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);
	}

 

Posted

Added in the renders for the other parts and it still doesn't work.  I used this earlier to see if it would show up, it was a first pass model meant for testing as it's only one simple cube (and yes, renderer was changed to fit this model).

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.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;

public class ThornWhipModel extends EntityModel<ThornWhipEntity> {
	private final ModelRenderer Body;
	
	public ThornWhipModel() {
		textureWidth = 64;
		textureHeight = 64;

		Body = new ModelRenderer(this);
		Body.setRotationPoint(0.0F, 24.0F, 0.0F);
		Body.setTextureOffset(0, 0).addBox(-2.0F, -4.0F, -8.0F, 4.0F, 4.0F, 16.0F, 0.0F, false);
	}

	@Override
	public void setRotationAngles(ThornWhipEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
		
	}

	@Override
	public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
		Body.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
	}
	
	public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
		modelRenderer.rotateAngleX = x;
		modelRenderer.rotateAngleY = y;
		modelRenderer.rotateAngleZ = z;
	}

	
}

 

Similar to the post I referenced for rendering models, the renderer doesn't seem to get called when the entity is created.

Posted

Yes

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);
	}
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.