Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How do i use meta data for logs in this case?? [UNSOLVED] [1.7.10]

Featured Replies

Posted

I am trying to make it so that my raw latex drops from oak logs but i can't get it to work cause of the meta data...

 

Here is my code:

 

ItemRawLatex class:

 

package com.hardwareplus.mod;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.world.BlockEvent;

public class ItemRawLatex extends Item{
 @SubscribeEvent
 public void onDrops(BlockEvent.HarvestDropsEvent event) {

 if (event.block == Blocks.log);
 event.drops.add(new ItemStack(HardwarePlus.itemRawLatex));
 }
}

 

and yes i have MinecraftForge.EVENT_BUS.register(new YourEventHandler()); in my main class in my event handler

 

i have it like this:

 

MinecraftForge.EVENT_BUS.register(new HardwarePlus());

  • Author

i mean when anyone has picked up the log once with the raw latex, they cannot just place it back down and get more raw latex!

 

My event handler:

 

package com.hardwareplus.mod;

import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class YourEventHandler {
 @SubscribeEvent
 public void blockBreak(BreakEvent event) {
	 Block block = event.block;
	 World world = event.world;
	 int x = event.x;
	 int y = event.y;
	 int z = event.z;
	 if (block == Blocks.log) {
	 if(event.blockMetadata == 0)
	 {
	 world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(HardwarePlus.itemRawLatex)));
	 }
	}
 }
}

  • Author

yes i dont want it to drop the log that was used to drop the latex and changed the code which still works

New code:

package com.hardwareplus.mod;

import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class YourEventHandler {
 @SubscribeEvent
 public void onBlockHarvest(HarvestDropsEvent event) {
	 Block block = event.block;
	 World world = event.world;
	 int x = event.x;
	 int y = event.y;
	 int z = event.z;
	 if (block == Blocks.log) {
	 if(event.blockMetadata == 0)
	 {
	 world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(HardwarePlus.itemRawLatex)));
	 }
	}
 }
}

 

Alternatively, if you are not comfortable with iterators / you just want one thing to drop, an easier solution is to clear the drops list completely and then add your stack to it.

event.drops.clear();
event.drops.add(new ItemStack(yourItem));

Done.

 

However, if you don't know how to use iterators, you could use this as an excuse to learn about them, because they are very useful.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.