Jump to content

Recommended Posts

Posted

Do you want this item to always drop? Or have a random chance from breaking this block?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Posted

For your own blocks: override

getDrops

.

 

For other mods/Minecraft's blocks: use the

HarvestDrops

event.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Yes like this:

    @SubscribeEvent
    public static void HarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
        Minecraft mc = Minecraft.getMinecraft();
        if(event.getHarvester() instanceof EntityPlayer) {
            if(!event.isSilkTouching()) {
                if(event.getDrops() == Blocks.COBBLESTONE) {
                    
                }
            }
        }
    }

 

So when cobble is dropped I want it to drop the cobble and x

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

event.getDrops().add(...)

 

Seriously, look at the event object and see what's there.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Okay this:

                if(event.getDrops() == Blocks.COBBLESTONE) {
                    event.getDrops().add(new ItemStack(InitBlocks.block_fire_opal_ore));
                }

seems not to drop when a block drops cobblestone (ex. stone), and also, is there a way to find the block that I'm mining, other than finding the drop?

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

ah yes, so look for a ItemStack like this?

        if(event.getHarvester() instanceof EntityPlayer) {
            if(!event.isSilkTouching()) {
                if(event.getDrops().contains(new ItemStack(Blocks.COBBLESTONE))) {
                    event.getDrops().add(new ItemStack(InitBlocks.block_fire_opal_ore));
                }
            }
        }

However, still doesnt seem to drop

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

You can't use

contains

in this context.  ItemStack does not override

equals

so it will never find a match.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
for(ItemStack stack : event.getDrops()) { //loop over everyting
  if(stack.getItem() == Item.getItemFromBlock(Blocks.COBBLESTONE)) { //check if each item is cobblestone
  }
}

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Thanks! However, the random chance thing seems to drop nothing, not even the cobble:

   if (event.getHarvester() instanceof EntityPlayer) {
            if (!event.isSilkTouching()) {
                for(ItemStack stack : event.getDrops()) {
                    if(stack.getItem() == Item.getItemFromBlock(Blocks.COBBLESTONE)) {
                        if(rand.nextInt(2) == 1) {
                            event.getDrops().add(new ItemStack(InitItems.item_gems, 1, 0));
                            event.getDrops().add(new ItemStack(InitItems.item_gems, 1, 1));
                            event.getDrops().add(new ItemStack(InitItems.item_gems, 1, 2));
                            event.getDrops().add(new ItemStack(InitItems.item_gems, 1, 3));
                            event.getDrops().add(new ItemStack(Blocks.COBBLESTONE, 1));
                        }
                        event.getDrops().add(new ItemStack(Blocks.COBBLESTONE, 1));
                    }
                }
            }
        }

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

By "not even the cobble" you mean that you're not getting two cobble stone (the statement outside the if(rand) statement)?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Assign it to a variable and print it out or use the debugger to figure out what value is coming out of it every time.

Odds are you've messed up initializing your random object.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Okay, So I seem to be getting this error:

[22:05:00] [server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_91]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_91]
at net.minecraft.util.Util.runTask(Util.java:27) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) ~[?:1.8.0_91]
at java.util.ArrayList$Itr.next(ArrayList.java:851) ~[?:1.8.0_91]
at com.lambda.plentifulmisc.events.CommonEvents.HarvestDropsEvent(CommonEvents.java:83) ~[CommonEvents.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_12_CommonEvents_HarvestDropsEvent_HarvestDropsEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) ~[EventBus.class:?]
at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:260) ~[ForgeEventFactory.class:?]
at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:692) ~[block.class:?]
at net.minecraft.block.Block.dropBlockAsItem(Block.java:681) ~[block.class:?]
at net.minecraft.block.Block.harvestBlock(Block.java:889) ~[block.class:?]
at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:355) ~[PlayerInteractionManager.class:?]
at net.minecraft.server.management.PlayerInteractionManager.blockRemoving(PlayerInteractionManager.java:264) ~[PlayerInteractionManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:664) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) ~[CPacketPlayerDigging.class:?]
at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) ~[CPacketPlayerDigging.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_91]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_91]
at net.minecraft.util.Util.runTask(Util.java:26) ~[util.class:?]
... 5 more
[22:05:01] [server thread/ERROR]: Exception caught during firing event net.minecraftforge.event.world.BlockEvent$HarvestDropsEvent@2ae16890:
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) ~[?:1.8.0_91]
at java.util.ArrayList$Itr.next(ArrayList.java:851) ~[?:1.8.0_91]
at com.lambda.plentifulmisc.events.CommonEvents.HarvestDropsEvent(CommonEvents.java:83) ~[CommonEvents.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_12_CommonEvents_HarvestDropsEvent_HarvestDropsEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) [EventBus.class:?]
at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:260) [ForgeEventFactory.class:?]
at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:692) [block.class:?]
at net.minecraft.block.Block.dropBlockAsItem(Block.java:681) [block.class:?]
at net.minecraft.block.Block.harvestBlock(Block.java:889) [block.class:?]
at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:355) [PlayerInteractionManager.class:?]
at net.minecraft.server.management.PlayerInteractionManager.blockRemoving(PlayerInteractionManager.java:264) [PlayerInteractionManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:664) [NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) [CPacketPlayerDigging.class:?]
at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) [CPacketPlayerDigging.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_91]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_91]
at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]
[22:05:01] [server thread/ERROR]: Index: 1 Listeners:
[22:05:01] [server thread/ERROR]: 0: NORMAL
[22:05:01] [server thread/ERROR]: 1: ASM: class com.lambda.plentifulmisc.events.CommonEvents HarvestDropsEvent(Lnet/minecraftforge/event/world/BlockEvent$HarvestDropsEvent;)V
[22:05:01] [server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_91]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_91]
at net.minecraft.util.Util.runTask(Util.java:27) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) ~[?:1.8.0_91]
at java.util.ArrayList$Itr.next(ArrayList.java:851) ~[?:1.8.0_91]
at com.lambda.plentifulmisc.events.CommonEvents.HarvestDropsEvent(CommonEvents.java:83) ~[CommonEvents.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_12_CommonEvents_HarvestDropsEvent_HarvestDropsEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) ~[EventBus.class:?]
at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:260) ~[ForgeEventFactory.class:?]
at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:692) ~[block.class:?]
at net.minecraft.block.Block.dropBlockAsItem(Block.java:681) ~[block.class:?]
at net.minecraft.block.Block.harvestBlock(Block.java:889) ~[block.class:?]
at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:355) ~[PlayerInteractionManager.class:?]
at net.minecraft.server.management.PlayerInteractionManager.blockRemoving(PlayerInteractionManager.java:264) ~[PlayerInteractionManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:664) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) ~[CPacketPlayerDigging.class:?]
at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) ~[CPacketPlayerDigging.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_91]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_91]
at net.minecraft.util.Util.runTask(Util.java:26) ~[util.class:?]
... 5 more

 

On line:

                for(ItemStack stack : event.getDrops()) {

 

This, however doesnt crash my game.

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

you can not modify a collection while you are iterating over it.

make a local boolean variable hasStoneOrWhatever and fill it if you find whatever. then, outside the loop, use it to decide how to edit the list of item stacks.

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



×
×
  • Create New...

Important Information

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