-
Posts
307 -
Joined
-
Last visited
Everything posted by Tschipp
-
So I need to cancel the event, if the player is holding the Item and sneaking, but I don't know how to get the EntityPlayerMP object. public class MouseScroll { @SideOnly(Side.CLIENT) @SubscribeEvent public void scroll(MouseEvent event) { EntityPlayerMP player = //what do I put here? System.out.println(player.getItemInUse()); if(player.getItemInUse() != null) { if(player.getItemInUse().getItem() == CustomItems.noiseFill && player.isSneaking()) { if(event.dwheel > 0) { CreativePlus.network.sendToServer(new NoisePacket(1)); System.out.println("Packet 1 Sent"); event.setCanceled(true); } else if(event.dwheel < 0) { CreativePlus.network.sendToServer(new NoisePacket(2)); System.out.println("Packet 2 Sent"); event.setCanceled(true); } } } } }
-
Oh your're right. Sometimes I derp
-
Alright, the packet now gets recieved, but a nullPointerException is being thrown at the if(player.getItemInUse....) public class NoisePacketHandler implements IMessageHandler<NoisePacket, IMessage> { @Override public IMessage onMessage(NoisePacket message, final MessageContext ctx) { IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.worldObj; mainThread.addScheduledTask(new Runnable(){ EntityPlayerMP player = ctx.getServerHandler().playerEntity; @Override public void run() { System.out.println("Packet Recieved"); if(player.getItemInUse().getItem() == CustomItems.noiseFill && player.isSneaking()) { ItemStack stack = player.getItemInUse(); NBTTagCompound subTag = stack.getTagCompound(); subTag.setDouble("percentage", subTag.getDouble("percentage") + 0.1); stack.setTagCompound(subTag); } else { return; } } }); return null; } }
-
Yes I have. This is where I send the packet: public class MouseScroll { @SideOnly(Side.CLIENT) @SubscribeEvent public void scroll(MouseEvent event) { if(event.dwheel > 0) { CreativePlus.network.sendToServer(new NoisePacket(1)); System.out.println("Packet 1 Sent"); } else if(event.dwheel < 0) { CreativePlus.network.sendToServer(new NoisePacket(2)); System.out.println("Packet 2 Sent"); } } } This is the Packet: public class NoisePacket implements IMessage{ private int upOrDown; public NoisePacket() { } public NoisePacket(int i) { this.upOrDown = i; } @Override public void fromBytes(ByteBuf buf) { upOrDown = ByteBufUtils.readVarInt(buf, 4); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeVarInt(buf, upOrDown, 4); } } This is the Packet Handler: public class NoisePacketHandler implements IMessageHandler<NoisePacket, IMessage> { @Override public IMessage onMessage(NoisePacket message, MessageContext ctx) { IThreadListener mainThread = Minecraft.getMinecraft(); mainThread.addScheduledTask(new Runnable(){ @Override public void run() { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; System.out.println("Packet Revieved"); if(player.getItemInUse().getItem() == CustomItems.noiseFill && player.isSneaking()) { ItemStack stack = player.getItemInUse(); NBTTagCompound subTag = stack.getTagCompound(); subTag.setDouble("percentage", subTag.getDouble("percentage") + 0.1); stack.setTagCompound(subTag); } } }); return null; } } I have registred the Packet on the client Side. How do I use the Packet Handler to change some nbt on the players currently held itemStack?
-
Ok... Can you be a little bit more specific how and where I should do that?
-
I see... But I still need to get the entity from the event. How would I do that?
-
Alright, I got the event sorta working. But how do I get the player from the event? And is this the correct way to make it client-side only?(probably not) I register the event in my main Classes Pre-Init. Is that the way to do it? This is my event class: public class MouseScroll { @SideOnly(Side.CLIENT) @SubscribeEvent public void scroll(MouseEvent event) { if(event.dwheel > 0) { } else if(event.dwheel < 0) { } } }
-
1. No, I didn't. How do I do that? 2. I think it is cancellable, it says it in the MouseEvent class 3. Where should I put it then?
-
I looked at the drinkable_bottle.json, and added another layer to my item like in there. Then, in my items getColorFromItemStack function, I checked if the renderpass was less than 1, so that I could only colorize that specified texture layer.
-
I'm trying to get the scrollwheel as input for my item, but what I currently have doesn't seem to work. I'm new to events so please tell me if I'm doing something completely wrong. This is the function that I have in my Item class: @SubscribeEvent public void scroll(MouseEvent event) { event.setCanceled(true); }
-
I solved it. If anyone is interested in the solution tell me
-
I'm trying to create a Item that uses multiple layers lof textures, like a potion. Also like a potion, I would like to give one of those layers a color. How would I do that? I looked at the potion class and the spawnegg class, but I couldn't get any smarter from it.
-
So how would that look like? Are you talking about NBT?
-
Lol Any Idea how to do this in 1.8?
-
Hi I'm trying to make a wand tool, similar to worldedit. I am saving the material of the wand into NBT but not pos1 and pos2, as I want the player to be able to use multiple wands that share positions, but not materials. Now I just run into the problem that when using the wand on a server, all players share the same pos1 and pos2, causing major problems. How do I make the positions individual for each player, but not for each wand? Should I edit the player's nbt? Here is the code that I have so far: (I know it's a mess, please bare with me : package tschipp.creativePlus.items; import java.util.List; import tschipp.creativePlus.CreativePlus; import net.minecraft.block.Block; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.Language; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumFacing; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class Wand extends Item{ public Vec3 pos1; public Vec3 pos2; public Vec3 difference; public Vec3 posToPlaceBlock; public IBlockState mat; public Wand() { this.setMaxStackSize(1); } @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> subItems) { NBTTagCompound tag = new NBTTagCompound(); tag.setString("material", "minecraft:stone"); tag.setInteger("damage", 0); ItemStack stack = new ItemStack(item, 1, 0); stack.setTagCompound(tag); subItems.add(stack); } public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { World world = player.worldObj; if(pos.getX() < 0) { pos2 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()); } if(pos.getX() > 0) { pos2 = new Vec3(pos.getX()+0.5, pos.getY(), pos.getZ()); } if(pos.getZ() < 0) { pos2 = new Vec3(pos.getX(), pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0) { pos2 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() < 0) { pos2 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0 && pos.getZ() > 0) { pos2 = new Vec3(pos.getX()+0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() > 0) { pos2 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() > 0 && pos.getZ() < 0) { pos2 = new Vec3(pos.getX()+0.5, pos.getY(), pos.getZ()-0.5); } if(!world.isRemote) { player.addChatComponentMessage(new ChatComponentText("§dSet Pos2 at X: " + (int)pos2.xCoord + ", Y: " + (int)pos2.yCoord + ", Z: " + (int)pos2.zCoord)); } world.markBlockForUpdate(pos); return false; } public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn) { if(pos1 != null && pos2 != null && playerIn.isSneaking()) { difference = pos1.subtractReverse(pos2).normalize(); posToPlaceBlock = pos1; World world = Minecraft.getMinecraft().getIntegratedServer().getEntityWorld(); if(compare()) { pos1 = null; if(!world.isRemote) { world.setBlockState(new BlockPos((int)pos1.xCoord, (int)pos1.yCoord, (int)pos1.zCoord), Block.getBlockFromName(stack.getTagCompound().getString("material")).getStateFromMeta(stack.getTagCompound().getInteger("damage")), 2); } pos2 = null; } else { while (!compare()) { posToPlaceBlock = posToPlaceBlock.add(difference); if(!world.isRemote) { world.setBlockState(new BlockPos((int)posToPlaceBlock.xCoord, (int)posToPlaceBlock.yCoord, (int)posToPlaceBlock.zCoord), Block.getBlockFromName(stack.getTagCompound().getString("material")).getStateFromMeta(stack.getTagCompound().getInteger("damage")), 2); } } } } return stack; } public boolean compare() { if(Math.abs(pos1.xCoord) <= Math.abs(pos2.xCoord) && Math.abs(pos1.zCoord) <= Math.abs(pos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) >= Math.abs(pos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) >= Math.abs(pos2.zCoord); } else if(Math.abs(pos1.xCoord) >= Math.abs(pos2.xCoord) && Math.abs(pos1.zCoord) >= Math.abs(pos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) <= Math.abs(pos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) <= Math.abs(pos2.zCoord); } else if(Math.abs(pos1.xCoord) <= Math.abs(pos2.xCoord) && Math.abs(pos1.zCoord) >= Math.abs(pos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) >= Math.abs(pos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) <= Math.abs(pos2.zCoord); } else if(Math.abs(pos1.xCoord) >= Math.abs(pos2.xCoord) && Math.abs(pos1.zCoord) <= Math.abs(pos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) <= Math.abs(pos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) >= Math.abs(pos2.zCoord); } else { return true; } } public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) { World world = player.worldObj; if(player.isSneaking()) { mat = world.getBlockState(pos); NBTTagCompound tag = new NBTTagCompound(); tag.setString("material", mat.getBlock().getRegistryName()); tag.setInteger("damage", mat.getBlock().getMetaFromState(mat)); itemstack.setTagCompound(tag); if(!world.isRemote) { player.addChatComponentMessage(new ChatComponentText("§dMaterial set to: " + StatCollector.translateToLocal(StatCollector.translateToLocal(Block.getBlockFromName(itemstack.getTagCompound().getString("material")).getLocalizedName())))); } world.markBlockForUpdate(pos); } else { if(pos.getX() < 0) { pos1 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()); } if(pos.getX() > 0) { pos1 = new Vec3(pos.getX()+0.5, pos.getY(), pos.getZ()); } if(pos.getZ() < 0) { pos1 = new Vec3(pos.getX(), pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0) { pos1 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() < 0) { pos1 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0 && pos.getZ() > 0) { pos1 = new Vec3(pos.getX()+0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() > 0) { pos1 = new Vec3(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() > 0 && pos.getZ() < 0) { pos1 = new Vec3(pos.getX()+0.5, pos.getY(), pos.getZ()-0.5); } if(!world.isRemote) { player.addChatComponentMessage(new ChatComponentText("§dSet Pos1 at X: " + (int)pos1.xCoord + ", Y: " + (int)pos1.yCoord + ", Z: " + (int)pos1.zCoord)); } world.markBlockForUpdate(pos); } return true; } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { tooltip.add("Draws a straight line from two points"); tooltip.add("Material: "+ StatCollector.translateToLocal(Block.getBlockFromName(stack.getTagCompound().getString("material")).getLocalizedName()) + ", Meta: " + stack.getTagCompound().getInteger("damage")); } }
-
Hi I have a wand tool, which saves its material value as nbt. I want however, that the base material for the wand is stone, when you get it from your creative tab. How would I do that?
-
I just don't understand why it places a double slab, and then tries to set its Properties even though these properties only exist on the single slab block...
-
Yes. How do I avoid that?
-
It works for all blocks but the Double Slabs. They crash when I try to place them, giving me this error: ---- Minecraft Crash Report ---- // Hey, that tickles! Hehehe! Time: 10.08.16 14:40 Description: Unexpected error java.lang.IllegalArgumentException: Cannot set property PropertyEnum{name=half, clazz=class net.minecraft.block.BlockSlab$EnumBlockHalf, values=[top, bottom]} as it does not exist in BlockState{block=minecraft:double_stone_slab, properties=[seamless, variant]} at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:156) at net.minecraft.block.BlockSlab.onBlockPlaced(BlockSlab.java:120) at tschipp.creativePlus.items.FakeItem.onItemUse(FakeItem.java:64) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:149) at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:438) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1569) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2123) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) at net.minecraft.client.Minecraft.run(Minecraft.java:380) at net.minecraft.client.main.Main.main(Main.java:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.block.state.BlockState$StateImplementation.withProperty(BlockState.java:156) at net.minecraft.block.BlockSlab.onBlockPlaced(BlockSlab.java:120) at tschipp.creativePlus.items.FakeItem.onItemUse(FakeItem.java:64) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:149) at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:438) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1569) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player753'/45, l='MpServer', x=76.35, y=5.79, z=716.28]] Chunk stats: MultiplayerChunkCache: 400, 400 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: 121.00,4.00,657.00 - World: (121,4,657), Chunk: (at 9,0,1 in 7,41; contains blocks 112,0,656 to 127,255,671), Region: (0,1; contains chunks 0,32 to 31,63, blocks 0,0,512 to 511,255,1023) Level time: 42045 game time, 42045 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 9 total; [EntityItem['item.tile.sapling.jungle'/16, l='MpServer', x=49.81, y=4.00, z=711.72], EntityPlayerSP['Player753'/45, l='MpServer', x=76.35, y=5.79, z=716.28], EntityRabbit['Rabbit'/22, l='MpServer', x=117.44, y=4.00, z=734.91], EntityItem['item.tile.sapling.jungle'/10, l='MpServer', x=33.34, y=18.00, z=702.13], EntityItem['item.tile.sapling.jungle'/11, l='MpServer', x=44.88, y=4.00, z=705.56], EntityItem['item.tile.sapling.jungle'/12, l='MpServer', x=32.31, y=26.00, z=706.69], EntityHorse['Horse'/13, l='MpServer', x=53.72, y=4.00, z=642.06], EntitySheep['Sheep'/14, l='MpServer', x=65.00, y=4.00, z=675.76], EntitySheep['Sheep'/15, l='MpServer', x=58.78, y=4.00, z=686.66]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:383) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2645) at net.minecraft.client.Minecraft.run(Minecraft.java:409) at net.minecraft.client.main.Main.main(Main.java:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.8.9 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_65, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 588351208 bytes (561 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.19 Powered by Forge 11.15.1.1875 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1875.jar) UCHIJAAAA Forge{11.15.1.1875} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1875.jar) UCHIJAAAA creativeplus{0.1} [§2Creative §6+] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 364.72' Renderer: 'GeForce 840M/PCIe/SSE2' Launched Version: 1.8.9 LWJGL: 2.9.4 OpenGL: GeForce 840M/PCIe/SSE2 GL version 4.5.0 NVIDIA 364.72, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: No Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 8x Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz I can see that it has something to do with its properties, but I can't really resolve it. This is my code: package tschipp.creativePlus.items; import net.minecraft.block.BlockDoubleStoneSlab; import net.minecraft.block.BlockDoubleStoneSlabNew; import net.minecraft.block.BlockDoubleWoodSlab; import net.minecraft.block.BlockStoneSlab; import net.minecraft.block.BlockStoneSlabNew; import net.minecraft.block.BlockWoodSlab; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemSword; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.registry.GameRegistry; public class CustomItems { public static Item flyingSpeed; public static Item walkSpeed; public static Item superBonemeal; public static ItemSword godSword; public static FakeItem fire; public static FakeItem litFurnace; public static FakeItem endPortal; public static FakeItem portal; public static FakeItem doubleStoneSlab; public static FakeItem doubleStoneSlab2; public static FakeItem doubleWoodenSlab; public static FakeItem water; public static FakeItem lava; //public static ToolMaterial godMaterial = EnumHelper.addToolMaterial("godMaterial", 100, 10000000, 25.0F, 1000000000.0F, 15); public static void createItems() { GameRegistry.registerItem(flyingSpeed = new FlyingSpeed("flyingSpeed"), "flyingSpeed"); GameRegistry.registerItem(walkSpeed = new WalkSpeed("walkSpeed"), "walkSpeed"); GameRegistry.registerItem(superBonemeal = new SuperBonemeal("superBonemeal"), "superBonemeal"); // GameRegistry.registerItem(godSword = new GodSword(godMaterial), "godSword"); GameRegistry.registerItem(fire = new FakeItem(Blocks.fire), "fire"); GameRegistry.registerItem(litFurnace = new FakeItem(Blocks.lit_furnace), "lit_furnace"); GameRegistry.registerItem(endPortal = new FakeItem(Blocks.end_portal), "end_portal"); GameRegistry.registerItem(portal = new FakeItem(Blocks.portal), "portal"); GameRegistry.registerItem(doubleStoneSlab = new FakeItem((BlockStoneSlab)Blocks.double_stone_slab), "double_stone_slab"); GameRegistry.registerItem(doubleStoneSlab2 = new FakeItem((BlockStoneSlabNew)Blocks.double_stone_slab2), "double_stone_slab2"); GameRegistry.registerItem(doubleWoodenSlab = new FakeItem((BlockWoodSlab)Blocks.double_wooden_slab), "double_wooden_slab"); GameRegistry.registerItem(water = new FakeItem(Blocks.water), "water"); GameRegistry.registerItem(lava = new FakeItem(Blocks.lava), "lava"); // EnumHelper.addToolMaterial(name, harvestLevel, maxUses, efficiency, damage, enchantability) } } package tschipp.creativePlus.items; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class FakeItem extends Item { public final Block block; public FakeItem(Block block) { this.block = block; } /** * Sets the unlocalized name of this item to the string passed as the parameter, prefixed by "item." */ public FakeItem setUnlocalizedName(String unlocalizedName) { super.setUnlocalizedName(unlocalizedName); return this; } /** * Called when a Block is right-clicked with this Item */ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (!block.isReplaceable(worldIn, pos)) { pos = pos.offset(side); } if (stack.stackSize == 0) { return false; } else if (!playerIn.canPlayerEdit(pos, side, stack)) { return false; } else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack)) { int i = this.getMetadata(stack.getMetadata()); IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); if (placeBlockAt(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ, iblockstate1)) { worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); --stack.stackSize; } return true; } else { return false; } } public static boolean setTileEntityNBT(World worldIn, EntityPlayer pos, BlockPos stack, ItemStack p_179224_3_) { MinecraftServer minecraftserver = MinecraftServer.getServer(); if (minecraftserver == null) { return false; } else { if (p_179224_3_.hasTagCompound() && p_179224_3_.getTagCompound().hasKey("BlockEntityTag", 10)) { TileEntity tileentity = worldIn.getTileEntity(stack); if (tileentity != null) { if (!worldIn.isRemote && tileentity.func_183000_F() && !minecraftserver.getConfigurationManager().canSendCommands(pos.getGameProfile())) { return false; } NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.copy(); tileentity.writeToNBT(nbttagcompound); NBTTagCompound nbttagcompound2 = (NBTTagCompound)p_179224_3_.getTagCompound().getTag("BlockEntityTag"); nbttagcompound.merge(nbttagcompound2); nbttagcompound.setInteger("x", stack.getX()); nbttagcompound.setInteger("y", stack.getY()); nbttagcompound.setInteger("z", stack.getZ()); if (!nbttagcompound.equals(nbttagcompound1)) { tileentity.readFromNBT(nbttagcompound); tileentity.markDirty(); return true; } } } return false; } } @SideOnly(Side.CLIENT) public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) { Block block = worldIn.getBlockState(pos).getBlock(); if (block == Blocks.snow_layer && block.isReplaceable(worldIn, pos)) { side = EnumFacing.UP; } else if (!block.isReplaceable(worldIn, pos)) { pos = pos.offset(side); } return worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack); } /** * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have * different names based on their damage or NBT. */ public String getUnlocalizedName(ItemStack stack) { return this.block.getUnlocalizedName(); } /** * Returns the unlocalized name of this item. */ public String getUnlocalizedName() { return this.block.getUnlocalizedName(); } /** * gets the CreativeTab this item is displayed on */ @SideOnly(Side.CLIENT) public CreativeTabs getCreativeTab() { return this.block.getCreativeTabToDisplayOn(); } /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @SideOnly(Side.CLIENT) public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) { this.block.getSubBlocks(itemIn, tab, subItems); } public Block getBlock() { return this.block; } /** * Called to actually place the block, after the location is determined * and all permission checks have been made. * * @param stack The item stack that was used to place the block. This can be changed inside the method. * @param player The player who is placing the block. Can be null if the block is not being placed by a player. * @param side The side the player (or machine) right-clicked on. */ public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { if (!world.setBlockState(pos, newState, 3)) return false; IBlockState state = world.getBlockState(pos); if (state.getBlock() == this.block) { setTileEntityNBT(world, player, pos, stack); this.block.onBlockPlacedBy(world, pos, state, player, stack); } return true; } } (Basically a copy of the ItemBlock class)
-
That seems to have worked, but the block is only obtainable via command, it doesn't show up in the creative tab.
-
In 1.8, some blocks like water, fire, portals, etc. are no longer obtainable as an Item in your inventory. I was wondering if anyone knew if that can be overridden somehow.
-
It works!!! Thank you so much!
-
Where? In the while loop?
-
It crashes ---- Minecraft Crash Report ---- // Don't be sad, have a hug! <3 Time: 05.08.16 12:41 Description: Unexpected error java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockState{block=minecraft:log, properties=[axis, variant]} at net.minecraft.block.state.BlockState$StateImplementation.getValue(BlockState.java:137) at net.minecraft.block.BlockSapling.grow(BlockSapling.java:65) at net.minecraft.block.BlockSapling.grow(BlockSapling.java:245) at tschipp.creativePlus.items.SuperBonemeal.onItemUse(SuperBonemeal.java:48) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:149) at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:438) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1569) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2123) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) at net.minecraft.client.Minecraft.run(Minecraft.java:380) at net.minecraft.client.main.Main.main(Main.java:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.block.state.BlockState$StateImplementation.getValue(BlockState.java:137) at net.minecraft.block.BlockSapling.grow(BlockSapling.java:65) at net.minecraft.block.BlockSapling.grow(BlockSapling.java:245) at tschipp.creativePlus.items.SuperBonemeal.onItemUse(SuperBonemeal.java:48) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:149) at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:438) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1569) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player669'/224, l='MpServer', x=-390.35, y=79.00, z=190.22]] Chunk stats: MultiplayerChunkCache: 625, 625 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: -255.00,64.00,263.00 - World: (-255,64,263), Chunk: (at 1,4,7 in -16,16; contains blocks -256,0,256 to -241,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 58907 game time, 58907 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: true), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 118 total; [EntityBat['Bat'/0, l='MpServer', x=-445.53, y=24.51, z=120.64], EntitySquid['Squid'/2, l='MpServer', x=-441.50, y=63.00, z=135.50], EntitySquid['Squid'/3, l='MpServer', x=-444.44, y=63.47, z=133.47], EntityChicken['Chicken'/4, l='MpServer', x=-446.78, y=63.59, z=141.47], EntityItem['item.item.egg'/1540, l='MpServer', x=-332.88, y=67.00, z=225.50], EntitySheep['Sheep'/5, l='MpServer', x=-447.47, y=74.00, z=177.19], EntitySheep['Sheep'/6, l='MpServer', x=-444.94, y=66.00, z=205.00], EntityItem['item.item.egg'/7, l='MpServer', x=-441.59, y=67.00, z=207.78], EntityItem['item.item.egg'/8, l='MpServer', x=-434.81, y=67.00, z=203.78], EntityChicken['Chicken'/9, l='MpServer', x=-438.75, y=67.00, z=206.53], EntitySheep['Sheep'/10, l='MpServer', x=-437.97, y=67.00, z=221.84], EntityItem['item.item.egg'/11, l='MpServer', x=-435.97, y=67.00, z=223.84], EntityChicken['Chicken'/12, l='MpServer', x=-436.50, y=67.00, z=224.63], EntityChicken['Chicken'/13, l='MpServer', x=-434.50, y=69.00, z=232.22], EntityItem['item.item.egg'/14, l='MpServer', x=-432.31, y=70.00, z=231.47], EntityChicken['Chicken'/15, l='MpServer', x=-433.50, y=70.00, z=232.63], EntityItem['item.item.egg'/783, l='MpServer', x=-386.47, y=70.00, z=207.59], EntityItem['item.item.egg'/16, l='MpServer', x=-434.13, y=68.00, z=231.44], EntityItem['item.item.dyePowder.black'/17, l='MpServer', x=-446.75, y=38.00, z=248.53], EntityChicken['Chicken'/18, l='MpServer', x=-446.63, y=70.00, z=244.31], EntityChicken['Chicken'/19, l='MpServer', x=-442.38, y=71.00, z=243.59], EntityItem['item.item.egg'/20, l='MpServer', x=-446.16, y=70.00, z=244.56], EntityChicken['Chicken'/21, l='MpServer', x=-441.38, y=69.00, z=241.41], EntityChicken['Chicken'/25, l='MpServer', x=-430.53, y=65.00, z=146.09], EntityChicken['Chicken'/26, l='MpServer', x=-425.50, y=70.97, z=153.53], EntityItem['item.item.egg'/27, l='MpServer', x=-430.94, y=65.00, z=145.72], EntityChicken['Chicken'/28, l='MpServer', x=-430.59, y=69.00, z=188.63], EntityItem['item.item.egg'/29, l='MpServer', x=-422.47, y=71.00, z=217.84], EntityRabbit['Rabbit'/30, l='MpServer', x=-421.56, y=74.00, z=236.94], EntityItem['item.item.egg'/31, l='MpServer', x=-431.69, y=71.00, z=239.09], EntityVillager['Villager'/32, l='MpServer', x=-416.47, y=70.00, z=236.75], EntityVillager['Villager'/33, l='MpServer', x=-416.84, y=69.50, z=251.91], EntityItem['item.item.egg'/38, l='MpServer', x=-409.88, y=69.00, z=141.44], EntityBat['Bat'/39, l='MpServer', x=-418.00, y=28.84, z=144.96], EntityItem['item.item.egg'/40, l='MpServer', x=-415.84, y=71.00, z=156.69], EntityChicken['Chicken'/41, l='MpServer', x=-400.88, y=68.00, z=159.47], EntityChicken['Chicken'/42, l='MpServer', x=-398.66, y=68.00, z=158.66], EntityItem['item.item.egg'/43, l='MpServer', x=-411.50, y=71.00, z=161.53], EntityChicken['Chicken'/44, l='MpServer', x=-408.66, y=71.00, z=162.53], EntityChicken['Chicken'/45, l='MpServer', x=-406.59, y=68.66, z=188.78], EntityItem['item.item.egg'/46, l='MpServer', x=-406.59, y=68.00, z=188.88], EntityChicken['Chicken'/47, l='MpServer', x=-414.34, y=71.00, z=215.47], EntityVillager['Villager'/48, l='MpServer', x=-415.47, y=70.00, z=236.28], EntityVillager['Villager'/49, l='MpServer', x=-416.16, y=70.00, z=238.06], EntityVillager['Villager'/50, l='MpServer', x=-415.28, y=70.00, z=237.16], EntityVillager['Villager'/51, l='MpServer', x=-414.31, y=70.00, z=238.69], EntityVillager['Villager'/52, l='MpServer', x=-414.31, y=70.00, z=237.81], EntityVillager['Villager'/53, l='MpServer', x=-415.19, y=70.00, z=238.69], EntityVillager['Villager'/54, l='MpServer', x=-417.16, y=70.00, z=237.69], EntityVillager['Villager'/55, l='MpServer', x=-414.63, y=69.00, z=251.06], EntitySquid['Squid'/6711, l='MpServer', x=-450.59, y=50.35, z=240.53], EntityVillager['Villager'/56, l='MpServer', x=-415.81, y=69.00, z=251.59], EntityRabbit['Rabbit'/57, l='MpServer', x=-409.25, y=71.00, z=261.28], EntityChicken['Chicken'/64, l='MpServer', x=-387.82, y=78.00, z=189.56], EntityChicken['Chicken'/65, l='MpServer', x=-386.44, y=70.00, z=207.66], EntityBat['Bat'/66, l='MpServer', x=-376.94, y=41.07, z=200.55], EntityItem['item.tile.doublePlant.grass'/67, l='MpServer', x=-389.94, y=71.00, z=238.81], EntityItem['item.tile.doublePlant.grass'/68, l='MpServer', x=-391.38, y=71.00, z=239.66], EntityItem['item.tile.doublePlant.grass'/69, l='MpServer', x=-391.34, y=71.00, z=239.09], EntityItem['item.tile.doublePlant.grass'/70, l='MpServer', x=-390.53, y=71.00, z=239.28], EntityRabbit['Rabbit'/71, l='MpServer', x=-387.81, y=71.00, z=231.22], EntityChicken['Chicken'/72, l='MpServer', x=-398.53, y=71.00, z=238.31], EntityItem['item.item.egg'/73, l='MpServer', x=-397.94, y=71.00, z=238.06], EntityItem['item.tile.doublePlant.grass'/74, l='MpServer', x=-390.50, y=71.00, z=240.06], EntityItem['item.tile.doublePlant.grass'/75, l='MpServer', x=-389.41, y=71.00, z=240.69], EntityVillager['Villager'/76, l='MpServer', x=-401.78, y=71.00, z=257.47], EntityChicken['Chicken'/85, l='MpServer', x=-383.50, y=67.66, z=174.31], EntityItem['item.item.egg'/86, l='MpServer', x=-383.88, y=66.00, z=174.72], EntityBat['Bat'/87, l='MpServer', x=-386.25, y=39.11, z=210.32], EntityChicken['Chicken'/88, l='MpServer', x=-380.47, y=68.69, z=210.13], EntityBat['Bat'/89, l='MpServer', x=-357.27, y=21.06, z=217.89], EntityItem['item.tile.sapling.jungle'/90, l='MpServer', x=-378.59, y=70.00, z=241.25], EntityChicken['Chicken'/96, l='MpServer', x=-362.38, y=70.00, z=136.59], EntityChicken['Chicken'/97, l='MpServer', x=-357.66, y=71.00, z=178.41], EntityItem['item.item.egg'/98, l='MpServer', x=-361.94, y=70.00, z=169.13], EntityChicken['Chicken'/99, l='MpServer', x=-365.69, y=68.59, z=184.00], EntityItem['item.item.egg'/100, l='MpServer', x=-366.47, y=68.00, z=183.47], EntityCow['Cow'/101, l='MpServer', x=-352.88, y=71.00, z=199.84], EntitySheep['Sheep'/102, l='MpServer', x=-352.84, y=71.00, z=204.13], EntityBat['Bat'/107, l='MpServer', x=-347.66, y=21.63, z=122.69], EntityBat['Bat'/108, l='MpServer', x=-348.90, y=19.79, z=131.36], EntityBat['Bat'/109, l='MpServer', x=-344.19, y=25.10, z=164.47], EntityBat['Bat'/110, l='MpServer', x=-343.65, y=24.00, z=168.61], EntityBat['Bat'/111, l='MpServer', x=-337.49, y=24.52, z=177.09], EntityChicken['Chicken'/112, l='MpServer', x=-349.44, y=71.00, z=190.34], EntityBat['Bat'/113, l='MpServer', x=-345.44, y=50.14, z=216.65], EntityBat['Bat'/124, l='MpServer', x=-334.13, y=26.00, z=176.04], EntityChicken['Chicken'/125, l='MpServer', x=-334.97, y=71.00, z=173.94], EntityCow['Cow'/126, l='MpServer', x=-334.47, y=70.00, z=168.53], EntityItem['item.item.egg'/127, l='MpServer', x=-329.13, y=71.00, z=168.50], EntityChicken['Chicken'/128, l='MpServer', x=-323.41, y=71.00, z=170.56], EntityItem['item.item.egg'/129, l='MpServer', x=-331.66, y=72.00, z=185.44], EntityChicken['Chicken'/130, l='MpServer', x=-341.41, y=71.00, z=200.59], EntityChicken['Chicken'/131, l='MpServer', x=-332.16, y=68.68, z=224.72], EntityCow['Cow'/140, l='MpServer', x=-319.16, y=71.00, z=164.03], EntityChicken['Chicken'/143, l='MpServer', x=-314.69, y=64.00, z=259.66], EntityBat['Bat'/154, l='MpServer', x=-310.13, y=23.33, z=194.56], EntityPlayerSP['Player669'/224, l='MpServer', x=-390.35, y=79.00, z=190.22], EntityBat['Bat'/5046, l='MpServer', x=-329.77, y=56.02, z=231.74], EntityChicken['Chicken'/225, l='MpServer', x=-450.38, y=74.00, z=177.69], EntitySheep['Sheep'/226, l='MpServer', x=-459.06, y=67.00, z=209.09], EntityChicken['Chicken'/228, l='MpServer', x=-454.53, y=75.00, z=171.75], EntityChicken['Chicken'/230, l='MpServer', x=-463.47, y=65.00, z=228.38], EntityChicken['Chicken'/231, l='MpServer', x=-461.53, y=68.00, z=218.09], EntityItem['item.item.egg'/232, l='MpServer', x=-451.56, y=66.00, z=214.88], EntitySheep['Sheep'/233, l='MpServer', x=-447.84, y=65.00, z=141.13], EntityItem['item.item.dyePowder.black'/235, l='MpServer', x=-453.59, y=56.00, z=238.28], EntityItem['item.item.dyePowder.black'/236, l='MpServer', x=-451.81, y=56.00, z=238.84], EntityItem['item.item.dyePowder.black'/237, l='MpServer', x=-451.88, y=51.00, z=239.63], EntityItem['item.item.dyePowder.black'/238, l='MpServer', x=-451.13, y=51.00, z=239.41], EntityChicken['Chicken'/239, l='MpServer', x=-450.72, y=63.63, z=138.63], EntityItem['item.item.egg'/240, l='MpServer', x=-450.41, y=63.00, z=137.41], EntityChicken['Chicken'/241, l='MpServer', x=-461.56, y=66.00, z=133.72], EntityChicken['Chicken'/242, l='MpServer', x=-451.63, y=65.00, z=137.69], EntitySheep['Sheep'/243, l='MpServer', x=-460.84, y=66.00, z=143.06], EntityItem['item.item.dyePowder.black'/248, l='MpServer', x=-449.00, y=47.00, z=242.34], EntityItem['item.item.dyePowder.black'/249, l='MpServer', x=-452.78, y=52.00, z=241.22], EntitySheep['Sheep'/250, l='MpServer', x=-458.50, y=68.00, z=117.31]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:383) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2645) at net.minecraft.client.Minecraft.run(Minecraft.java:409) at net.minecraft.client.main.Main.main(Main.java:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.8.9 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_65, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 576428784 bytes (549 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.19 Powered by Forge 11.15.1.1875 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1875.jar) UCHIJAAAA Forge{11.15.1.1875} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1875.jar) UCHIJAAAA creativeplus{0.1} [§2Creative §6+] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 364.72' Renderer: 'GeForce 840M/PCIe/SSE2' Launched Version: 1.8.9 LWJGL: 2.9.4 OpenGL: GeForce 840M/PCIe/SSE2 GL version 4.5.0 NVIDIA 364.72, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: No Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 8x Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz It seems that it is trying to grow the Log block once more, even though that the Log doesn't implement IGrowable... May also well be that I just don't understand how while loops work...
-
package tschipp.creativePlus.items; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockCrops; import net.minecraft.block.BlockSapling; import net.minecraft.block.IGrowable; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.world.World; public class SuperBonemeal extends Item { public SuperBonemeal(String name) { this.setUnlocalizedName(name); this.hasEffect(new ItemStack(CustomItems.superBonemeal)); this.setMaxStackSize(1); } public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, iblockstate, stack); if (hook != 0) return hook > 0; if (iblockstate.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable)iblockstate.getBlock(); if (!worldIn.isRemote) { while(iblockstate.getBlock() instanceof IGrowable) { igrowable.grow(worldIn, worldIn.rand, pos, worldIn.getBlockState(pos)); } } /* Block block = worldIn.getBlockState(pos).getBlock(); double d0 = itemRand.nextGaussian() * 0.02D; double d1 = itemRand.nextGaussian() * 0.02D; double d2 = itemRand.nextGaussian() * 0.02D; worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)pos.getX() + itemRand.nextFloat()), (double)pos.getY() + (double)itemRand.nextFloat() * block.getBlockBoundsMaxY(), (double)((float)pos.getZ() + itemRand.nextFloat()), d0, d1, d2, 200); */ } return false; } }