init
This commit is contained in:
parent
289fb241bd
commit
e8894ba675
@ -1,23 +0,0 @@
|
||||
package com.punkcraft.example;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
|
||||
|
||||
@Mod(modid = Example.MODID, name = Example.NAME, version = Example.VERSION)
|
||||
public class Example {
|
||||
public static final String MODID = "example";
|
||||
public static final String NAME = "Example";
|
||||
public static final String VERSION = "1.0";
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
}
|
||||
|
||||
|
||||
}
|
53
src/main/java/com/punkcraft/zombiedrop/ZombieDrop.java
Normal file
53
src/main/java/com/punkcraft/zombiedrop/ZombieDrop.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.punkcraft.zombiedrop;
|
||||
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod(modid = ZombieDrop.MODID, name = ZombieDrop.NAME, version = ZombieDrop.VERSION)
|
||||
public class ZombieDrop {
|
||||
public static final String MODID = "zombiedrop";
|
||||
public static final String NAME = "ZombieDrop";
|
||||
public static final String VERSION = "1.0";
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
// Регистрируем слушатель событий
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Обработчик события дропа предметов.
|
||||
*/
|
||||
@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()) {
|
||||
// Генерируем случайное число от 0 до 99
|
||||
int random = zombie.world.rand.nextInt(100);
|
||||
|
||||
// Если число меньше 4, добавляем эндерпёрл в дроп
|
||||
if (random < 4) {
|
||||
ItemStack enderPearl = new ItemStack(Item.getItemById(368), 1); // ID эндерпёрла: 368
|
||||
event.getDrops().add(new net.minecraft.entity.item.EntityItem(zombie.world, zombie.posX, zombie.posY, zombie.posZ, enderPearl));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"modid": "example",
|
||||
"name": "Example",
|
||||
"modid": "zombiedrop",
|
||||
"name": "ZombieDrop",
|
||||
"description": "",
|
||||
"version": "${version}",
|
||||
"mcversion": "${mcversion}",
|
||||
|
Loading…
Reference in New Issue
Block a user