43 lines
1.6 KiB
Java
43 lines
1.6 KiB
Java
![]() |
package com.punkcraft.zombiedrop;
|
||
|
|
||
|
import net.minecraft.util.DamageSource;
|
||
|
import net.minecraft.world.World;
|
||
|
import net.minecraft.entity.monster.EntityZombie;
|
||
|
import net.minecraft.item.Item;
|
||
|
import net.minecraft.item.ItemStack;
|
||
|
import net.minecraft.entity.item.EntityItem;
|
||
|
import net.minecraftforge.common.MinecraftForge;
|
||
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||
|
|
||
|
public class ServerProxy extends CommonProxy {
|
||
|
|
||
|
@Override
|
||
|
public void preInit(FMLPreInitializationEvent event) {
|
||
|
MinecraftForge.EVENT_BUS.register(this);
|
||
|
}
|
||
|
|
||
|
@SubscribeEvent
|
||
|
public void onLivingDrops(LivingDropsEvent event) {
|
||
|
if (event.getEntityLiving() instanceof EntityZombie) {
|
||
|
EntityZombie zombie = (EntityZombie) event.getEntityLiving();
|
||
|
DamageSource source = event.getSource();
|
||
|
|
||
|
if (source.getTrueSource() != null || source.isExplosion()) {
|
||
|
int random = zombie.world.rand.nextInt(100);
|
||
|
if (random < 4) {
|
||
|
ItemStack enderPearl = new ItemStack(Item.getItemById(368), 1);
|
||
|
World world = zombie.world;
|
||
|
double x = zombie.posX;
|
||
|
double y = zombie.posY;
|
||
|
double z = zombie.posZ;
|
||
|
|
||
|
EntityItem entityItem = new EntityItem(world, x, y, z, enderPearl);
|
||
|
event.getDrops().add(entityItem);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|