init
This commit is contained in:
parent
289fb241bd
commit
4f1b973180
12
build.gradle
12
build.gradle
@ -14,8 +14,8 @@ apply plugin: 'eclipse'
|
|||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
version = '1.0'
|
version = '1.0'
|
||||||
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = 'com.punkcraft.zombiedrop' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = 'modid'
|
archivesBaseName = 'zombiedrop'
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
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'
|
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 {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes([
|
attributes([
|
||||||
"Specification-Title": "examplemod",
|
"Specification-Title": "zombiedropmod",
|
||||||
"Specification-Vendor": "examplemodsareus",
|
"Specification-Vendor": "zombiedropmodsareus",
|
||||||
"Specification-Version": "1", // We are version 1 of ourselves
|
"Specification-Version": "1", // We are version 1 of ourselves
|
||||||
"Implementation-Title": project.name,
|
"Implementation-Title": project.name,
|
||||||
"Implementation-Version": "${version}",
|
"Implementation-Version": "${version}",
|
||||||
"Implementation-Vendor" :"examplemodsareus",
|
"Implementation-Vendor" :"zombiedropmodsareus",
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
src/main/java/com/punkcraft/zombiedrop/ZombieDrop.java
Normal file
26
src/main/java/com/punkcraft/zombiedrop/ZombieDrop.java
Normal 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) {
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"modid": "example",
|
"modid": "zombiedrop",
|
||||||
"name": "Example",
|
"name": "ZombieDrop",
|
||||||
"description": "",
|
"description": "",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"mcversion": "${mcversion}",
|
"mcversion": "${mcversion}",
|
||||||
|
Loading…
Reference in New Issue
Block a user