Jump to content

Ferrettomato

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by Ferrettomato

  1. I'm trying to make an armor item that can't be removed from its slot, by either moving it in the inventory or pressing Q on it, until certain requirements are fulfilled. (I don't really care about keeping it after death, for now.) How would I go about this? I couldn't find any cancelable events for it.
  2. Yes, but when they come back down it freezes the water in a checkerboard pattern. I'm wondering if there's any way to make it so that landing on the water and immediately going back up is enough to freeze every block.
  3. Okay, I've changed it to !world.isRemote to correctly check if it's on the server, but now I'm getting the strange checkerboard effect again. (To reiterate, this is only while the player is sprint-jumping along the water. When the player is on the ground, there's a bit of delay on the block directly ahead of the player.)
  4. BlockPos pos = player.getPosition(); if(world.isRemote) { if(world.getBlockState(pos.add(0, -1, 0)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(0, -1, 0), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(1, -1, -1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(1, -1, -1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(1, -1, 0)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(1, -1, 0), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(1, -1, 1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(1, -1, 1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(0, -1, -1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(0, -1, -1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(0, -1, 1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(0, -1, 1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(-1, -1, -1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(-1, -1, -1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(-1, -1, 0)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(-1, -1, 0), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(-1, -1, 1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(-1, -1, 1), Blocks.ice.getStateFromMeta(0)); }
  5. I tried that, and, although it corrected the block placement, block updates made the ice revert to water. (I mentioned this in my first post.)
  6. I'm trying to make an item that turns water in to ice underfoot. Whenever I try to do this, though, the block changes act a bit glitchy when the player is walking, and the blocks are just in a checkerboard when sprint-jumping. From what I can tell, it's to do with the client and the server having problems with each other. (world.isRemote fixes the glitch, but the blocks revert to water when updated.) Here's my code, can anyone tell me how I can fix it? public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { BlockPos pos = player.getPosition(); if(world.getBlockState(pos.add(0, -1, 0)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(0, -1, 0), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(1, -1, -1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(1, -1, -1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(1, -1, 0)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(1, -1, 0), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(1, -1, 1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(1, -1, 1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(0, -1, -1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(0, -1, -1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(0, -1, 1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(0, -1, 1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(-1, -1, -1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(-1, -1, -1), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(-1, -1, 0)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(-1, -1, 0), Blocks.ice.getStateFromMeta(0)); if(world.getBlockState(pos.add(-1, -1, 1)).getBlock().equals(Blocks.water)) world.setBlockState(pos.add(-1, -1, 1), Blocks.ice.getStateFromMeta(0)); }
  7. I tried that, no luck. I've also updated the crash log and code accordingly. It's crashing whenever I even ask about the bounding box (it crashes on the if statement).
  8. I'm trying to make an item that affects entities within a radius around the player using World#getEntitiesWithinAABB and AxisAlignedBB#expand, but the game crashes whenever I try to create the List<EntityLiving> of entities to affect. Here's the crash log: [16:18:18] [Client thread/FATAL]: Reported exception thrown! [16:32:44] [Client thread/FATAL]: Reported exception thrown! net.minecraft.util.ReportedException: Ticking entity at net.minecraft.world.World.updateEntities(World.java:1837) ~[World.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:2176) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.NullPointerException at com.ferret.myfirstmod.items.ItemIceMask.onArmorTick(ItemIceMask.java:85) ~[itemIceMask.class:?] at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:358) ~[inventoryPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:623) ~[EntityPlayer.class:?] at net.minecraft.client.entity.EntityPlayerSP.onLivingUpdate(EntityPlayerSP.java:913) ~[EntityPlayerSP.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1828) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:334) ~[EntityPlayer.class:?] at net.minecraft.client.entity.EntityPlayerSP.onUpdate(EntityPlayerSP.java:165) ~[EntityPlayerSP.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2031) ~[World.class:?] at net.minecraft.world.World.updateEntity(World.java:1997) ~[World.class:?] at net.minecraft.world.World.updateEntities(World.java:1823) ~[World.class:?] ... 12 more And the method in question: public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if(KeyBindings.ability.isPressed()) { if(!world.getEntitiesWithinAABB(EntityLiving.class, player.getBoundingBox().expand(10, 10, 10)).isEmpty()) // the problematic line { List<EntityLiving> entities = world.getEntitiesWithinAABB(EntityLiving.class, player.getBoundingBox().expand(10, 10, 10)); for(EntityLiving entity : entities) { if(!entity.equals(player)) { entity.addPotionEffect(new PotionEffect(2, 2000, 99)); } } } } }
  9. Thanks so much! By looking at your code, I learned about using the player's motionX/Y/Z along with their LookVec, and now it works like a charm! (if a little differently to my plans)
  10. (shameless bump) If it'll help others understand what I'm trying to do, here's my code: static final AttributeModifier attribute = new AttributeModifier(UUID.fromString("ABE2DC00-867B-4842-B773-FA91B0901CFE"), "movementSpeed", 1D, 2); public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if(player.getAir() < 300) { player.setAir(300); } if(KeyBindings.ability.isKeyDown()) { if(player.isInWater()) { if(player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getModifier(UUID.fromString("ABE2DC00-867B-4842-B773-FA91B0901CFE")) == null) { player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).applyModifier(attribute); } } else player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).removeModifier(attribute); } } (the AttributeModifier is created at the beginning of the class, I just cut out some unnecessary code)
  11. I'm trying to make an item that speeds up the player in water using attribute modifiers, but it's massively restrained by the apparently unstoppable force of water lowering the player's movement speed. Is there any way to stop this? Would removing water's attribute modifier work? If so, where can I find its UUID?
  12. I'm attempting to empty the "contents" of an item by dropping them on the ground to eliminate the possibility of the contents being deleted due to a full inventory, but, whenever I attempt to do this, a ghost copy of the previously stored item is created in addition to the actual, collectible item. Is there any way to fix this? Method (there are two uses of playerIn.entityDropItem()): public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { if(itemStackIn.getItem() instanceof ItemInlayArmor) { int focusTarget = playerIn.inventory.currentItem + 1; if(!playerIn.isSneaking()) { if(itemStackIn.hasTagCompound()) { if(playerIn.inventory.getStackInSlot(focusTarget) != null) { if(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")).equals(playerIn.inventory.getStackInSlot(focusTarget).getItem())) { return itemStackIn; } } playerIn.entityDropItem(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage")), 0); //playerIn.inventory.addItemStackToInventory(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage"))); itemStackIn.setTagCompound(null); } ItemInlayArmor item = (ItemInlayArmor)itemStackIn.getItem(); if(playerIn.inventory.getStackInSlot(focusTarget) != null) { ItemStack focusItem = playerIn.inventory.getStackInSlot(focusTarget); if(validItems.contains(Item.itemRegistry.getNameForObject(focusItem.getItem()).toString())) { if(Item.itemRegistry.getNameForObject(focusItem.getItem()).toString().equals("minecraft:dye") && focusItem.getItemDamage() != 0) { return itemStackIn; } playerIn.inventory.decrStackSize(focusTarget, 1); NBTTagCompound nbt = itemStackIn.getTagCompound(); if(nbt == null) { nbt = new NBTTagCompound(); itemStackIn.setTagCompound(nbt); } itemStackIn.loadItemStackFromNBT(focusItem.writeToNBT(nbt)); } } } else if(itemStackIn.hasTagCompound()) { playerIn.entityDropItem(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage")), 0); //playerIn.inventory.addItemStackToInventory(new ItemStack(Item.getByNameOrId(itemStackIn.getTagCompound().getString("id")), 1, itemStackIn.getTagCompound().getShort("Damage"))); itemStackIn.setTagCompound(null); return itemStackIn; } } return itemStackIn; } I tried worldIn.updateEntities() without knowing its precise function, but, regardless, it had no effect.
  13. I'm attempting to create an explosion in the world when LivingAttackEvent is triggered and certain criteria are met, but, when said criteria are met, the console spams the debug println and subsequently spits out an apparently endless error message that repeats the same few lines. Could someone please explain what's wrong with this? The event (with unrelated parts omitted): @SubscribeEvent public void onHit(LivingAttackEvent event) { if(event.entityLiving instanceof EntityPlayer) { if(event.source.getSourceOfDamage() != null) { if(event.entityLiving.getCurrentArmor(2) != null) { if(event.entityLiving.getCurrentArmor(2).getItem() instanceof ItemInlayArmor) { ItemStack armor = event.entityLiving.getCurrentArmor(2); if(armor.hasTagCompound()) { if(armor.getTagCompound().getString("id").equals("minecraft:gunpowder")) { System.out.println("BANG!"); event.entityLiving.worldObj.createExplosion(event.source.getSourceOfDamage(), event.source.getSourceOfDamage().posX, event.source.getSourceOfDamage().posY, event.source.getSourceOfDamage().posZ, 1F, true); } One section of the repeating error: at com.ferret.relics.handlers.RelicEventHandler.onHit(RelicEventHandler.java:120) ~[RelicEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_RelicEventHandler_onHit_LivingAttackEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?] at net.minecraftforge.common.ForgeHooks.onLivingAttack(ForgeHooks.java:341) ~[ForgeHooks.class:?] at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1125) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:594) ~[EntityPlayerMP.class:?] at net.minecraft.world.Explosion.doExplosionA(Explosion.java:166) ~[Explosion.class:?] at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:1087) ~[WorldServer.class:?] at net.minecraft.world.World.createExplosion(World.java:2362) ~[World.class:?] at com.ferret.relics.handlers.RelicEventHandler.onHit(RelicEventHandler.java:120) ~[RelicEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_RelicEventHandler_onHit_LivingAttackEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?] at net.minecraftforge.common.ForgeHooks.onLivingAttack(ForgeHooks.java:341) ~[ForgeHooks.class:?] at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1125) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:594) ~[EntityPlayerMP.class:?] at net.minecraft.world.Explosion.doExplosionA(Explosion.java:166) ~[Explosion.class:?] at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:1087) ~[WorldServer.class:?] at net.minecraft.world.World.createExplosion(World.java:2362) ~[World.class:?]
  14. Yeah... I noticed that after I posted. Thanks!
  15. Can those affect the entity trying to damage the recipient? It seems like LivingAttackEvent and LivingHurtEvent can only affect the recipient. (correct me if I'm wrong)
  16. I'm trying to use events to affect an entity's attacker based on a certain item's NBT data, but none of the LivingEvents seem to allow this. Am I blind to some feature in the LivingEvents, or is there another way to do this?
  17. Thanks! One more question: I haven't delved in to containers yet, but would I need knowledge of them if I wanted to have the item store an actual ItemStack?
  18. I'm doing some experimenting, and that involves making a chestplate capable of storing an Item object. Unfortunately, this Item object is reset whenever the game is restarted (closed and reopened, leaving a world and coming back in the same instance of the game does not trigger the bug). I'm a novice modder, and, thus, I don't know what I've done wrong. I find it likely that the answer will be something blatantly obvious. Could someone please enlighten me? ItemInlayArmor class: package com.ferret.relics.items; import java.util.List; import com.ferret.myfirstmod.MyFirstMod; import com.ferret.myfirstmod.items.ModItems; import com.ferret.relics.Relics; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class ItemInlayArmor extends ItemArmor { Item focus; public ItemInlayArmor(ArmorMaterial material, int renderIndex, int armorType, String name) { super(material, 0, armorType); setUnlocalizedName(Relics.MODID + "_" + name); System.out.println(this.getUnlocalizedName()); } public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { return Relics.MODID + ":models/armor/inlayarmor1.png"; } public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { if(itemStackIn.getItem() instanceof ItemInlayArmor) { if(playerIn.isSneaking()) { ItemInlayArmor item = (ItemInlayArmor)itemStackIn.getItem(); int focusTarget = playerIn.inventory.currentItem + 1; if(playerIn.inventory.getStackInSlot(focusTarget) != null) { Item focusItem = playerIn.inventory.getStackInSlot(focusTarget).getItem(); playerIn.inventory.decrStackSize(focusTarget, 1); item.focus = focusItem; itemStackIn.setItem(item); } } } return itemStackIn; } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { if(focus != null) list.add(focus.getUnlocalizedName()); else list.add("Empty"); } @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if(itemStack.getItem() instanceof ItemInlayArmor) { if(focus != null) { if(focus.equals(Items.rabbit_foot)) { player.addPotionEffect(new PotionEffect(8, 300, 3)); } } } } }
  19. ClientProxy: package com.ferret.myfirstmod.proxies; import com.ferret.myfirstmod.ModBlocks; import com.ferret.myfirstmod.MyFirstMod; import com.ferret.myfirstmod.entity.EntityBlockThrowable; import com.ferret.myfirstmod.entity.EntityHusk; import com.ferret.myfirstmod.entity.EntityToxicThrowable; import com.ferret.myfirstmod.render.ModelHusk; import com.ferret.myfirstmod.render.RenderBlockThrowable; import com.ferret.myfirstmod.render.RenderHusk; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraftforge.fml.client.registry.RenderingRegistry; public class ClientProxyFerret extends CommonProxyFerret { @Override public void registerRendering() { RenderingRegistry.registerEntityRenderingHandler(EntityHusk.class, new RenderHusk(Minecraft.getMinecraft().getRenderManager(), new ModelHusk(), 0.5F)); } public void registerItemRenders() { RenderingRegistry.registerEntityRenderingHandler(EntityToxicThrowable.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), Item.getItemFromBlock(ModBlocks.lightstone), Minecraft.getMinecraft().getRenderItem())); RenderingRegistry.registerEntityRenderingHandler(EntityBlockThrowable.class, new RenderBlockThrowable(Minecraft.getMinecraft().getRenderManager(), Item.getItemFromBlock(Blocks.sand), Minecraft.getMinecraft().getRenderItem())); } } The CommonProxy is empty.
  20. I'm in the process of cleaning up my code, and something I've done in that process has broken my once-functional mob. Can anyone make sense of my ineptitude? Crash: [23:53:01] [Client thread/FATAL]: Reported exception thrown! net.minecraft.util.ReportedException: Rendering entity in world at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:425) ~[RenderManager.class:?] at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:334) ~[RenderManager.class:?] at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:301) ~[RenderManager.class:?] at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:657) ~[RenderGlobal.class:?] at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1350) ~[EntityRenderer.class:?] at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1263) ~[EntityRenderer.class:?] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1088) ~[EntityRenderer.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.NullPointerException at net.minecraft.client.renderer.entity.RendererLivingEntity.canRenderName(RendererLivingEntity.java:599) ~[RendererLivingEntity.class:?] at net.minecraft.client.renderer.entity.RenderLiving.canRenderName(RenderLiving.java:31) ~[RenderLiving.class:?] at net.minecraft.client.renderer.entity.RenderLiving.canRenderName(RenderLiving.java:172) ~[RenderLiving.class:?] at net.minecraft.client.renderer.entity.RendererLivingEntity.passSpecialRender(RendererLivingEntity.java:514) ~[RendererLivingEntity.class:?] at net.minecraft.client.renderer.entity.RendererLivingEntity.renderName(RendererLivingEntity.java:614) ~[RendererLivingEntity.class:?] at net.minecraft.client.renderer.entity.Render.doRender(Render.java:53) ~[Render.class:?] at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:209) ~[RendererLivingEntity.class:?] at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:59) ~[RenderLiving.class:?] at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:199) ~[RenderLiving.class:?] at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:377) ~[RenderManager.class:?] ... 17 more Mod class: package com.ferret.myfirstmod; import com.ferret.myfirstmod.blocks.BlockBethanysViolet; import com.ferret.myfirstmod.blocks.BlockBlightPlant; import com.ferret.myfirstmod.blocks.BlockFerretTE; import com.ferret.myfirstmod.blocks.BlockLightStone; import com.ferret.myfirstmod.entity.EntityBlockThrowable; import com.ferret.myfirstmod.entity.EntityHusk; import com.ferret.myfirstmod.handlers.FerretEventHandler; import com.ferret.myfirstmod.items.ItemBerry; import com.ferret.myfirstmod.items.ItemBlightSeed; import com.ferret.myfirstmod.items.ItemBlightSpore; import com.ferret.myfirstmod.items.ItemCheckeredBand; import com.ferret.myfirstmod.items.ItemCube; import com.ferret.myfirstmod.items.ItemDeath; import com.ferret.myfirstmod.items.ItemKey; import com.ferret.myfirstmod.items.ItemLightArmor; import com.ferret.myfirstmod.items.ItemLightIngot; import com.ferret.myfirstmod.items.ItemRainStaff; import com.ferret.myfirstmod.items.tools.ItemLightAxe; import com.ferret.myfirstmod.items.tools.ItemLightHoe; import com.ferret.myfirstmod.items.tools.ItemLightPaxel; import com.ferret.myfirstmod.items.tools.ItemLightPickaxe; import com.ferret.myfirstmod.items.tools.ItemLightShovel; import com.ferret.myfirstmod.items.tools.ItemLightStone; import com.ferret.myfirstmod.items.tools.ItemLightSword; import com.ferret.myfirstmod.proxies.ClientProxyFerret; import com.ferret.myfirstmod.proxies.CommonProxyFerret; import com.ferret.myfirstmod.tileentities.TileEntityFerret; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.DungeonHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; @Mod(modid = MyFirstMod.MODID, version = MyFirstMod.VERSION) public class MyFirstMod { public static final String MODID = "ferret_myfirstmod"; public static final String VERSION = "1.0"; FerretEventHandler handler = new FerretEventHandler(); @SidedProxy(clientSide = "com.ferret.myfirstmod.proxies.ClientProxyFerret", serverSide = "com.ferret.myfirstmod.proxies.CommonProxyFerret") public static CommonProxyFerret proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.registerRendering(); ModBlocks.loadBlocks(); GameRegistry.registerTileEntity(TileEntityFerret.class, "TE_ferretTE"); ModItems.loadItems(); proxy.registerItemRenders(); ModEntities.loadEntities(this); GameRegistry.registerWorldGenerator(handler, 0); MinecraftForge.EVENT_BUS.register(handler); OreDictionary.registerOre("ingotLight", new ItemStack(ModItems.lightingot)); } @EventHandler public void init(FMLInitializationEvent event) { //Block models Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.lightstone), 0, new ModelResourceLocation("ferret_myfirstmod:lightstone", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.lightstone), 1, new ModelResourceLocation("ferret_myfirstmod:lightwall", "inventory")); ModelBakery.addVariantName(Item.getItemFromBlock(ModBlocks.lightstone), new String[]{"ferret_myfirstmod:lightstone", "ferret_myfirstmod:lightwall"}); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blightplant), 0, new ModelResourceLocation("ferret_myfirstmod:blightplant", "inventory")); ModelBakery.addVariantName(Item.getItemFromBlock(ModBlocks.blightplant), new String[]{"ferret_myfirstmod:blightplant1", "ferret_myfirstmod:blightplant2", "ferret_myfirstmod:blightplant3", "ferret_myfirstmod:blightplant4"}); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.ferretTE), 0, new ModelResourceLocation("ferret_myfirstmod:zero", "inventory")); ModelBakery.addVariantName(Item.getItemFromBlock(ModBlocks.ferretTE), new String[]{"ferret_myfirstmod:zero"}); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.bethanysviolet), 0, new ModelResourceLocation("ferret_myfirstmod:bethanysviolet", "inventory")); //Item models Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.key, 0, new ModelResourceLocation("ferret_myfirstmod:greykey", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.key, 1, new ModelResourceLocation("ferret_myfirstmod:redkey", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.key, 2, new ModelResourceLocation("ferret_myfirstmod:greenkey", "inventory")); ModelBakery.addVariantName(ModItems.key, new String[]{"ferret_myfirstmod:greykey", "ferret_myfirstmod:redkey", "ferret_myfirstmod:greenkey"}); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.cube, 0, new ModelResourceLocation("ferret_myfirstmod:cube", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.berry, 0, new ModelResourceLocation("ferret_myfirstmod:berry", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightingot, 0, new ModelResourceLocation("ferret_myfirstmod:lightingot", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.death, 0, new ModelResourceLocation("ferret_myfirstmod:death", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.rainstaff, 0, new ModelResourceLocation("ferret_myfirstmod:rainstaff", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.blightseed, 0, new ModelResourceLocation("ferret_myfirstmod:blightseed", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.blightspore, 0, new ModelResourceLocation("ferret_myfirstmod:blightspore", "inventory")); //Tool models Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightpickaxe, 0, new ModelResourceLocation("ferret_myfirstmod:lightpickaxe", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightsword, 0, new ModelResourceLocation("ferret_myfirstmod:lightsword", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightaxe, 0, new ModelResourceLocation("ferret_myfirstmod:lightaxe", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightshovel, 0, new ModelResourceLocation("ferret_myfirstmod:lightshovel", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lighthoe, 0, new ModelResourceLocation("ferret_myfirstmod:lighthoe", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightpaxel, 0, new ModelResourceLocation("ferret_myfirstmod:lightpaxel", "inventory")); //Armor models Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lighthelmet, 0, new ModelResourceLocation("ferret_myfirstmod:lighthelmet", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightchestplate, 0, new ModelResourceLocation("ferret_myfirstmod:lightchestplate", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightleggings, 0, new ModelResourceLocation("ferret_myfirstmod:lightleggings", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.lightboots, 0, new ModelResourceLocation("ferret_myfirstmod:lightboots", "inventory")); ModelBakery.addVariantName(ModItems.lighthelmet, new String[]{"ferret_myfirstmod:lighthelmet", "ferret_myfirstmod:lightchestplate", "ferret_myfirstmod:lightleggings", "ferret_myfirstmod:lightboots"}); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.checkeredband, 0, new ModelResourceLocation("ferret_myfirstmod:checkeredband", "inventory")); ModelBakery.addVariantName(ModItems.checkeredband, new String[]{"ferret_myfirstmod:checkeredband"}); //Recipes GameRegistry.addSmelting(new ItemStack(ModBlocks.lightstone, 1, 0), new ItemStack(ModItems.lightingot), 0.1F); GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.lightsword, " X ", " X ", " Y ", 'X', "ingotLight", 'Y', Items.stick )); GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.lightpickaxe, "XXX", " Y ", " Y ", 'X', "ingotLight", 'Y', Items.stick )); GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.lightaxe, " XX", " YX", " Y ", 'X', "ingotLight", 'Y', Items.stick )); GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.lightshovel, " X ", " Y ", " Y ", 'X', "ingotLight", 'Y', Items.stick )); GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.lighthoe, " XX", " Y ", " Y ", 'X', "ingotLight", 'Y', Items.stick )); GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.lightpaxel, "YXZ", 'X', "ingotLight", 'Y', ModItems.lightpickaxe, 'Z', ModItems.lightaxe )); GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 5), ModBlocks.bethanysviolet ); GameRegistry.addSmelting(Blocks.stone, new ItemStack(Blocks.stonebrick), 0.1F); ItemStack enchantedSwordItemStack = new ItemStack(Items.stone_sword); enchantedSwordItemStack.addEnchantment(Enchantment.sharpness, 1); GameRegistry.addShapelessRecipe(enchantedSwordItemStack, Items.flint, Items.stone_sword ); //Dungeon changes DungeonHooks.removeDungeonMob("Spider"); DungeonHooks.addDungeonMob("Blaze", 100); ChestGenHooks.addItem(ChestGenHooks.BONUS_CHEST, new WeightedRandomChestContent(new ItemStack(Blocks.cobblestone), 25, 50, 10)); } } ModEntities class: package com.ferret.myfirstmod; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.fml.common.registry.EntityRegistry; import com.ferret.myfirstmod.entity.EntityBlockThrowable; import com.ferret.myfirstmod.entity.EntityHusk; public class ModEntities { static int startEntityId = 300; public static void loadEntities(MyFirstMod mod) { EntityRegistry.registerModEntity(EntityHusk.class, "husk", 0, mod, 80, 3, true); EntityRegistry.registerModEntity(EntityBlockThrowable.class, "blockthrow", 1, mod, 80, 3, true); for(int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++) { if(BiomeGenBase.getBiomeGenArray()[i] != null) { EntityRegistry.addSpawn(EntityHusk.class, 10, 1, 3, EnumCreatureType.MONSTER, BiomeGenBase.getBiomeGenArray()[i]); } } registerEntityEgg(EntityHusk.class, 0xd8bb9d, 0xa63c1a); } @SuppressWarnings("unchecked") public static void registerEntityEgg(Class<? extends Entity> entity, int primaryColor, int secondaryColor) { int id = getUniqueEntityId(); EntityList.idToClassMapping.put(id, entity); EntityList.entityEggs.put(id, new EntityList.EntityEggInfo(id, primaryColor, secondaryColor)); } public static int getUniqueEntityId() { do { startEntityId++; } while(EntityList.getStringFromID(startEntityId) != null); return startEntityId; } } Entity class: package com.ferret.myfirstmod.entity; import com.ferret.myfirstmod.ModBlocks; import com.ferret.myfirstmod.ModItems; import com.ferret.myfirstmod.MyFirstMod; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class EntityHusk extends EntityMob { public EntityHusk(World par1World) { super(par1World); //this.getNavigator().setBreakDoors(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); this.tasks.addTask(3, new EntityAIWander(this, 1.0D)); this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(4, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); } protected Item getDropItem() { return ModItems.death; } protected void getRareDrop(int par1) { switch (this.rand.nextInt(2)) { case 0: this.dropItem(ModItems.blightseed, 1); break; case 1: this.dropItem(Item.getItemFromBlock(ModBlocks.ferretTE), 1); } } } Render class: package com.ferret.myfirstmod.render; import com.ferret.myfirstmod.MyFirstMod; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class RenderHusk extends RenderLiving { public RenderHusk(RenderManager renderManager, ModelBase par1ModelBase, float par2) { super(renderManager, par1ModelBase, par2); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation(MyFirstMod.MODID, "textures/textures/models/husk.png"); } }
  21. I'm attempting to follow the instructions laid out by "Sams Teach Yourself Minecraft Mod Development in 24 Hours" that allows the player to throw eggs when they right click with an empty hand if they're wearing certain armor. Unfortunately, when I attempt to use this function in-game, it only works if the player is targeting a block. RIGHT_CLICK_AIR and RIGHT_CLICK_BLOCK are located in the same part of my code, so what's going on? Method inside of FerretEventHandler: @SubscribeEvent public void throwEggs(PlayerInteractEvent event) { if(!event.world.isRemote) { if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR || event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { if(event.entityPlayer.getCurrentEquippedItem() == null) { boolean hasFullSuit = true; for(int i = 0; i < 4; i++) { if(event.entityPlayer.getCurrentArmor(i) == null) { hasFullSuit = false; return; } else if(!(event.entityPlayer.getCurrentArmor(i).getItem() instanceof ItemLightArmor)) { hasFullSuit = false; } if(hasFullSuit) { event.entityPlayer.worldObj.spawnEntityInWorld(new EntityEgg(event.entityPlayer.getEntityWorld(), event.entityPlayer)); } } } } } }
  22. I'm trying to make a throwable that places a specified Block on impact, and I'm trying to have it change to the appearance of the block specified. The ClientProxy render code doesn't seem to be usable for this, since it needs everything to be static. Is there any way to do this?
  23. Okay, I've done that and it seems to like it, but now, when I try to get it to do what it does in the tick method, nothing happens. The method is never called, according to the println at the beginning. I know that other methods, such as "editCounter", are being correctly called, since it prints "Switch" when I right click the block (hence, the entity IS working with the block as intended to that extent), but there's no "Tick". What's wrong this time? TileEntityFerret class: package com.ferret.myfirstmod; import net.minecraft.block.Block; import net.minecraft.block.BlockJukebox; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.texture.ITickable; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.tileentity.TileEntityBeacon; import net.minecraft.tileentity.TileEntityBrewingStand; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntityComparator; import net.minecraft.tileentity.TileEntityDaylightDetector; import net.minecraft.tileentity.TileEntityDispenser; import net.minecraft.tileentity.TileEntityDropper; import net.minecraft.tileentity.TileEntityEnchantmentTable; import net.minecraft.tileentity.TileEntityEndPortal; import net.minecraft.tileentity.TileEntityEnderChest; import net.minecraft.tileentity.TileEntityFlowerPot; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityHopper; import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraft.tileentity.TileEntityNote; import net.minecraft.tileentity.TileEntityPiston; import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySkull; public class TileEntityFerret extends TileEntity implements ITickable { private int counter = 0; private int metadata; private IBlockState state; private boolean counterEnabled = true; @Override public void tick() { System.out.println("Tick"); if(counterEnabled) { counter++; if(counter > 20) { counter = 0; metadata = this.getBlockMetadata() + 1; if(metadata > 9) { metadata = 0; } if(!worldObj.isRemote) { worldObj.setBlockState(pos, worldObj.getBlockState(pos).getBlock().getStateFromMeta(metadata)); System.out.println("Block changed!"); } } } } public void editCounter() { System.out.println("Switch"); counterEnabled = !counterEnabled; markDirty(); worldObj.markBlockForUpdate(pos); } @Override public void readFromNBT (NBTTagCompound tag) { super.readFromNBT(tag); counter = tag.getInteger("counter"); counterEnabled = tag.getBoolean("counterEnabled"); } @Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setInteger("counter", counter); tag.setBoolean("counterEnabled", counterEnabled); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { this.readFromNBT(packet.getNbtCompound()); } @Override public Packet getDescriptionPacket() { NBTTagCompound var1 = new NBTTagCompound(); this.writeToNBT(var1); return new S35PacketUpdateTileEntity(pos, 1, var1); } }
×
×
  • Create New...

Important Information

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