Everything posted by Leviathan143
-
(SOLVED) [1.10.2] Custom block rendering with weird black stuff?
Block#createTileEntity()
-
[1.10.2] IllegalArgumentException Name and ID cannot both be blank
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.
-
[1.10.2] How to change item icons on runtime?[solved]
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.
-
[1.9.4+] Render Item/Block on top of my item
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.
-
[1.7.10] PlayerFlying Event ?
In addition to the problems Matryoshika mentioned, methods annotated with @SubscribeEvent can only have one parameter(the event).
-
[1.7.10][UNSOLVED] Models for armor not working
Were you wearing the armor when you obtained that log?
-
Having a mod compatible with 1.9/1.10 without a new file.
Why not update your workspace?
-
[1.7.10][UNSOLVED] Models for armor not working
Can you post the log? There should be an error.
-
How Do I Dispense A Custom Throwable Entity? (1.10.2)
- How Do I Dispense A Custom Throwable Entity? (1.10.2)
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.- How Do I Dispense A Custom Throwable Entity? (1.10.2)
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.- How Do I Dispense A Custom Throwable Entity? (1.10.2)
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.- [SOLVED]Using config numbers in code
Try registering your event handler after you've synced the config for the first time.- [1.10] [SOLVED] Custom Armor Rendering
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.- (solved)Damage item in an event[1.10]
You're thinking of right-clicking air. Right clicking items/blocks definitely occurs on both client and server.- 1.9. Giving textures with different color based on a grayscale (Like Spawn Eggs)
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.- Entity class field not propagating to client.
IEntityAdditionalSpawnData is what I was looking for, thanks.- Entity class field not propagating to client.
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; } } }- I Need Help Registering Items in [1.10]
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?- 1.9.4 registry error
What errors is Eclipse throwing? That crash is caused by launching when Eclipse has detected errors.- [1.10/1.9.4] Block requires a block above it to exist
Override Block#canPlaceBlockAt() to return false if there is no block above.- [1.9.4] Playing player arm animations
I'd suggest manipulating the player model/hand in RenderPlayerEvent & RenderHandEvent.- [1.7.10] Making an item that spawns random monsters? <Unsolved>
Most of those errors are due to missing imports, Ctrl+Shift+O will fix them.- How do I create a custom liquid that has potion effects? [NOT SOLVED: HARD]
Reply #9 on: November 03, 2013 Do not necropost, it's common internet etiquette.- My knawlidge isn't working [what is NBT baby don't hurt me no more].
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. - How Do I Dispense A Custom Throwable Entity? (1.10.2)
IPS spam blocked by CleanTalk.
Important Information
By using this site, you agree to our Terms of Use.