Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sack Of Potatoes

Members
  • Joined

  • Last visited

Everything posted by Sack Of Potatoes

  1. I'm not entirely sure, it would make sense if it's the latter but I can't see the entity even behind me
  2. Still haven't solved this issue, if anyone has any potential thoughts or ideas I'm open to suggestions
  3. I have a thread for the issue here. The renderer is called in client.java preinit() and everything else is in the commonproxy
  4. I've been having issues trying to render an entity. I believe I've narrowed the issue down to either my custom item class or my custom entity class. So I've been looking at the EntitySnowball.java as a reference. The only difference I see is the snowball entity class has a method that registers a data fix to the snowball. Can someone explain what "registerFixesThrowable()" does and what a DataFixer is and its purpose? // In EntitySnowball.java public static void registerFixesSnowball(DataFixer fixer) { EntityThrowable.registerFixesThrowable(fixer, "Snowball"); } But funny enough, if you look inside EntityThrowable.java to see the "registerFixesThrowable()" method, it's empty... // In EntityThrowable.java public static void registerFixesThrowable(DataFixer fixer, String name) { } I was confused by this but I decided to look up the call hierarchy for "registerFixesSnowball()". And "registerFixesSnowball()" gets called in DataFixesManager.java which calls a LOT of other entity fixes (which I will remove from the code block for readability purposes). // In DataFixesManager.java public static DataFixer createFixer() { DataFixer datafixer = new DataFixer(922); datafixer = new net.minecraftforge.common.util.CompoundDataFixer(datafixer); WorldInfo.registerFixes(datafixer); EntityPlayerMP.func_191522_a(datafixer); EntityPlayer.registerFixesPlayer(datafixer); AnvilChunkLoader.registerFixes(datafixer); ItemStack.registerFixes(datafixer); Template.registerFixes(datafixer); Entity.registerFixes(datafixer); EntityArmorStand.registerFixesArmorStand(datafixer); // ... EntitySnowball.registerFixesSnowball(datafixer); // ... registerFixes(datafixer); return datafixer; } This "createFixer()" gets called in "main()" method of MinecraftServer.java and in the CONSTRUCTOR of Minecraft.java
  5. This is quite an interesting issue. I have a throwable entity (shuriken) that functionally works. BUT the shuriken seems to only render when I'm looking down, moving side-to-side, or moving backwards. If I'm standing still or moving forward the shuriken doesn't render. Note the entity is definitely there (though invisible) since I can see it damage the environment. Thank you for any and all help I will post the code for the shuriken item, entity, and render classes below. I do NOT believe the issue is in RenderShuriken.java since I still had this issue when I instantiated the shuriken render off of the RenderSnowball class. Here is a video demonstrating the rendering issue ItemShuriken.java package com.puresalvation.test.items; import com.puresalvation.test.Reference; import com.puresalvation.test.TestMod; import com.puresalvation.test.entity.EntityShuriken; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; public class ItemShuriken extends Item { // [CONSTRUCTOR] public ItemShuriken() { setUnlocalizedName(Reference.TestItems.SHURIKEN.getUnlocalizedName()); setRegistryName(Reference.TestItems.SHURIKEN.getRegistryName()); setCreativeTab(TestMod.modTab); } // [METHODS] /* * Item is NOT repairable in an anvil */ @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return false; } /* * When right-clicked... * (1) Decrement the stack size (if in Survival Mode) * (2) Perform any animation and play sound * (3) Create and Spawn the corresponding entity into the world */ @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { // Create an ItemStack from the item being held in the Main/Offhand of player (Main/Offhand determined by "handIn") ItemStack itemstack = playerIn.getHeldItem(handIn); // (1) Decrement the stack size if NOT in creative mode if (!playerIn.capabilities.isCreativeMode) { itemstack.shrink(1); } // (2) Play the sound worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); // (3) Create and Spawn the shuriken entity into the world if (!worldIn.isRemote) { EntityShuriken shuriken = new EntityShuriken(worldIn, playerIn); // Set the entity's direction, velocity, inaccuracy, rotation, etc. shuriken.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntity(shuriken); // spawn the entity into the world } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); } } EntityShuriken.java package com.puresalvation.test.entity; import java.util.Arrays; import com.puresalvation.test.Reference; import com.puresalvation.test.TestMod; import com.puresalvation.test.init.ModItems; import com.puresalvation.test.render.RenderShuriken; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.registry.EntityRegistry; public class EntityShuriken extends EntityThrowable { public static final float GRAVITY = 0.03F; public static final Block[] SHURIKEN_BREAKS_THROUGH = {Blocks.TALLGRASS, Blocks.VINE, Blocks.RED_FLOWER, Blocks.YELLOW_FLOWER, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM, Blocks.REEDS, Blocks.DOUBLE_PLANT, Blocks.DEADBUSH, Blocks.WHEAT, Blocks.WATERLILY, Blocks.CARROTS, Blocks.POTATOES, Blocks.SNOW_LAYER}; // [CONSTRUCTORS] public EntityShuriken(World worldIn) { super(worldIn); } public EntityShuriken(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public EntityShuriken(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } // [METHODS] public static void registerEntity() { EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "textures/items/shuriken.png"), EntityShuriken.class, Reference.TestItems.SHURIKEN.getUnlocalizedName(), 0, TestMod.instance, 64, 10, true); } /* Custom Helper Method * * Inflict damage on the entity hit by the shuriken */ private void inflictDamage(RayTraceResult result) { // Get the entity that was hit by the shuriken and inflict damage result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 4); } /* Custom Helper Method * * Destroy the shuriken entity once it hits another entity or a block. Also add a little animation too */ private void destroySelf() { // A little smoke animation this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]); // Destroy the shuriken entity and remove it from the world (inherited from the entity class) this.setDead(); } /* * When the shuriken entity hits something... */ @Override protected void onImpact(RayTraceResult result) { if (result.typeOfHit == RayTraceResult.Type.BLOCK) // Shuriken hits a block { // Get the block that the shuriken hit Block block = this.world.getBlockState(result.getBlockPos()).getBlock(); // If the shuriken collides with vegetation and other "quasi" blocks, destroy the thing and continue on its path if (Arrays.asList(SHURIKEN_BREAKS_THROUGH).contains(block)) { // Get info relevant so the broken vegetation block is harvestable BlockPos blockpos = result.getBlockPos(); IBlockState blockstate = this.world.getBlockState(blockpos); TileEntity te = this.world.getTileEntity(blockpos); if (this.getThrower() instanceof EntityPlayer) // if thrower is a player { // Destroy the block but make sure it's harvestable EntityPlayer player = (EntityPlayer)this.getThrower(); this.world.destroyBlock(blockpos, false); block.harvestBlock(this.world, player, blockpos, blockstate, te, new ItemStack(ModItems.shuriken)); // TODO: Verify the last parameter is correct (making a guess on this one) } } // Otherwise it hit a block or entity and can be destroyed else { this.destroySelf(); } } else { if (result.entityHit != null) { this.inflictDamage(result); } this.destroySelf(); } } /* * Override impact of gravity to be minimal */ @Override protected float getGravityVelocity() { return this.GRAVITY; } } RenderShuriken.java package com.puresalvation.test.render; import org.lwjgl.opengl.GL11; import com.puresalvation.test.Reference; import com.puresalvation.test.entity.EntityShuriken; import com.puresalvation.test.init.ModItems; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; public class RenderShuriken extends Render<EntityShuriken> { // Location of the texture private static final ResourceLocation shurikenTexture = new ResourceLocation(Reference.MOD_ID, "textures/items/shuriken.png"); protected final Item item; private final RenderItem itemRenderer; // [CONSTRUCTORS] public RenderShuriken(RenderManager renderManager) { super(renderManager); this.item = ModItems.shuriken; this.itemRenderer = Minecraft.getMinecraft().getRenderItem(); } // [METHODS] public static void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityShuriken.class, new IRenderFactory() { @Override public Render createRenderFor(RenderManager manager) { return new RenderShuriken(manager); } }); } /* Custom Helper Method * * Return the texture of the shuriken */ @Override protected ResourceLocation getEntityTexture(EntityShuriken shuriken) { return this.shurikenTexture; } public ItemStack getStackToRender(EntityShuriken entityIn) { return new ItemStack(this.item); } @Override public void doRender(EntityShuriken shuriken, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y, (float)z); GlStateManager.enableRescaleNormal(); GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate((float)(this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); this.bindEntityTexture(shuriken); if (this.renderOutlines) { GlStateManager.enableColorMaterial(); GlStateManager.enableOutlineMode(this.getTeamColor(shuriken)); } this.itemRenderer.renderItem(this.getStackToRender(shuriken), ItemCameraTransforms.TransformType.GROUND); if (this.renderOutlines) { GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); super.doRender(shuriken, x, y, z, entityYaw, partialTicks); } }
  6. Ah now I see! For those following this thread, if I were to do this I would move the following code into "preinit()" inside my clientproxy.java class (since this is being called on the client side) RenderingRegistry.registerEntityRenderingHandler(EntityShuriken.class, new IRenderFactory() { @Override public Render createRenderFor(RenderManager manager) { // NOTE: there are 2 new parameters needed // 1. ModItems.shuriken is the instance of the shuriken item // 2. Since you need a RenderItem for the RenderSnowball constructor, I'm using the one from the Minecraft instance return new RenderSnowball(manager, ModItems.shuriken, Minecraft.getMinecraft().getRenderItem()); } });
  7. Ah ok that makes sense! And conceptually I see what you're saying about not needing a custom class at all. However, in practice, I'm not sure where that instantiation would take place (in EntityShuriken.java? ItemShuriken.java?). I can't seem to find where the RenderShuriken class is explicitly called. Also if there's no custom class, how would the renderer know to draw the custom shuriken texture instead of a snowball? Thank you very much for the help and information btw. Apologies for all the questions, I'm really trying to understand the framework.
  8. For the sake of simplicity, let's say I want my entity to render as an item model like snowballs. What would the code supposedly look like? (Sorry I'm pretty unfamiliar with extending generic classes) EDIT: Courtesy of Draco18s I now understand how the generic should be implemented. I will post my interpretation of the what the code would look like for those who might be wondering or who aren't sure how to implement it. FOR THE RECORD: If RenderShuriken were to extend RenderSnowball with the proper generic implementation. public class RenderShuriken extends RenderSnowball<EntityShuriken> { // Location of the texture private static final ResourceLocation shurikenTexture = new ResourceLocation(Reference.MOD_ID, "textures/items/shuriken.png"); // [CONSTRUCTORS] public RenderShuriken(RenderManager renderManager) { // The constructor for the snowball includes two extra paramaters super(renderManager, ModItems.shuriken, Minecraft.getMinecraft().getRenderItem()); } // [METHODS] public static void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityShuriken.class, new IRenderFactory() { @Override public Render createRenderFor(RenderManager manager) { return new RenderShuriken(manager); } }); } /* * Return the texture of the shuriken */ @Override protected ResourceLocation getEntityTexture(EntityShuriken shuriken) { return this.shurikenTexture; } /* * Render the shuriken */ @Override public void doRender(EntityShuriken shuriken, double x, double y, double z, float entityYaw, float partialTicks) { //EntityShuriken shuriken = (EntityShuriken)entity; this.bindEntityTexture(shuriken); super.doRender(shuriken, x, y, z, entityYaw, partialTicks); } }
  9. That seems to have done the trick! I no longer crash when throwing the shuriken. Thank you very much! Curious though, it may be because of the way I'm rendering the shuriken but I can't seem to see the shuriken being thrown. I can see the smoke animation when it hits a block but not the shuriken itself. I'm wondering if that's because of the way I'm initializing "new ResourceLocation(...)". Can you verify that this is the proper way of constructing a resource location? private static final ResourceLocation shurikenTexture = new ResourceLocation(Reference.MOD_ID, "textures/items/shuriken.png"); I can post the code for Reference.java if need be
  10. I called that in clientproxy.java in "preinit()" which I've just added to the original post I'll also include it here ClientProxy.java package com.puresalvation.test.proxy; import com.puresalvation.test.entity.EntityShuriken; import com.puresalvation.test.init.ModItems; import com.puresalvation.test.render.RenderShuriken; public class ClientProxy implements CommonProxy { @Override public void preInit() { // Called on Client Side RenderShuriken.registerRender(); } @Override public void init() { // Called on the client side ModItems.registerRenders(); } }
  11. [SOLUTION] So in my case, in RenderShuriken.java, I changed the createRenderFor(...) in the registerRender() method to look like the following... public static void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityShuriken.class, new IRenderFactory() { @Override public Render createRenderFor(RenderManager manager) { return new RenderShuriken(manager); } }); } ================================================================================================================= I'm having issues with my shuriken (ninja star) entity (throwable) that is causing a null pointer exception when spawned into the minecraft world. I believe it happens when it tries to draw the entity because if I don't register the entity, I can throw the shuriken, it'll just be invisible when I do. I appreciate any and all help Potential Causes - things I think could be the issue but aren't sure 1. I'm pretty sure I'm doing something wrong when initializing "new ResourceLocation(<domain>, <path>)". Can someone please verify if I'm doing it correctly? 2. I have a method that registers all of my entities. I think that could be in the wrong place as well (e.g. putting it in "init()" when it should be in "postinit()" or something) PLEASE let me know if I need to post/add anything else. Thank you! CRASH REPORT ItemShuriken.java package com.puresalvation.test.items; import com.puresalvation.test.Reference; import com.puresalvation.test.TestMod; import com.puresalvation.test.entity.EntityShuriken; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; public class ItemShuriken extends Item { // [CONSTRUCTOR] public ItemShuriken() { setUnlocalizedName(Reference.TestItems.SHURIKEN.getUnlocalizedName()); setRegistryName(Reference.TestItems.SHURIKEN.getRegistryName()); setCreativeTab(TestMod.modTab); } // [METHODS] /* * Item is NOT repairable in an anvil */ @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return false; } /* * When right-clicked... * (1) Decrement the stack size (if in Survival Mode) * (2) Perform any animation and play sound * (3) Create and Spawn the corresponding entity into the world */ @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { // Create an ItemStack from the item being held in the Main/Offhand of player (Main/Offhand determined by "handIn") ItemStack itemstack = playerIn.getHeldItem(handIn); // (1) Decrement the stack size if NOT in creative mode if (!playerIn.capabilities.isCreativeMode) { itemstack.shrink(1); } // (2) Play the sound worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); // (3) Create and Spawn the shuriken entity into the world if (!worldIn.isRemote) { EntityShuriken shuriken = new EntityShuriken(worldIn, playerIn); //EntitySnowball snowball = new EntitySnowball(worldIn, playerIn); // Set the entity's direction, velocity, inaccuracy, rotation, etc. //snowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); shuriken.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); //worldIn.spawnEntity(snowball); // spawn the entity into the world worldIn.spawnEntity(shuriken); // spawn the entity into the world } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); //return super.onItemRightClick(worldIn, playerIn, handIn); } } EntityShuriken.java - can someone verify I'm doing "new ResourceLocation(...)" correctly? package com.puresalvation.test.entity; import java.util.Arrays; import com.puresalvation.test.Reference; import com.puresalvation.test.TestMod; import com.puresalvation.test.init.ModItems; import com.puresalvation.test.render.RenderShuriken; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.registry.EntityRegistry; public class EntityShuriken extends EntityThrowable { public static final float GRAVITY = 0.03F; public static final Block[] SHURIKEN_BREAKS_THROUGH = {Blocks.TALLGRASS, Blocks.VINE, Blocks.RED_FLOWER, Blocks.YELLOW_FLOWER, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM, Blocks.REEDS, Blocks.DOUBLE_PLANT, Blocks.DEADBUSH, Blocks.WHEAT, Blocks.WATERLILY, Blocks.CARROTS, Blocks.POTATOES, Blocks.SNOW_LAYER}; // [CONSTRUCTORS] public EntityShuriken(World worldIn) { super(worldIn); } public EntityShuriken(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public EntityShuriken(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } // [METHODS] public static void registerEntity() { EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "textures/items/shuriken.png"), EntityShuriken.class, Reference.TestItems.SHURIKEN.getUnlocalizedName(), 0, TestMod.instance, 64, 10, true); } /* Custom Helper Method * * Inflict damage on the entity hit by the shuriken */ private void inflictDamage(RayTraceResult result) { // Get the entity that was hit by the shuriken and inflict damage result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 4); } /* Custom Helper Method * * Destroy the shuriken entity once it hits another entity or a block. Also add a little animation too */ private void destroySelf() { // A little smoke animation this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]); // Destroy the shuriken entity and remove it from the world (inherited from the entity class) this.setDead(); } /* * When the shuriken entity hits something... */ @Override protected void onImpact(RayTraceResult result) { if (result.typeOfHit == RayTraceResult.Type.BLOCK) // Shuriken hits a block { // Get the block that the shuriken hit Block block = this.world.getBlockState(result.getBlockPos()).getBlock(); // If the shuriken collides with vegetation and other "quasi" blocks, destroy the thing and continue on its path if (Arrays.asList(SHURIKEN_BREAKS_THROUGH).contains(block)) { // Get info relevant so the broken vegetation block is harvestable BlockPos blockpos = result.getBlockPos(); IBlockState blockstate = this.world.getBlockState(blockpos); TileEntity te = this.world.getTileEntity(blockpos); if (this.getThrower() instanceof EntityPlayer) // if thrower is a player { // Destroy the block but make sure it's harvestable EntityPlayer player = (EntityPlayer)this.getThrower(); this.world.destroyBlock(blockpos, false); block.harvestBlock(this.world, player, blockpos, blockstate, te, new ItemStack(ModItems.shuriken)); // TODO: Verify the last parameter is correct (making a guess on this one) } } // Otherwise it hit a block or entity and can be destroyed else { this.destroySelf(); } } else { if (result.entityHit != null) { this.inflictDamage(result); } this.destroySelf(); } } /* * Override impact of gravity to be minimal */ @Override protected float getGravityVelocity() { return this.GRAVITY; } } RenderShuriken.java - can someone verify I'm doing "new ResourceLocation(...)" correctly? package com.puresalvation.test.render; import org.lwjgl.opengl.GL11; import com.puresalvation.test.Reference; import com.puresalvation.test.entity.EntityShuriken; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.RenderingRegistry; public class RenderShuriken extends Render { // Location of the texture private static final ResourceLocation shurikenTexture = new ResourceLocation(Reference.MOD_ID, "textures/items/shuriken.png"); // [CONSTRUCTORS] public RenderShuriken(RenderManager renderManager) { super(renderManager); } // [METHODS] public static void registerRender() { //RenderingRegistry.registerEntityRenderingHandler(EntityShuriken.class, new RenderShuriken(Minecraft.getMinecraft().getRenderManager())); RenderingRegistry.registerEntityRenderingHandler(EntityShuriken.class, new IRenderFactory() { @Override public Render createRenderFor(RenderManager manager) { return new RenderShuriken(Minecraft.getMinecraft().getRenderManager()); } }); } /* Custom Helper Method * * Return the texture of the shuriken */ protected ResourceLocation getEntityTexture(EntityShuriken shuriken) { return this.shurikenTexture; } /* * Cast the entity to a shuriken and call the helper method to get the texture */ @Override protected ResourceLocation getEntityTexture(Entity entity) { return this.getEntityTexture((EntityShuriken)entity); } @Override public void doRender(Entity entity, double x, double y, double z, float entityYaw, float partialTicks) { doRender((EntityShuriken)entity, x, y, z, entityYaw, partialTicks); } public void doRender(EntityShuriken shuriken, double x, double y, double z, float entityYaw, float partialTicks) { //EntityShuriken shuriken = (EntityShuriken)entity; this.bindEntityTexture(shuriken); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); // set texture color to white // Everything between pushMatrix and popMatrix will affect the render GlStateManager.pushMatrix(); // push Matrix and start operations GlStateManager.translate((float)x, (float)y, (float)z); // Move matrix to the world position of the shuriken //GlStateManager.rotate(shuriken.prevRotationYaw + (shuriken.rotationYaw - shuriken.prevRotationYaw) * entityYaw - 90.0F, 0.0F, 1.0F, 0.0F); // rotate on y-axis to face the direction the player is facing Tessellator tessellator = Tessellator.getInstance(); // Tessellator generates quad faces from a list of vertices VertexBuffer vertexbuffer = tessellator.getBuffer(); // Draws the quad faces GlStateManager.enableRescaleNormal(); // Performs OpenGL operation which sets a flag to enable uniform normal rescaling // Set scale variable to use as a global scaling value for the matrix and normals. Then scale the matrix accordingly float scale = 0.05F; GlStateManager.scale(scale, scale, scale); GL11.glNormal3f(0.0F, 0.0F, scale); // set facing direction of normal. Basically set direction of individual vertices or a quad // ==================================================================== // Draw quads for the shuriken model (will be manually creating quads) // ____________________________________________________________________ // Draw front-facing quad vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); // start of quad drawing vertexbuffer.pos(-2.0D, -2.0D, 0.0D).tex(0, 0).endVertex(); vertexbuffer.pos(2.0D, -2.0D, 0.0D).tex(1, 0).endVertex(); vertexbuffer.pos(2.0D, 2.0D, 0.0D).tex(1, 1).endVertex(); vertexbuffer.pos(-2.0D, 2.0D, 0.0D).tex(0, 1).endVertex(); tessellator.draw(); // end of quad drawing // Draw back-facing quad (by rotating it 180 degrees and redrawing the same quad) GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); // rotate 180 degrees vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos(-2.0D, -2.0D, 0.0D).tex(0, 0).endVertex(); vertexbuffer.pos(2.0D, -2.0D, 0.0D).tex(1, 0).endVertex(); vertexbuffer.pos(2.0D, 2.0D, 0.0D).tex(1, 1).endVertex(); vertexbuffer.pos(-2.0D, 2.0D, 0.0D).tex(0, 1).endVertex(); tessellator.draw(); // ==================================================================== GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); // return matrix to default translation super.doRender(shuriken, x, y, z, entityYaw, partialTicks); } } Main class - included a comment on line 68 (inside "preinit()") pointing out the code causing my crash package com.puresalvation.test; import java.util.Set; import com.google.common.collect.Sets; import com.puresalvation.test.entity.EntityShuriken; import com.puresalvation.test.init.ModCrafting; import com.puresalvation.test.init.ModItems; import com.puresalvation.test.proxy.CommonProxy; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; /* * Most of the initializations will happen here */ @Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_VERSIONS) public class TestMod { @Instance public static TestMod instance; @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; // Creative Tab public static CreativeTabs modTab = new ModTab("tab_mod"); // adds a creative tab for our mod // Tools related public static ToolMaterial SAVAGE_MATERIAL = EnumHelper.addToolMaterial("Savage", 3, 200, 64.0F, 10.0F, 15); // New Tool Material: Savage public static ToolMaterial BASIC_MULTITOOL_MATERIAL = EnumHelper.addToolMaterial("Basic Multi-Tool", 3, 2800, 10.0F, 6.0F, 10); // New Tool Material: Basic Multi-Tool Material public static ToolMaterial MULTITOOL_MATERIAL = EnumHelper.addToolMaterial("Multi-Tool", 3, 85000, 64.0F, 20.0F, 15); // New Tool Material: Multi-Tool public static final Set<Block> MY_EFFECTIVE_ON_1 = Sets.newHashSet(new Block[] {Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE}); public static final Set<Block> MULTITOOL_EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH, Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE, Blocks.LEAVES}); @EventHandler public void preInit(FMLPreInitializationEvent event) { System.out.println("Pre Init"); // Using Polymorphism, will appropriately call preInit for both client and server side proxy.preInit(); ModItems.init(); ModItems.register(); // Register Entities EntityShuriken.registerEntity(); // !!!!! CAUSING CRASH !!!!! } @EventHandler public void init(FMLInitializationEvent event) { System.out.println("Init"); // Using Polymorphism, will appropriately call init for both client and server side proxy.init(); // Register the crafting recipes ModCrafting.register(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { System.out.println("Post Init"); } } ClientProxy.java package com.puresalvation.test.proxy; import com.puresalvation.test.entity.EntityShuriken; import com.puresalvation.test.init.ModItems; import com.puresalvation.test.render.RenderShuriken; public class ClientProxy implements CommonProxy { @Override public void preInit() { // Called on Client Side RenderShuriken.registerRender(); } @Override public void init() { // Called on the client side ModItems.registerRenders(); } } SCREENSHOT - Class Model Hierarchy

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.