Jump to content

Recommended Posts

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());

Posted

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)));
	 }
	}
 }
}

Posted

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)));
	 }
	}
 }
}

 

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • This is my crash log and i dont know what anything means [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.entity.CuboidMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.entity.ModelPartMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.entity.cull.EntityRendererMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.entity.shadows.EntityRenderDispatcherMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.gui.font.GlyphRendererMixin' as rule 'mixin.features.render.gui.font' (added by mods [oculus]) disables it and children [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.world.sky.BackgroundRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.world.sky.ClientWorldMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [22:05:56] [main/WARN]:Force-disabling mixin 'features.render.world.sky.WorldRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [22:05:57] [main/INFO]:Patching IForgeItemStack#getEnchantmentLevel [22:05:57] [main/INFO]:Patching IForgeItemStack#getEnchantmentLevel [22:06:00] [main/INFO]:Loaded config for: betterfpsdist.json [22:06:02] [main/WARN]:Error loading class: me/jellysquid/mods/sodium/client/render/vertex/buffer/SodiumBufferBuilder (java.lang.ClassNotFoundException: me.jellysquid.mods.sodium.client.render.vertex.buffer.SodiumBufferBuilder) [22:06:02] [main/WARN]:@Mixin target me.jellysquid.mods.sodium.client.render.vertex.buffer.SodiumBufferBuilder was not found mixins.oculus.compat.sodium.json:vertex_format.MixinSodiumBufferBuilder [22:06:02] [main/WARN]:Error loading class: vazkii/quark/addons/oddities/inventory/BackpackMenu (java.lang.ClassNotFoundException: vazkii.quark.addons.oddities.inventory.BackpackMenu) [22:06:03] [main/INFO]:Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.6). [22:06:09] [main/INFO]:Patching IForgeItemStack#getEnchantmentLevel [22:06:09] [main/INFO]:Patching IForgeItemStack#getEnchantmentLevel [22:06:09] [main/INFO]:Patching IForgeItemStack#getEnchantmentLevel [22:06:09] [main/INFO]:Patching IForgeItemStack#getEnchantmentLevel [22:06:14] [main/WARN]:Static binding violation: PRIVATE @Overwrite method m_172993_ in rubidium.mixins.json:core.render.world.WorldRendererMixin cannot reduce visibiliy of PUBLIC target method, visibility will be upgraded.
    • I'm super new to making servers and i literally have no idea what this means LOL, any insight would be appreciated.   for context this is the first time I've loaded up the server and was met immediately with this error. https://cdn.discordapp.com/attachments/878466718425579520/1310810580671795260/image_2024-11-25_213313949.png?ex=674692fc&is=6745417c&hm=22fd87a5727db2cb485a89ecd3cdd133ef86d6995b518a9f8a4ad1e9bc955d09&
    • No, every one of the [REDACTED]'s represent a single word, like a name, or a user ID. For special characters, none of the [REDACTED]'s had any special characters in them. So, in reality, they were all a single entity (string of regular characters, or numbers). Some examples: "1234567abcdefg" or "aNameOfaPerson52".
    • So I had other people in the server go into creative and they are not having any issues, it is only me   
    • [ Five Months Later ] Did you, perchance, make any progress on this?  I'm on 1.21.1 and am experiencing the same inability to find "Direction" in net.minecraft.core -- BlockPos from the same package, fine!  The Direction Enum, nope. I don't think I have the patience to deal with the IntelliJ reporting an increasing number of not-really-errors.
  • Topics

×
×
  • Create New...

Important Information

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