diff --git a/build.gradle b/build.gradle index 6c041ab..451b133 100644 --- a/build.gradle +++ b/build.gradle @@ -9,13 +9,12 @@ buildscript { } apply plugin: 'net.minecraftforge.gradle' -// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. 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' +archivesBaseName = 'zombiedrop' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. @@ -45,21 +44,6 @@ 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.. -jar { - manifest { - attributes([ - "Specification-Title": "examplemod", - "Specification-Vendor": "examplemodsareus", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"examplemodsareus", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } -} - jar.finalizedBy('reobfJar') publishing { diff --git a/src/main/java/com/punkcraft/example/Example.java b/src/main/java/com/punkcraft/example/Example.java deleted file mode 100644 index b530012..0000000 --- a/src/main/java/com/punkcraft/example/Example.java +++ /dev/null @@ -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) { - } - - -} diff --git a/src/main/java/com/punkcraft/zombiedrop/ClientProxy.java b/src/main/java/com/punkcraft/zombiedrop/ClientProxy.java new file mode 100644 index 0000000..cd0b9db --- /dev/null +++ b/src/main/java/com/punkcraft/zombiedrop/ClientProxy.java @@ -0,0 +1,12 @@ +package com.punkcraft.zombiedrop; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy { + @Override + public void preInit(FMLPreInitializationEvent event) {} + + @Override + public void init(FMLInitializationEvent event) {} +} diff --git a/src/main/java/com/punkcraft/zombiedrop/CommonProxy.java b/src/main/java/com/punkcraft/zombiedrop/CommonProxy.java new file mode 100644 index 0000000..d74b4ec --- /dev/null +++ b/src/main/java/com/punkcraft/zombiedrop/CommonProxy.java @@ -0,0 +1,10 @@ +package com.punkcraft.zombiedrop; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy { + public void preInit(FMLPreInitializationEvent event) {} + + public void init(FMLInitializationEvent event) {} +} diff --git a/src/main/java/com/punkcraft/zombiedrop/ServerProxy.java b/src/main/java/com/punkcraft/zombiedrop/ServerProxy.java new file mode 100644 index 0000000..c50f7c2 --- /dev/null +++ b/src/main/java/com/punkcraft/zombiedrop/ServerProxy.java @@ -0,0 +1,42 @@ +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); + } + } + } + } +} diff --git a/src/main/java/com/punkcraft/zombiedrop/ZombieDrop.java b/src/main/java/com/punkcraft/zombiedrop/ZombieDrop.java new file mode 100644 index 0000000..32844dc --- /dev/null +++ b/src/main/java/com/punkcraft/zombiedrop/ZombieDrop.java @@ -0,0 +1,26 @@ +package com.punkcraft.zombiedrop; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +@Mod(modid = ZombieDrop.MODID, name = ZombieDrop.NAME, version = ZombieDrop.VERSION, canBeDeactivated = true) +public class ZombieDrop { + public static final String MODID = "zombiedrop"; + public static final String NAME = "ZombieDrop"; + public static final String VERSION = "1.0"; + + @SidedProxy(serverSide = "com.punkcraft.zombiedrop.ServerProxy") + public static CommonProxy proxy; + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) { + proxy.preInit(event); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + proxy.init(event); + } +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 4e65d29..0c781b2 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,16 +1,16 @@ [ -{ - "modid": "example", - "name": "Example", - "description": "", - "version": "${version}", - "mcversion": "${mcversion}", - "url": "", - "updateUrl": "", - "authorList": ["PIVODEVAT"], - "credits": "", - "logoFile": "", - "screenshots": [], - "dependencies": [] -} + { + "modid": "zombiedrop", + "name": "ZombieDrop", + "description": "Добавляет 99% шанс дропа эндерпёрла с зомби. Мод работает только на сервере и не требует установки на клиенте.", + "version": "1.0", + "mcversion": "1.12.2", + "url": "", + "updateUrl": "", + "authorList": ["PIVODEVAT"], + "credits": "", + "logoFile": "", + "screenshots": [], + "dependencies": [], + } ] diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta deleted file mode 100644 index 4018267..0000000 --- a/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pack": { - "description": "examplemod resources", - "pack_format": 3, - "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." - } -}