-
Item Not Spawning
I fixed my problem. The block name has a space in it
-
Item Not Spawning
I have an event where when the block is broken, a random item is dropped, although, sometimes, the item isn't dropped. The item is spanwed in the generate() method, and my item's name is Lucky Ore. Here's my code: @Override public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state) { // TODO Auto-generated method stub super.onBlockDestroyedByPlayer(worldIn, pos, state); Random random = new Random(); int index = random.nextInt(GameRegistry.findRegistry(Item.class).getValues().size()); if (this.name == "Lucky Ore" && !world.isRemote) { generate(); } } @Override public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) { // TODO Auto-generated method stub super.onBlockDestroyedByExplosion(worldIn, pos, explosionIn); if (this.name == "Lucky Ore" && !world.isRemote) { generate(); } } public void generate(){ Random random = new Random(); int index = random.nextInt(GameRegistry.findRegistry(Item.class).getValues().size()); world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(GameRegistry.findRegistry(Item.class).getValues().get(index)))); System.out.println("Item Dropped: " + GameRegistry.findRegistry(Item.class).getValues().get(index)); }
-
Items Not Collectible / Add Pause
Here's my code: @Override public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state) { // TODO Auto-generated method stub super.onBlockDestroyedByPlayer(worldIn, pos, state); Random random = new Random(); int index = random.nextInt(GameRegistry.findRegistry(Item.class).getValues().size()); if (this.name == "Lucky Ore") { generate(); } } @Override public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) { // TODO Auto-generated method stub super.onBlockDestroyedByExplosion(worldIn, pos, explosionIn); if (this.name == "Lucky Ore") { generate(); } } public void generate(){ Random random = new Random(); int index = random.nextInt(GameRegistry.findRegistry(Item.class).getValues().size()); world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(GameRegistry.findRegistry(Item.class).getValues().get(index)))); System.out.println("Item Dropped: " + GameRegistry.findRegistry(Item.class).getValues().get(index)); }
-
Items Not Collectible / Add Pause
I have a for loop, and the for loop drops items on the ground. Although, the items are sometimes not collectible, and I think it is because there needs to be a pause in between each time the for loop runs. Here's my code for my for loop: for (int i = 0; i == 5, i ++) { world.spawnItem(//spawn an item, code not shown); //add pause statement } If the problem isn't the pause, then please show me how to fix it. Thanks!
-
Place Item when Block Mined
Yes
-
Random Item
I want to have a string, and the value of that string contains the name of a random item in the game.
-
Place Item when Block Mined
When I mine my block, it drops a lava bucket. Although, instead of dropping the lava bucket, I want it to place the lava bucket. Code would be very helpful.
-
Random Item
What is the most efficient way, or any way, to have a variable store the value of a random item in the game?
-
How to View Code of Minecraft Mobs
I'm trying to make a flying minecraft mob, and when I search it up, I see answers like "Look at the code of an enderdragon." Although, where is the code of an enderdragon? Please help.
-
Can't Subscribe Method to Register<Block>
I'm a beginner at Minecraft Modding, and I was looking at this answer here: I'm stuck on this step right here: I'm trying to do that, and here is my method: @SubscribeEvent public static void registerBlocks(Register<Block> event){} I haven't added in the code inside the method yet, but the compiler gives an error at the Register<Block> part. Here's my error: The type Tcp.Register is not generic; it cannot be parameterized with arguments <Block> Then, it gives a suggestion to remove the type parameter. What can I do? I'm using Eclipse, and I'm coding in Minecraft 1.11
-
Help Understanding Stringbuilder Append
I was looking through some code about textures, and I found these lines: StringBuilder builder = new StringBuilder(); builder.append(" \"all\": \"" + BaseMod.MODID + ":blocks/" + texture + "\""); The variable`texture` is an image file. What I understand is that the first line declares a StringBuilder (I'm not really sure what that is). Then, the second line applies textures to all sides of the block because of the `all` part. I need help understanding this, and how would I change the code so that the second line only applies textures to the front side?
-
Register a Block in Minecraft 1.11
Can you show me some code on how to do this? Sorry, I'm new at Java, and I'm not sure how to suscribe.
-
Register a Block in Minecraft 1.11
That's all my code. There is no console error, it just doesn't appear in the creative inventory.
-
Register a Block in Minecraft 1.11
I'm trying to make a block in Minecraft 1.11. Although, I'm having trouble registering it. Here's my code for my block: import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.registry.GameRegistry; public class BlockPower extends Block { public static final String name = "Power"; public BlockPower() { super(Material.IRON); this.setCreativeTab(CreativeTabs.REDSTONE); } }
IPS spam blocked by CleanTalk.