This commit is contained in:
OpexHunter 2025-02-21 14:01:06 +03:00
parent 289fb241bd
commit 4f1b973180
5 changed files with 81 additions and 31 deletions

View File

@ -14,8 +14,8 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = '1.0'
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'modid'
group = 'com.punkcraft.zombiedrop' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'zombiedrop'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
@ -45,16 +45,16 @@ dependencies {
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860'
}
// Example for how to get properties into the manifest for reading by the runtime..
// ZombieDrop for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": "examplemod",
"Specification-Vendor": "examplemodsareus",
"Specification-Title": "zombiedropmod",
"Specification-Vendor": "zombiedropmodsareus",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"examplemodsareus",
"Implementation-Vendor" :"zombiedropmodsareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}

View File

@ -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) {
}
}

View File

@ -0,0 +1,47 @@
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.minecraft.world.World;
import net.minecraft.entity.item.EntityItem;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
@Mod.EventBusSubscriber(value = Side.SERVER, modid = ZombieDrop.MODID)
public class ServerEventHandler {
/**
* Обработчик события дропа предметов.
*/
@SubscribeEvent
public static 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
World world = zombie.world;
double x = zombie.posX;
double y = zombie.posY;
double z = zombie.posZ;
// Создаем EntityItem и добавляем его в дроп
EntityItem entityItem = new EntityItem(world, x, y, z, enderPearl);
event.getDrops().add(entityItem);
}
}
}
}
}

View File

@ -0,0 +1,26 @@
package com.punkcraft.zombiedrop;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
@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) {
// Регистрируем слушатель событий только на серверной стороне
if (event.getSide() == Side.SERVER) {
MinecraftForge.EVENT_BUS.register(new ServerEventHandler());
}
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
}
}

View File

@ -1,7 +1,7 @@
[
{
"modid": "example",
"name": "Example",
"modid": "zombiedrop",
"name": "ZombieDrop",
"description": "",
"version": "${version}",
"mcversion": "${mcversion}",