Jump to content

Leviathan143

Forge Modder
  • Posts

    211
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Leviathan143

  1. In 1.10.2 you do not need deobfuscated jars to run mods in the dev workspace, Forge will deobfuscate the jar automatically. Also I'd test with a FakePlayer, instances of FakePlayer should have UUIDs, but testing doesn't hurt.
  2. if(stack.getItem().getClass() == BuildHelperMod.exchangeWand.getClass()) This is unnecessary, stack will always be an ItemStack of the Item the ItemMeshDefinition was registered to. Also, Items are singletons, you can compare directly with stack.getItem() == BuildHelperMod.exchangeWand. The only instance of an Item that will ever exist ingame is the one registered through GameRegistry . Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, 0, new ModelResourceLocation(BuildHelperMod.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory")); This is deprecated, use ModelLoader#setCustomModelResourceLocation() . Refer here for why. Get rid of getUnlocalizedName().substring(5) too, use IForgeRegistryEntry#getRegistryName ( IForgeRegistryEntry is implemented by both Block and Item ). The unlocalised name should not determine the registry name, unlocalised names can change, registry names should not. In addition, post the console log, it may have useful information.
  3. Entity renders and TESRs have hooks that allow complete control of rendering. As far as I am aware, there is no longer anything like that for items.
  4. In addition to the problems Matryoshika mentioned, methods annotated with @SubscribeEvent can only have one parameter(the event).
  5. Were you wearing the armor when you obtained that log?
  6. Can you post the log? There should be an error.
  7. A dispenser can only dispense items, you cannot put an Entity in it's inventory. Hence the interface is called IBehaviourDispenseItem, because it defines how the dispenser should behave when it dispenses a certain Item. However you can create and register an IBehaviorDispenseItem to spawn an entity when an Item is dispensed. If you just want your item to behave like a snowball, you want BehaviorProjectileDispense. Override BehaviorProjectileDispense#getProjectileEntity() to return the appropriate Entity using an anonymous class. Examples can be found in net.minecraft.init.Bootstrap#registerDispenserBehaviors(). I also recommend that you investigate the options in the context menu that appears when you right-click inside the code window. I figure out how to use most things by looking at call hierarchies; The options labeled Open Type Hierarchy, Declarations and References are useful for figuring out how something works or what it does.
  8. Insult or not, you are being less than friendly. I simply asked you if you knew how to search through the MC source? If you do not, I will teach you how. No one is giving you crap or misleading you either, you have a problem, we have given solutions. The solution coolAlias gave for registering dispenser behaviours would be valid if the mappings hadn't changed in 1.10.2(dispenseBehaviorRegistry is now DISPENSE_BEHAVIOR_REGISTRY); since you did not open BlockDispenser and find that out yourself, I am assuming you do not know how to search the MC source. If a solution isn't clear, ask for clarification.
  9. If you want examples, there are plenty in the MC source. Do you know how to search it? Also, calm down, insulting people who are trying to help will get you nowhere.
  10. Try registering your event handler after you've synced the config for the first time.
  11. Make an armour model class that extends ModelBiped. Return an instance of this class from Item#getArmorModel. I recommend Tabula by iChun for modelling the armour. Make sure that the armour parts have the same rotation point as the body part they render on.
  12. You're thinking of right-clicking air. Right clicking items/blocks definitely occurs on both client and server.
  13. You'll need to create a class that implements IItemColor and register it with the ItemColors class, there's a getter for ItemColors in Minecraft(The class) . Do not ever reference your IItemColor server-side, IItemColor is client-side only so it does not exist in the server .jar.
  14. IEntityAdditionalSpawnData is what I was looking for, thanks.
  15. I'm currently attempting to make a throwable knife, however one of the fields in the entity class isn't propagating to the client. This is in 1.8, using Forge 11.14.4.1577. I would update, however the mod is large enough that this would not be the work of a few minutes, and I'd have to discuss it with my fellow dev. The problem: The field EntityThrownKnife#knife, which stores the thrown knife is null clientside. The expected behaviour: EntityThrownKnife#knife is sent to the client in the entity's NBT. The actual behaviour: EntityThrownKnife#knife has the correct value server-side, but it is null client-side. ItemKnife.java package net.einsteinsci.betterbeginnings.items; import net.einsteinsci.betterbeginnings.entity.projectile.EntityThrownKnife; import net.einsteinsci.betterbeginnings.register.IBBName; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.world.World; import java.util.HashSet; import java.util.Set; public abstract class ItemKnife extends ItemTool implements IBBName { public static final float DAMAGE = 3.0f; public ItemKnife(ToolMaterial material) { super(DAMAGE, material, getBreakable()); } public static Set getBreakable() { Set<Block> s = new HashSet<>(); // s.add(Blocks.log); // s.add(Blocks.log2); // s.add(Blocks.planks); s.add(Blocks.pumpkin); s.add(Blocks.lit_pumpkin); s.add(Blocks.melon_block); s.add(Blocks.clay); s.add(Blocks.grass); s.add(Blocks.mycelium); s.add(Blocks.leaves); s.add(Blocks.leaves2); s.add(Blocks.brown_mushroom_block); s.add(Blocks.red_mushroom_block); s.add(Blocks.glass); s.add(Blocks.glass_pane); s.add(Blocks.soul_sand); s.add(Blocks.stained_glass); s.add(Blocks.stained_glass_pane); s.add(Blocks.cactus); return s; } @Override public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); return super.onItemRightClick(itemStackIn, worldIn, playerIn); } @Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) { if(!worldIn.isRemote) { worldIn.spawnEntityInWorld(new EntityThrownKnife(worldIn, playerIn, stack)); playerIn.destroyCurrentEquippedItem(); } } @Override public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.BOW; } @Override public int getMaxItemUseDuration(ItemStack stack) { return 72000; } @Override public boolean shouldRotateAroundWhenRendering() { return true; } @Override public int getHarvestLevel(ItemStack stack, String toolClass) { return toolMaterial.getHarvestLevel(); } @Override public Set<String> getToolClasses(ItemStack stack) { Set<String> res = new HashSet<>(); res.add("knife"); return res; } // ...which also requires this... @Override public ItemStack getContainerItem(ItemStack itemStack) { ItemStack result = itemStack.copy(); result.setItemDamage(itemStack.getItemDamage() + 1); return result; } // Allows durability-based crafting. @Override public boolean hasContainerItem(ItemStack stack) { return true; } @Override public abstract String getName(); } EntityThrownKnife.java package net.einsteinsci.betterbeginnings.entity.projectile; import net.einsteinsci.betterbeginnings.items.ItemKnife; import net.einsteinsci.betterbeginnings.register.RegisterItems; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityThrownKnife extends EntityThrowable { private static final String TAG_THROWN_KNIFE = "ThrownKnife"; private ItemStack knife; public EntityThrownKnife(World worldIn) { super(worldIn); } public EntityThrownKnife(World world, EntityLivingBase thrower, ItemStack knife) { super(world, thrower); this.knife = knife; } @Override protected void onImpact(MovingObjectPosition mop) { switch(mop.typeOfHit) { case BLOCK: if(this.knife != null && !worldObj.isRemote && !this.damageKnifeFromBlock(mop.getBlockPos(), knife)) { System.out.println("Block Hit"); EntityItem droppedKnife = new EntityItem(worldObj, posX, posY, posZ, knife); worldObj.spawnEntityInWorld(droppedKnife); } break; case ENTITY: mop.entityHit.attackEntityFrom(DamageSource.generic, ((ItemTool)knife.getItem()).getToolMaterial().getDamageVsEntity() + ItemKnife.DAMAGE); if(this.knife != null && !worldObj.isRemote && !knife.attemptDamageItem(2, rand)) { EntityItem droppedKnife = new EntityItem(worldObj, posX, posY, posZ, knife); worldObj.spawnEntityInWorld(droppedKnife); } break; default: break; } this.setDead(); } private boolean damageKnifeFromBlock(BlockPos pos, ItemStack knife) { Block blockHit = worldObj.getBlockState(pos).getBlock(); int damage = Math.round(blockHit.getBlockHardness(worldObj, pos)); if (damage == -1) damage = knife.getMaxDamage() + 1; return knife.attemptDamageItem(damage, rand); } @Override public void readEntityFromNBT(NBTTagCompound tagCompound) { super.readEntityFromNBT(tagCompound); knife = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag(TAG_THROWN_KNIFE)); } @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); if(knife != null) { NBTTagCompound thrownKnife = knife.writeToNBT(new NBTTagCompound()); tagCompound.setTag(TAG_THROWN_KNIFE, thrownKnife); System.out.println(tagCompound); } } public ItemStack getKnife() { return knife != null ? knife : new ItemStack(Items.stick); } } RenderThrownKnife.java package net.einsteinsci.betterbeginnings.client; import net.einsteinsci.betterbeginnings.entity.projectile.EntityThrownKnife; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.entity.Entity; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; public class RenderThrownKnife extends RenderSnowball { public RenderThrownKnife(Minecraft minecraft) { super(minecraft.getRenderManager(), Items.stick, minecraft.getRenderItem()); } @Override public ItemStack func_177082_d(Entity entityIn) { return ((EntityThrownKnife) entityIn).getKnife(); } } An alternate version of EntityThrownKnife which uses the DataWatcher package net.einsteinsci.betterbeginnings.entity.projectile; import net.einsteinsci.betterbeginnings.items.ItemKnife; import net.einsteinsci.betterbeginnings.register.RegisterItems; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityThrownKnife extends EntityThrowable { private static final String TAG_THROWN_KNIFE = "ThrownKnife"; private static final int DATA_THROWN_KNIFE = 16; private ItemStack knife; public EntityThrownKnife(World worldIn) { super(worldIn); } public EntityThrownKnife(World world, EntityLivingBase thrower, ItemStack knife) { super(world, thrower); this.knife = knife; } @Override protected void entityInit() { this.dataWatcher.addObjectByDataType(DATA_THROWN_KNIFE, 5); if(knife != null) { this.dataWatcher.updateObject(DATA_THROWN_KNIFE, knife); this.dataWatcher.setObjectWatched(DATA_THROWN_KNIFE); } } @Override protected void onImpact(MovingObjectPosition mop) { switch(mop.typeOfHit) { case BLOCK: if(this.knife != null && !worldObj.isRemote && !this.damageKnifeFromBlock(mop.getBlockPos(), knife)) { System.out.println("Block Hit"); EntityItem droppedKnife = new EntityItem(worldObj, posX, posY, posZ, knife); worldObj.spawnEntityInWorld(droppedKnife); } break; case ENTITY: mop.entityHit.attackEntityFrom(DamageSource.generic, ((ItemTool)knife.getItem()).getToolMaterial().getDamageVsEntity() + ItemKnife.DAMAGE); if(this.knife != null && !worldObj.isRemote && !knife.attemptDamageItem(2, rand)) { EntityItem droppedKnife = new EntityItem(worldObj, posX, posY, posZ, knife); worldObj.spawnEntityInWorld(droppedKnife); } break; default: break; } this.setDead(); } private boolean damageKnifeFromBlock(BlockPos pos, ItemStack knife) { Block blockHit = worldObj.getBlockState(pos).getBlock(); int damage = Math.round(blockHit.getBlockHardness(worldObj, pos)); if (damage == -1) damage = knife.getMaxDamage() + 1; return knife.attemptDamageItem(damage, rand); } @Override public void readEntityFromNBT(NBTTagCompound tagCompound) { super.readEntityFromNBT(tagCompound); knife = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag(TAG_THROWN_KNIFE)); } @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); if(knife != null) { NBTTagCompound thrownKnife = knife.writeToNBT(new NBTTagCompound()); tagCompound.setTag(TAG_THROWN_KNIFE, thrownKnife); System.out.println(tagCompound); } } public ItemStack getKnife() { return this.dataWatcher.getWatchableObjectItemStack(DATA_THROWN_KNIFE); } private enum KnifeType { GOLD(RegisterItems.goldKnife), FLINT(RegisterItems.flintKnife), BONE(RegisterItems.boneKnife), IRON(RegisterItems.ironKnife), DIAMOND(RegisterItems.diamondKnife); private Item item; private KnifeType(Item item) { this.item = item; } public Item getItem() { return item; } public static int getKnifeId(Item item) { return GOLD.getItem() == item ? GOLD.ordinal() : FLINT.getItem() == item ? FLINT.ordinal() : BONE.getItem() == item ? BONE.ordinal() : IRON.getItem() == item ? IRON.ordinal() : DIAMOND.getItem() == item ? DIAMOND.ordinal() : -1; } } }
  16. Nothing changed with regards to unlocalised and localised names, you still set the unlocalised name with setUnlocalizedName() and then defined the localised name in the .lang file. What version did you last mod in?
  17. What errors is Eclipse throwing? That crash is caused by launching when Eclipse has detected errors.
  18. Override Block#canPlaceBlockAt() to return false if there is no block above.
  19. I'd suggest manipulating the player model/hand in RenderPlayerEvent & RenderHandEvent.
  20. Most of those errors are due to missing imports, Ctrl+Shift+O will fix them.
  21. Reply #9 on: November 03, 2013 Do not necropost, it's common internet etiquette.
  22. It will be used in the future because there will be other properties that will require #onCreated specifically. This, too, doesn't help the crash. Thanks anyway Then you have done something horribly wrong. The provided code should work.
×
×
  • Create New...

Important Information

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