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.

Featured Replies

Posted

Ok, I noticed the Cray Tokens mod by MrCrayfish has not been updated from 1.6.4 to 1.7.10, so I decided to see if I could get an update working(then sending the update to him to upload on his site, of course).  However, the class in his mod called LivingDropEvent has been giving me fits, as the vanilla hostile mobs(i.e. Creeper, Zombie, Skeleton, Spider, etc.) aren't dropping Cray Tokens like they're supposed to.

 

LivingDropEvent.java:

/*  1:   */ package com.mrcrayfish.craytokens;
/*  2:   */ 
/*  3:   */ /*  5:   */ import java.util.Random;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
/*  4:   */ 
/*  8:   */ 
/*  9:   */ 
/* 10:   */ 
/* 11:   */ 
/* 12:   */ 
/* 13:   */ public class LivingDropEvent
/* 14:   */ {
/* 15:   */   @SubscribeEvent
/* 16:   */   public void onDeath(LivingDropsEvent e)
/* 17:   */   {
/* 18:16 */     Random rand = new Random();
/* 19:17 */     if ((e.entityLiving.isCreatureType(EnumCreatureType.monster, true)) && (!e.entityLiving.captureDrops))
/* 20:   */     {
/* 21:18 */       World world = e.entityLiving.worldObj;
/* 22:19 */       EntityLiving living = (EntityLiving) e.entityLiving;
/* 23:25 */       if (CrayTokens.platinumRarity == 0)
/* 24:   */       {
/* 25:26 */         EntityItem platinumCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 26:27 */         platinumCoin.dropItem(CrayTokens.platinumToken, 1);
/* 27:28 */         e.drops.add(platinumCoin);
/* 28:   */       }
/* 29:29 */       else if (rand.nextInt(CrayTokens.platinumRarity) == 0)
/* 30:   */       {
/* 31:30 */         EntityItem platinumCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 32:31 */         platinumCoin.dropItem(CrayTokens.platinumToken, 1);
/* 33:32 */         e.drops.add(platinumCoin);
/* 34:   */       }
/* 35:35 */       if (CrayTokens.goldRarity == 0)
/* 36:   */       {
/* 37:36 */         EntityItem goldCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 38:37 */         goldCoin.dropItem(CrayTokens.goldToken, 1);
/* 39:38 */         e.drops.add(goldCoin);
/* 40:   */       }
/* 41:39 */       else if (rand.nextInt(CrayTokens.goldRarity) == 0)
/* 42:   */       {
/* 43:40 */         EntityItem goldCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 44:41 */         goldCoin.dropItem(CrayTokens.goldToken, 1);
/* 45:42 */         e.drops.add(goldCoin);
/* 46:   */       }
/* 47:45 */       if (CrayTokens.silverRarity == 0)
/* 48:   */       {
/* 49:46 */         EntityItem silverCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 50:47 */         silverCoin.dropItem(CrayTokens.silverToken, 1);
/* 51:48 */         e.drops.add(silverCoin);
/* 52:   */       }
/* 53:49 */       else if (rand.nextInt(CrayTokens.silverRarity) == 0)
/* 54:   */       {
/* 55:50 */         EntityItem silverCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 56:51 */         silverCoin.dropItem(CrayTokens.silverToken, 1);
/* 57:52 */         e.drops.add(silverCoin);
/* 58:   */       }
/* 59:55 */       if (CrayTokens.copperRarity == 0)
/* 60:   */       {
/* 61:56 */         EntityItem copperCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 62:57 */         int chance = rand.nextInt(4);
/* 63:58 */         copperCoin.dropItem(CrayTokens.copperToken, chance);
/* 64:59 */         e.drops.add(copperCoin);
/* 65:   */       }
/* 66:60 */       else if (rand.nextInt(CrayTokens.copperRarity) == 0)
/* 67:   */       {
/* 68:61 */         EntityItem copperCoin = new EntityItem(world, living.chunkCoordX, living.chunkCoordY, living.chunkCoordZ);
/* 69:62 */         int chance = rand.nextInt(4);
/* 71:64 */         e.drops.add(copperCoin);
/* 72:   */       }
/* 73:   */     }
/* 74:   */   }
/* 75:   */ }



/* Location:           C:\Users\joshl\Downloads\[Forge]CrayTokensv1.0(1.6.4).zip

* Qualified Name:     com.mrcrayfish.craytokens.LivingDropEvent

* JD-Core Version:    0.7.0.1

*/

Check to see what's going on with the .dropItem() function. For each coin.

Developer of small, unreleased, basic, and incomplete mods since 2014!

Try adding the ItemStack as an arg to the item and use e..world.spawnentityinworld(itementity)

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

here is a part of my working eventhandler.

this may help you.

 

 @SubscribeEvent
    public void onEntityDrop(LivingDropsEvent event) {
  	  if(event.entityLiving instanceof EntityCow) {
  		event.entityLiving.dropItem(EnderpowerItems.blood, r.nextInt(3));
  		 
  	  }

 

I should change EntityCow to EntityMob.

  • Author

I'll test.  Thanks for the example code.

 

Edit: Ok, now MrCrayfish sets it so that if the rarity is set to 0 in the config file, they always drop, but if it's not equal to zero, then the chance of coins dropping is one out of whatever the rarity is set to(i.e. rarity for copperToken is 8, it will be 1/8 chance of copperToken dropping).

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.