-
Posts
11 -
Joined
-
Last visited
Posts posted by Harystolho
-
-
@Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { if ((stack.getMaxItemUseDuration() - entityLiving.getItemInUseCount()) / 20.0F > 5.0) { NBTTagCompound tag = stack.getTagCompound(); int radius = tag.getInteger("ToolRadius"); for (int x = -radius; x < radius + 1; x++) { for (int y = -radius; y < radius + 1; y++) { for (int z = -radius; z < radius + 1; z++) { BlockPos blockpos = new BlockPos(entityLiving.getPosition().getX() + x, entityLiving.getPosition().getY() + y, entityLiving.getPosition().getZ() + z); IBlockState iblockstate = worldIn.getBlockState(blockpos); if (isOre(iblockstate.getBlock())) { IBlockState stone = Blocks.STONE.getDefaultState(); worldIn.setBlockState(blockpos, stone); ItemStack item = new ItemStack(iblockstate.getBlock()); entityLiving.entityDropItem(item, 1F); } } } } } }
I'd like to put the blocks I break in the player inventory but I couldn't find an way to do that, so I tried spawning them in the ground, It works but It also spawns some ghost items that I can't pickup
-
1 hour ago, diesieben07 said:
- Do not use ITileEntityProvider. Override hasTileEntity and createTileEntity.
- Do not use breakBlock for block drops, use getDrops. You will need additional checks, to preserve the TileEntity, see the forge patches to BlockFlowerPot.
Take a look at my class
Override hasTileEntity and createTileEntity. - OK
Do not use breakBlock for block drops, use getDrops. - OK
see the forge patches to BlockFlowerPot. - Didn't find
-
2 hours ago, Draco18s said:
The fact that the chest being not-empty causes the undesired behavior, we can look at your code and find that you have a conditional for exactly this case:
if (!tileentityiubertable.isEmpty()) {
Therefore, this code is responsible for dropping one of the two items.
spawnAsEntity(worldIn, pos, itemstack);
Oh, look, it does.
However we know that this is also the version we want to drop therefore it must be something else that's causing the empty copy to drop. Hmm. Empty chest...wait, we get one of these when the chest is empty too! There must be a line that is probably responsible and outside that if-block.
Getting a TE...no
Casting a TE...no
Only one other line:
super.breakBlock(worldIn, pos, state);
This must be responsible.
Unfortunately as you did not include your whole class, I cannot be sure that the parent class is not just Block.
public class BlockUberTable extends Block implements IHasModel, ITileEntityProvider
And I tried to do this
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityUberTable) { TileEntityUberTable tileentityiubertable = (TileEntityUberTable) tileentity; if (!tileentityiubertable.isEmpty()) { ItemStack itemstack = new ItemStack(Item.getItemFromBlock(this), 1, 0); NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound.setTag("BlockEntityTag", ((TileEntityUberTable) tileentity).writeToNBT(nbttagcompound1)); itemstack.setTagCompound(nbttagcompound); if (tileentityiubertable.hasCustomName()) { itemstack.setStackDisplayName(tileentityiubertable.getName()); tileentityiubertable.setCustomName("Uber Table"); } spawnAsEntity(worldIn, pos, itemstack); worldIn.updateComparatorOutputLevel(pos, state.getBlock()); } else { super.breakBlock(worldIn, pos, state); } } }
It still doesn't work, I still get 2 items
-
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityUberTable) { TileEntityUberTable tileentityiubertable = (TileEntityUberTable) tileentity; if (!tileentityiubertable.isEmpty()) { ItemStack itemstack = new ItemStack(Item.getItemFromBlock(this), 1, 0); NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound.setTag("BlockEntityTag", ((TileEntityUberTable) tileentity).writeToNBT(nbttagcompound1)); itemstack.setTagCompound(nbttagcompound); if (tileentityiubertable.hasCustomName()) { itemstack.setStackDisplayName(tileentityiubertable.getName()); tileentityiubertable.setCustomName("Uber Table"); } spawnAsEntity(worldIn, pos, itemstack); worldIn.updateComparatorOutputLevel(pos, state.getBlock()); } super.breakBlock(worldIn, pos, state); } }
This is a chest, if it's empty and I break it, it drops only 1 item(the chest itself) but if I put something inside it, it drops two items, one has nbt(It's a chest with the items saved in it), the other one doesn't, it's just an empty chest
-
public class ItemUberTool extends Item implements IHasModel{ public ItemUberTool(String name) { setUnlocalizedName(name); setRegistryName(name); setMaxStackSize(1); setCreativeTab(Main.UBERMINER); ItemInit.ITEMS.add(this); } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } }
I'm using setMaxStackSize(1); but it's not working, it can get a full stack of this item.
-
So I need to add the NEI for do a plugin but when i install it, it wants my MCP folder but i don't know where it is, if you know how to install NEI in minecraft 1.8 please help me
-
I found my problem and now i solved it, my furnace is working well, thank you for the help
-
Hello, I tried copying his code to mine and doing some changes but now i'm getting an error and i don't know what is it, the error is here http://pastebin.com/AWnCAvrW and the source code https://github.com/Harystolho/Hmod please help me, it's not a big thing but i can't solve
-
Hello, I'm trying to do a custom furnace in minecraft 1.8 but my furnace doesn't cook items
Furnace Container https://github.com/Harystolho/Hmod/blob/master/src/main/java/com/Hmod/container/ContainerFurnace.java
FurnaceTilyEntity https://github.com/Harystolho/Hmod/blob/master/src/main/java/com/Hmod/tile_entity/TileEntityFurnace.java
FurnaceGui https://github.com/Harystolho/Hmod/blob/master/src/main/java/com/Hmod/gui/GuiHFurnace.java
if you can help me thank you
-
Hello, I'm trying to create my 1.8 furnace but i can't if you can give me your furnace code to help me
thank you
How to perform an operation on the server side through the Event Handler?
in Modder Support
Posted
Take a look at this, try to understand it