diff --git a/src/src/main/java/com/zivilon/cinder_loe/CinderLoE.java b/src/src/main/java/com/zivilon/cinder_loe/CinderLoE.java new file mode 100644 index 0000000..3faead7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/CinderLoE.java @@ -0,0 +1,1116 @@ +package com.zivilon.cinder_loe; + +import com.zivilon.cinder_loe.blocks.*; +import com.zivilon.cinder_loe.character.CharacterEventListener; +import com.zivilon.cinder_loe.character.CharacterRoleAPI; +import com.zivilon.cinder_loe.client.render.*; +import com.zivilon.cinder_loe.command.CommandCinderCharacter; +import com.zivilon.cinder_loe.entity.*; +import com.zivilon.cinder_loe.items.*; +import com.zivilon.cinder_loe.tileentity.*; +import com.zivilon.cinder_loe.util.Utilities; +import com.zivilon.cinder_loe.ItemRegistration; +import com.zivilon.cindercore.CinderCore; +import lotr.common.item.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.util.TraceClassVisitor; + +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; + +import lotr.client.render.entity.*; +import lotr.client.render.entity.LOTRRenderSauron; +import lotr.client.render.tileentity.LOTRRenderUtumnoPortal; +import lotr.common.LOTRCreativeTabs; +import lotr.common.LOTRMod; +import lotr.common.entity.animal.*; +import lotr.common.entity.npc.*; +import lotr.common.entity.npc.LOTREntityBarrowWight; +import lotr.common.entity.npc.LOTREntitySauron; +import lotr.common.entity.projectile.LOTREntityGandalfFireball; +import lotr.common.world.biome.LOTRBiome; +import lotr.common.world.spawning.LOTRBiomeSpawnList; +import lotr.common.world.spawning.LOTRSpawnEntry; +import lotr.common.world.spawning.LOTRSpawnList; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.WorldEvent; + +import static lotr.common.LOTRMod.horseArmorIron; + +import net.minecraft.command.ICommandSender; +import net.minecraft.command.CommandBase; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.client.ClientCommandHandler; + +@Mod( + modid = "cinder_loe", + version = "1.2.1", + name = "CinderLoE", + dependencies = "required-after:spongemixins@[1.1.0,);required-after:lotr", + acceptedMinecraftVersions = "[1.7.10]", + acceptableRemoteVersions = "*") +public class CinderLoE { + + @Instance("cinder_loe") + public static CinderLoE instance; + + public static final Logger LOG = LogManager.getLogger(Tags.MODID); + + // LOTR Materials + public static LOTRMaterial MATERIAL_RED_DWARF; + public static LOTRMaterial WIZARD; + public static LOTRMaterial MATERIAL_LIMWAITH_BONE; + public static LOTRMaterial MATERIAL_BONEMOLD; + public static LOTRMaterial MATERIAL_LIMWAITH_WOOD; + public static LOTRMaterial EVENT; + public static LOTRMaterial MATERIAL_BREE; + public static LOTRMaterial MATERIAL_BATTLENUN; + public static LOTRMaterial MATERIAL_ASH; + + // Blocks + public static Block cinderBlock; + public static Block ivoryBlock; + public static Block blockRedDwarfSteel; + public static Block barsRedDwarf; + public static Block chandelierRedDwarf; + public static Block furBundle; + public static Block leatherBundle; + public static Block reedBale; + public static Block dwarvenBrickRuned; + public static Block fishBarrel; + public static Block mistBlock; + public static Block cutDrystone; + public static Block cobbleDrystone; + public static Block reeflessCoral; + public static Block silverChain; + public static Block goldChain; + public static Block ironChain; + public static Block bronzeChain; + + + // Misc + public static Item frostblade; + public static Item spearsolidgold; + public static Item whip; + public static Item swordAsh; + public static Item daggerAsh; + public static Item spearAsh; + public static Item hammerAsh; + public static Item battleaxeAsh; + public static Item pikeAsh; + public static Item bowAsh; + public static Item ingotAsh; + + // Red Dwarves + public static Item redDwarfSteel; + public static Item helmetRedDwarf; + public static Item bodyRedDwarf; + public static Item legsRedDwarf; + public static Item bootsRedDwarf; + public static Item spearRedDwarf; + public static Item swordRedDwarf; + public static Item battleaxeRedDwarf; + public static Item pikeRedDwarf; + public static Item hammerRedDwarf; + public static Item daggerRedDwarf; + public static Item daggerRedDwarfPoisoned; + public static Item crossbowRedDwarf; + public static Item boarArmorRedDwarf; + public static LOTRUnitTradeEntries RED_DWARF_COMMANDER; + + // Limwaith + public static Item bonemold; + public static Item helmetLimwaith; + public static Item bodyLimwaith; + public static Item legsLimwaith; + public static Item bootsLimwaith; + public static Item helmetboneLimwaith; + public static Item bodyboneLimwaith; + public static Item legsboneLimwaith; + public static Item bootsboneLimwaith; + public static Item tridentLimwaith; + public static Item spearLimwaith; + public static Item truncheonLimwaith; + public static Item battleaxeLimwaith; + public static Item daggerLimwaith; + public static Item daggerLimwaithPoisoned; + public static Item blowgunLimwaith; + public static LOTRUnitTradeEntries LIMWAITH_COMMANDER; + + //Bree + public static Item helmetBree; + public static Item bodyBree; + public static Item legsBree; + public static Item bootsBree; + public static Item swordBree; + public static LOTRUnitTradeEntries BREE_CAPTAIN; + + // Arnor + public static Item helmetArnorBanner; + public static Item bodyArnorBanner; + public static Item legsArnorBanner; + public static Item bootsArnorBanner; + public static Item maceArnor; + public static LOTRUnitTradeEntries ARNOR_CAPTAIN; + public static Item battleNunSpawnEgg; + + // Wizards + public static Item radagastStaff; + public static Item pallandoStaff; + public static Item alatarStaff; + public static Item sarumanStaff; + + // Spawn eggs + public static Item redDwarfWarriorSpawnEgg; + public static Item redDwarfArbalestSpawnEgg; + public static Item redDwarfCommanderSpawnEgg; + public static Item redDwarfBannerBearerSpawnEgg; + public static Item redDwarfSmithSpawnEgg; + + public static Item limwaithSpawnEgg; + public static Item limwaithWarriorSpawnEgg; + public static Item limwaithBoneWarriorSpawnEgg; + public static Item limwaithBlowgunnerSpawnEgg; + public static Item limwaithBannerBearerSpawnEgg; + public static Item limwaithChieftainSpawnEgg; + public static Item limwaithFishmongerSpawnEgg; + public static Item limwaithShamanSpawnEgg; + + + public static Item fangornBearSpawnEgg; + public static Item fangornWildBoarSpawnEgg; + public static Item fangornAurochSpawnEgg; + public static Item fangornElkSpawnEgg; + public static Item renegadeSpawnEgg; + public static Item renegadeCaptainSpawnEgg; + public static Item wraithSpawnEgg; + + public static Item ArnorSoldierSpawnEgg; + public static Item ArnorSoldierArcherSpawnEgg; + public static Item ArnorCaptainSpawnEgg; + public static Item ArnorBannerBearerSpawnEgg; + + public static Item BreeSoldierSpawnEgg; + public static Item BreeCrossbowmanSpawnEgg; + public static Item BreeCaptainSpawnEgg; + public static Item BreeSoldierBannerBearerSpawnEgg; + public static Item BreeOutriderSpawnEgg; + + public static Item SauronSpawnEgg; + + public static Item utumnoSlaveSpawnEgg; + + // Spawn lists + public static LOTRSpawnList RED_DWARF; + public static LOTRSpawnList LIMWAITH; + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) { + CinderLoE_Config.init(event); + Materials.registerMaterials(); + registerItems(); + ItemRegistration.registerItems(); + registerBlocks(); + registerEntities(); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + CommonProxy proxy = event.getSide() == Side.CLIENT ? new ClientProxy() : new ServerProxy(); + proxy.setup(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + FMLCommonHandler.instance().bus().register(this); + } + MinecraftForge.EVENT_BUS.register(this); + new CharacterEventListener(); + + if (event.getSide().isClient()) { + ClientCommandHandler.instance.registerCommand(new DevCommand()); + } + } + + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent event) { + if (event.getSide() + .isServer()) { + SpeechBankModifier.insertSpeechBanks(); + modifySpawnLists(); + } + Utilities.initialize_reflects(); + recipes.registerRecipes(); // Register recipes at com.zivilon.cinder_loe.recipes.java + setupTradeEntries(); + LOTRWeaponStats.registerMeleeReach(Whip.class, 1.5F); + } + + + @Mod.EventHandler + public void serverStarting(FMLServerStartingEvent event) { + CharacterRoleAPI.loadRolesFromFile(); + event.registerServerCommand(new CommandCinderCharacter()); + } + + public void registerEntities() { // Last ID added: 34 + GameRegistry.registerTileEntity(TileEntityMistBlock.class, "TileEntityMistBlock"); + + int entityID = 7320; // Always increment entityID by 1 over the last entity to ensure unique IDs + EntityRegistry.registerModEntity(SarumanFireball.class, "SarumanFireball", entityID + 0, this, 64, 10, true); + EntityRegistry.registerModEntity(Renegade.class, "Renegade", (entityID + 1), this, 64, 1, true); + EntityRegistry.registerModEntity(RenegadeCaptain.class, "RenegadeCaptain", (entityID + 16), this, 64, 1, true); + + EntityRegistry.registerModEntity(RedDwarfWarrior.class, "RedDwarfWarrior", (entityID + 2), this, 64, 1, true); + EntityRegistry.registerModEntity(RedDwarfArbalest.class, "RedDwarfArbalest", (entityID + 3), this, 64, 1, true); + EntityRegistry.registerModEntity(RedDwarfBannerBearer.class, "RedDwarfBannerBearer", (entityID + 4), this, 64, 1, true); + EntityRegistry.registerModEntity(RedDwarfCommander.class, "RedDwarfCommander", (entityID + 5), this, 64, 1, true); + EntityRegistry.registerModEntity(RedDwarfSmith.class, "RedDwarfSmith", (entityID + 29), this, 64, 1, true); + + EntityRegistry.registerModEntity(FangornBear.class, "FangornBear", (entityID + 6), this, 64, 1, true); + EntityRegistry.registerModEntity(FangornWildBoar.class, "FangornWildBoar", (entityID + 7), this, 64, 1, true); + EntityRegistry.registerModEntity(FangornAuroch.class, "FangornAuroch", (entityID + 8), this, 64, 1, true); + EntityRegistry.registerModEntity(FangornElk.class, "FangornElk", (entityID + 9), this, 64, 1, true); + EntityRegistry.registerModEntity(FangornWolf.class, "FangornWolf", (entityID + 10), this, 64, 1, true); + + EntityRegistry.registerModEntity(Limwaith.class, "Limwaith", (entityID + 31), this, 64, 1, true); + EntityRegistry.registerModEntity(LimwaithWarrior.class, "LimwaithWarrior", (entityID + 11), this, 64, 1, true); + EntityRegistry.registerModEntity(LimwaithBoneWarrior.class, "LimwaithBoneWarrior", (entityID + 32), this, 64, 1, true); + EntityRegistry.registerModEntity(LimwaithBlowgunner.class, "LimwaithBlowgunner", (entityID + 12), this, 64, 1, true); + EntityRegistry.registerModEntity(LimwaithBannerBearer.class, "LimwaithBannerBearer", (entityID + 13), this, 64, 1, true); + EntityRegistry.registerModEntity(LimwaithFishmonger.class, "LimwaithFishmonger", (entityID + 33), this, 64, 1, true); + EntityRegistry.registerModEntity(LimwaithShaman.class, "LimwaithShaman", (entityID + 34), this, 64, 1, true); + EntityRegistry.registerModEntity(LimwaithChieftain.class, "LimwaithChieftain", (entityID + 14), this, 64, 1, true); + + EntityRegistry.registerModEntity(Wraith.class, "Wraith", (entityID + 15), this, 64, 1, true); + + EntityRegistry.registerModEntity(ArnorSoldier.class, "ArnorSoldier", (entityID + 17), this, 64, 1, true); + EntityRegistry.registerModEntity(ArnorSoldierArcher.class, "ArnorSoldierArcher", (entityID + 19), this, 64, 1, true); + EntityRegistry.registerModEntity(ArnorCaptain.class, "ArnorCaptain", (entityID + 20), this, 64, 1, true); + EntityRegistry.registerModEntity(ArnorBannerBearer.class, "ArnorBannerBearer", (entityID + 21), this, 64, 1, true); + EntityRegistry.registerModEntity(BattleNun.class, "BattleNun", (entityID + 27), this, 64, 1, true); + + EntityRegistry.registerModEntity(BreeSoldier.class, "BreeSoldier", (entityID + 22), this, 64, 1, true); + EntityRegistry.registerModEntity(BreeCrossbowman.class, "BreeCrossbowman", (entityID + 23), this, 64, 1, true); + EntityRegistry.registerModEntity(BreeCaptain.class, "BreeCaptain", (entityID + 24), this, 64, 1, true); + EntityRegistry.registerModEntity(BreeSoldierBannerBearer.class, "BreeSoldierBannerBearer", (entityID + 25), this, 64, 1, true); + EntityRegistry.registerModEntity(BreeOutrider.class, "BreeOutrider", (entityID + 26), this, 64, 1, true); + + EntityRegistry.registerModEntity(LOTREntitySauron.class, "LOTREntitySauron", (entityID + 28), this, 64, 1, true); + + EntityRegistry.registerModEntity(UtumnoSlaveTrader.class, "UtumnoSlaveTrader", (entityID + 30), this, 64, 1, true); + } + + public void registerBlocks() { + // Cinder Block + cinderBlock = (new CinderBlock()); + GameRegistry.registerBlock(cinderBlock, "cinderBlock"); + + // Ivory Block + ivoryBlock = (new IvoryBlock()); + GameRegistry.registerBlock(ivoryBlock, "ivoryBlock"); + + // Reefless Coral + reeflessCoral = (new reeflessCoral()); + GameRegistry.registerBlock(reeflessCoral, "reeflessCoral"); + + // Red Dwarven Steel Block + blockRedDwarfSteel = (new BlockRedDwarfSteel()); + GameRegistry.registerBlock(blockRedDwarfSteel, "blockRedDwarfSteel"); + + // Red Dwarven Steel Bars + barsRedDwarf = (new RedDwarfBars()); + GameRegistry.registerBlock(barsRedDwarf, "barsRedDwarf"); + + // Red dwarven chandelier + chandelierRedDwarf = (new RedDwarfChandelier()); + GameRegistry.registerBlock(chandelierRedDwarf, "chandelierRedDwarf"); + + // Bundles + furBundle = (new FurBundle()); + GameRegistry.registerBlock(furBundle, "furBundle"); + leatherBundle = (new LeatherBundle()); + GameRegistry.registerBlock(leatherBundle, "leatherBundle"); + reedBale = (new ReedBale()); + GameRegistry.registerBlock(reedBale, "reedBale"); + + // Runed Dwarven Brick + dwarvenBrickRuned = (new RunedDwarvenBrick()); + GameRegistry.registerBlock(dwarvenBrickRuned, "dwarvenBrickRuned"); + + // Fish Barrel + fishBarrel = (new FishBarrel()); + GameRegistry.registerBlock(fishBarrel, "fishbarrel"); + + // Chains + silverChain = (new silverChain()); + GameRegistry.registerBlock(silverChain, "silverChain"); + goldChain = (new goldChain()); + GameRegistry.registerBlock(goldChain, "goldChain"); + ironChain = (new ironChain()); + GameRegistry.registerBlock(ironChain, "ironChain"); + bronzeChain = (new bronzeChain()); + GameRegistry.registerBlock(bronzeChain, "bronzeChain"); + + // Mist Block + mistBlock = (new MistBlock()); + GameRegistry.registerBlock(mistBlock, "mist"); + + // Drystones + cutDrystone = (new cutDrystone()); + GameRegistry.registerBlock(cutDrystone, "cutDrystone"); + cobbleDrystone = (new cobbleDrystone()); + GameRegistry.registerBlock(cobbleDrystone, "cobbleDrystone"); + } + + public void registerItems() { + // Get materials tab via reflection because ForgeGradle insists on obfuscating it when it should not + LOTRCreativeTabs materials = null; + try { + Field tabField = LOTRCreativeTabs.class.getDeclaredField("tabMaterials"); // Stupid workaround because ForgeGradle tries to obfuscate field LOTRCreativeTabs.tabBlock when it's not supposed to be + materials = (LOTRCreativeTabs) tabField.get(null); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + + redDwarfWarriorSpawnEgg = new CinderLoESpawnEgg(RedDwarfWarrior.class).setTextureName("lotr:spawn_egg"); + redDwarfArbalestSpawnEgg = new CinderLoESpawnEgg(RedDwarfArbalest.class).setTextureName("lotr:spawn_egg"); + redDwarfCommanderSpawnEgg = new CinderLoESpawnEgg(RedDwarfCommander.class).setTextureName("lotr:spawn_egg"); + redDwarfBannerBearerSpawnEgg = new CinderLoESpawnEgg(RedDwarfBannerBearer.class).setTextureName("lotr:spawn_egg"); + redDwarfSmithSpawnEgg = new CinderLoESpawnEgg(RedDwarfSmith.class).setTextureName("lotr:spawn_egg"); + + limwaithSpawnEgg = new CinderLoESpawnEgg(Limwaith.class).setTextureName("lotr:spawn_egg"); + limwaithFishmongerSpawnEgg = new CinderLoESpawnEgg(LimwaithFishmonger.class).setTextureName("lotr:spawn_egg"); + limwaithShamanSpawnEgg = new CinderLoESpawnEgg(LimwaithShaman.class).setTextureName("lotr:spawn_egg"); + limwaithWarriorSpawnEgg = new CinderLoESpawnEgg(LimwaithWarrior.class).setTextureName("lotr:spawn_egg"); + limwaithBoneWarriorSpawnEgg = new CinderLoESpawnEgg(LimwaithBoneWarrior.class).setTextureName("lotr:spawn_egg"); + limwaithBlowgunnerSpawnEgg = new CinderLoESpawnEgg(LimwaithBlowgunner.class).setTextureName("lotr:spawn_egg"); + limwaithChieftainSpawnEgg = new CinderLoESpawnEgg(LimwaithChieftain.class).setTextureName("lotr:spawn_egg"); + limwaithBannerBearerSpawnEgg = new CinderLoESpawnEgg(LimwaithBannerBearer.class).setTextureName("lotr:spawn_egg"); + + fangornBearSpawnEgg = new CinderLoESpawnEgg(FangornBear.class).setTextureName("lotr:spawn_egg"); + fangornWildBoarSpawnEgg = new CinderLoESpawnEgg(FangornWildBoar.class).setTextureName("lotr:spawn_egg"); + fangornAurochSpawnEgg = new CinderLoESpawnEgg(FangornAuroch.class).setTextureName("lotr:spawn_egg"); + fangornElkSpawnEgg = new CinderLoESpawnEgg(FangornElk.class).setTextureName("lotr:spawn_egg"); + + renegadeSpawnEgg = new CinderLoESpawnEgg(Renegade.class).setTextureName("lotr:spawn_egg"); + renegadeCaptainSpawnEgg = new CinderLoESpawnEgg(RenegadeCaptain.class).setTextureName("lotr:spawn_egg"); + + ArnorSoldierSpawnEgg = new CinderLoESpawnEgg(ArnorSoldier.class).setTextureName("lotr:spawn_egg"); + ArnorSoldierArcherSpawnEgg = new CinderLoESpawnEgg(ArnorSoldierArcher.class).setTextureName("lotr:spawn_egg"); + ArnorCaptainSpawnEgg = new CinderLoESpawnEgg(ArnorCaptain.class).setTextureName("lotr:spawn_egg"); + ArnorBannerBearerSpawnEgg = new CinderLoESpawnEgg(ArnorBannerBearer.class).setTextureName("lotr:spawn_egg"); + battleNunSpawnEgg = new CinderLoESpawnEgg(BattleNun.class).setTextureName("lotr:spawn_egg"); + + BreeSoldierSpawnEgg = new CinderLoESpawnEgg(BreeSoldier.class).setTextureName("lotr:spawn_egg"); + BreeCrossbowmanSpawnEgg = new CinderLoESpawnEgg(BreeCrossbowman.class).setTextureName("lotr:spawn_egg"); + BreeCaptainSpawnEgg = new CinderLoESpawnEgg(BreeCaptain.class).setTextureName("lotr:spawn_egg"); + BreeSoldierBannerBearerSpawnEgg = new CinderLoESpawnEgg(BreeSoldierBannerBearer.class).setTextureName("lotr:spawn_egg"); + BreeOutriderSpawnEgg = new CinderLoESpawnEgg(BreeOutrider.class).setTextureName("lotr:spawn_egg"); + + SauronSpawnEgg = new CinderLoESpawnEgg(LOTREntitySauron.class).setTextureName("lotr:spawn_egg"); + wraithSpawnEgg = new CinderLoESpawnEgg(Wraith.class).setTextureName("lotr:spawn_egg"); + + radagastStaff = (new RadagastStaff()).setUnlocalizedName("lotr:radagastStaff").setTextureName("lotr:radagastStaff"); + pallandoStaff = (new PallandoStaff()).setUnlocalizedName("lotr:pallandoStaff").setTextureName("lotr:pallandoStaff"); + alatarStaff = (new AlatarStaff()).setUnlocalizedName("lotr:alatarStaff").setTextureName("lotr:alatarStaff"); + sarumanStaff = (new SarumanStaff()).setUnlocalizedName("lotr:sarumanStaff").setTextureName("lotr:sarumanStaff"); + + utumnoSlaveSpawnEgg = new CinderLoESpawnEgg(UtumnoSlaveTrader.class).setTextureName("lotr:spawn_egg"); + + + // Last ID added: 86 + ItemRegistration.registerItem(redDwarfWarriorSpawnEgg, "redDwarfWarriorSpawnEgg", 0); + ItemRegistration.registerItem(redDwarfArbalestSpawnEgg, "redDwarfArbalestSpawnEgg", 1); + ItemRegistration.registerItem(redDwarfCommanderSpawnEgg, "redDwarfCommanderSpawnEgg", 2); + ItemRegistration.registerItem(redDwarfBannerBearerSpawnEgg, "redDwarfBannerBearerSpawnEgg", 3); + ItemRegistration.registerItem(redDwarfSmithSpawnEgg, "redDwarfSmithSpawnEgg", 68); + + ItemRegistration.registerItem(fangornBearSpawnEgg, "fangornBearSpawnEgg", 4); + ItemRegistration.registerItem(fangornWildBoarSpawnEgg, "fangornWildBoarSpawnEgg", 5); + ItemRegistration.registerItem(fangornAurochSpawnEgg, "fangornAurochSpawnEgg", 6); + ItemRegistration.registerItem(fangornElkSpawnEgg, "fangornElkSpawnEgg", 7); + ItemRegistration.registerItem(renegadeSpawnEgg, "renegadeSpawnEgg", 8); + ItemRegistration.registerItem(renegadeCaptainSpawnEgg, "renegadeCaptainSpawnEgg", 9); + ItemRegistration.registerItem(wraithSpawnEgg, "wraithSpawnEgg", 10); + + ItemRegistration.registerItem(limwaithSpawnEgg, "limwaithSpawnEgg", 82); + ItemRegistration.registerItem(limwaithShamanSpawnEgg, "limwaithShamanSpawnEgg", 85); + ItemRegistration.registerItem(limwaithFishmongerSpawnEgg, "limwaithFishmongerSpawnEgg", 86); + ItemRegistration.registerItem(limwaithWarriorSpawnEgg, "limwaithWarriorSpawnEgg", 11); + ItemRegistration.registerItem(limwaithBoneWarriorSpawnEgg, "limwaithBoneWarriorSpawnEgg", 84); + ItemRegistration.registerItem(limwaithBlowgunnerSpawnEgg, "limwaithBlowgunnerSpawnEgg", 12); + ItemRegistration.registerItem(limwaithBannerBearerSpawnEgg, "limwaithBannerBearerSpawnEgg", 13); + ItemRegistration.registerItem(limwaithChieftainSpawnEgg, "limwaithChieftainSpawnEgg", 14); + + ItemRegistration.registerItem(ArnorSoldierSpawnEgg, "ArnorSoldierSpawnEgg", 15); + ItemRegistration.registerItem(ArnorSoldierArcherSpawnEgg, "ArnorSoldierArcherSpawnEgg", 16); + ItemRegistration.registerItem(ArnorCaptainSpawnEgg, "ArnorCaptainSpawnEgg", 17); + ItemRegistration.registerItem(ArnorBannerBearerSpawnEgg, "ArnorBannerBearerSpawnEgg", 18); + ItemRegistration.registerItem(battleNunSpawnEgg, "battleNunSpawnEgg", 19); + + ItemRegistration.registerItem(BreeSoldierSpawnEgg, "BreeSoldierSpawnEgg", 20); + ItemRegistration.registerItem(BreeCrossbowmanSpawnEgg, "BreeCrossbowmanSpawnEgg", 21); + ItemRegistration.registerItem(BreeCaptainSpawnEgg, "BreeCaptainSpawnEgg", 22); + ItemRegistration.registerItem(BreeSoldierBannerBearerSpawnEgg, "BreeSoldierBannerBearerSpawnEgg", 23); + ItemRegistration.registerItem(BreeOutriderSpawnEgg, "BreeOutriderSpawnEgg", 24); + + ItemRegistration.registerItem(SauronSpawnEgg, "SauronSpawnEgg", 25); + + ItemRegistration.registerItem(utumnoSlaveSpawnEgg, "utumnoSlaveSpawnEgg", 69); + + // Wizards + ItemRegistration.registerItem(radagastStaff, "radagastStaff", 26); + ItemRegistration.registerItem(pallandoStaff, "pallandoStaff", 27); + ItemRegistration.registerItem(alatarStaff, "alatarStaff", 28); + ItemRegistration.registerItem(sarumanStaff, "sarumanStaff", 29); + + linkLOTRWeapon(radagastStaff, "radagastStaff"); + linkLOTRWeapon(pallandoStaff, "pallandoStaff"); + linkLOTRWeapon(alatarStaff, "alatarStaff"); + linkLOTRWeapon(sarumanStaff, "sarumanStaff"); + + // Misc + EVENT = getLOTRMaterialByName("EVENT"); + frostblade = (new LOTRItemSword(EVENT)).setUnlocalizedName("lotr:frostblade").setTextureName("lotr:frostblade"); + spearsolidgold = (new LOTRItemSpear(EVENT)).setUnlocalizedName("lotr:spearsolidgold").setTextureName("lotr:spearsolidgold"); + whip = (new Whip()).setUnlocalizedName("lotr:whip").setTextureName("lotr:whip"); + + ItemRegistration.registerItem(frostblade, "frostblade", 30); + ItemRegistration.registerItem(spearsolidgold, "spearsolidgold", 31); + ItemRegistration.registerItem(whip, "whip", 32); + linkLOTRWeapon(frostblade, "frostblade"); + linkLOTRWeapon(spearsolidgold, "spearsolidgold"); + linkLOTRWeapon(whip, "whip"); + + //ASH + MATERIAL_ASH = getLOTRMaterialByName("ASH"); + ingotAsh = new Item().setUnlocalizedName("lotr:ingotAsh").setTextureName("lotr:ingotAsh").setCreativeTab((CreativeTabs) materials); + if (MATERIAL_ASH != null) { + swordAsh = (new LOTRItemSword(MATERIAL_ASH)).setUnlocalizedName("lotr:swordAsh").setTextureName("lotr:swordAsh"); + daggerAsh = (new LOTRItemDagger(MATERIAL_ASH)).setUnlocalizedName("lotr:daggerAsh").setTextureName("lotr:daggerAsh"); + hammerAsh = (new LOTRItemHammer(MATERIAL_ASH)).setUnlocalizedName("lotr:hammerAsh").setTextureName("lotr:hammerAsh"); + battleaxeAsh = (new LOTRItemBattleaxe(MATERIAL_ASH)).setUnlocalizedName("lotr:battleaxeAsh").setTextureName("lotr:battleaxeAsh"); + bowAsh = (new LOTRItemBow(MATERIAL_ASH)).setUnlocalizedName("lotr:bowAsh").setTextureName("lotr:bowAsh"); + pikeAsh = (new LOTRItemPike(MATERIAL_ASH)).setUnlocalizedName("lotr:pikeAsh").setTextureName("lotr:pikeAsh"); + spearAsh = (new LOTRItemSpear(MATERIAL_ASH)).setUnlocalizedName("lotr:spearAsh").setTextureName("lotr:spearAsh"); + + ItemRegistration.registerItem(ingotAsh, "ingotAsh", 74); + + ItemRegistration.registerItem(swordAsh, "swordAsh", 75); + ItemRegistration.registerItem(daggerAsh, "daggerAsh", 76); + ItemRegistration.registerItem(hammerAsh, "hammerAsh", 77); + ItemRegistration.registerItem(battleaxeAsh, "battleaxeAsh", 78); + ItemRegistration.registerItem(bowAsh, "bowAsh", 79); + ItemRegistration.registerItem(pikeAsh, "pikeAsh", 80); + ItemRegistration.registerItem(spearAsh, "spearAsh", 81); + } else { + // Log an error or handle the case where the material could not be found + System.err.println("Failed to find MATERIAL_ASH material for armor initialization."); + } + linkLOTRWeapon(swordAsh, "swordAsh"); + linkLOTRWeapon(daggerAsh, "daggerAsh"); + linkLOTRWeapon(hammerAsh, "hammerAsh"); + linkLOTRWeapon(battleaxeAsh, "battleaxeAsh"); + linkLOTRWeapon(bowAsh, "bowAsh"); + linkLOTRWeapon(pikeAsh, "pikeAsh"); + linkLOTRWeapon(spearAsh, "spearAsh"); + + // Red Dwarves + redDwarfSteel = new Item().setUnlocalizedName("lotr:redDwarfSteel").setTextureName("lotr:redDwarfSteel").setCreativeTab((CreativeTabs) materials); + ItemRegistration.registerItem(redDwarfSteel, "redDwarfSteel", 33); + + MATERIAL_RED_DWARF = getLOTRMaterialByName("RED_DWARF"); + if (MATERIAL_RED_DWARF != null) { + helmetRedDwarf = (new LOTRItemArmor(MATERIAL_RED_DWARF, 0, "helmet")).setUnlocalizedName("lotr:helmetRedDwarf").setTextureName("lotr:helmetRedDwarf"); + bodyRedDwarf = (new LOTRItemArmor(MATERIAL_RED_DWARF, 1)).setUnlocalizedName("lotr:bodyRedDwarf").setTextureName("lotr:bodyRedDwarf"); + legsRedDwarf = (new LOTRItemArmor(MATERIAL_RED_DWARF, 2)).setUnlocalizedName("lotr:legsRedDwarf").setTextureName("lotr:legsRedDwarf"); + bootsRedDwarf = (new LOTRItemArmor(MATERIAL_RED_DWARF, 3)).setUnlocalizedName("lotr:bootsRedDwarf").setTextureName("lotr:bootsRedDwarf"); + spearRedDwarf = (new LOTRItemSpear(MATERIAL_RED_DWARF)).setUnlocalizedName("lotr:spearRedDwarf").setTextureName("lotr:spearRedDwarf"); + swordRedDwarf = (new LOTRItemSword(MATERIAL_RED_DWARF)).setUnlocalizedName("lotr:swordRedDwarf").setTextureName("lotr:swordRedDwarf"); + battleaxeRedDwarf = (new LOTRItemBattleaxe(MATERIAL_RED_DWARF)).setUnlocalizedName("lotr:battleaxeRedDwarf").setTextureName("lotr:battleaxeRedDwarf"); + pikeRedDwarf = (new LOTRItemPike(MATERIAL_RED_DWARF)).setUnlocalizedName("lotr:pikeRedDwarf").setTextureName("lotr:pikeRedDwarf"); + hammerRedDwarf = (new LOTRItemHammer(MATERIAL_RED_DWARF)).setUnlocalizedName("lotr:hammerRedDwarf").setTextureName("lotr:hammerRedDwarf"); + daggerRedDwarf = (new LOTRItemDagger(MATERIAL_RED_DWARF)).setUnlocalizedName("lotr:daggerRedDwarf").setTextureName("lotr:daggerRedDwarf"); + daggerRedDwarfPoisoned = (new LOTRItemDagger(MATERIAL_RED_DWARF, LOTRItemDagger.DaggerEffect.POISON)).setUnlocalizedName("lotr:daggerRedDwarfPoisoned").setTextureName("lotr:daggerRedDwarfPoisoned"); + crossbowRedDwarf = (new LOTRItemCrossbow(MATERIAL_RED_DWARF)).setUnlocalizedName("lotr:crossbowRedDwarf").setTextureName("lotr:crossbowRedDwarf"); + boarArmorRedDwarf = (new LOTRItemMountArmor(MATERIAL_RED_DWARF, LOTRItemMountArmor.Mount.BOAR)).setUnlocalizedName("lotr:boarArmorRedDwarf").setTextureName("lotr:boarArmorRedDwarf"); + + ItemRegistration.registerItem(helmetRedDwarf, "helmetRedDwarf", 34); + ItemRegistration.registerItem(bodyRedDwarf, "bodyRedDwarf", 35); + ItemRegistration.registerItem(legsRedDwarf, "legsRedDwarf", 36); + ItemRegistration.registerItem(bootsRedDwarf, "bootsRedDwarf", 37); + ItemRegistration.registerItem(spearRedDwarf, "spearRedDwarf", 38); + ItemRegistration.registerItem(swordRedDwarf, "swordRedDwarf", 39); + ItemRegistration.registerItem(battleaxeRedDwarf, "battleaxeRedDwarf", 40); + ItemRegistration.registerItem(pikeRedDwarf, "pikeRedDwarf", 41); + ItemRegistration.registerItem(hammerRedDwarf, "hammerRedDwarf", 42); + ItemRegistration.registerItem(daggerRedDwarf, "daggerRedDwarf", 43); + ItemRegistration.registerItem(daggerRedDwarfPoisoned, "daggerRedDwarfPoisoned", 44); + ItemRegistration.registerItem(crossbowRedDwarf, "crossbowRedDwarf", 45); + ItemRegistration.registerItem(boarArmorRedDwarf, "boarArmorRedDwarf", 46); +// System.out.println("Registered red dwarf equipment"); + } else { + // Log an error or handle the case where the material could not be found + System.err.println("Failed to find RED_DWARF material for armor initialization."); + } + linkLOTRWeapon(spearRedDwarf, "spearRedDwarf"); + linkLOTRWeapon(swordRedDwarf, "swordRedDwarf"); + linkLOTRWeapon(battleaxeRedDwarf, "battleaxeRedDwarf"); + linkLOTRWeapon(pikeRedDwarf, "pikeRedDwarf"); + linkLOTRWeapon(hammerRedDwarf, "hammerRedDwarf"); + linkLOTRWeapon(daggerRedDwarf, "daggerRedDwarf"); + linkLOTRWeapon(daggerRedDwarfPoisoned, "daggerRedDwarfPoisoned"); + linkLOTRWeapon(crossbowRedDwarf, "crossbowRedDwarf"); + + // Limwaith + + bonemold = new Item().setUnlocalizedName("lotr:bonemold").setTextureName("lotr:bonemold").setCreativeTab((CreativeTabs) materials); + ItemRegistration.registerItem(bonemold, "bonemold", 83); + + MATERIAL_LIMWAITH_BONE = getLOTRMaterialByName("LIMWAITH_BONE"); + MATERIAL_LIMWAITH_WOOD = getLOTRMaterialByName("LIMWAITH_WOOD"); + MATERIAL_BONEMOLD = getLOTRMaterialByName("BONEMOLD"); + if (MATERIAL_LIMWAITH_WOOD != null && MATERIAL_LIMWAITH_BONE != null) { + helmetLimwaith = (new LOTRItemArmor(MATERIAL_LIMWAITH_WOOD, 0)).setUnlocalizedName("lotr:helmetLimwaith").setTextureName("lotr:helmetLimwaith"); + bodyLimwaith = (new LOTRItemArmor(MATERIAL_LIMWAITH_WOOD, 1)).setUnlocalizedName("lotr:bodyLimwaith").setTextureName("lotr:bodyLimwaith"); + legsLimwaith = (new LOTRItemArmor(MATERIAL_LIMWAITH_WOOD, 2)).setUnlocalizedName("lotr:legsLimwaith").setTextureName("lotr:legsLimwaith"); + bootsLimwaith = (new LOTRItemArmor(MATERIAL_LIMWAITH_WOOD, 3)).setUnlocalizedName("lotr:bootsLimwaith").setTextureName("lotr:bootsLimwaith"); + + helmetboneLimwaith = (new LOTRItemArmor(MATERIAL_BONEMOLD, 0)).setUnlocalizedName("lotr:helmetboneLimwaith").setTextureName("lotr:helmetboneLimwaith"); + bodyboneLimwaith = (new LOTRItemArmor(MATERIAL_BONEMOLD, 1)).setUnlocalizedName("lotr:bodyboneLimwaith").setTextureName("lotr:bodyboneLimwaith"); + legsboneLimwaith = (new LOTRItemArmor(MATERIAL_BONEMOLD, 2)).setUnlocalizedName("lotr:legsboneLimwaith").setTextureName("lotr:legsboneLimwaith"); + bootsboneLimwaith = (new LOTRItemArmor(MATERIAL_BONEMOLD, 3)).setUnlocalizedName("lotr:bootsboneLimwaith").setTextureName("lotr:bootsboneLimwaith"); + + spearLimwaith = (new LOTRItemSpear(MATERIAL_LIMWAITH_BONE)).setUnlocalizedName("lotr:spearLimwaith").setTextureName("lotr:spearLimwaith"); + truncheonLimwaith = (new LOTRItemSword(MATERIAL_LIMWAITH_BONE)).setUnlocalizedName("lotr:truncheonLimwaith").setTextureName("lotr:truncheonLimwaith"); + battleaxeLimwaith = (new LOTRItemBattleaxe(MATERIAL_LIMWAITH_BONE)).setUnlocalizedName("lotr:battleaxeLimwaith").setTextureName("lotr:battleaxeLimwaith"); + tridentLimwaith = (new LOTRItemTrident(MATERIAL_LIMWAITH_BONE)).setUnlocalizedName("lotr:tridentLimwaith").setTextureName("lotr:tridentLimwaith"); + daggerLimwaith = (new LOTRItemDagger(MATERIAL_LIMWAITH_BONE)).setUnlocalizedName("lotr:daggerLimwaith").setTextureName("lotr:daggerLimwaith"); + daggerLimwaithPoisoned = (new LOTRItemDagger(MATERIAL_LIMWAITH_BONE, LOTRItemDagger.DaggerEffect.POISON)).setUnlocalizedName("lotr:daggerLimwaithPoisoned").setTextureName("lotr:daggerLimwaithPoisoned"); + blowgunLimwaith = (new LOTRItemBlowgun(LOTRMaterial.TAUREDAIN)).setUnlocalizedName("lotr:blowgunLimwaith").setTextureName("lotr:blowgunLimwaith"); + + ItemRegistration.registerItem(helmetLimwaith, "helmetLimwaith", 47); + ItemRegistration.registerItem(bodyLimwaith, "bodyLimwaith", 48); + ItemRegistration.registerItem(legsLimwaith, "legsLimwaith", 49); + ItemRegistration.registerItem(bootsLimwaith, "bootsLimwaith", 50); + + ItemRegistration.registerItem(helmetboneLimwaith, "helmetboneLimwaith", 70); + ItemRegistration.registerItem(bodyboneLimwaith, "bodyboneLimwaith", 71); + ItemRegistration.registerItem(legsboneLimwaith, "legsboneLimwaith", 72); + ItemRegistration.registerItem(bootsboneLimwaith, "bootsboneLimwaith", 73); + + ItemRegistration.registerItem(spearLimwaith, "spearLimwaith", 51); + ItemRegistration.registerItem(tridentLimwaith, "tridentLimwaith", 52); + ItemRegistration.registerItem(truncheonLimwaith, "truncheonLimwaith", 53); + ItemRegistration.registerItem(battleaxeLimwaith, "battleaxeLimwaith", 54); + ItemRegistration.registerItem(daggerLimwaith, "daggerLimwaith", 55); + ItemRegistration.registerItem(daggerLimwaithPoisoned, "daggerLimwaithPoisoned", 56); + ItemRegistration.registerItem(blowgunLimwaith, "blowgunLimwaith", 57); + } else { + System.err.println("Failed to find LIMWAITH material for armor initialization."); + } + linkLOTRWeapon(spearLimwaith, "spearLimwaith"); + linkLOTRWeapon(truncheonLimwaith, "truncheonLimwaith"); + linkLOTRWeapon(battleaxeLimwaith, "battleaxeLimwaith"); + linkLOTRWeapon(tridentLimwaith, "tridentLimwaith"); + linkLOTRWeapon(daggerLimwaith, "daggerLimwaith"); + linkLOTRWeapon(daggerLimwaithPoisoned, "daggerLimwaithPoisoned"); + linkLOTRWeapon(blowgunLimwaith, "blowgunLimwaith"); + + //Bree + MATERIAL_BREE = getLOTRMaterialByName("BREE"); + if (MATERIAL_BREE != null) { + helmetBree = (new LOTRItemArmor(MATERIAL_BREE, 0, "helmet")).setUnlocalizedName("lotr:helmetBree").setTextureName("lotr:helmetBree"); + bodyBree = (new LOTRItemArmor(MATERIAL_BREE, 1)).setUnlocalizedName("lotr:bodyBree").setTextureName("lotr:bodyBree"); + legsBree = (new LOTRItemArmor(MATERIAL_BREE, 2)).setUnlocalizedName("lotr:legsBree").setTextureName("lotr:legsBree"); + bootsBree = (new LOTRItemArmor(MATERIAL_BREE, 3)).setUnlocalizedName("lotr:bootsBree").setTextureName("lotr:bootsBree"); + swordBree = (new LOTRItemSword(MATERIAL_BREE)).setUnlocalizedName("lotr:swordBree").setTextureName("lotr:swordBree"); + + ItemRegistration.registerItem(helmetBree, "helmetBree", 58); + ItemRegistration.registerItem(bodyBree, "bodyBree", 59); + ItemRegistration.registerItem(legsBree, "legsBree", 60); + ItemRegistration.registerItem(bootsBree, "bootsBree", 61); + ItemRegistration.registerItem(swordBree, "swordBree", 62); + } else { + System.err.println("Failed to find BREE material for armor initialization."); + } + linkLOTRWeapon(swordBree, "swordBree"); + + //Arnor + MATERIAL_BATTLENUN = getLOTRMaterialByName("BATTLENUN"); + if (MATERIAL_BATTLENUN != null) { + helmetArnorBanner = (new LOTRItemArmor(MATERIAL_BATTLENUN, 0)).setUnlocalizedName("lotr:helmetArnorBanner").setTextureName("lotr:helmetArnorBanner"); + bodyArnorBanner = (new LOTRItemArmor(MATERIAL_BATTLENUN, 1)).setUnlocalizedName("lotr:bodyArnorBanner").setTextureName("lotr:bodyArnorBanner"); + legsArnorBanner = (new LOTRItemArmor(MATERIAL_BATTLENUN, 2)).setUnlocalizedName("lotr:legsArnorBanner").setTextureName("lotr:legsArnorBanner"); + bootsArnorBanner = (new LOTRItemArmor(MATERIAL_BATTLENUN, 3)).setUnlocalizedName("lotr:bootsArnorBanner").setTextureName("lotr:bootsArnorBanner"); + maceArnor = (new LOTRItemHammer(LOTRMaterial.ARNOR)).setUnlocalizedName("lotr:maceArnor").setTextureName("lotr:maceArnor"); + + ItemRegistration.registerItem(helmetArnorBanner, "helmetArnorBanner", 63); + ItemRegistration.registerItem(bodyArnorBanner, "bodyArnorBanner", 64); + ItemRegistration.registerItem(legsArnorBanner, "legsArnorBanner", 65); + ItemRegistration.registerItem(bootsArnorBanner, "bootsArnorBanner", 66); + ItemRegistration.registerItem(maceArnor, "maceArnor", 67); + } else { + System.err.println("Failed to find ARNOR material for armor initialization."); + } + linkLOTRWeapon(maceArnor, "maceArnor"); + } + + public static ModContainer getModContainer() { + return FMLCommonHandler.instance() + .findContainerFor(instance); + } + + public void linkLOTRWeapon(Item item, String weapon_name) { + try { + Field field = LOTRMod.class.getField(weapon_name); + field.set(null, item); + } catch (Exception e) { + System.err.println("[CinderLoE] linkLOTRWeapon: Failed to find field " + weapon_name + " in LOTRMod!"); + } + } + + public static class CommonProxy { + public void setup() { + } + } + + public static class ClientProxy extends CommonProxy { + @Override + public void setup() { + RenderingRegistry.registerEntityRenderingHandler(SarumanFireball.class, new RenderSarumanFireball()); + RenderingRegistry.registerEntityRenderingHandler(Renegade.class, new RenderRenegade()); + RenderingRegistry.registerEntityRenderingHandler(RenegadeCaptain.class, new RenderRenegade()); + RenderingRegistry.registerEntityRenderingHandler(Wraith.class, new RenderWraith()); + + RenderingRegistry.registerEntityRenderingHandler(RedDwarfWarrior.class, new LOTRRenderDwarf()); + RenderingRegistry.registerEntityRenderingHandler(RedDwarfArbalest.class, new LOTRRenderDwarf()); + RenderingRegistry.registerEntityRenderingHandler(RedDwarfBannerBearer.class, new LOTRRenderDwarf()); + RenderingRegistry.registerEntityRenderingHandler(RedDwarfCommander.class, new LOTRRenderDwarf()); + RenderingRegistry.registerEntityRenderingHandler(RedDwarfSmith.class, new LOTRRenderDwarf()); + + RenderingRegistry.registerEntityRenderingHandler(Limwaith.class, new RenderLimwaith()); + RenderingRegistry.registerEntityRenderingHandler(LimwaithFishmonger.class, new RenderLimwaith()); + RenderingRegistry.registerEntityRenderingHandler(LimwaithShaman.class, new RenderLimwaithShaman()); + RenderingRegistry.registerEntityRenderingHandler(LimwaithWarrior.class, new RenderLimwaith()); + RenderingRegistry.registerEntityRenderingHandler(LimwaithBoneWarrior.class, new RenderLimwaith()); + RenderingRegistry.registerEntityRenderingHandler(LimwaithBlowgunner.class, new RenderLimwaith()); + RenderingRegistry.registerEntityRenderingHandler(LimwaithBannerBearer.class, new RenderLimwaith()); + RenderingRegistry.registerEntityRenderingHandler(LimwaithChieftain.class, new RenderLimwaith()); + + RenderingRegistry.registerEntityRenderingHandler(FangornBear.class, new RenderFangornBear()); + RenderingRegistry.registerEntityRenderingHandler(FangornWildBoar.class, new RenderFangornWildBoar()); + RenderingRegistry.registerEntityRenderingHandler(FangornAuroch.class, new RenderFangornAuroch()); + RenderingRegistry.registerEntityRenderingHandler(FangornElk.class, new RenderFangornElk()); + RenderingRegistry.registerEntityRenderingHandler(FangornWolf.class, new RenderFangornWolf()); + + RenderingRegistry.registerEntityRenderingHandler(ArnorSoldier.class, new LOTRRenderDunedain()); + RenderingRegistry.registerEntityRenderingHandler(ArnorSoldierArcher.class, new LOTRRenderDunedain()); + RenderingRegistry.registerEntityRenderingHandler(ArnorCaptain.class, new LOTRRenderDunedain()); + RenderingRegistry.registerEntityRenderingHandler(ArnorBannerBearer.class, new LOTRRenderDunedain()); + RenderingRegistry.registerEntityRenderingHandler(BattleNun.class, new RenderBattleNun()); + + RenderingRegistry.registerEntityRenderingHandler(BreeSoldier.class, new LOTRRenderBreeMan()); + RenderingRegistry.registerEntityRenderingHandler(BreeCrossbowman.class, new LOTRRenderBreeMan()); + RenderingRegistry.registerEntityRenderingHandler(BreeCaptain.class, new LOTRRenderBreeMan()); + RenderingRegistry.registerEntityRenderingHandler(BreeSoldierBannerBearer.class, new LOTRRenderBreeMan()); + RenderingRegistry.registerEntityRenderingHandler(BreeOutrider.class, new LOTRRenderBreeMan()); + + RenderingRegistry.registerEntityRenderingHandler(LOTREntitySauron.class, new LOTRRenderSauron()); + RenderingRegistry.registerEntityRenderingHandler(UtumnoSlaveTrader.class, new RenderUtumnoSlave()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMistBlock.class, (TileEntitySpecialRenderer)new LOTRRenderUtumnoPortal()); + } + } + + public static class ServerProxy extends CommonProxy { + @Override + public void setup() { + } + } + + public void modifySpawnLists() { + try { + // Retrieve the constructor of LOTRSpawnList class + Constructor constructor = LOTRSpawnList.class.getDeclaredConstructor(LOTRSpawnEntry[].class); + constructor.setAccessible(true); // Make the private constructor accessible + + // RED_DWARF is initialized earlier in this class + LOTRSpawnList RED_DWARF = constructor.newInstance((Object) new LOTRSpawnEntry[]{ + new LOTRSpawnEntry(LOTREntityDwarf.class, 100, 4, 4), + new LOTRSpawnEntry(LOTREntityDwarfMiner.class, 15, 1, 3), + new LOTRSpawnEntry(RedDwarfWarrior.class, 20, 4, 4), + new LOTRSpawnEntry(RedDwarfArbalest.class, 10, 4, 4) + }); + + LOTRSpawnList LIMWAITH = constructor.newInstance((Object) new LOTRSpawnEntry[]{ + new LOTRSpawnEntry(Limwaith.class, 100, 4, 6), + new LOTRSpawnEntry(LimwaithWarrior.class, 20, 4, 6), + new LOTRSpawnEntry(LimwaithBlowgunner.class, 15, 1, 3), + new LOTRSpawnEntry(LimwaithBoneWarrior.class, 10, 1, 3) + }); + + + Field redDwarfField = LOTRSpawnList.class.getDeclaredField("RED_DWARF"); + redDwarfField.setAccessible(true); + redDwarfField.set(null, RED_DWARF); + + Field limwaithField = LOTRSpawnList.class.getDeclaredField("LIMWAITH"); + limwaithField.setAccessible(true); + limwaithField.set(null, LIMWAITH); + + + if (LOTRBiome.redMountains != null) { + LOTRBiome.redMountains.npcSpawnList.newFactionList(500) + .add(new LOTRBiomeSpawnList.SpawnListContainer[]{ + LOTRBiomeSpawnList.entry((LOTRSpawnList) redDwarfField.get(null), 10) + }); + } else { + System.out.println("Red Mountains biome is not available."); + } + if (LOTRBiome.farHaradMangrove != null) { + LOTRBiome.farHaradMangrove.npcSpawnList.newFactionList(500) + .add(new LOTRBiomeSpawnList.SpawnListContainer[]{ + LOTRBiomeSpawnList.entry((LOTRSpawnList) limwaithField.get(null), 10) + }); + } else { + System.out.println("Mangrove biome is not available."); + } + } catch (Exception e) { + System.err.println("[CinderLoE] linkLOTRWeapon: Failed to find field RED_DWARF in LOTRSpawnList!"); + } + } + + public static LOTRMaterial getLOTRMaterialByName(String materialName) { + try { + Field materialField = LOTRMaterial.class.getField(materialName); + return (LOTRMaterial) materialField.get(null); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + // Debug method + public static void printClass(String className) { + String resourcePath = "/" + className.replace('.', '/') + ".class"; + InputStream in = CinderLoE.class.getResourceAsStream(resourcePath); + if (in == null) { + System.out.println("Class resource not found: " + resourcePath); + return; + } + try { + ClassReader classReader = new ClassReader(in); + classReader.accept(new TraceClassVisitor(new PrintWriter(System.out)), 0); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + @SubscribeEvent + @SideOnly(Side.SERVER) + public void onWorldLoad(WorldEvent.Load event) { + CinderCore.registerItemFallback(Block.getIdFromBlock(cinderBlock), Block.getIdFromBlock(Blocks.netherrack), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(ivoryBlock), Block.getIdFromBlock(LOTRMod.boneBlock), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(blockRedDwarfSteel), Block.getIdFromBlock(LOTRMod.blockOreStorage), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(chandelierRedDwarf), Block.getIdFromBlock(LOTRMod.chandelier), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(barsRedDwarf), Block.getIdFromBlock(LOTRMod.dwarfBars), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(furBundle), Block.getIdFromBlock(Blocks.hay_block), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(leatherBundle), Block.getIdFromBlock(Blocks.hay_block), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(reedBale), Block.getIdFromBlock(Blocks.hay_block), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(dwarvenBrickRuned), Block.getIdFromBlock(LOTRMod.brick), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Block.getIdFromBlock(fishBarrel), Block.getIdFromBlock(LOTRMod.woodBeam1), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Block.getIdFromBlock(silverChain), Block.getIdFromBlock(LOTRMod.orcChain), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Block.getIdFromBlock(goldChain), Block.getIdFromBlock(LOTRMod.orcChain), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Block.getIdFromBlock(ironChain), Block.getIdFromBlock(LOTRMod.orcChain), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Block.getIdFromBlock(bronzeChain), Block.getIdFromBlock(LOTRMod.orcChain), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Block.getIdFromBlock(mistBlock), Block.getIdFromBlock(LOTRMod.utumnoPortal), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Block.getIdFromBlock(cutDrystone), Block.getIdFromBlock(LOTRMod.cobblebrick), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Block.getIdFromBlock(cobbleDrystone), Block.getIdFromBlock(LOTRMod.cobblebrick), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Block.getIdFromBlock(reeflessCoral), Block.getIdFromBlock(LOTRMod.coralReef), "cinder_loe", "1.2"); + + CinderCore.registerItemFallback(Item.getIdFromItem(redDwarfSteel), Item.getIdFromItem(LOTRMod.dwarfSteel), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(spearRedDwarf), Item.getIdFromItem(LOTRMod.spearDwarven), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(swordRedDwarf), Item.getIdFromItem(LOTRMod.swordDwarven), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(battleaxeRedDwarf), Item.getIdFromItem(LOTRMod.battleaxeDwarven), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(pikeRedDwarf), Item.getIdFromItem(LOTRMod.pikeDwarven), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(hammerRedDwarf), Item.getIdFromItem(LOTRMod.hammerDwarven), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(daggerRedDwarf), Item.getIdFromItem(LOTRMod.daggerDwarven), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(daggerRedDwarfPoisoned), Item.getIdFromItem(LOTRMod.daggerDwarvenPoisoned), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(helmetRedDwarf), Item.getIdFromItem(LOTRMod.helmetDwarvenGold), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(bodyRedDwarf), Item.getIdFromItem(LOTRMod.bodyDwarvenGold), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(legsRedDwarf), Item.getIdFromItem(LOTRMod.legsDwarvenGold), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(bootsRedDwarf), Item.getIdFromItem(LOTRMod.bootsDwarvenGold), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(crossbowRedDwarf), Item.getIdFromItem(LOTRMod.ironCrossbow), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(boarArmorRedDwarf), Item.getIdFromItem(LOTRMod.boarArmorDwarven), "cinder_loe", "1.0"); + + CinderCore.registerItemFallback(Item.getIdFromItem(radagastStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(pallandoStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(alatarStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(sarumanStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.0"); + + CinderCore.registerItemFallback(Item.getIdFromItem(frostblade), Item.getIdFromItem(LOTRMod.swordMithril), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(spearsolidgold), Item.getIdFromItem(LOTRMod.spearMithril), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(whip), Item.getIdFromItem(LOTRMod.balrogWhip), "cinder_loe", "1.2"); + + CinderCore.registerItemFallback(Item.getIdFromItem(ingotAsh), Item.getIdFromItem(LOTRMod.galvorn), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(daggerAsh), Item.getIdFromItem(LOTRMod.daggerBlackUruk), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(swordAsh), Item.getIdFromItem(LOTRMod.scimitarBlackUruk), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(hammerAsh), Item.getIdFromItem(LOTRMod.hammerBlackUruk), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(battleaxeAsh), Item.getIdFromItem(LOTRMod.battleaxeBlackUruk), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(pikeAsh), Item.getIdFromItem(LOTRMod.pikeDolGuldur), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(bowAsh), Item.getIdFromItem(LOTRMod.blackUrukBow), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(spearAsh), Item.getIdFromItem(LOTRMod.spearBlackUruk), "cinder_loe", "1.2"); + + CinderCore.registerItemFallback(Item.getIdFromItem(fangornBearSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(fangornAurochSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(fangornWildBoarSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(fangornElkSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(redDwarfWarriorSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(redDwarfArbalestSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(redDwarfCommanderSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(redDwarfBannerBearerSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(redDwarfSmithSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.2.1"); + + CinderCore.registerItemFallback(Item.getIdFromItem(bonemold), Item.getIdFromItem(LOTRMod.leekSoup), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithFishmongerSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithShamanSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithWarriorSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithBoneWarriorSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithBlowgunnerSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithBannerBearerSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(limwaithChieftainSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(renegadeSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(renegadeCaptainSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(wraithSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(ArnorSoldierSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(ArnorSoldierArcherSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(ArnorCaptainSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(ArnorBannerBearerSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(battleNunSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(BreeSoldierSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(BreeCrossbowmanSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(BreeCaptainSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(BreeSoldierBannerBearerSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(BreeOutriderSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(SauronSpawnEgg), Item.getIdFromItem(Items.spawn_egg), "cinder_loe", "1.1"); + + CinderCore.registerItemFallback(Item.getIdFromItem(helmetLimwaith), Item.getIdFromItem(LOTRMod.helmetMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(bodyLimwaith), Item.getIdFromItem(LOTRMod.bodyMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(legsLimwaith), Item.getIdFromItem(LOTRMod.legsMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(bootsLimwaith), Item.getIdFromItem(LOTRMod.bootsMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(helmetboneLimwaith), Item.getIdFromItem(LOTRMod.helmetBone), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(bodyboneLimwaith), Item.getIdFromItem(LOTRMod.bodyBone), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(legsboneLimwaith), Item.getIdFromItem(LOTRMod.legsBone), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(bootsboneLimwaith), Item.getIdFromItem(LOTRMod.bootsBone), "cinder_loe", "1.2"); + CinderCore.registerItemFallback(Item.getIdFromItem(spearLimwaith), Item.getIdFromItem(LOTRMod.spearMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(tridentLimwaith), Item.getIdFromItem(LOTRMod.dunlendingTrident), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(truncheonLimwaith), Item.getIdFromItem(LOTRMod.swordMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(battleaxeLimwaith), Item.getIdFromItem(LOTRMod.battleaxeMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(daggerLimwaith), Item.getIdFromItem(LOTRMod.daggerMoredain), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(daggerLimwaithPoisoned), Item.getIdFromItem(LOTRMod.daggerMoredainPoisoned), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(blowgunLimwaith), Item.getIdFromItem(LOTRMod.tauredainBlowgun), "cinder_loe", "1.0"); + + CinderCore.registerItemFallback(Item.getIdFromItem(helmetBree), Item.getIdFromItem(Items.iron_helmet), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(bodyBree), Item.getIdFromItem(Items.chainmail_chestplate), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(legsBree), Item.getIdFromItem(Items.chainmail_leggings), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(bootsBree), Item.getIdFromItem(Items.iron_boots), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(swordBree), Item.getIdFromItem(Items.iron_sword), "cinder_loe", "1.1"); + + CinderCore.registerItemFallback(Item.getIdFromItem(helmetArnorBanner), Item.getIdFromItem(Items.chainmail_helmet), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(bodyArnorBanner), Item.getIdFromItem(Items.chainmail_chestplate), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(legsArnorBanner), Item.getIdFromItem(Items.chainmail_leggings), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(bootsArnorBanner), Item.getIdFromItem(Items.chainmail_boots), "cinder_loe", "1.1"); + CinderCore.registerItemFallback(Item.getIdFromItem(maceArnor), Item.getIdFromItem(LOTRMod.blacksmithHammer), "cinder_loe", "1.1"); + + CinderCore.registerEntityFallback(SarumanFireball.class, LOTREntityGandalfFireball.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(Renegade.class, LOTREntityBandit.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(RenegadeCaptain.class, LOTREntityBandit.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(Wraith.class, LOTREntityMarshWraith.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(LOTREntitySauron.class, LOTREntityBarrowWight.class, "cinder_loe", "1.1"); + + CinderCore.registerEntityFallback(RedDwarfWarrior.class, LOTREntityDwarfWarrior.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(RedDwarfArbalest.class, LOTREntityDwarfAxeThrower.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(RedDwarfBannerBearer.class, LOTREntityDwarfBannerBearer.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(RedDwarfCommander.class, LOTREntityDwarfCommander.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(RedDwarfSmith.class, LOTREntityDwarfSmith.class, "cinder_loe", "1.2.1"); + + CinderCore.registerEntityFallback(Limwaith.class, LOTREntityMoredain.class, "cinder_loe", "1.2"); + CinderCore.registerEntityFallback(LimwaithFishmonger.class, LOTREntityMoredain.class, "cinder_loe", "1.2"); + CinderCore.registerEntityFallback(LimwaithShaman.class, LOTREntityTauredainShaman.class, "cinder_loe", "1.2"); + CinderCore.registerEntityFallback(LimwaithWarrior.class, LOTREntityMoredain.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(LimwaithBoneWarrior.class, LOTREntityMoredain.class, "cinder_loe", "1.2"); + CinderCore.registerEntityFallback(LimwaithBlowgunner.class, LOTREntityMoredain.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(LimwaithBannerBearer.class, LOTREntityMoredainBannerBearer.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(LimwaithChieftain.class, LOTREntityMoredainChieftain.class, "cinder_loe", "1.0"); + + CinderCore.registerEntityFallback(FangornBear.class, LOTREntityBear.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(FangornWildBoar.class, LOTREntityWildBoar.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(FangornAuroch.class, LOTREntityAurochs.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(FangornElk.class, LOTREntityElk.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(FangornWolf.class, EntityWolf.class, "cinder_loe", "1.0"); + + CinderCore.registerEntityFallback(ArnorSoldier.class, LOTREntityDunedain.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(ArnorSoldierArcher.class, LOTREntityDunedain.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(ArnorCaptain.class, LOTREntityDunedain.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(ArnorBannerBearer.class, LOTREntityDunedain.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(BattleNun.class, LOTREntityDunedain.class, "cinder_loe", "1.1"); + + CinderCore.registerEntityFallback(BreeSoldier.class, LOTREntityBreeMan.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(BreeCrossbowman.class, LOTREntityBreeMan.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(BreeCaptain.class, LOTREntityBreeMan.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(BreeSoldierBannerBearer.class, LOTREntityBreeMan.class, "cinder_loe", "1.1"); + CinderCore.registerEntityFallback(BreeOutrider.class, LOTREntityBreeMan.class, "cinder_loe", "1.1"); + } + + // Create unit trade entries here, out of the way of important code + public void setupTradeEntries() { + RED_DWARF_COMMANDER = new LOTRUnitTradeEntries(200.0F, new LOTRUnitTradeEntry[]{ + new LOTRUnitTradeEntry(LOTREntityDwarf.class, 20, 0.0F), + (new LOTRUnitTradeEntry(RedDwarfWarrior.class, 30, 50.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.ANY_DWARF), + (new LOTRUnitTradeEntry(RedDwarfArbalest.class, 50, 100.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.ANY_DWARF), + (new LOTRUnitTradeEntry(RedDwarfWarrior.class, LOTREntityWildBoar.class, "RedDwarfWarrior_Boar", 50, 150.0F)).setMountArmor(boarArmorRedDwarf).setPledgeType(LOTRUnitTradeEntry.PledgeType.ANY_DWARF), + (new LOTRUnitTradeEntry(RedDwarfArbalest.class, LOTREntityWildBoar.class, "RedDwarfArbalest_Boar", 70, 200.0F)).setMountArmor(boarArmorRedDwarf).setPledgeType(LOTRUnitTradeEntry.PledgeType.ANY_DWARF), + (new LOTRUnitTradeEntry(RedDwarfBannerBearer.class, 50, 200.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.ANY_DWARF) }); + + LIMWAITH_COMMANDER = new LOTRUnitTradeEntries(200.0F, new LOTRUnitTradeEntry[]{ + new LOTRUnitTradeEntry(LimwaithWarrior.class, 30, 50.0F), + (new LOTRUnitTradeEntry(LimwaithBlowgunner.class, 50, 100.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(LimwaithBoneWarrior.class, 70, 200.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(LimwaithBannerBearer.class, 50, 200.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION) }); + + ARNOR_CAPTAIN = new LOTRUnitTradeEntries(200.0F, new LOTRUnitTradeEntry[]{ + (new LOTRUnitTradeEntry(ArnorSoldier.class, 60, 250.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(ArnorSoldierArcher.class, 100, 300.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(ArnorSoldier.class, LOTREntityHorse.class, "Arnor_Horse", 100, 150.0F)).setMountArmor(horseArmorIron).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(ArnorSoldierArcher.class, LOTREntityHorse.class, "Arnor_Horse", 140, 200.0F)).setMountArmor(horseArmorIron).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(LOTREntityRangerNorth.class, 50, 0.0f)), + (new LOTRUnitTradeEntry(LOTREntityRangerNorth.class, LOTREntityHorse.class, "RangerNorth_Horse", 70, 100.0f)), + (new LOTRUnitTradeEntry(LOTREntityRangerNorthBannerBearer.class, 70, 150.0f)), + (new LOTRUnitTradeEntry(ArnorBannerBearer.class, 100, 400.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION) }); + + BREE_CAPTAIN = new LOTRUnitTradeEntries(150.0F, new LOTRUnitTradeEntry[]{ + (new LOTRUnitTradeEntry(LOTREntityBreeGuard.class, 20, 0.0f)), + (new LOTRUnitTradeEntry(BreeSoldier.class, 60, 250.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(BreeCrossbowman.class, 100, 300.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(BreeOutrider.class, LOTREntityHorse.class, "Bree_Horse", 150, 400.0F)).setMountArmor(horseArmorIron).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION), + (new LOTRUnitTradeEntry(LOTREntityBreeBannerBearer.class, 40, 150.0f)), + (new LOTRUnitTradeEntry(BreeSoldierBannerBearer.class, 100, 400.0F)).setPledgeType(LOTRUnitTradeEntry.PledgeType.FACTION) }); + } + + + public class DevCommand extends CommandBase { +/* + public static float box1 = -7F; + public static float box2 = -6F; + public static float box3 = -7F; + public static int box4 = 14; + public static int box5 = 0; + public static int box6 = 14; +*/ + public static float box1 = -7F; // X position + public static float box2 = -6.5F; // Y position + public static float box3 = -7F; // Z position + public static int box4 = 14; // X Texture map size + public static int box5 = 0; // Y Texture map size + public static int box6 = 14; // Z Texture map size + + @Override + public String getCommandName() { + return "dev"; // Command name + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "/dev"; // Usage + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (args.length < 1) { + sender.addChatMessage(new ChatComponentText("Usage: /dev ")); + return; + } else if (args.length < 2 && args[0].equals("print")) { + sender.addChatMessage(new ChatComponentText("Variable box1: " + box1)); + sender.addChatMessage(new ChatComponentText("Variable box2: " + box2)); + sender.addChatMessage(new ChatComponentText("Variable box3: " + box3)); + sender.addChatMessage(new ChatComponentText("Variable box4: " + box4)); + sender.addChatMessage(new ChatComponentText("Variable box5: " + box5)); + sender.addChatMessage(new ChatComponentText("Variable box6: " + box6)); + return; + } + + + String variableName = args[0]; + String value = args[1]; + + try { + switch (variableName) { + case "box1": + box1 = Float.parseFloat(value); + break; + case "box2": + box2 = Float.parseFloat(value); + break; + case "box3": + box3 = Float.parseFloat(value); + break; + case "box4": + box4 = Integer.parseInt(value); + break; + case "box5": + box5 = Integer.parseInt(value); + break; + case "box6": + box6 = Integer.parseInt(value); + break; + default: + sender.addChatMessage(new ChatComponentText("Unknown variable.")); + return; + } + sender.addChatMessage(new ChatComponentText(variableName + " set to " + value)); + } catch (NumberFormatException e) { + sender.addChatMessage(new ChatComponentText("Invalid value format for " + variableName)); + } + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; // Here you can add permission checks if necessary + } + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/CinderLoE_Config.java b/src/src/main/java/com/zivilon/cinder_loe/CinderLoE_Config.java new file mode 100644 index 0000000..23c6693 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/CinderLoE_Config.java @@ -0,0 +1,38 @@ +package com.zivilon.cinder_loe; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +import java.io.File; + +import net.minecraftforge.common.config.Configuration; + +public class CinderLoE_Config { + public static Configuration config; + public static float enchantment_color_red; + public static float enchantment_color_green; + public static float enchantment_color_blue; + + public static void init(FMLPreInitializationEvent event) { + File configFile = new File(event.getModConfigurationDirectory(), "CinderLoE.cfg"); + config = new Configuration(configFile); + syncConfig(); + } + + public static void syncConfig() { + try { + // Load the configuration file + config.load(); + + // Read properties, define categories and keys + enchantment_color_red = config.getFloat("EnchantmentColorRed", Configuration.CATEGORY_GENERAL, 0.38f, 0.0f, 1.0f, "Configure red color for enchantments"); + enchantment_color_green = config.getFloat("EnchantmentColorGreen", Configuration.CATEGORY_GENERAL, 0.19f, 0.0f, 1.0f, "Configure green color for enchantments"); + enchantment_color_blue = config.getFloat("EnchantmentColorBlue", Configuration.CATEGORY_GENERAL, 0.608f, 0.0f, 1.0f, "Configure blue color for enchantments"); + + // Save the configuration if it has changed + if (config.hasChanged()) { + config.save(); + } + } catch (Exception e) { + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/ItemRegistration.java b/src/src/main/java/com/zivilon/cinder_loe/ItemRegistration.java new file mode 100644 index 0000000..aade39f --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/ItemRegistration.java @@ -0,0 +1,32 @@ +package com.zivilon.cinder_loe; + +import java.util.AbstractMap.SimpleEntry; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.item.Item; +import cpw.mods.fml.common.registry.GameRegistry; + +public class ItemRegistration { + public static List> list = new ArrayList<>(); + + public static void registerItem(Item item, String item_name, int ordinal) { + while (list.size() <= ordinal) { + list.add(new SimpleEntry<>(null, null)); + } + list.set(ordinal, new SimpleEntry<>(item, item_name)); + } + + // Register items in consistent order that persists through mod updates while enabling us to keep the item lists neatly organized. + // Unknown if this is actually necessary, but might help to prevent item ID shifts + public static void registerItems() { + for (int i = 0; i < list.size(); i++) { + SimpleEntry entry = list.get(i); + + if (entry == null || entry.getKey() == null || entry.getValue() == null) { + break; + } + + GameRegistry.registerItem(entry.getKey(), entry.getValue()); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/Materials.java b/src/src/main/java/com/zivilon/cinder_loe/Materials.java new file mode 100644 index 0000000..feeb5d7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/Materials.java @@ -0,0 +1,69 @@ +package com.zivilon.cinder_loe; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; + +import lotr.common.item.LOTRMaterial; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Field; + +import com.zivilon.cinder_loe.CinderLoE; + +public class Materials { + public static void registerMaterials() { + modifyMaterial("RED_DWARF", 700, 3.0F, 0.7F, 3, 7.0F, 10, CinderLoE.redDwarfSteel); + modifyMaterial("WIZARD", 1000, 3.0F, 0.7F, 3, 7.0F, 10, null); + modifyMaterial("LIMWAITH_BONE", 250, 2.0F, 0.7F, 2, 6.0F, 10, null); + modifyMaterial("BONEMOLD", 350, 2.0F, 0.6F, 2, 6.0F, 10, CinderLoE.bonemold); + modifyMaterial("LIMWAITH_WOOD", 230, 1.5F, 0.5F, 2, 5.0F, 10, null); + modifyMaterial("EVENT", 2400, 5.0F, 0.0F, 0, 9.0F, 10, null); + modifyMaterial("BREE", 350, 2.5F, 0.6F, 2, 6.0F, 10, Items.iron_ingot); + modifyMaterial("BATTLENUN", 300, 3F, 0.6F, 2, 6.0F, 10, Items.iron_ingot); + modifyMaterial("ASH", 2000, 4.25F, 0.6F, 2, 7.0F, 10, CinderLoE.ingotAsh); + } + + public static void modifyMaterial(String fieldName, int uses, float weapon_damage, float protection, int harvest_level, float speed, int enchantability, Item crafting_item) { + try { + Class lotrMaterialClass = Class.forName("lotr.common.item.LOTRMaterial"); + Field materialField = lotrMaterialClass.getField(fieldName); + + // Reflection to access and instantiate the private constructor of LOTRMaterial + Constructor constructor = lotrMaterialClass.getDeclaredConstructor(String.class); + constructor.setAccessible(true); + Object materialLocal = constructor.newInstance(fieldName); + + // Reflection to call the private methods on the new instance + Method setUses = lotrMaterialClass.getDeclaredMethod("setUses", int.class); + Method setDamage = lotrMaterialClass.getDeclaredMethod("setDamage", float.class); + Method setProtection = lotrMaterialClass.getDeclaredMethod("setProtection", float.class); + Method setHarvestLevel = lotrMaterialClass.getDeclaredMethod("setHarvestLevel", int.class); + Method setSpeed = lotrMaterialClass.getDeclaredMethod("setSpeed", float.class); + Method setEnchantability = lotrMaterialClass.getDeclaredMethod("setEnchantability", int.class); + Method setCraftingItem = lotrMaterialClass.getDeclaredMethod("setCraftingItem", Item.class); + + setUses.setAccessible(true); + setDamage.setAccessible(true); + setProtection.setAccessible(true); + setHarvestLevel.setAccessible(true); + setSpeed.setAccessible(true); + setEnchantability.setAccessible(true); + setCraftingItem.setAccessible(true); + + setUses.invoke(materialLocal, uses); + setDamage.invoke(materialLocal, weapon_damage); + setProtection.invoke(materialLocal, protection); + setHarvestLevel.invoke(materialLocal, harvest_level); + setSpeed.invoke(materialLocal, speed); + setEnchantability.invoke(materialLocal, enchantability); + if (crafting_item != null) { + setCraftingItem.invoke(materialLocal, crafting_item); + } + + materialField.set(null, materialLocal); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/BarsBase.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/BarsBase.java new file mode 100644 index 0000000..0dab051 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/BarsBase.java @@ -0,0 +1,51 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockPane; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import lotr.common.LOTRCreativeTabs; +import lotr.common.block.LOTRBlockOrcChain; +import lotr.common.block.LOTRBlockPane; + +import com.zivilon.cinder_loe.util.Utilities; + +public abstract class BarsBase extends BlockPane { + public String textureName; + protected IIcon icon; + + public BarsBase(String blockName) { + super("", "", Material.iron, true); + this.textureName = Utilities.toSnakeCase(blockName); + this.setBlockName(blockName); + setCreativeTab((CreativeTabs)LOTRCreativeTabs.tabDeco); + setHardness(5.0F); + setResistance(10.0F); + setStepSound(Block.soundTypeMetal); + } + + public void registerBlockIcons(IIconRegister iconregister) { + this.icon = iconregister.registerIcon(textureName); + System.out.println("Registering texture " + textureName); + } + + public IIcon getIcon() { + return this.icon; + } + + public IIcon getIcon(int i, int j) { + return this.icon; + } + + public IIcon func_150097_e() { + return this.icon; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/BlockRedDwarfSteel.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/BlockRedDwarfSteel.java new file mode 100644 index 0000000..3715765 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/BlockRedDwarfSteel.java @@ -0,0 +1,37 @@ +package com.zivilon.cinder_loe.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; + +import lotr.common.LOTRCreativeTabs; + +import java.lang.reflect.Field; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockRedDwarfSteel extends Block { + + public BlockRedDwarfSteel() { + super(Material.iron); // Choose the appropriate material + try { + Field tabField = LOTRCreativeTabs.class.getDeclaredField("tabBlock"); // Stupid workaround because ForgeGradle tries to obfuscate field LOTRCreativeTabs.tabBlock when it's not supposed to + LOTRCreativeTabs tab = (LOTRCreativeTabs)tabField.get(null); + setCreativeTab((CreativeTabs)tab); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + setHardness(5.0F); + setResistance(15.0F); + setStepSound(Block.soundTypeMetal); + setBlockTextureName("lotr:red_dwarf_steel"); + setBlockName("lotr:blockRedDwarfSteel"); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon("lotr:red_dwarf_steel"); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/ChandelierBase.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/ChandelierBase.java new file mode 100644 index 0000000..1f345e5 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/ChandelierBase.java @@ -0,0 +1,105 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import lotr.common.LOTRCreativeTabs; +import lotr.common.block.LOTRBlockOrcChain; + +import com.zivilon.cinder_loe.util.Utilities; + +public abstract class ChandelierBase extends Block { + public String textureName; + public IIcon icon; + + public ChandelierBase(String blockName) { + super(Material.circuits); + this.textureName = Utilities.toSnakeCase(blockName); + this.setBlockName(blockName); + setCreativeTab((CreativeTabs)LOTRCreativeTabs.tabDeco); + setHardness(0.0F); + setResistance(2.0F); + setStepSound(Block.soundTypeMetal); + setLightLevel(0.9375F); + setBlockBounds(0.0625F, 0.1875F, 0.0625F, 0.9375F, 1.0F, 0.9375F); + } + + public IIcon getIcon(int i, int j) { + return this.icon; + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + icon = reg.registerIcon(this.textureName); + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public int getRenderType() { + return 1; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { + return null; + } + + public boolean canBlockStay(World world, int i, int j, int k) { + Block block = world.getBlock(i, j + 1, k); + int meta = world.getBlockMetadata(i, j + 1, k); + if (block instanceof net.minecraft.block.BlockFence || block instanceof net.minecraft.block.BlockWall) + return true; + if (block instanceof net.minecraft.block.BlockSlab && !block.isOpaqueCube() && (meta & 0x8) == 0) + return true; + if (block instanceof net.minecraft.block.BlockStairs && (meta & 0x4) == 0) + return true; + if (block instanceof LOTRBlockOrcChain) + return true; + return world.getBlock(i, j + 1, k).isSideSolid((IBlockAccess)world, i, j + 1, k, ForgeDirection.DOWN); + } + + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + return canBlockStay(world, i, j, k); + } + + public void onNeighborBlockChange(World world, int i, int j, int k, Block block) { + if (!canBlockStay(world, i, j, k)) { + dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0); + world.setBlockToAir(i, j, k); + } + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int i, int j, int k, Random random) { + double d = 0.13D; + double d1 = 1.0D - d; + double d2 = 0.6875D; + spawnChandelierParticles(world, i + d, j + d2, k + d); + spawnChandelierParticles(world, i + d1, j + d2, k + d1); + spawnChandelierParticles(world, i + d, j + d2, k + d1); + spawnChandelierParticles(world, i + d1, j + d2, k + d); + } + + private void spawnChandelierParticles(World world, double d, double d1, double d2) { + world.spawnParticle("smoke", d, d1, d2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", d, d1, d2, 0.0D, 0.0D, 0.0D); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/CinderBlock.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/CinderBlock.java new file mode 100644 index 0000000..202e3cc --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/CinderBlock.java @@ -0,0 +1,32 @@ +package com.zivilon.cinder_loe.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CinderBlock extends Block { + + public CinderBlock() { + super(Material.rock); + setHardness(2.0F); + setResistance(5.0F); + setBlockTextureName("lotr:cinder_block"); + setBlockName("lotr:cinderBlock"); + setLightLevel(0.25F); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon("lotr:cinder_block"); + } + + @Override + public void onEntityWalking(World world, int x, int y, int z, Entity entity) { + entity.setFire(20); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/FishBarrel.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/FishBarrel.java new file mode 100644 index 0000000..5a385fc --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/FishBarrel.java @@ -0,0 +1,23 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lotr.common.LOTRCreativeTabs; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.IIcon; + +import java.lang.reflect.Field; + +public class FishBarrel extends StaticBlockBase3 { + + public FishBarrel() { + super(Material.wood, "lotr:fishbarrel"); + setStepSound(Block.soundTypeWood); + setBlockName("lotr:fishbarrel"); + setHardness(1.0F); + setResistance(2.0F); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/FurBundle.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/FurBundle.java new file mode 100644 index 0000000..a8e9a49 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/FurBundle.java @@ -0,0 +1,16 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.blocks.RotatableBlockBase3; +import net.minecraft.block.Block; + +import net.minecraft.block.material.Material; + +public class FurBundle extends RotatableBlockBase3 { + public FurBundle() { + super(Material.cloth, "lotr:furBundle"); + setStepSound(Block.soundTypeCloth); + setBlockName("lotr:furBundle"); + setHardness(0.5F); + setResistance(0.5F); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/IvoryBlock.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/IvoryBlock.java new file mode 100644 index 0000000..3fa59d1 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/IvoryBlock.java @@ -0,0 +1,17 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.blocks.RotatableBlockBase2; +import net.minecraft.block.Block; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; + +public class IvoryBlock extends RotatableBlockBase2 { + public IvoryBlock() { + super(Material.rock, "lotr:ivoryBlock"); + setStepSound(Block.soundTypeStone); + setBlockName("lotr:ivoryBlock"); + setHardness(1.0F); + setResistance(5.0F); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/LeatherBundle.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/LeatherBundle.java new file mode 100644 index 0000000..d72a61e --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/LeatherBundle.java @@ -0,0 +1,16 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.blocks.RotatableBlockBase3; +import net.minecraft.block.Block; + +import net.minecraft.block.material.Material; + +public class LeatherBundle extends RotatableBlockBase3 { + public LeatherBundle() { + super(Material.cloth, "lotr:leatherBundle"); + setStepSound(Block.soundTypeCloth); + setBlockName("lotr:leatherBundle"); + setHardness(0.5F); + setResistance(0.5F); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/MistBlock.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/MistBlock.java new file mode 100644 index 0000000..80fe590 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/MistBlock.java @@ -0,0 +1,56 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.List; +import java.util.Random; + +import lotr.common.LOTRDimension; +import lotr.common.block.LOTRBlockUtumnoPortal; +import lotr.common.tileentity.LOTRTileEntityUtumnoPortal; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import com.zivilon.cinder_loe.tileentity.TileEntityMistBlock; + +public class MistBlock extends LOTRBlockUtumnoPortal { + public float color_red; + public float color_green; + public float color_blue; + public MistBlock() { + super(); + color_red = 0.0F; + color_green = 0.0F; + color_blue = 0.0F; + setBlockTextureName("lotr:mist_block"); + setBlockName("lotr:mistBlock"); + } + public MistBlock(float r, float g, float b) { + super(); + color_red = r; + color_green = g; + color_blue = b; + setHardness(-1.0F); + setResistance(Float.MAX_VALUE); + setBlockTextureName("lotr:mist_block"); + setBlockName("lotr:mistBlock"); + } + + public TileEntity createNewTileEntity(World world, int i) { + return (TileEntity)new TileEntityMistBlock(color_red, color_green, color_blue); + } + + @Override + public void func_149670_a(World world, int i, int j, int k, Entity entity) {} + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/RedDwarfBars.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/RedDwarfBars.java new file mode 100644 index 0000000..1a34f73 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/RedDwarfBars.java @@ -0,0 +1,12 @@ +package com.zivilon.cinder_loe.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +import com.zivilon.cinder_loe.blocks.BarsBase; + +public class RedDwarfBars extends BarsBase { + public RedDwarfBars() { + super("lotr:barsRedDwarf"); + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/RedDwarfChandelier.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/RedDwarfChandelier.java new file mode 100644 index 0000000..d28ef08 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/RedDwarfChandelier.java @@ -0,0 +1,12 @@ +package com.zivilon.cinder_loe.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +import com.zivilon.cinder_loe.blocks.ChandelierBase; + +public class RedDwarfChandelier extends ChandelierBase { + public RedDwarfChandelier() { + super("lotr:chandelierRedDwarf"); + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/ReedBale.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/ReedBale.java new file mode 100644 index 0000000..fb0f1f2 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/ReedBale.java @@ -0,0 +1,16 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.blocks.RotatableBlockBase3; +import net.minecraft.block.Block; + +import net.minecraft.block.material.Material; + +public class ReedBale extends RotatableBlockBase3 { + public ReedBale() { + super(Material.grass, "lotr:reedBale"); + setStepSound(Block.soundTypeGrass); + setBlockName("lotr:reedBale"); + setHardness(0.5F); + setResistance(0.5F); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/RotatableBlockBase2.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/RotatableBlockBase2.java new file mode 100644 index 0000000..9e64596 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/RotatableBlockBase2.java @@ -0,0 +1,88 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockRotatedPillar; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.util.Utilities; + +public abstract class RotatableBlockBase2 extends BlockRotatedPillar { + public String textureName; + public IIcon[] icons = new IIcon[3]; + + public RotatableBlockBase2(Material material, String blockName) { + super(material); + this.textureName = Utilities.toSnakeCase(blockName); + this.setBlockName(blockName); + // Get LOTRCreativeTabs.tabBlock without ForgeGradle incorrectly obfuscating it. Uses cached field, not real-time reflection + this.setCreativeTab((CreativeTabs)Utilities.reflected_tab_block); + } + + public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) { + int orientation = 0; + switch (side) { + case 0: // Bottom + case 1: // Top + orientation = 0; + break; + case 2: // North + case 3: // South + orientation = 1; + break; + case 4: // West + case 5: // East + orientation = 2; + break; + } + + return orientation; + } + + public int damageDropped(int i) { + return 0; + } + + + @Override + public IIcon getIcon(int side, int meta) { + switch(meta) { + case 0: // Facing up + if(side == 0 || side == 1) return this.icons[0]; + else return this.icons[1]; + case 1: // Facing North-South + if(side == 2 || side == 3) return this.icons[0]; + if(side == 4 || side == 5) return this.icons[2]; + else return this.icons[1]; + case 2: // Facing East-West + if(side == 4 || side == 5) return this.icons[0]; + else return this.icons[2]; + case 3: // Uniform block + return this.icons[1]; + } + + return this.blockIcon; // Default case, should not happen + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(this.textureName + "_top"); + icons[1] = reg.registerIcon(this.textureName + "_side_0"); + icons[2] = reg.registerIcon(this.textureName + "_side_90"); + } + + @SideOnly(Side.CLIENT) + protected IIcon getSideIcon(int i) { + return null; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/RotatableBlockBase3.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/RotatableBlockBase3.java new file mode 100644 index 0000000..9dac237 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/RotatableBlockBase3.java @@ -0,0 +1,165 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockRotatedPillar; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.IIcon; +import net.minecraft.client.renderer.texture.IIconRegister; +import lotr.common.LOTRCreativeTabs; +import net.minecraft.creativetab.CreativeTabs; + +import com.zivilon.cinder_loe.util.Utilities; + +public abstract class RotatableBlockBase3 extends BlockRotatedPillar { + public String textureName; + public IIcon[] icons = new IIcon[6]; + + public RotatableBlockBase3(Material material, String blockName) { + super(material); + this.textureName = Utilities.toSnakeCase(blockName); + this.setBlockName(blockName); + // Get LOTRCreativeTabs.tabBlock without ForgeGradle incorrectly obfuscating it. Uses cached field, not real-time reflection + this.setCreativeTab((CreativeTabs)Utilities.reflected_tab_block); + +/* Examples for block properties + this.setHardness(2.0F); // How long it takes to break the block + this.setResistance(10.0F); // Explosion resistance + this.setStepSound(soundTypePiston); // The sound made when walking on the block + this.setLightLevel(0.5F); // Light emitted by the block, 0.0 - 1.0 + this.setLightOpacity(255); // How much light is blocked, 0 - 255 + this.setBlockName("exampleBlock"); // The unique name of the block + this.setBlockTextureName("modid:exampleBlock"); // Texture for the block + this.setCreativeTab(CreativeTabs.tabBlock); // The creative tab it appears in +*/ + } + + public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) { + // Default orientation (meta 0) + int orientation = 0; + + // Determine orientation based on the side of the block the player is placing against + switch (side) { + case 0: // Bottom + orientation = 5; // Unique orientation for bottom + break; + case 1: // Top + orientation = 0; // Default vertical orientation + break; + case 2: // North + orientation = 1; // North-South horizontal + break; + case 3: // South + orientation = 2; // South-North horizontal + break; + case 4: // West + orientation = 3; // West-East horizontal + break; + case 5: // East + orientation = 4; // East-West horizontal + break; + } + + return orientation; + } + + public int damageDropped(int i) { + return 0; + } + + + @Override + public IIcon getIcon(int side, int meta) { + switch(meta) { + case 0: // Facing up + if(side == 0) return this.icons[0]; + else if(side == 1) return this.icons[1]; + else return this.icons[2]; + case 1: // Facing North + if(side == 0) return this.icons[2]; + else if(side == 1) return this.icons[2]; + else if(side == 2) return this.icons[1]; + else if(side == 3) return this.icons[0]; + else if(side == 4) return this.icons[5]; + else if(side == 5) return this.icons[3]; + case 2: // Facing South + if(side == 0) return this.icons[4]; + else if(side == 1) return this.icons[4]; + else if(side == 2) return this.icons[0]; + else if(side == 3) return this.icons[1]; + else if(side == 4) return this.icons[3]; + else if(side == 5) return this.icons[5]; + case 3: // Facing West + if(side == 0) return this.icons[5]; + else if(side == 1) return this.icons[5]; + else if(side == 2) return this.icons[3]; + else if(side == 3) return this.icons[5]; + else if(side == 4) return this.icons[1]; + else if(side == 5) return this.icons[0]; + case 4: // Facing East + if(side == 4) return this.icons[0]; + else if(side == 5) return this.icons[1]; + else return this.icons[2]; + case 5: // Facing down + if(side == 0) return this.icons[1]; + else if(side == 1) return this.icons[0]; + else if (side == 2) return this.icons[3]; + else if (side == 3) return this.icons[3]; + else return this.icons[4]; + } + + return this.blockIcon; + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(this.textureName + "_bottom"); + icons[1] = reg.registerIcon(this.textureName + "_top"); + icons[2] = reg.registerIcon(this.textureName + "_side_0"); + icons[3] = reg.registerIcon(this.textureName + "_side_90"); + icons[4] = reg.registerIcon(this.textureName + "_side_180"); + icons[5] = reg.registerIcon(this.textureName + "_side_270"); + } + + @SideOnly(Side.CLIENT) + protected IIcon getSideIcon(int i) { + return null; + } +} + + +/* Example method overrides for blocks + @Override + public void onBlockAdded(World world, int x, int y, int z) { + // Called when the block is placed in the world + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int metadata) { + // Called when the block is broken + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + // Called when the player right-clicks the block + return true; + } + + @Override + public void onEntityWalking(World world, int x, int y, int z, Entity entity) { + // Called when an entity walks over the block + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + // Determines the redstone power output + return 15; + } +*/ \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/RunedDwarvenBrick.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/RunedDwarvenBrick.java new file mode 100644 index 0000000..ec033d7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/RunedDwarvenBrick.java @@ -0,0 +1,31 @@ +package com.zivilon.cinder_loe.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import com.zivilon.cinder_loe.util.Utilities; + +public class RunedDwarvenBrick extends Block { + + public RunedDwarvenBrick() { + super(Material.rock); // Choose the appropriate material + // Set other properties like hardness, resistance, name, etc. + setHardness(2.0F); + setResistance(5.0F); + setBlockTextureName(Utilities.toSnakeCase("lotr:dwarven_brick_runed")); + setBlockName("lotr:dwarvenBrickRuned"); + setCreativeTab((CreativeTabs)Utilities.reflected_tab_block); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon("lotr:dwarven_brick_runed"); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/StaticBlockBase3.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/StaticBlockBase3.java new file mode 100644 index 0000000..821147c --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/StaticBlockBase3.java @@ -0,0 +1,55 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockRotatedPillar; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.IIcon; +import net.minecraft.client.renderer.texture.IIconRegister; +import lotr.common.LOTRCreativeTabs; +import net.minecraft.creativetab.CreativeTabs; + +import com.zivilon.cinder_loe.util.Utilities; + +public abstract class StaticBlockBase3 extends Block { + public String textureName; + public IIcon[] icons = new IIcon[3]; + + public StaticBlockBase3(Material material, String blockName) { + super(material); + this.textureName = Utilities.toSnakeCase(blockName); + this.setBlockName(blockName); + this.setCreativeTab((CreativeTabs)Utilities.reflected_tab_block); + } + + @Override + public IIcon getIcon(int side, int meta) { + switch(side) { + case 0: // Facing down + return this.icons[0]; + case 1: // Facing up + return this.icons[1]; + case 2: // Facing North + case 3: // Facing South + case 4: // Facing West + case 5: // Facing East + return this.icons[2]; + } + + return this.blockIcon; + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(this.textureName + "_bottom"); + icons[1] = reg.registerIcon(this.textureName + "_top"); + icons[2] = reg.registerIcon(this.textureName + "_side"); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/bronzeChain.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/bronzeChain.java new file mode 100644 index 0000000..d8fd0a2 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/bronzeChain.java @@ -0,0 +1,120 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lotr.common.block.LOTRBlockChandelier; +import lotr.common.block.LOTRBlockOrcChain; +import net.minecraft.block.*; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class bronzeChain extends LOTRBlockOrcChain { + + public IIcon icon; + @SideOnly(value= Side.CLIENT) + private IIcon iconMiddle; + @SideOnly(value=Side.CLIENT) + private IIcon iconTop; + @SideOnly(value=Side.CLIENT) + private IIcon iconBottom; + @SideOnly(value=Side.CLIENT) + private IIcon iconSingle; + + public bronzeChain() { + this.setHardness(1.0f); + this.setStepSound(Block.soundTypeMetal); + this.textureName = "lotr:bronzeChain"; + setBlockName("lotr:bronzeChain"); + setBlockTextureName("lotr:bronzeChain"); + float f = 0.2f; + this.setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, 1.0f, 0.5f + f); + } + + @SideOnly(value=Side.CLIENT) + public void registerBlockIcons(IIconRegister iconregister) { + this.iconMiddle = iconregister.registerIcon(this.getTextureName() + "_mid"); + this.iconTop = iconregister.registerIcon(this.getTextureName() + "_top"); + this.iconBottom = iconregister.registerIcon(this.getTextureName() + "_bottom"); + this.iconSingle = iconregister.registerIcon(this.getTextureName() + "_single"); + this.blockIcon = iconregister.registerIcon(this.getTextureName()); + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int i, int j, int k, int side) { + boolean chainBelow; + Block above = world.getBlock(i, j + 1, k); + Block below = world.getBlock(i, j - 1, k); + boolean chainAbove = above instanceof bronzeChain; + boolean bl = chainBelow = below instanceof bronzeChain || below instanceof LOTRBlockChandelier; + if (chainAbove && chainBelow) { + return this.iconMiddle; + } + if (chainAbove) { + return this.iconBottom; + } + if (chainBelow) { + return this.iconTop; + } + return this.iconSingle; + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(int i, int j) { + return this.iconMiddle; + } + + @SideOnly(value=Side.CLIENT) + public String getItemIconName() { + return this.getTextureName(); + } + + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + Block block = world.getBlock(i, j + 1, k); + int meta = world.getBlockMetadata(i, j + 1, k); + if (block instanceof bronzeChain) { + return true; + } + if (block instanceof BlockFence || block instanceof BlockWall) { + return true; + } + if (block instanceof BlockSlab && !block.isOpaqueCube() && (meta & 8) == 0) { + return true; + } + if (block instanceof BlockStairs && (meta & 4) == 0) { + return true; + } + return world.getBlock(i, j + 1, k).isSideSolid((IBlockAccess)world, i, j + 1, k, ForgeDirection.DOWN); + } + + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int side, float f, float f1, float f2) { + ItemStack itemstack = entityplayer.getHeldItem(); + if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock((Block)this)) { + Block block; + int j1; + for (j1 = j; j1 >= 0 && j1 < world.getHeight() && (block = world.getBlock(i, j1, k)) == this; --j1) { + } + if (j1 >= 0 && j1 < world.getHeight()) { + block = world.getBlock(i, j1, k); + if (this.canPlaceBlockOnSide(world, i, j1, k, side) && block.isReplaceable((IBlockAccess)world, i, j1, k) && !block.getMaterial().isLiquid()) { + int thisMeta = world.getBlockMetadata(i, j, k); + world.setBlock(i, j1, k, (Block)this, thisMeta, 3); + world.playSoundEffect((double)((float)i + 0.5f), (double)((float)j1 + 0.5f), (double)((float)k + 0.5f), this.stepSound.func_150496_b(), (this.stepSound.getVolume() + 1.0f) / 2.0f, this.stepSound.getPitch() * 0.8f); + if (!entityplayer.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + if (itemstack.stackSize <= 0) { + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); + } + return true; + } + } + } + return false; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/cobbleDrystone.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/cobbleDrystone.java new file mode 100644 index 0000000..0740054 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/cobbleDrystone.java @@ -0,0 +1,28 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.util.Utilities; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; + +public class cobbleDrystone extends Block { + + public cobbleDrystone() { + super(Material.rock); // Choose the appropriate material + // Set other properties like hardness, resistance, name, etc. + setHardness(2.0F); + setResistance(5.0F); + setBlockTextureName(Utilities.toSnakeCase("lotr:cobble_drystone")); + setBlockName("lotr:cobbleDrystone"); + setCreativeTab((CreativeTabs)Utilities.reflected_tab_block); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon("lotr:cobbleDrystone"); + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/cutDrystone.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/cutDrystone.java new file mode 100644 index 0000000..57d141a --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/cutDrystone.java @@ -0,0 +1,28 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.util.Utilities; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; + +public class cutDrystone extends Block { + + public cutDrystone() { + super(Material.rock); // Choose the appropriate material + // Set other properties like hardness, resistance, name, etc. + setHardness(2.0F); + setResistance(5.0F); + setBlockTextureName(Utilities.toSnakeCase("lotr:cut_drystone")); + setBlockName("lotr:cutDrystone"); + setCreativeTab((CreativeTabs)Utilities.reflected_tab_block); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon("lotr:cutDrystone"); + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/goldChain.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/goldChain.java new file mode 100644 index 0000000..b4498f1 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/goldChain.java @@ -0,0 +1,121 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lotr.common.block.LOTRBlockChandelier; +import lotr.common.block.LOTRBlockOrcChain; +import net.minecraft.block.*; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class goldChain + extends LOTRBlockOrcChain { + + public IIcon icon; + @SideOnly(value= Side.CLIENT) + private IIcon iconMiddle; + @SideOnly(value=Side.CLIENT) + private IIcon iconTop; + @SideOnly(value=Side.CLIENT) + private IIcon iconBottom; + @SideOnly(value=Side.CLIENT) + private IIcon iconSingle; + + public goldChain() { + this.setHardness(1.0f); + this.setStepSound(Block.soundTypeMetal); + this.textureName = "lotr:goldChain"; + setBlockName("lotr:goldChain"); + setBlockTextureName("lotr:goldChain"); + float f = 0.2f; + this.setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, 1.0f, 0.5f + f); + } + + @SideOnly(value=Side.CLIENT) + public void registerBlockIcons(IIconRegister iconregister) { + this.iconMiddle = iconregister.registerIcon(this.getTextureName() + "_mid"); + this.iconTop = iconregister.registerIcon(this.getTextureName() + "_top"); + this.iconBottom = iconregister.registerIcon(this.getTextureName() + "_bottom"); + this.iconSingle = iconregister.registerIcon(this.getTextureName() + "_single"); + this.blockIcon = iconregister.registerIcon(this.getTextureName()); + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int i, int j, int k, int side) { + boolean chainBelow; + Block above = world.getBlock(i, j + 1, k); + Block below = world.getBlock(i, j - 1, k); + boolean chainAbove = above instanceof goldChain; + boolean bl = chainBelow = below instanceof goldChain || below instanceof LOTRBlockChandelier; + if (chainAbove && chainBelow) { + return this.iconMiddle; + } + if (chainAbove) { + return this.iconBottom; + } + if (chainBelow) { + return this.iconTop; + } + return this.iconSingle; + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(int i, int j) { + return this.iconMiddle; + } + + @SideOnly(value=Side.CLIENT) + public String getItemIconName() { + return this.getTextureName(); + } + + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + Block block = world.getBlock(i, j + 1, k); + int meta = world.getBlockMetadata(i, j + 1, k); + if (block instanceof goldChain) { + return true; + } + if (block instanceof BlockFence || block instanceof BlockWall) { + return true; + } + if (block instanceof BlockSlab && !block.isOpaqueCube() && (meta & 8) == 0) { + return true; + } + if (block instanceof BlockStairs && (meta & 4) == 0) { + return true; + } + return world.getBlock(i, j + 1, k).isSideSolid((IBlockAccess)world, i, j + 1, k, ForgeDirection.DOWN); + } + + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int side, float f, float f1, float f2) { + ItemStack itemstack = entityplayer.getHeldItem(); + if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock((Block)this)) { + Block block; + int j1; + for (j1 = j; j1 >= 0 && j1 < world.getHeight() && (block = world.getBlock(i, j1, k)) == this; --j1) { + } + if (j1 >= 0 && j1 < world.getHeight()) { + block = world.getBlock(i, j1, k); + if (this.canPlaceBlockOnSide(world, i, j1, k, side) && block.isReplaceable((IBlockAccess)world, i, j1, k) && !block.getMaterial().isLiquid()) { + int thisMeta = world.getBlockMetadata(i, j, k); + world.setBlock(i, j1, k, (Block)this, thisMeta, 3); + world.playSoundEffect((double)((float)i + 0.5f), (double)((float)j1 + 0.5f), (double)((float)k + 0.5f), this.stepSound.func_150496_b(), (this.stepSound.getVolume() + 1.0f) / 2.0f, this.stepSound.getPitch() * 0.8f); + if (!entityplayer.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + if (itemstack.stackSize <= 0) { + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); + } + return true; + } + } + } + return false; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/ironChain.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/ironChain.java new file mode 100644 index 0000000..180e6b6 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/ironChain.java @@ -0,0 +1,121 @@ +package com.zivilon.cinder_loe.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lotr.common.block.LOTRBlockChandelier; +import lotr.common.block.LOTRBlockOrcChain; +import net.minecraft.block.*; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class ironChain + extends LOTRBlockOrcChain { + + public IIcon icon; + @SideOnly(value= Side.CLIENT) + private IIcon iconMiddle; + @SideOnly(value=Side.CLIENT) + private IIcon iconTop; + @SideOnly(value=Side.CLIENT) + private IIcon iconBottom; + @SideOnly(value=Side.CLIENT) + private IIcon iconSingle; + + public ironChain() { + this.setHardness(1.0f); + this.setStepSound(Block.soundTypeMetal); + this.textureName = "lotr:ironChain"; + setBlockName("lotr:ironChain"); + setBlockTextureName("lotr:ironChain"); + float f = 0.2f; + this.setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, 1.0f, 0.5f + f); + } + + @SideOnly(value=Side.CLIENT) + public void registerBlockIcons(IIconRegister iconregister) { + this.iconMiddle = iconregister.registerIcon(this.getTextureName() + "_mid"); + this.iconTop = iconregister.registerIcon(this.getTextureName() + "_top"); + this.iconBottom = iconregister.registerIcon(this.getTextureName() + "_bottom"); + this.iconSingle = iconregister.registerIcon(this.getTextureName() + "_single"); + this.blockIcon = iconregister.registerIcon(this.getTextureName()); + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int i, int j, int k, int side) { + boolean chainBelow; + Block above = world.getBlock(i, j + 1, k); + Block below = world.getBlock(i, j - 1, k); + boolean chainAbove = above instanceof ironChain; + boolean bl = chainBelow = below instanceof ironChain || below instanceof LOTRBlockChandelier; + if (chainAbove && chainBelow) { + return this.iconMiddle; + } + if (chainAbove) { + return this.iconBottom; + } + if (chainBelow) { + return this.iconTop; + } + return this.iconSingle; + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(int i, int j) { + return this.iconMiddle; + } + + @SideOnly(value=Side.CLIENT) + public String getItemIconName() { + return this.getTextureName(); + } + + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + Block block = world.getBlock(i, j + 1, k); + int meta = world.getBlockMetadata(i, j + 1, k); + if (block instanceof ironChain) { + return true; + } + if (block instanceof BlockFence || block instanceof BlockWall) { + return true; + } + if (block instanceof BlockSlab && !block.isOpaqueCube() && (meta & 8) == 0) { + return true; + } + if (block instanceof BlockStairs && (meta & 4) == 0) { + return true; + } + return world.getBlock(i, j + 1, k).isSideSolid((IBlockAccess)world, i, j + 1, k, ForgeDirection.DOWN); + } + + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int side, float f, float f1, float f2) { + ItemStack itemstack = entityplayer.getHeldItem(); + if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock((Block)this)) { + Block block; + int j1; + for (j1 = j; j1 >= 0 && j1 < world.getHeight() && (block = world.getBlock(i, j1, k)) == this; --j1) { + } + if (j1 >= 0 && j1 < world.getHeight()) { + block = world.getBlock(i, j1, k); + if (this.canPlaceBlockOnSide(world, i, j1, k, side) && block.isReplaceable((IBlockAccess)world, i, j1, k) && !block.getMaterial().isLiquid()) { + int thisMeta = world.getBlockMetadata(i, j, k); + world.setBlock(i, j1, k, (Block)this, thisMeta, 3); + world.playSoundEffect((double)((float)i + 0.5f), (double)((float)j1 + 0.5f), (double)((float)k + 0.5f), this.stepSound.func_150496_b(), (this.stepSound.getVolume() + 1.0f) / 2.0f, this.stepSound.getPitch() * 0.8f); + if (!entityplayer.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + if (itemstack.stackSize <= 0) { + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); + } + return true; + } + } + } + return false; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/reeflessCoral.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/reeflessCoral.java new file mode 100644 index 0000000..76c97f8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/reeflessCoral.java @@ -0,0 +1,28 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.util.Utilities; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; + +public class reeflessCoral extends Block { + + public reeflessCoral() { + super(Material.rock); // Choose the appropriate material + // Set other properties like hardness, resistance, name, etc. + setHardness(2.0F); + setResistance(5.0F); + setBlockTextureName(Utilities.toSnakeCase("lotr:reeflessCoral")); + setBlockName("lotr:reeflessCoral"); + setCreativeTab((CreativeTabs)Utilities.reflected_tab_block); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon("lotr:reeflessCoral"); + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/blocks/silverChain.java b/src/src/main/java/com/zivilon/cinder_loe/blocks/silverChain.java new file mode 100644 index 0000000..4236d1b --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/blocks/silverChain.java @@ -0,0 +1,125 @@ +package com.zivilon.cinder_loe.blocks; + +import com.zivilon.cinder_loe.util.Utilities; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import lotr.common.LOTRMod; +import lotr.common.block.LOTRBlockChandelier; +import lotr.common.block.LOTRBlockOrcChain; +import net.minecraft.block.*; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class silverChain extends LOTRBlockOrcChain { + + public IIcon icon; + @SideOnly(value= Side.CLIENT) + private IIcon iconMiddle; + @SideOnly(value=Side.CLIENT) + private IIcon iconTop; + @SideOnly(value=Side.CLIENT) + private IIcon iconBottom; + @SideOnly(value=Side.CLIENT) + private IIcon iconSingle; + + public silverChain() { + this.setHardness(1.0f); + this.setStepSound(Block.soundTypeMetal); + this.textureName = "lotr:silverChain"; + setBlockName("lotr:silverChain"); + setBlockTextureName("lotr:silverChain"); + float f = 0.2f; + this.setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, 1.0f, 0.5f + f); + } + + @SideOnly(value=Side.CLIENT) + public void registerBlockIcons(IIconRegister iconregister) { + this.iconMiddle = iconregister.registerIcon(this.getTextureName() + "_mid"); + this.iconTop = iconregister.registerIcon(this.getTextureName() + "_top"); + this.iconBottom = iconregister.registerIcon(this.getTextureName() + "_bottom"); + this.iconSingle = iconregister.registerIcon(this.getTextureName() + "_single"); + this.blockIcon = iconregister.registerIcon(this.getTextureName()); + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int i, int j, int k, int side) { + boolean chainBelow; + Block above = world.getBlock(i, j + 1, k); + Block below = world.getBlock(i, j - 1, k); + boolean chainAbove = above instanceof silverChain; + boolean bl = chainBelow = below instanceof silverChain || below instanceof LOTRBlockChandelier; + if (chainAbove && chainBelow) { + return this.iconMiddle; + } + if (chainAbove) { + return this.iconBottom; + } + if (chainBelow) { + return this.iconTop; + } + return this.iconSingle; + } + + @SideOnly(value=Side.CLIENT) + public IIcon getIcon(int i, int j) { + return this.iconMiddle; + } + + @SideOnly(value=Side.CLIENT) + public String getItemIconName() { + return this.getTextureName(); + } + + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + Block block = world.getBlock(i, j + 1, k); + int meta = world.getBlockMetadata(i, j + 1, k); + if (block instanceof silverChain) { + return true; + } + if (block instanceof BlockFence || block instanceof BlockWall) { + return true; + } + if (block instanceof BlockSlab && !block.isOpaqueCube() && (meta & 8) == 0) { + return true; + } + if (block instanceof BlockStairs && (meta & 4) == 0) { + return true; + } + return world.getBlock(i, j + 1, k).isSideSolid((IBlockAccess)world, i, j + 1, k, ForgeDirection.DOWN); + } + + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int side, float f, float f1, float f2) { + ItemStack itemstack = entityplayer.getHeldItem(); + if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock((Block)this)) { + Block block; + int j1; + for (j1 = j; j1 >= 0 && j1 < world.getHeight() && (block = world.getBlock(i, j1, k)) == this; --j1) { + } + if (j1 >= 0 && j1 < world.getHeight()) { + block = world.getBlock(i, j1, k); + if (this.canPlaceBlockOnSide(world, i, j1, k, side) && block.isReplaceable((IBlockAccess)world, i, j1, k) && !block.getMaterial().isLiquid()) { + int thisMeta = world.getBlockMetadata(i, j, k); + world.setBlock(i, j1, k, (Block)this, thisMeta, 3); + world.playSoundEffect((double)((float)i + 0.5f), (double)((float)j1 + 0.5f), (double)((float)k + 0.5f), this.stepSound.func_150496_b(), (this.stepSound.getVolume() + 1.0f) / 2.0f, this.stepSound.getPitch() * 0.8f); + if (!entityplayer.capabilities.isCreativeMode) { + --itemstack.stackSize; + } + if (itemstack.stackSize <= 0) { + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); + } + return true; + } + } + } + return false; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/character/CharacterEventListener.java b/src/src/main/java/com/zivilon/cinder_loe/character/CharacterEventListener.java new file mode 100644 index 0000000..9a881c7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/character/CharacterEventListener.java @@ -0,0 +1,79 @@ +package com.zivilon.cinder_loe.character; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHurtEvent; + +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.zivilon.cinder_loe.character.CharacterRoleAPI; +import com.zivilon.cinder_loe.entity.FangornAnimal; + +public class CharacterEventListener { + + public CharacterEventListener() { + // Register the event listener + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) + public void onLivingHurt(LivingHurtEvent event) { + // Check if the entity being hurt is a character of interest + EntityLivingBase damagedEntity = event.entityLiving; + + // Check if the source of damage is an entity + if (event.source.getSourceOfDamage() instanceof EntityLivingBase) { + // The entity that caused the damage + EntityLivingBase damagerEntity = (EntityLivingBase) event.source.getSourceOfDamage(); + + if (damagedEntity instanceof EntityPlayerMP) { + EntityPlayerMP player = (EntityPlayerMP)damagedEntity; + + UUID radagast = CharacterRoleAPI.getCharacterRoleUUID("Radagast"); + if (player.getUniqueID().equals(radagast)) { + List entities = findAnimalsAndFangornEntities((EntityLivingBase)player); + for (EntityLivingBase entity : entities) { + EntityLiving animal = (EntityLiving) entity; + animal.setAttackTarget((EntityLivingBase)damagerEntity); + } + } + } + } + } + + public static List findAnimalsAndFangornEntities(EntityLivingBase centerEntity) { + World world = centerEntity.worldObj; + double searchRadius = 32.0D; // Define the search radius + + // Calculate the search area + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox( + centerEntity.posX - searchRadius, centerEntity.posY - searchRadius, centerEntity.posZ - searchRadius, + centerEntity.posX + searchRadius, centerEntity.posY + searchRadius, centerEntity.posZ + searchRadius); + + // Retrieve all entities within the search area + List entitiesWithinAABB = world.getEntitiesWithinAABB(EntityLivingBase.class, searchArea); + List foundEntities = new ArrayList(); + + // Manually filter the entities to match your criteria + for (Object obj : entitiesWithinAABB) { + if (obj instanceof EntityAnimal || obj instanceof FangornAnimal) { // Adjust for your custom entity + foundEntities.add((EntityLivingBase) obj); + } + } + + return foundEntities; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/character/CharacterRoleAPI.java b/src/src/main/java/com/zivilon/cinder_loe/character/CharacterRoleAPI.java new file mode 100644 index 0000000..c45722a --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/character/CharacterRoleAPI.java @@ -0,0 +1,61 @@ +package com.zivilon.cinder_loe.character; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import java.io.*; +import java.nio.file.*; +import java.lang.reflect.Type; +import java.util.*; + +public class CharacterRoleAPI { + + private static final Path FILE_PATH = Paths.get("character_roles.json"); + private static Map characterRoles = new HashMap<>(); + + public static void loadRolesFromFile() { + if (!Files.exists(FILE_PATH)) { + try { + Files.createFile(FILE_PATH); + } catch (IOException e) { + e.printStackTrace(); + } + return; + } + + try (Reader reader = Files.newBufferedReader(FILE_PATH)) { + Gson gson = new Gson(); + Type type = new TypeToken>() {}.getType(); + characterRoles = gson.fromJson(reader, type); + if (characterRoles == null) { + characterRoles = new HashMap<>(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void saveRolesToFile() { + Gson gson = new Gson(); + try (Writer writer = Files.newBufferedWriter(FILE_PATH)) { + gson.toJson(characterRoles, writer); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static UUID getCharacterRoleUUID(String roleName) { + return characterRoles.get(roleName); + } + + public static void setCharacterRoleUUID(String roleName, UUID playerUUID) { + characterRoles.put(roleName, playerUUID); + saveRolesToFile(); + } + + public static void removeCharacterRole(String roleName) { + if (characterRoles.containsKey(roleName)) { + characterRoles.remove(roleName); + saveRolesToFile(); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelBreeHelmet.java b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelBreeHelmet.java new file mode 100644 index 0000000..5ea9f3d --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelBreeHelmet.java @@ -0,0 +1,40 @@ +package com.zivilon.cinder_loe.client.model; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; +//import lotr.client.model.LOTRModelBiped; +import net.minecraft.entity.Entity; + +/** + * Created using Tabula 4.1.1 + */ +public class ModelBreeHelmet extends ModelBiped { + public ModelRenderer shape9; + + public ModelBreeHelmet() { + this.textureWidth = 64; + this.textureHeight = 32; + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 1.0F); + this.shape9 = new ModelRenderer(this, 0, 16); + this.shape9.setRotationPoint(0.0F, 0.0F, 0.0F); + this.shape9.addBox(-7.0F, -4.75F, -7.0F, 14, 0, 14, 1.75F); + this.bipedHead.addChild(shape9); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + this.bipedHead.render(f5); +// this.shape9.render(f5); + } + + /** + * This is a helper function from Tabula to set the rotation of model parts + */ + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornAuroch.java b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornAuroch.java new file mode 100644 index 0000000..7fdd37f --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornAuroch.java @@ -0,0 +1,126 @@ +package com.zivilon.cinder_loe.client.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +import com.zivilon.cinder_loe.entity.FangornAuroch; + +public class ModelFangornAuroch extends ModelBase { + public ModelRenderer body; + + public ModelRenderer leg1; + + public ModelRenderer leg2; + + public ModelRenderer leg3; + + public ModelRenderer leg4; + + public ModelRenderer tail; + + public ModelRenderer head; + + public ModelRenderer horns; + + public ModelRenderer hornLeft1; + + public ModelRenderer hornLeft2; + + public ModelRenderer hornRight1; + + public ModelRenderer hornRight2; + + public ModelFangornAuroch() { + this.textureWidth = 128; + this.textureHeight = 64; + this.body = new ModelRenderer(this, 0, 0); + this.body.setRotationPoint(0.0F, 2.0F, -1.0F); + this.body.addBox(-8.0F, -6.0F, -11.0F, 16, 16, 26); + this.body.setTextureOffset(28, 42).addBox(-8.0F, -8.0F, -8.0F, 16, 2, 10); + this.body.setTextureOffset(84, 31).addBox(-3.0F, 10.0F, 4.0F, 6, 1, 6); + this.leg1 = new ModelRenderer(this, 0, 42); + this.leg1.setRotationPoint(-5.0F, 12.0F, 9.0F); + this.leg1.addBox(-2.5F, 0.0F, -2.5F, 5, 12, 5); + this.leg2 = new ModelRenderer(this, 0, 42); + this.leg2.setRotationPoint(5.0F, 12.0F, 9.0F); + this.leg2.mirror = true; + this.leg2.addBox(-2.5F, 0.0F, -2.5F, 5, 12, 5); + this.leg3 = new ModelRenderer(this, 0, 42); + this.leg3.setRotationPoint(-5.0F, 12.0F, -7.0F); + this.leg3.addBox(-2.5F, 0.0F, -2.5F, 5, 12, 5); + this.leg4 = new ModelRenderer(this, 0, 42); + this.leg4.setRotationPoint(5.0F, 12.0F, -7.0F); + this.leg4.mirror = true; + this.leg4.addBox(-2.5F, 0.0F, -2.5F, 5, 12, 5); + this.tail = new ModelRenderer(this, 20, 42); + this.tail.setRotationPoint(0.0F, 1.0F, 14.0F); + this.tail.addBox(-1.0F, -1.0F, 0.0F, 2, 12, 1); + this.head = new ModelRenderer(this, 58, 0); + this.head.setRotationPoint(0.0F, -1.0F, -10.0F); + this.head.addBox(-5.0F, -4.0F, -12.0F, 10, 10, 11); + this.head.setTextureOffset(89, 0).addBox(-3.0F, 1.0F, -15.0F, 6, 4, 4); + this.head.setTextureOffset(105, 0); + this.head.addBox(-8.0F, -2.5F, -7.0F, 3, 2, 1); + this.head.mirror = true; + this.head.addBox(5.0F, -2.5F, -7.0F, 3, 2, 1); + this.head.mirror = false; + this.horns = new ModelRenderer(this, 98, 21); + this.horns.setRotationPoint(0.0F, -3.5F, -5.0F); + this.horns.addBox(-6.0F, -1.5F, -1.5F, 12, 3, 3); + this.head.addChild(this.horns); + this.hornLeft1 = new ModelRenderer(this, 112, 27); + this.hornLeft1.setRotationPoint(-6.0F, 0.0F, 0.0F); + this.hornLeft1.addBox(-5.0F, -1.0F, -1.0F, 6, 2, 2); + this.hornLeft2 = new ModelRenderer(this, 114, 31); + this.hornLeft2.setRotationPoint(-5.0F, 0.0F, 0.0F); + this.hornLeft2.addBox(-5.0F, -0.5F, -0.5F, 6, 1, 1); + this.hornLeft1.addChild(this.hornLeft2); + this.horns.addChild(this.hornLeft1); + this.hornRight1 = new ModelRenderer(this, 112, 27); + this.hornRight1.mirror = true; + this.hornRight1.setRotationPoint(6.0F, 0.0F, 0.0F); + this.hornRight1.addBox(-1.0F, -1.0F, -1.0F, 6, 2, 2); + this.hornRight2 = new ModelRenderer(this, 114, 31); + this.hornRight2.mirror = true; + this.hornRight2.setRotationPoint(5.0F, 0.0F, 0.0F); + this.hornRight2.addBox(-1.0F, -0.5F, -0.5F, 6, 1, 1); + this.hornRight1.addChild(this.hornRight2); + this.horns.addChild(this.hornRight1); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + this.horns.showModel = true; + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + this.head.render(f5); + this.body.render(f5); + this.leg1.render(f5); + this.leg2.render(f5); + this.leg3.render(f5); + this.leg4.render(f5); + this.tail.render(f5); + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + this.head.rotateAngleX = 0.0F; + this.head.rotateAngleY = 0.0F; + this.head.rotateAngleZ = 0.0F; + this.head.rotateAngleX += (float)Math.toRadians(f4); + this.head.rotateAngleY += (float)Math.toRadians(f3); + this.head.rotateAngleX += MathHelper.cos(f * 0.2F) * f1 * 0.4F; + this.hornLeft1.rotateAngleZ = (float)Math.toRadians(25.0D); + this.hornLeft2.rotateAngleZ = (float)Math.toRadians(15.0D); + this.hornRight1.rotateAngleZ = -this.hornLeft1.rotateAngleZ; + this.hornRight2.rotateAngleZ = -this.hornLeft2.rotateAngleZ; + this.hornLeft1.rotateAngleY = (float)Math.toRadians(-25.0D); + this.hornRight1.rotateAngleY = -this.hornLeft1.rotateAngleY; + this.hornLeft1.rotateAngleX = (float)Math.toRadians(35.0D); + this.hornRight1.rotateAngleX = this.hornLeft1.rotateAngleX; + this.leg1.rotateAngleX = MathHelper.cos(f * 0.4F) * f1 * 0.8F; + this.leg2.rotateAngleX = MathHelper.cos(f * 0.4F + 3.1415927F) * f1 * 0.8F; + this.leg3.rotateAngleX = MathHelper.cos(f * 0.4F + 3.1415927F) * f1 * 0.8F; + this.leg4.rotateAngleX = MathHelper.cos(f * 0.4F) * f1 * 0.8F; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornElk.java b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornElk.java new file mode 100644 index 0000000..50e1a37 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornElk.java @@ -0,0 +1,188 @@ +package com.zivilon.cinder_loe.client.model; + +import lotr.client.LOTRTickHandlerClient; +import lotr.common.LOTRMod; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +import com.zivilon.cinder_loe.entity.FangornElk; + +public class ModelFangornElk extends ModelBase { + private ModelRenderer body; + + private ModelRenderer leg1; + + private ModelRenderer leg2; + + private ModelRenderer leg3; + + private ModelRenderer leg4; + + private ModelRenderer head; + + private ModelRenderer nose; + + private ModelRenderer antlersRight_1; + + private ModelRenderer antlersRight_2; + + private ModelRenderer antlersRight_3; + + private ModelRenderer antlersRight_4; + + private ModelRenderer antlersLeft_1; + + private ModelRenderer antlersLeft_2; + + private ModelRenderer antlersLeft_3; + + private ModelRenderer antlersLeft_4; + + public ModelFangornElk() { + this(0.0F); + } + + public ModelFangornElk(float f) { + this.textureWidth = 128; + this.textureHeight = 64; + this.body = new ModelRenderer(this, 0, 0); + this.body.setRotationPoint(0.0F, 4.0F, 9.0F); + this.body.addBox(-6.0F, -4.0F, -21.0F, 12, 11, 26, f); + ModelRenderer tail = new ModelRenderer(this, 0, 54); + tail.addBox(-1.0F, -5.0F, 2.0F, 2, 2, 8, f); + tail.rotateAngleX = (float)Math.toRadians(-60.0D); + this.body.addChild(tail); + this.leg1 = new ModelRenderer(this, 42, 37); + this.leg1.setRotationPoint(-4.0F, 3.0F, 8.0F); + this.leg1.addBox(-5.5F, 0.0F, -3.0F, 7, 11, 8, f); + this.leg1.setTextureOffset(26, 37).addBox(-4.0F, 11.0F, -1.0F, 4, 10, 4, f); + this.leg2 = new ModelRenderer(this, 42, 37); + this.leg2.mirror = true; + this.leg2.setRotationPoint(4.0F, 3.0F, 8.0F); + this.leg2.addBox(-1.5F, 0.0F, -3.0F, 7, 11, 8, f); + this.leg2.setTextureOffset(26, 37).addBox(0.0F, 11.0F, -1.0F, 4, 10, 4, f); + this.leg3 = new ModelRenderer(this, 0, 37); + this.leg3.setRotationPoint(-4.0F, 4.0F, -6.0F); + this.leg3.addBox(-4.5F, 0.0F, -3.0F, 6, 10, 7, f); + this.leg3.setTextureOffset(26, 37).addBox(-3.5F, 10.0F, -2.0F, 4, 10, 4, f); + this.leg4 = new ModelRenderer(this, 0, 37); + this.leg4.mirror = true; + this.leg4.setRotationPoint(4.0F, 4.0F, -6.0F); + this.leg4.addBox(-1.5F, 0.0F, -3.0F, 6, 10, 7, f); + this.leg4.setTextureOffset(26, 37).addBox(-0.5F, 10.0F, -2.0F, 4, 10, 4, f); + this.head = new ModelRenderer(this, 50, 0); + this.head.setRotationPoint(0.0F, 4.0F, -10.0F); + this.head.addBox(-2.0F, -10.0F, -4.0F, 4, 12, 8, f); + this.head.setTextureOffset(74, 0).addBox(-3.0F, -16.0F, -8.0F, 6, 6, 13, f); + this.head.setTextureOffset(50, 20); + this.head.addBox(-2.0F, -18.0F, 3.0F, 1, 2, 1, f); + this.head.mirror = true; + this.head.addBox(1.0F, -18.0F, 3.0F, 1, 2, 1, f); + this.nose = new ModelRenderer(this, 56, 20); + this.nose.addBox(-1.0F, -14.5F, -9.0F, 2, 2, 1, f); + this.antlersRight_1 = new ModelRenderer(this, 0, 0); + this.antlersRight_1.addBox(10.0F, -19.0F, 2.5F, 1, 12, 1, f); + this.antlersRight_1.rotateAngleZ = (float)Math.toRadians(-65.0D); + this.antlersRight_2 = new ModelRenderer(this, 4, 0); + this.antlersRight_2.addBox(-3.0F, -23.6F, 2.5F, 1, 8, 1, f); + this.antlersRight_2.rotateAngleZ = (float)Math.toRadians(-15.0D); + this.antlersRight_3 = new ModelRenderer(this, 8, 0); + this.antlersRight_3.addBox(-8.0F, -36.0F, 2.5F, 1, 16, 1, f); + this.antlersRight_3.rotateAngleZ = (float)Math.toRadians(-15.0D); + this.antlersRight_4 = new ModelRenderer(this, 12, 0); + this.antlersRight_4.addBox(7.5F, -35.0F, 2.5F, 1, 10, 1, f); + this.antlersRight_4.rotateAngleZ = (float)Math.toRadians(-50.0D); + this.head.addChild(this.antlersRight_1); + this.head.addChild(this.antlersRight_2); + this.head.addChild(this.antlersRight_3); + this.head.addChild(this.antlersRight_4); + this.antlersLeft_1 = new ModelRenderer(this, 0, 0); + this.antlersLeft_1.mirror = true; + this.antlersLeft_1.addBox(-11.0F, -19.0F, 2.5F, 1, 12, 1, f); + this.antlersLeft_1.rotateAngleZ = (float)Math.toRadians(65.0D); + this.antlersLeft_2 = new ModelRenderer(this, 4, 0); + this.antlersLeft_2.mirror = true; + this.antlersLeft_2.addBox(2.0F, -23.6F, 2.5F, 1, 8, 1, f); + this.antlersLeft_2.rotateAngleZ = (float)Math.toRadians(15.0D); + this.antlersLeft_3 = new ModelRenderer(this, 8, 0); + this.antlersLeft_3.mirror = true; + this.antlersLeft_3.addBox(7.0F, -36.0F, 2.5F, 1, 16, 1, f); + this.antlersLeft_3.rotateAngleZ = (float)Math.toRadians(15.0D); + this.antlersLeft_4 = new ModelRenderer(this, 12, 0); + this.antlersLeft_4.mirror = true; + this.antlersLeft_4.addBox(-8.5F, -35.0F, 2.5F, 1, 10, 1, f); + this.antlersLeft_4.rotateAngleZ = (float)Math.toRadians(50.0D); + this.head.addChild(this.antlersLeft_1); + this.head.addChild(this.antlersLeft_2); + this.head.addChild(this.antlersLeft_3); + this.head.addChild(this.antlersLeft_4); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + FangornElk elk = (FangornElk)entity; + setRotationAngles(f, f1, f2, f3, f4, f5, (Entity)elk); + GL11.glPushMatrix(); + float scale = 1.0F; + GL11.glTranslatef(0.0F, 24.0F * (1.0F - scale) * f5, 0.0F); + GL11.glScalef(scale, scale, scale); + boolean showAntlers = (scale > 0.75F); + this.antlersRight_1.showModel = showAntlers; + this.antlersRight_2.showModel = showAntlers; + this.antlersRight_3.showModel = showAntlers; + this.antlersRight_4.showModel = showAntlers; + this.antlersLeft_1.showModel = showAntlers; + this.antlersLeft_2.showModel = showAntlers; + this.antlersLeft_3.showModel = showAntlers; + this.antlersLeft_4.showModel = showAntlers; + this.body.render(f5); + this.leg1.render(f5); + this.leg2.render(f5); + this.leg3.render(f5); + this.leg4.render(f5); + this.head.render(f5); + if (LOTRMod.isChristmas()) + GL11.glColor3f(1.0F, 0.0F, 0.0F); + this.nose.render(f5); + if (LOTRMod.isChristmas()) + GL11.glColor3f(1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + float rearAmount = 0.0F; + float antiRearAmount = 1.0F - rearAmount; + this.head.rotationPointY = 4.0F; + this.head.rotationPointZ = -10.0F; + this.head.rotateAngleX = (float)Math.toRadians(20.0D); + this.head.rotateAngleY = 0.0F; + this.head.rotationPointY = rearAmount * -6.0F + antiRearAmount * this.head.rotationPointY; + this.head.rotationPointZ = rearAmount * -1.0F + antiRearAmount * this.head.rotationPointZ; + this.head.rotateAngleX = (float)(this.head.rotateAngleX + Math.toRadians(f4)); + this.head.rotateAngleY = (float)(this.head.rotateAngleY + Math.toRadians(f3)); + this.head.rotateAngleX = antiRearAmount * this.head.rotateAngleX; + this.head.rotateAngleY = antiRearAmount * this.head.rotateAngleY; + if (f1 > 0.2F) + this.head.rotateAngleX += MathHelper.cos(f * 0.3F) * 0.1F * f1; + this.nose.setRotationPoint(this.head.rotationPointX, this.head.rotationPointY, this.head.rotationPointZ); + this.nose.rotateAngleX = this.head.rotateAngleX; + this.nose.rotateAngleY = this.head.rotateAngleY; + this.nose.rotateAngleZ = this.head.rotateAngleZ; + this.body.rotateAngleX = 0.0F; + this.body.rotateAngleX = rearAmount * -0.7853982F + antiRearAmount * this.body.rotateAngleX; + float legRotation = MathHelper.cos(f * 0.4F + 3.1415927F) * f1; + float f17 = -1.0471976F; + float f18 = 0.2617994F * rearAmount; + float f19 = MathHelper.cos(f2 * 0.4F + 3.1415927F); + this.leg4.rotationPointY = -2.0F * rearAmount + 4.0F * antiRearAmount; + this.leg4.rotationPointZ = -2.0F * rearAmount + -6.0F * antiRearAmount; + this.leg3.rotationPointY = this.leg4.rotationPointY; + this.leg3.rotationPointZ = this.leg4.rotationPointZ; + this.leg1.rotateAngleX = f18 + legRotation * antiRearAmount; + this.leg2.rotateAngleX = f18 + -legRotation * antiRearAmount; + this.leg3.rotateAngleX = (f17 + -f19) * rearAmount + -legRotation * 0.8F * antiRearAmount; + this.leg4.rotateAngleX = (f17 + f19) * rearAmount + legRotation * 0.8F * antiRearAmount; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornWolf.java b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornWolf.java new file mode 100644 index 0000000..c08dc8b --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelFangornWolf.java @@ -0,0 +1,126 @@ +package com.zivilon.cinder_loe.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import com.zivilon.cinder_loe.entity.FangornWolf; + +@SideOnly(Side.CLIENT) +public class ModelFangornWolf extends ModelBase { + /** main box for the wolf head */ + public ModelRenderer wolfHeadMain; + /** The wolf's body */ + public ModelRenderer wolfBody; + /** Wolf'se first leg */ + public ModelRenderer wolfLeg1; + /** Wolf's second leg */ + public ModelRenderer wolfLeg2; + /** Wolf's third leg */ + public ModelRenderer wolfLeg3; + /** Wolf's fourth leg */ + public ModelRenderer wolfLeg4; + /** The wolf's tail */ + ModelRenderer wolfTail; + /** The wolf's mane */ + ModelRenderer wolfMane; + + public ModelFangornWolf() + { + float f = 0.0F; + float f1 = 13.5F; + this.wolfHeadMain = new ModelRenderer(this, 0, 0); + this.wolfHeadMain.addBox(-3.0F, -3.0F, -2.0F, 6, 6, 4, f); + this.wolfHeadMain.setRotationPoint(-1.0F, f1, -7.0F); + this.wolfBody = new ModelRenderer(this, 18, 14); + this.wolfBody.addBox(-4.0F, -2.0F, -3.0F, 6, 9, 6, f); + this.wolfBody.setRotationPoint(0.0F, 14.0F, 2.0F); + this.wolfMane = new ModelRenderer(this, 21, 0); + this.wolfMane.addBox(-4.0F, -3.0F, -3.0F, 8, 6, 7, f); + this.wolfMane.setRotationPoint(-1.0F, 14.0F, 2.0F); + this.wolfLeg1 = new ModelRenderer(this, 0, 18); + this.wolfLeg1.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); + this.wolfLeg2 = new ModelRenderer(this, 0, 18); + this.wolfLeg2.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); + this.wolfLeg3 = new ModelRenderer(this, 0, 18); + this.wolfLeg3.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); + this.wolfLeg4 = new ModelRenderer(this, 0, 18); + this.wolfLeg4.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); + this.wolfTail = new ModelRenderer(this, 9, 18); + this.wolfTail.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfTail.setRotationPoint(-1.0F, 12.0F, 8.0F); + this.wolfHeadMain.setTextureOffset(16, 14).addBox(-3.0F, -5.0F, 0.0F, 2, 2, 1, f); + this.wolfHeadMain.setTextureOffset(16, 14).addBox(1.0F, -5.0F, 0.0F, 2, 2, 1, f); + this.wolfHeadMain.setTextureOffset(0, 10).addBox(-1.5F, 0.0F, -5.0F, 3, 3, 4, f); + } + + /** + * Sets the models various rotation angles then renders the model. + */ + public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) + { + super.render(p_78088_1_, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_); + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); + + this.wolfHeadMain.renderWithRotation(p_78088_7_); + this.wolfBody.render(p_78088_7_); + this.wolfLeg1.render(p_78088_7_); + this.wolfLeg2.render(p_78088_7_); + this.wolfLeg3.render(p_78088_7_); + this.wolfLeg4.render(p_78088_7_); + this.wolfTail.renderWithRotation(p_78088_7_); + this.wolfMane.render(p_78088_7_); + } + + /** + * Used for easily adding entity-dependent animations. The second and third float params here are the same second + * and third as in the setRotationAngles method. + */ + public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) + { + FangornWolf entitywolf = (FangornWolf)p_78086_1_; + + this.wolfTail.rotateAngleY = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; + + this.wolfBody.setRotationPoint(0.0F, 14.0F, 2.0F); + this.wolfBody.rotateAngleX = ((float)Math.PI / 2F); + this.wolfMane.setRotationPoint(-1.0F, 14.0F, -3.0F); + this.wolfMane.rotateAngleX = this.wolfBody.rotateAngleX; + this.wolfTail.setRotationPoint(-1.0F, 12.0F, 8.0F); + this.wolfLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); + this.wolfLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); + this.wolfLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); + this.wolfLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); + this.wolfLeg1.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; + this.wolfLeg2.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F + (float)Math.PI) * 1.4F * p_78086_3_; + this.wolfLeg3.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F + (float)Math.PI) * 1.4F * p_78086_3_; + this.wolfLeg4.rotateAngleX = MathHelper.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; + + this.wolfHeadMain.rotateAngleZ = 0.0F; + this.wolfMane.rotateAngleZ = -0.08F; + this.wolfBody.rotateAngleZ = -0.16F; + this.wolfTail.rotateAngleZ = -0.2F; + } + + /** + * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms + * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how + * "far" arms and legs can swing at most. + */ + public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) + { + super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); + this.wolfHeadMain.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI); + this.wolfHeadMain.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI); + this.wolfTail.rotateAngleX = p_78087_3_; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelRedDwarfHelmet.java b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelRedDwarfHelmet.java new file mode 100644 index 0000000..8c625e6 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/model/ModelRedDwarfHelmet.java @@ -0,0 +1,61 @@ +package com.zivilon.cinder_loe.client.model; + +import lotr.client.model.LOTRModelBiped; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelRedDwarfHelmet extends LOTRModelBiped { + //fields + ModelRenderer rightneckguard; + ModelRenderer leftneckguard = new ModelRenderer(this, 32, 0); + ModelRenderer shape1 = new ModelRenderer(this, 32, 18); + + public ModelRedDwarfHelmet() { + + } + + public ModelRedDwarfHelmet(float f) { + super(f); + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.setRotationPoint(0F, 0F, 0F); + this.bipedHead.addBox(-4F, -8F, -4F, 8, 8, 8, f); + + rightneckguard = new ModelRenderer(this, 32, 9); + rightneckguard.addBox(4.6F, 2.15F, -3.0F, 0, 1, 8); + rightneckguard.setRotationPoint(0F, 0F, 0F); + rightneckguard.setTextureSize(64, 32); + rightneckguard.mirror = true; + setRotation(rightneckguard, 0F, 0F, -0.2443461F); + this.bipedHead.addChild(rightneckguard); + + leftneckguard = new ModelRenderer(this, 32, 0); + leftneckguard.addBox(-4.6F, 2.15F, -3.0F, 0, 1, 8); + leftneckguard.setRotationPoint(0F, 0F, 0F); + leftneckguard.setTextureSize(64, 32); + leftneckguard.mirror = true; + setRotation(leftneckguard, 0F, 0F, 0.2443461F); + this.bipedHead.addChild(leftneckguard); + + shape1 = new ModelRenderer(this, 32, 18); + shape1.setRotationPoint(0F, 0F, 0F); + shape1.addBox(0F, -13F, -4F, 0, 4, 10); + shape1.setTextureSize(64, 32); + setRotation(shape1, 0F, 0F, 0F); + this.bipedHead.addChild(shape1); + + this.bipedHeadwear.cubeList.clear(); + this.bipedBody.cubeList.clear(); + this.bipedRightArm.cubeList.clear(); + this.bipedLeftArm.cubeList.clear(); + this.bipedRightLeg.cubeList.clear(); + this.bipedLeftLeg.cubeList.clear(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderBattleNun.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderBattleNun.java new file mode 100644 index 0000000..d4097a8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderBattleNun.java @@ -0,0 +1,40 @@ +package com.zivilon.cinder_loe.client.render; + +import com.zivilon.cinder_loe.entity.BattleNun; +import lotr.client.model.LOTRModelHuman; +import lotr.client.render.entity.LOTRRenderBiped; +import lotr.client.render.entity.LOTRRandomSkins; +import lotr.common.entity.LOTRRandomSkinEntity; +import lotr.common.entity.npc.LOTREntityNPC; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; + +import com.zivilon.cinder_loe.entity.Limwaith; + +public class RenderBattleNun extends LOTRRenderBiped { + + public static LOTRRandomSkins skinsFemale; + + public ModelBiped outfitModel = (ModelBiped)new LOTRModelHuman(0.6F, false); + + public RenderBattleNun() { + super((ModelBiped)new LOTRModelHuman(), 0.5F); + setRenderPassModel((ModelBase)this.outfitModel); + skinsFemale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/arnorNun/arnorNun_female"); + } + + public ResourceLocation getEntityTexture(Entity entity) { + BattleNun battleNun = (BattleNun)entity; + if (((LOTREntityNPC)battleNun).familyInfo.isMale()) + return skinsFemale.getRandomSkin((LOTRRandomSkinEntity)battleNun); + return skinsFemale.getRandomSkin((LOTRRandomSkinEntity)battleNun); + } + + public int shouldRenderPass(EntityLiving entity, int pass, float f) { + BattleNun battleNun = (BattleNun)entity; + return super.shouldRenderPass((EntityLiving)battleNun, pass, f); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornAuroch.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornAuroch.java new file mode 100644 index 0000000..ab03624 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornAuroch.java @@ -0,0 +1,26 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.client.render.entity.LOTRRandomSkins; +import lotr.common.entity.LOTRRandomSkinEntity; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +import com.zivilon.cinder_loe.client.model.ModelFangornAuroch; +import com.zivilon.cinder_loe.entity.FangornAuroch; + +public class RenderFangornAuroch extends RenderLiving { + public static LOTRRandomSkins aurochsSkins; + + public RenderFangornAuroch() { + super((ModelBase)new ModelFangornAuroch(), 0.5F); + aurochsSkins = LOTRRandomSkins.loadSkinsList("lotr:mob/aurochs"); + } + + public ResourceLocation getEntityTexture(Entity entity) { + FangornAuroch aurochs = (FangornAuroch)entity; + ResourceLocation skin = aurochsSkins.getRandomSkin((LOTRRandomSkinEntity)aurochs); + return skin; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornBear.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornBear.java new file mode 100644 index 0000000..8876ae0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornBear.java @@ -0,0 +1,46 @@ +package com.zivilon.cinder_loe.client.render; + +import com.zivilon.cinder_loe.entity.FangornBear; + +import java.util.HashMap; +import java.util.Map; +import lotr.client.model.LOTRModelBear; +import lotr.client.render.entity.LOTRRenderBear; +import lotr.common.entity.animal.LOTREntityBear; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class RenderFangornBear extends RenderLiving { + public static Map bearSkins = new HashMap(); + + public RenderFangornBear() { + super((ModelBase)new LOTRModelBear(), 0.5F); + } + + protected ResourceLocation getEntityTexture(Entity entity) { + FangornBear bear = (FangornBear)entity; + return getBearSkin(bear.getBearType()); + } + public static ResourceLocation getBearSkin(LOTREntityBear.BearType type) { + String s = type.textureName(); + ResourceLocation skin = (ResourceLocation)bearSkins.get(s); + if (skin == null) { + skin = new ResourceLocation("lotr:mob/bear/" + s + ".png"); + bearSkins.put(s, skin); + } + return skin; + } + + public void preRenderCallback(EntityLivingBase entity, float f) { + scaleBearModel(); + } + + public static void scaleBearModel() { + float scale = 1.2F; + GL11.glScalef(scale, scale, scale); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornElk.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornElk.java new file mode 100644 index 0000000..16f3ced --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornElk.java @@ -0,0 +1,32 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.common.entity.LOTRRandomSkinEntity; +import lotr.client.render.entity.LOTRRandomSkins; +import lotr.common.entity.animal.LOTREntityElk; +import lotr.common.entity.npc.LOTRNPCMount; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; + +import com.zivilon.cinder_loe.client.model.ModelFangornElk; +import com.zivilon.cinder_loe.entity.FangornElk; + +public class RenderFangornElk extends RenderLiving { + private static LOTRRandomSkins elkSkins; + + private static ResourceLocation saddleTexture = new ResourceLocation("lotr:mob/elk/saddle.png"); + + public RenderFangornElk() { + super((ModelBase)new ModelFangornElk(), 0.5F); + setRenderPassModel((ModelBase)new ModelFangornElk(0.5F)); + elkSkins = LOTRRandomSkins.loadSkinsList("lotr:mob/elk/elk"); + } + + public ResourceLocation getEntityTexture(Entity entity) { + FangornElk elk = (FangornElk)entity; + ResourceLocation elkSkin = elkSkins.getRandomSkin((LOTRRandomSkinEntity)elk); + return elkSkin; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornWildBoar.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornWildBoar.java new file mode 100644 index 0000000..b6dd3e0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornWildBoar.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.client.model.LOTRModelBoar; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +public class RenderFangornWildBoar extends RenderLiving { + public static ResourceLocation boarSkin = new ResourceLocation("lotr:mob/boar/boar.png"); + + public RenderFangornWildBoar() { + super((ModelBase)new LOTRModelBoar(), 0.7F); + setRenderPassModel((ModelBase)new LOTRModelBoar(0.5F)); + } + + protected ResourceLocation getEntityTexture(Entity entity) { + return boarSkin; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornWolf.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornWolf.java new file mode 100644 index 0000000..05153c4 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderFangornWolf.java @@ -0,0 +1,26 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.common.entity.npc.LOTRNPCMount; +import lotr.client.render.entity.LOTRRenderHorse; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; + +import com.zivilon.cinder_loe.entity.FangornWolf; +import com.zivilon.cinder_loe.client.model.ModelFangornWolf; + +public class RenderFangornWolf extends RenderLiving { + public static final ResourceLocation wolfSkin = new ResourceLocation("minecraft:textures/entity/wolf/wolf.png"); + + public RenderFangornWolf() { + super((ModelBase)new ModelFangornWolf(), 0.7F); + setRenderPassModel((ModelBase)new ModelFangornWolf()); + } + + protected ResourceLocation getEntityTexture(Entity entity) { + return wolfSkin; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderLimwaith.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderLimwaith.java new file mode 100644 index 0000000..783c0e5 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderLimwaith.java @@ -0,0 +1,42 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.client.model.LOTRModelHuman; +import lotr.client.render.entity.LOTRRenderBiped; +import lotr.client.render.entity.LOTRRandomSkins; +import lotr.common.entity.LOTRRandomSkinEntity; +import lotr.common.entity.npc.LOTREntityMoredain; +import lotr.common.entity.npc.LOTREntityNPC; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; + +import com.zivilon.cinder_loe.entity.Limwaith; + +public class RenderLimwaith extends LOTRRenderBiped { + public static LOTRRandomSkins skinsMale; + + public static LOTRRandomSkins skinsFemale; + + public ModelBiped outfitModel = (ModelBiped)new LOTRModelHuman(0.6F, false); + + public RenderLimwaith() { + super((ModelBiped)new LOTRModelHuman(), 0.5F); + setRenderPassModel((ModelBase)this.outfitModel); + skinsMale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/limwaith/limwaith_male"); + skinsFemale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/limwaith/limwaith_female"); + } + + public ResourceLocation getEntityTexture(Entity entity) { + Limwaith limwaith = (Limwaith)entity; + if (((LOTREntityNPC)limwaith).familyInfo.isMale()) + return skinsMale.getRandomSkin((LOTRRandomSkinEntity)limwaith); + return skinsFemale.getRandomSkin((LOTRRandomSkinEntity)limwaith); + } + + public int shouldRenderPass(EntityLiving entity, int pass, float f) { + Limwaith limwaith = (Limwaith)entity; + return super.shouldRenderPass((EntityLiving)limwaith, pass, f); + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderLimwaithShaman.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderLimwaithShaman.java new file mode 100644 index 0000000..8968d03 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderLimwaithShaman.java @@ -0,0 +1,32 @@ +package com.zivilon.cinder_loe.client.render; + +import com.zivilon.cinder_loe.entity.Limwaith; +import lotr.client.model.LOTRModelHuman; +import lotr.client.render.entity.LOTRRandomSkins; +import lotr.client.render.entity.LOTRRenderBiped; +import lotr.common.entity.LOTRRandomSkinEntity; +import lotr.common.entity.npc.LOTREntityNPC; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; + +public class RenderLimwaithShaman extends RenderLimwaith { + private static LOTRRandomSkins outfits; + + public RenderLimwaithShaman() { + outfits = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/limwaith/shaman_outfit"); + } + + @Override + public int shouldRenderPass(EntityLiving entity, int pass, float f) { + Limwaith shaman = (Limwaith) entity; + if (pass == 1 && shaman.getEquipmentInSlot(3) == null) { + this.setRenderPassModel((ModelBase)this.outfitModel); + this.bindTexture(outfits.getRandomSkin(shaman)); + return 1; + } + return super.shouldRenderPass((EntityLiving)shaman, pass, f); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderRenegade.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderRenegade.java new file mode 100644 index 0000000..37b9ae3 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderRenegade.java @@ -0,0 +1,50 @@ +package com.zivilon.cinder_loe.client.render; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; + +import com.zivilon.cinder_loe.entity.Renegade; + +import lotr.client.model.LOTRModelHuman; +import lotr.client.render.entity.LOTRRandomSkins; +import lotr.client.render.entity.LOTRRenderBiped; +import lotr.common.entity.LOTRRandomSkinEntity; +import lotr.common.entity.npc.LOTREntityNPC; + +public class RenderRenegade extends LOTRRenderBiped { + + private static LOTRRandomSkins skinsMale; + + private static LOTRRandomSkins skinsFemale; + + private static LOTRRandomSkins headwearFemale; + + protected ModelBiped outfitModel = (ModelBiped) new LOTRModelHuman(0.6F, false); + + public RenderRenegade() { + super((ModelBiped) new LOTRModelHuman(), 0.5F); + skinsMale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/renegade/renegade_male"); + skinsFemale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/renegade/renegade_female"); + headwearFemale = LOTRRandomSkins.loadSkinsList("cinder_loe:mob/renegade/headwear_female"); + } + + public ResourceLocation getEntityTexture(Entity entity) { + Renegade man = (Renegade) entity; + if (((LOTREntityNPC) man).familyInfo.isMale()) return skinsMale.getRandomSkin((LOTRRandomSkinEntity) man); + return skinsFemale.getRandomSkin((LOTRRandomSkinEntity) man); + } + + public int shouldRenderPass(EntityLiving entity, int pass, float f) { + Renegade man = (Renegade) entity; + if (pass == 0 && man.getEquipmentInSlot(4) == null) if (!((LOTREntityNPC) man).familyInfo.isMale() + && LOTRRandomSkins.nextInt((LOTRRandomSkinEntity) man, 4) == 0) { + setRenderPassModel((ModelBase) this.outfitModel); + bindTexture(headwearFemale.getRandomSkin((LOTRRandomSkinEntity) man)); + return 1; + } + return super.shouldRenderPass((EntityLiving) man, pass, f); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderSarumanFireball.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderSarumanFireball.java new file mode 100644 index 0000000..fad8631 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderSarumanFireball.java @@ -0,0 +1,50 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.client.LOTRClientProxy; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import com.zivilon.cinder_loe.entity.SarumanFireball; + +public class RenderSarumanFireball extends Render { + public static final ResourceLocation particlesTexture = new ResourceLocation("cinder_loe:misc/particles.png"); + + protected ResourceLocation getEntityTexture(Entity entity) { + return particlesTexture; + } + + public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) { + GL11.glPushMatrix(); + GL11.glTranslatef((float)d, (float)d1, (float)d2); + GL11.glEnable(32826); + bindEntityTexture(entity); + Tessellator tessellator = Tessellator.instance; + drawSprite(tessellator, 24 + ((SarumanFireball)entity).animationTick); + GL11.glDisable(32826); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + + private void drawSprite(Tessellator tessellator, int index) { + float f = (index % 8 * 16 + 0) / 128.0F; + float f1 = (index % 8 * 16 + 16) / 128.0F; + float f2 = (index / 8 * 16 + 0) / 128.0F; + float f3 = (index / 8 * 16 + 16) / 128.0F; + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.setBrightness(15728880); + tessellator.addVertexWithUV((0.0F - f5), (0.0F - f6), 0.0D, f, f3); + tessellator.addVertexWithUV((f4 - f5), (0.0F - f6), 0.0D, f1, f3); + tessellator.addVertexWithUV((f4 - f5), (f4 - f6), 0.0D, f1, f2); + tessellator.addVertexWithUV((0.0F - f5), (f4 - f6), 0.0D, f, f2); + tessellator.draw(); + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderUtumnoSlave.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderUtumnoSlave.java new file mode 100644 index 0000000..ecabba9 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderUtumnoSlave.java @@ -0,0 +1,33 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.client.model.LOTRModelHuman; +import lotr.client.render.entity.LOTRRenderBiped; +import lotr.client.render.entity.LOTRRandomSkins; +import lotr.common.entity.LOTRRandomSkinEntity; +import lotr.common.entity.npc.LOTREntityNPC; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.ResourceLocation; + +public class RenderUtumnoSlave extends LOTRRenderBiped { + public static LOTRRandomSkins skins; + + public ModelBiped outfitModel = (ModelBiped)new LOTRModelHuman(0.6F, false); + + public RenderUtumnoSlave() { + super((ModelBiped)new LOTRModelHuman(), 0.5F); + setRenderPassModel((ModelBase)this.outfitModel); + skins = LOTRRandomSkins.loadSkinsList("lotr:mob/scrapTrader"); + } + + public ResourceLocation getEntityTexture(Entity entity) { + LOTREntityNPC lotrEntity = (LOTREntityNPC) entity; + return skins.getRandomSkin(lotrEntity); + } + + public int shouldRenderPass(EntityLiving entity, int pass, float f) { + return super.shouldRenderPass(entity, pass, f); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderWraith.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderWraith.java new file mode 100644 index 0000000..d9ad866 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/RenderWraith.java @@ -0,0 +1,43 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.client.model.LOTRModelMarshWraith; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import com.zivilon.cinder_loe.entity.Wraith; + +public class RenderWraith extends RenderLiving { + private static ResourceLocation skin = new ResourceLocation("cinder_loe:mob/wraith/wraith.png"); + + public RenderWraith() { + super((ModelBase)new LOTRModelMarshWraith(), 0.5F); + } + + protected ResourceLocation getEntityTexture(Entity entity) { + return skin; + } + + protected void preRenderCallback(EntityLivingBase entity, float f) { + super.preRenderCallback(entity, f); + float f1 = 0.9375F; + float hover = MathHelper.sin((((Entity)entity).ticksExisted + f) * 0.15F) * 0.2F - 0.5F; + GL11.glScalef(f1, f1, f1); + GL11.glTranslatef(0.0F, hover, 0.0F); + Wraith wraith = (Wraith)entity; + if (wraith.getDeathFadeTime() > 0) { + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glEnable(3008); + GL11.glColor4f(1.0F, 1.0F, 1.0F, wraith.getDeathFadeTime() / 30.0F); + } + } + + protected float getDeathMaxRotation(EntityLivingBase entity) { + return 0.0F; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/block/RenderMistBlock.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/block/RenderMistBlock.java new file mode 100644 index 0000000..6c2a61a --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/block/RenderMistBlock.java @@ -0,0 +1,43 @@ +package com.zivilon.cinder_loe.client.render.block; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import org.lwjgl.opengl.GL11; +import com.zivilon.cinder_loe.tileentity.TileEntityMistBlock; +import lotr.client.render.tileentity.LOTRRenderUtumnoPortal; + +public class RenderMistBlock extends TileEntitySpecialRenderer { + public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) { + TileEntityMistBlock mist = (TileEntityMistBlock)tileentity; + GL11.glPushMatrix(); + GL11.glDisable(2884); + GL11.glDisable(3553); + GL11.glDisable(2896); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDepthMask(false); + int passes = 60; + for (int i = 0; i < passes; i++) { + GL11.glPushMatrix(); + GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.0F + i * 0.5F, (float)d2 + 0.5F); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(mist.color_red, mist.color_green, mist.color_blue, (passes - i) / passes); + double width = 0.5D; + tessellator.addVertexWithUV(width, 0.0D, width, 0.0D, 0.0D); + tessellator.addVertexWithUV(width, 0.0D, -width, 0.0D, 0.0D); + tessellator.addVertexWithUV(-width, 0.0D, -width, 0.0D, 0.0D); + tessellator.addVertexWithUV(-width, 0.0D, width, 0.0D, 0.0D); + tessellator.draw(); + GL11.glPopMatrix(); + } + GL11.glDepthMask(true); + GL11.glEnable(3553); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(3042); + GL11.glEnable(2896); + GL11.glEnable(2884); + GL11.glPopMatrix(); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/client/render/item/RenderHelper.java b/src/src/main/java/com/zivilon/cinder_loe/client/render/item/RenderHelper.java new file mode 100644 index 0000000..1d55579 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/client/render/item/RenderHelper.java @@ -0,0 +1,151 @@ +package com.zivilon.cinder_loe.client.render.item; + +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.MapData; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.RenderBlocks; + +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; +import net.minecraftforge.client.MinecraftForgeClient; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*; + +public class RenderHelper extends ItemRenderer { + public RenderHelper() { + super(Minecraft.getMinecraft()); + } + + public static void customRenderItemIn2D(Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int p_78439_5_, int p_78439_6_, float p_78439_7_, boolean enchant) { + if (!enchant) GL11.glPushMatrix(); // Save the current OpenGL state + if (!enchant) GL11.glEnable(GL11.GL_BLEND); // Enable blending + if (!enchant) OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); // Apply your custom blend function for semi-transparency + + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.draw(); + + + float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)p_78439_5_; + float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)p_78439_6_; + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + + for (k = 0; k < p_78439_5_; ++k) + { + f7 = (float)k / (float)p_78439_5_; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(1.0F, 0.0F, 0.0F); + float f9; + + for (k = 0; k < p_78439_5_; ++k) + { + f7 = (float)k / (float)p_78439_5_; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + f9 = f7 + 1.0F / (float)p_78439_5_; + p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 1.0F, 0.0F); + + for (k = 0; k < p_78439_6_; ++k) + { + f7 = (float)k / (float)p_78439_6_; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + f9 = f7 + 1.0F / (float)p_78439_6_; + p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, -1.0F, 0.0F); + + for (k = 0; k < p_78439_6_; ++k) + { + f7 = (float)k / (float)p_78439_6_; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + } + + p_78439_0_.draw(); + if (!enchant) GL11.glPopMatrix(); // Restore the saved OpenGL state + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/command/CommandCinderCharacter.java b/src/src/main/java/com/zivilon/cinder_loe/command/CommandCinderCharacter.java new file mode 100644 index 0000000..971886e --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/command/CommandCinderCharacter.java @@ -0,0 +1,81 @@ +package com.zivilon.cinder_loe.command; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; + +import com.zivilon.cinder_loe.character.CharacterRoleAPI; +import com.zivilon.cinder_loe.util.Utilities; + +import java.util.UUID; + +public class CommandCinderCharacter extends CommandBase { + + @Override + public String getCommandName() { + return "cinder_character"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "/cinder_character [player_name]"; + } + + @Override + public int getRequiredPermissionLevel() { + return 4; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if(args.length < 2) { + sender.addChatMessage(new ChatComponentText("Incorrect arguments. Usage: " + getCommandUsage(sender))); + return; + } + + String action = args[0]; + String character = args[1]; + + if (action.equals("set")) { + if(args.length < 3) { + // Set character UUID to player UUID + sender.addChatMessage(new ChatComponentText("Incorrect arguments. Please specify player: " + getCommandUsage(sender))); + } else { + String player = args[2]; + EntityPlayerMP player_entity = MinecraftServer.getServer().getConfigurationManager().func_152612_a(player); + if (player_entity == null) { + sender.addChatMessage(new ChatComponentText("Invalid player name")); + } else { + sender.addChatMessage(new ChatComponentText("Setting player " + player_entity.getCommandSenderName() + " as " + character)); + CharacterRoleAPI.setCharacterRoleUUID(character, player_entity.getUniqueID()); + } + } + } else if (action.equals("remove")) { + UUID uuid = CharacterRoleAPI.getCharacterRoleUUID(character); + if (uuid == null) { + sender.addChatMessage(new ChatComponentText("Invalid character name")); + return; + } + + sender.addChatMessage(new ChatComponentText("Cleared player for character " + character)); + CharacterRoleAPI.removeCharacterRole(character); + } else if (action.equals("get")) { + UUID uuid = CharacterRoleAPI.getCharacterRoleUUID(character); + if (uuid == null) { + sender.addChatMessage(new ChatComponentText("Character " + character + " is unclaimed")); + return; + } + String player_name = Utilities.getPlayerByUUID(uuid).getCommandSenderName(); + if (player_name != null) { + sender.addChatMessage(new ChatComponentText("Character " + character + " is currently set to " + player_name)); + return; + } + sender.addChatMessage(new ChatComponentText("Character " + character + " is currently set to offline player " + uuid.toString())); + } else { + sender.addChatMessage(new ChatComponentText("Incorrect arguments. Usage: " + getCommandUsage(sender))); + return; + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/coremod/CoreMod.java b/src/src/main/java/com/zivilon/cinder_loe/coremod/CoreMod.java new file mode 100644 index 0000000..09716a8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/coremod/CoreMod.java @@ -0,0 +1,43 @@ +package com.zivilon.cinder_loe.coremod; + +import cpw.mods.fml.relauncher.IFMLLoadingPlugin; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions; +import org.spongepowered.asm.launch.MixinBootstrap; +import org.spongepowered.asm.mixin.Mixins; +import java.util.Map; + +@TransformerExclusions({"com.zivilon.cinder_loe.coremod"}) +@SortingIndex(1001) +@MCVersion("1.7.10") +public class CoreMod implements IFMLLoadingPlugin { + @Override + public String[] getASMTransformerClass() { + return new String[] {"com.zivilon.cinder_loe.coremod.LOTRMaterialTransformer","com.zivilon.cinder_loe.coremod.DwarvenForgeTransformer","com.zivilon.cinder_loe.coremod.LOTRWeaponLinker", "com.zivilon.cinder_loe.coremod.LOTRBannerAdder", "com.zivilon.cinder_loe.coremod.LOTRSpawnListLinker", "com.zivilon.cinder_loe.coremod.OptiFinePatcher"}; + } + + @Override + public String getModContainerClass() { + // Return the class name of your @Mod class + return null; + } + + @Override + public String getSetupClass() { + // Return the class name that sets up coremod environment, or null if none + return null; + } + + @Override + public void injectData(Map data) { + MixinBootstrap.init(); + Mixins.addConfiguration("mixins.cinder_loe.json"); + } + + @Override + public String getAccessTransformerClass() { + // Return the class name of your access transformer or null if none + return null; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRBannerAdder.java b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRBannerAdder.java new file mode 100644 index 0000000..4f08720 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRBannerAdder.java @@ -0,0 +1,168 @@ +package com.zivilon.cinder_loe.coremod; + +import net.minecraft.launchwrapper.IClassTransformer; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.IntInsnNode; +import org.objectweb.asm.tree.TypeInsnNode; +import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.LdcInsnNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; + +import java.util.List; +import java.util.ArrayList; + +public class LOTRBannerAdder implements IClassTransformer { + public static List custom_banners = new ArrayList<>(); + + public void registerBanners() { + custom_banners = new ArrayList<>(); + // Arguments: enum name, texture name, ID, faction name +// register("RED_DWARF", "redDwarf", 42, "DURINS_FOLK"); +// register("TEST", "test", 43, "GONDOR"); + + // NOT FUNCTIONAL, DO NOT REGISTER + // Non-compliant clients crash if original banner is unrecognized even if fallback is vanilla + // Most likely something in PacketEntityMetadata + } + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + if ("lotr.common.item.LOTRItemBanner$BannerType".equals(transformedName)) { + registerBanners(); + + // Get class + ClassReader classReader = new ClassReader(basicClass); + ClassNode classNode = new ClassNode(); + classReader.accept(classNode, 0); + + + // Add the new enum constant + for (BannerInfo banner : custom_banners) { + FieldNode newEnumConstant = new FieldNode( + Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL + Opcodes.ACC_ENUM, + banner.enum_name, + "Llotr/common/item/LOTRItemBanner$BannerType;", + null, + null + ); + classNode.fields.add(newEnumConstant); + } + + + // Locate + MethodNode clinit = null; + for (MethodNode method : classNode.methods) { + if ("".equals(method.name)) { + clinit = method; + break; + } + } + + InsnList insns = clinit.instructions; + AbstractInsnNode constructor_injection_point = null; + + for (int i = 0; i < insns.size(); i++) { + AbstractInsnNode insn = insns.get(i); + // Check if the instruction is a BIPUSH + if (insn.getOpcode() == Opcodes.BIPUSH) { + IntInsnNode intInsn = (IntInsnNode) insn; + // Check if the operand is 42, indicating the size of the $VALUES array + if (intInsn.operand == 42) { + // Found the instruction to modify + constructor_injection_point = insn; + // Modify the operand from 42 to 43 to account for the new enum constant + intInsn.operand = 42 + custom_banners.size(); + System.out.println("Enum array length set to " + intInsn.operand); + System.out.println("Banner list size: " + custom_banners.size()); + break; + } + } + } + + // Create the constructor instructions to add new banner + InsnList constructor_injection = new InsnList(); + for (BannerInfo banner : custom_banners) { + constructor_injection.add(new TypeInsnNode(Opcodes.NEW, "lotr/common/item/LOTRItemBanner$BannerType")); + constructor_injection.add(new InsnNode(Opcodes.DUP)); + System.out.println("Registering with enum " + banner.enum_name); + constructor_injection.add(new LdcInsnNode(banner.enum_name)); + System.out.println("Registering with ordinal " + banner.ordinal); + constructor_injection.add(new IntInsnNode(Opcodes.BIPUSH, banner.ordinal)); + constructor_injection.add(new IntInsnNode(Opcodes.BIPUSH, banner.ordinal)); + System.out.println("Registering with identifier " + banner.identifier); + constructor_injection.add(new LdcInsnNode(banner.identifier)); + constructor_injection.add(new FieldInsnNode(Opcodes.GETSTATIC, "lotr/common/fac/LOTRFaction", banner.faction, "Llotr/common/fac/LOTRFaction;")); + constructor_injection.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "lotr/common/item/LOTRItemBanner$BannerType", "", "(Ljava/lang/String;IILjava/lang/String;Llotr/common/fac/LOTRFaction;)V", false)); + constructor_injection.add(new FieldInsnNode(Opcodes.PUTSTATIC, "lotr/common/item/LOTRItemBanner$BannerType", banner.enum_name, "Llotr/common/item/LOTRItemBanner$BannerType;")); + } + // Insert the new instructions + if (constructor_injection_point != null) { + insns.insertBefore(constructor_injection_point, constructor_injection); + } + + + // Modifying the $VALUES array + // Create new instruction list to be injected later + InsnList values_array_injection = new InsnList(); + + // Add instructions to the instruction list + for (BannerInfo banner : custom_banners) { + values_array_injection.add(new InsnNode(Opcodes.DUP)); + values_array_injection.add(new IntInsnNode(Opcodes.BIPUSH, banner.ordinal)); + values_array_injection.add(new FieldInsnNode(Opcodes.GETSTATIC, "lotr/common/item/LOTRItemBanner$BannerType", banner.enum_name, "Llotr/common/item/LOTRItemBanner$BannerType;")); + values_array_injection.add(new InsnNode(Opcodes.AASTORE)); + } + + // Find the putstatic instruction for $VALUES + // This is where the fields are injected into a list, we want to inject our instructions before this + AbstractInsnNode values_injection_point = null; + + while (constructor_injection_point != null) { + constructor_injection_point = constructor_injection_point.getNext(); + if (constructor_injection_point.getOpcode() == Opcodes.PUTSTATIC) { + values_injection_point = constructor_injection_point; + break; + } + } + + // Insert the new instructions before the putstatic instruction + if (values_injection_point != null) { + insns.insertBefore(values_injection_point, values_array_injection); + } + + // Write the modified class back to a byte array + ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + classNode.accept(classWriter); + return classWriter.toByteArray(); // Return the modified class + } + return basicClass; // Return the unmodified class for all other classes + } + + public void register(String enum_name, String identifier, int ordinal, String faction) { + System.out.println("Registering banner " + enum_name + " " + identifier); + custom_banners.add(new BannerInfo(enum_name, identifier, ordinal, faction)); + } + + public class BannerInfo { + String enum_name; + String identifier; + int ordinal; + String faction; + + public BannerInfo(String enum_name, String identifier, int ordinal, String faction) { + this.enum_name = enum_name; + this.identifier = identifier; + this.ordinal = ordinal; + this.faction = faction; + } + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRMaterialTransformer.java b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRMaterialTransformer.java new file mode 100644 index 0000000..9552328 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRMaterialTransformer.java @@ -0,0 +1,52 @@ +package com.zivilon.cinder_loe.coremod; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; + +public class LOTRMaterialTransformer implements IClassTransformer { + @Override + public byte[] transform(String name, String transformedName, byte[] classBytes) { + if (transformedName.equals("lotr.common.item.LOTRMaterial")) { + System.out.println("[CinderLoE] Transforming LOTRMaterial..."); + + ClassReader reader = new ClassReader(classBytes); + ClassNode classNode = new ClassNode(); + reader.accept(classNode, 0); + + // Add the RED_DWARF_STEEL field + addMaterial("RED_DWARF", classNode); + addMaterial("WIZARD", classNode); + addMaterial("LIMWAITH_BONE", classNode); + addMaterial("BONEMOLD", classNode); + addMaterial("LIMWAITH_WOOD", classNode); + addMaterial("EVENT", classNode); + addMaterial("BREE", classNode); + addMaterial("BATTLENUN", classNode); + addMaterial("ASH", classNode); + + // Convert your ClassNode back to byte array with ClassWriter + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + classNode.accept(writer); + + byte[] transformedBytes = writer.toByteArray(); + return transformedBytes; + } + return classBytes; + } + + public void addMaterial(String fieldName, ClassNode classNode) { + FieldNode field = new FieldNode( + Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, + fieldName, + "Llotr/common/item/LOTRMaterial;", // Adjust the descriptor based on the actual package name + null, + null + ); + classNode.fields.add(field); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRSpawnListLinker.java b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRSpawnListLinker.java new file mode 100644 index 0000000..917b82f --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRSpawnListLinker.java @@ -0,0 +1,49 @@ +package com.zivilon.cinder_loe.coremod; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; + +public class LOTRSpawnListLinker implements IClassTransformer { + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + if ("lotr.common.world.spawning.LOTRSpawnList".equals(transformedName)) { + System.out.println("[CinderLoE] Linking CinderLoE spawn-lists to LOTRMod..."); + return addLinks(basicClass, "RED_DWARF", "LIMWAITH"); // Can add any number of items, append with comma + } + return basicClass; + } + + private byte[] addLinks(byte[] classBytes, String... fieldNames) { + ClassReader reader = new ClassReader(classBytes); + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + + reader.accept(new ClassVisitor(Opcodes.ASM5, writer) { + @Override + public void visitEnd() { + // Add each field specified in the fieldNames array + for (String fieldName : fieldNames) { + addSpawnListLink(fieldName, cv); + } + super.visitEnd(); + } + }, 0); + + return writer.toByteArray(); + } + + private void addSpawnListLink(String fieldName, ClassVisitor cv) { + // Define the field with public static access, name from the parameter, and type net.minecraft.item.Item + FieldVisitor fv = cv.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, fieldName, "Llotr/common/world/spawning/LOTRSpawnList;", null, null); + if (fv != null) { + fv.visitEnd(); + } + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java new file mode 100644 index 0000000..e8c43ef --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java @@ -0,0 +1,58 @@ +package com.zivilon.cinder_loe.coremod; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; + +public class LOTRWeaponLinker implements IClassTransformer { + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + if ("lotr.common.LOTRMod".equals(transformedName)) { + System.out.println("[CinderLoE] Linking CinderLoE items to LOTRMod..."); + + // Can add any number of items, append with comma + return addLinks(basicClass, + "spearRedDwarf", "crossbowRedDwarf", "swordRedDwarf", "battleaxeRedDwarf", "pikeRedDwarf", "daggerRedDwarf", "daggerRedDwarfPoisoned", "hammerRedDwarf", + "radagastStaff", "alatarStaff", "pallandoStaff", "sarumanStaff", + "spearLimwaith", "tridentLimwaith", "daggerLimwaith", "daggerLimwaithPoisoned", "truncheonLimwaith", "battleaxeLimwaith", "blowgunLimwaith", + "frostblade", "spearsolidgold", "whip", + "swordBree", + "maceArnor", + "daggerAsh","bowAsh","hammerAsh","pikeAsh","battleaxeAsh","swordAsh","spearAsh"); + } + return basicClass; + } + + private byte[] addLinks(byte[] classBytes, String... fieldNames) { + ClassReader reader = new ClassReader(classBytes); + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + + reader.accept(new ClassVisitor(Opcodes.ASM5, writer) { + @Override + public void visitEnd() { + // Add each field specified in the fieldNames array + for (String fieldName : fieldNames) { + addItemLink(fieldName, cv); + } + super.visitEnd(); + } + }, 0); + + return writer.toByteArray(); + } + + private void addItemLink(String fieldName, ClassVisitor cv) { + // Define the field with public static access, name from the parameter, and type net.minecraft.item.Item + FieldVisitor fv = cv.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, fieldName, "Lnet/minecraft/item/Item;", null, null); + if (fv != null) { + fv.visitEnd(); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/coremod/OptiFinePatcher.java b/src/src/main/java/com/zivilon/cinder_loe/coremod/OptiFinePatcher.java new file mode 100644 index 0000000..46d83c5 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/coremod/OptiFinePatcher.java @@ -0,0 +1,130 @@ +package com.zivilon.cinder_loe.coremod; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.LdcInsnNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.util.Printer; +import org.objectweb.asm.util.Textifier; +import org.objectweb.asm.util.TraceMethodVisitor; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Iterator; + +import net.minecraft.launchwrapper.IClassTransformer; + +public class OptiFinePatcher implements IClassTransformer { + @Override + public byte[] transform(String name, String transformedName, byte[] classBytes) { + if (transformedName.equals("ItemRendererOF")) { + System.out.println("[CinderLoE] Transforming ItemRendererOF..."); + + ClassReader reader = new ClassReader(classBytes); + ClassNode classNode = new ClassNode(); + reader.accept(classNode, 0); + + for (MethodNode method : classNode.methods) { + if (method.name.equals("func_78443_a") && method.desc.equals("(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;I)V")) { + InsnList instructions = method.instructions; + AbstractInsnNode currentNode = null; + Iterator nodes = instructions.iterator(); + + int occurrenceCounter = 0; + + while (nodes.hasNext()) { + currentNode = nodes.next(); + + if (currentNode.getOpcode() == Opcodes.INVOKESTATIC) { + MethodInsnNode methodCall = (MethodInsnNode) currentNode; + if (methodCall.owner.equals("ItemRendererOF") && methodCall.name.equals("func_78439_a") && methodCall.desc.equals("(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) { + occurrenceCounter++; + + InsnNode bool = null; + + if (occurrenceCounter == 1) { + bool = new InsnNode(Opcodes.ICONST_0); + instructions.insertBefore(currentNode, bool); + MethodInsnNode newMethodCall = new MethodInsnNode(Opcodes.INVOKESTATIC, "com/zivilon/cinder_loe/client/render/item/RenderHelper", "customRenderItemIn2D", "(Lnet/minecraft/client/renderer/Tessellator;FFFFIIFZ)V", false); + instructions.set(currentNode, newMethodCall); + } + + if (occurrenceCounter == 2) { + bool = new InsnNode(Opcodes.ICONST_1); + instructions.insertBefore(currentNode, bool); + MethodInsnNode newMethodCall = new MethodInsnNode(Opcodes.INVOKESTATIC, "com/zivilon/cinder_loe/client/render/item/RenderHelper", "customRenderItemIn2D", "(Lnet/minecraft/client/renderer/Tessellator;FFFFIIFZ)V", false); + instructions.set(currentNode, newMethodCall); + } + + // Modify only the second occurrence + if (occurrenceCounter == 3) { + bool = new InsnNode(Opcodes.ICONST_1); + instructions.insertBefore(currentNode, bool); + MethodInsnNode newMethodCall = new MethodInsnNode(Opcodes.INVOKESTATIC, "com/zivilon/cinder_loe/client/render/item/RenderHelper", "customRenderItemIn2D", "(Lnet/minecraft/client/renderer/Tessellator;FFFFIIFZ)V", false); + instructions.set(currentNode, newMethodCall); + break; + } + } + } + } + // Color code here + int index = -1; + + for (int i = 0; i < instructions.size(); i++) { + currentNode = instructions.get(i); + if (currentNode.getOpcode() == Opcodes.LDC && ((LdcInsnNode) currentNode).cst.equals(0.7599999904632568f)) { + System.out.println("[CinderLoE-Coremod] Found Optifine code to remove..."); + index = i; + break; + } + } + + if (index != -1) { + for (int i = 0; i < 15; i++) { + AbstractInsnNode targetNode = instructions.get(index); + System.out.println(insnToString(targetNode)); + instructions.remove(targetNode); + } + + InsnList toInject = new InsnList(); + toInject.add(new FieldInsnNode(Opcodes.GETSTATIC, "com/zivilon/cinder_loe/CinderLoE_Config", "enchantment_color_red", "F")); + toInject.add(new FieldInsnNode(Opcodes.GETSTATIC, "com/zivilon/cinder_loe/CinderLoE_Config", "enchantment_color_green", "F")); + toInject.add(new FieldInsnNode(Opcodes.GETSTATIC, "com/zivilon/cinder_loe/CinderLoE_Config", "enchantment_color_blue", "F")); + toInject.add(new InsnNode(Opcodes.FCONST_1)); + toInject.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "org/lwjgl/opengl/GL11", "glColor4f", "(FFFF)V", false)); + + instructions.insertBefore(instructions.get(index), toInject); + break; + } + } + } + + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + classNode.accept(writer); // Liine 104 + + byte[] transformedBytes = writer.toByteArray(); + return transformedBytes; + } + return classBytes; + } + + // Method to convert an instruction node to string + public static String insnToString(AbstractInsnNode insn){ + insn.accept(new TraceMethodVisitor(new Textifier())); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + Textifier textifier = new Textifier(); + TraceMethodVisitor tmv = new TraceMethodVisitor(textifier); + insn.accept(tmv); + textifier.print(pw); + return sw.toString(); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorBannerBearer.java b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorBannerBearer.java new file mode 100644 index 0000000..bd73ba8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorBannerBearer.java @@ -0,0 +1,23 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.entity.npc.LOTRBannerBearer; +import lotr.common.item.LOTRItemBanner; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class ArnorBannerBearer extends ArnorSoldier implements LOTRBannerBearer { + public ArnorBannerBearer(World world) { + super(world); + } + @Override + public LOTRItemBanner.BannerType getBannerType() { + return LOTRItemBanner.BannerType.RANGER_NORTH; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.ArnorSoldierSpawnEgg, 1); + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorCaptain.java b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorCaptain.java new file mode 100644 index 0000000..7f892f0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorCaptain.java @@ -0,0 +1,74 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRCapes; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.entity.npc.LOTRUnitTradeEntries; +import lotr.common.entity.npc.LOTRUnitTradeable; +import lotr.common.world.spawning.LOTRInvasions; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class ArnorCaptain extends ArnorSoldier implements LOTRUnitTradeable { + public ArnorCaptain(World world) { + super(world); + addTargetTasks(false); + this.npcCape = LOTRCapes.RANGER; + } + + public float getAlignmentBonus() { + return 5.0F; + } + + public LOTRUnitTradeEntries getUnits() { + return CinderLoE.ARNOR_CAPTAIN; + } + + public LOTRInvasions getWarhorn() { + return LOTRInvasions.RANGER_NORTH; + } + + public void onUnitTrade(EntityPlayer entityplayer) { + } + + public boolean canTradeWith(EntityPlayer entityplayer) { + return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 150.0F && isFriendlyAndAligned(entityplayer)); + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.ArnorCaptainSpawnEgg, 1); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = rand.nextInt(4); + if (i == 0) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.swordArnor)); + } else if (i == 1 || i == 2) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.daggerArnor)); + } else if (i == 3 || i == 4) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearArnor)); + } + if (rand.nextInt(4) == 0) { + this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon()); + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearArnor)); + } + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(LOTRMod.bootsArnor)); + setCurrentItemOrArmor(2, new ItemStack(LOTRMod.legsArnor)); + setCurrentItemOrArmor(3, new ItemStack(LOTRMod.bodyArnor)); + setCurrentItemOrArmor(4, null); + return data; + } + public String getSpeechBank(EntityPlayer entityplayer) { + if (isFriendlyAndAligned(entityplayer)) { + return "arnorSoldier/captain/friendly"; + } + return "arnorSoldier/captain/neutral"; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorSoldier.java b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorSoldier.java new file mode 100644 index 0000000..e9aeda5 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorSoldier.java @@ -0,0 +1,95 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.npc.LOTREntityDunedain; +import lotr.common.entity.npc.LOTREntityDwarfWarrior; +import lotr.common.LOTRMod; +import lotr.common.LOTRShields; +import lotr.common.entity.npc.LOTREntityGondorSoldier; +import lotr.common.fac.LOTRFaction; +import lotr.common.quest.LOTRMiniQuest; +import lotr.common.quest.LOTRMiniQuestFactory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.CinderLoE; + +public class ArnorSoldier extends LOTREntityDunedain { + public ArnorSoldier(World world) { + super(world); + this.npcShield = LOTRShields.ALIGNMENT_RANGER; + } + + @Override + public void setupNPCGender() { + this.familyInfo.setMale(true); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = rand.nextInt(4); + if (i == 0) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.swordArnor)); + } else if (i == 1 || i == 2) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.swordArnor)); + } else if (i == 3 || i == 4) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearArnor)); + } + if (rand.nextInt(4) == 0) { + this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon()); + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.spearArnor)); + } + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(LOTRMod.bootsArnor)); + setCurrentItemOrArmor(2, new ItemStack(LOTRMod.legsArnor)); + setCurrentItemOrArmor(3, new ItemStack(LOTRMod.bodyArnor)); + setCurrentItemOrArmor(4, new ItemStack(LOTRMod.helmetArnor)); + return data; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.ArnorSoldierSpawnEgg, 1); + } + @Override + public LOTRFaction getFaction() { + return LOTRFaction.RANGER_NORTH; + } + + @Override + public float getAlignmentBonus() { + return 2.0f; + } + + public String getSpeechBank(EntityPlayer entityplayer) { + if (isFriendlyAndAligned(entityplayer)) { + if (this.hiredNPCInfo.getHiringPlayer() == entityplayer) + return "arnorSoldier/soldier/hired"; + return "arnorSoldier/soldier/friendly"; + } + return "arnorSoldier/soldier/hostile"; + } + + @Override + public LOTRMiniQuest createMiniQuest() { + if (rand.nextInt(8) == 0) { + return LOTRMiniQuestFactory.RANGER_NORTH_ARNOR_RELIC.createQuest(this); + } + return LOTRMiniQuestFactory.RANGER_NORTH.createQuest(this); + } + + @Override + public LOTRMiniQuestFactory getBountyHelpSpeechDir() { + return LOTRMiniQuestFactory.RANGER_NORTH; + } + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorSoldierArcher.java b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorSoldierArcher.java new file mode 100644 index 0000000..91f964a --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/ArnorSoldierArcher.java @@ -0,0 +1,54 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRMod; +import lotr.common.LOTRShields; +import lotr.common.entity.ai.LOTREntityAIRangedAttack; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.projectile.LOTREntityDart; +import lotr.common.item.LOTRItemBlowgun; +import lotr.common.item.LOTRItemDart; +import net.minecraft.entity.*; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class ArnorSoldierArcher extends ArnorSoldier { + + public ArnorSoldierArcher(World world) { + super(world); + this.spawnRidingHorse = false; + ((EntityLiving)this).tasks.addTask(0, (EntityAIBase)new LOTREntityAIRangedAttack(this, 1.3, 30, 50, 16.0f)); + this.npcShield = null; + } + + @Override + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setRangedWeapon(new ItemStack(LOTRMod.rangerBow)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getRangedWeapon()); + return data; + } + + @Override + protected void onAttackModeChange(LOTREntityNPC.AttackMode mode, boolean mounted) { + if (mode == LOTREntityNPC.AttackMode.IDLE) { + this.setCurrentItemOrArmor(0, this.npcItemsInv.getIdleItem()); + } else { + this.setCurrentItemOrArmor(0, this.npcItemsInv.getRangedWeapon()); + } + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase target, float f) { + npcArrowAttack(target, f); + } + @Override + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + this.dropNPCArrows(i); + } +} + diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/BattleNun.java b/src/src/main/java/com/zivilon/cinder_loe/entity/BattleNun.java new file mode 100644 index 0000000..6b767bd --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/BattleNun.java @@ -0,0 +1,49 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRAchievement; +import lotr.common.LOTRShields; +import lotr.common.entity.npc.LOTREntityDunedain; +import lotr.common.entity.npc.LOTREntityMoredain; +import lotr.common.entity.npc.LOTRNPCMount; +import lotr.common.quest.LOTRMiniQuest; +import lotr.common.quest.LOTRMiniQuestFactory; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BattleNun extends ArnorSoldier { + public BattleNun(World world) { + super(world); + this.spawnRidingHorse = false; + this.questInfo.setOfferChance(4000); + this.questInfo.setMinAlignment(150.0f); + this.npcShield = null; + } + + @Override + public void setupNPCGender() { + this.familyInfo.setMale(false); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.maceArnor)); + this.npcItemsInv.setIdleItem(new ItemStack(CinderLoE.maceArnor)); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsArnorBanner)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsArnorBanner)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyArnorBanner)); + if (this.rand.nextBoolean()) { + this.setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetArnorBanner)); + } else { + this.setCurrentItemOrArmor(4, null); + } + return data; + } + + @Override + public LOTRMiniQuest createMiniQuest() { + return LOTRMiniQuestFactory.RANGER_NORTH.createQuest(this); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/BreeCaptain.java b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeCaptain.java new file mode 100644 index 0000000..1d4239e --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeCaptain.java @@ -0,0 +1,64 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRAchievement; +import lotr.common.LOTRCapes; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.entity.npc.LOTRUnitTradeEntries; +import lotr.common.entity.npc.LOTRUnitTradeable; +import lotr.common.item.LOTRItemLeatherHat; +import lotr.common.world.spawning.LOTRInvasions; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class BreeCaptain extends BreeSoldier implements LOTRUnitTradeable { + public BreeCaptain(World world) { + super(world); + addTargetTasks(false); + this.npcCape = LOTRCapes.RANGER; + } + @Override + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setIdleItem(new ItemStack(Items.writable_book)); + ItemStack hat = new ItemStack(LOTRMod.leatherHat); + LOTRItemLeatherHat.setHatColor(hat, 6834742); + LOTRItemLeatherHat.setFeatherColor(hat, 40960); + this.setCurrentItemOrArmor(4, hat); + return data; + } + public float getAlignmentBonus() { + return 5.0F; + } + + public LOTRUnitTradeEntries getUnits() { + return CinderLoE.BREE_CAPTAIN; + } + + public LOTRInvasions getWarhorn() { + return LOTRInvasions.BREE; + } + + public void onUnitTrade(EntityPlayer entityplayer) { + LOTRLevelData.getData(entityplayer).addAchievement(LOTRAchievement.tradeBreeCaptain); + } + + public boolean canTradeWith(EntityPlayer entityplayer) { + return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 150.0F && isFriendlyAndAligned(entityplayer)); + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.BreeCaptainSpawnEgg, 1); + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/BreeCrossbowman.java b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeCrossbowman.java new file mode 100644 index 0000000..6f6af37 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeCrossbowman.java @@ -0,0 +1,53 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRMod; +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.ai.LOTREntityAIRangedAttack; +import lotr.common.entity.npc.LOTREntityNPC; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class BreeCrossbowman extends BreeSoldier { + + public BreeCrossbowman(World world) { + super(world); + this.npcShield = null; + } + + protected int addBreeAttackAI(int prio) { + ((EntityLiving)this).tasks.addTask(prio, (EntityAIBase)new LOTREntityAIRangedAttack(this, 1.25, 30, 50, 16.0f)); + return prio; + } + + @Override + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setRangedWeapon(new ItemStack(LOTRMod.ironCrossbow)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getRangedWeapon()); + return data; + } + + @Override + protected void onAttackModeChange(LOTREntityNPC.AttackMode mode, boolean mounted) { + if (mode == LOTREntityNPC.AttackMode.IDLE) { + this.setCurrentItemOrArmor(0, this.npcItemsInv.getIdleItem()); + } else { + this.setCurrentItemOrArmor(0, this.npcItemsInv.getRangedWeapon()); + } + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float f) { + npcCrossbowAttack(target, f); + } + + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + dropNPCCrossbowBolts(i); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/BreeOutrider.java b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeOutrider.java new file mode 100644 index 0000000..7a0eaa0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeOutrider.java @@ -0,0 +1,94 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRCapes; +import lotr.common.LOTRMod; +import lotr.common.LOTRShields; +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.ai.LOTREntityAIRangedAttack; +import lotr.common.entity.animal.LOTREntityHorse; +import lotr.common.entity.npc.LOTREntityGondorSoldier; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.npc.LOTRNPCMount; +import lotr.common.fac.LOTRFaction; +import lotr.common.quest.LOTRMiniQuest; +import lotr.common.quest.LOTRMiniQuestFactory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class BreeOutrider extends BreeCrossbowman { + protected EntityAIBase rangedAttackAI = this.createBreeRangedAttackAI(); + protected EntityAIBase meleeAttackAI; + public BreeOutrider(World world) { + super(world); + this.addTargetTasks(true); + this.npcCape = LOTRCapes.RANGER; + this.spawnRidingHorse = true; + this.npcShield = LOTRShields.ALIGNMENT_BREE; + } + protected EntityAIBase createBreeRangedAttackAI() { + return new LOTREntityAIRangedAttack(this, 1.25, 30, 40, 16.0f); + } + protected EntityAIBase addBreeAttackAI() { + return new LOTREntityAIAttackOnCollide(this, 1.45D, true); + } + + @Override + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + return data; + } + + @Override + public void onAttackModeChange(LOTREntityNPC.AttackMode mode, boolean mounted) { + if (this.rangedAttackAI == null) System.out.println("Ranged attack AI is null"); + if (this.meleeAttackAI == null) System.out.println("Melee attack AI is null"); + if (mode == LOTREntityNPC.AttackMode.IDLE) { + ((EntityLiving)this).tasks.removeTask(this.meleeAttackAI); + ((EntityLiving)this).tasks.removeTask(this.rangedAttackAI); + this.setCurrentItemOrArmor(0, this.npcItemsInv.getIdleItem()); + } + if (mode == LOTREntityNPC.AttackMode.MELEE) { + ((EntityLiving)this).tasks.removeTask(this.meleeAttackAI); + ((EntityLiving)this).tasks.removeTask(this.rangedAttackAI); + ((EntityLiving)this).tasks.addTask(2, this.meleeAttackAI); + this.setCurrentItemOrArmor(0, this.npcItemsInv.getMeleeWeapon()); + } + if (mode == LOTREntityNPC.AttackMode.RANGED) { + ((EntityLiving)this).tasks.removeTask(this.meleeAttackAI); + ((EntityLiving)this).tasks.removeTask(this.rangedAttackAI); + ((EntityLiving)this).tasks.addTask(2, this.rangedAttackAI); + this.setCurrentItemOrArmor(0, this.npcItemsInv.getRangedWeapon()); + } + } + + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.BreeOutriderSpawnEgg, 1); + } + @Override + public LOTRNPCMount createMountToRide() { + LOTREntityHorse horse = (LOTREntityHorse)super.createMountToRide(); + horse.setMountArmor(new ItemStack(LOTRMod.horseArmorIron)); + return horse; + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float f) { + npcCrossbowAttack(target, f); + } + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + dropNPCCrossbowBolts(i); + } + @Override + public float getAlignmentBonus() { + return 3.0f; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/BreeSoldier.java b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeSoldier.java new file mode 100644 index 0000000..f38af2b --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeSoldier.java @@ -0,0 +1,30 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRMod; +import lotr.common.entity.npc.LOTREntityBreeGuard; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BreeSoldier extends LOTREntityBreeGuard { + private static ItemStack[] guardWeapons = new ItemStack[]{new ItemStack(CinderLoE.swordBree), new ItemStack(CinderLoE.swordBree), new ItemStack(LOTRMod.pikeIron)}; + + public BreeSoldier(World world) { + super(world); + this.spawnRidingHorse = false; + } + + @Override + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = (rand.nextInt(guardWeapons.length)); + this.npcItemsInv.setMeleeWeapon(guardWeapons[i].copy()); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsBree)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsBree)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyBree)); + setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetBree)); + return data; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/BreeSoldierBannerBearer.java b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeSoldierBannerBearer.java new file mode 100644 index 0000000..00b21b8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/BreeSoldierBannerBearer.java @@ -0,0 +1,22 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.npc.LOTRBannerBearer; +import lotr.common.item.LOTRItemBanner; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.World; + +public class BreeSoldierBannerBearer extends BreeSoldier implements LOTRBannerBearer { + public BreeSoldierBannerBearer(World world) { + super(world); + } + @Override + public LOTRItemBanner.BannerType getBannerType() { + return LOTRItemBanner.BannerType.BREE; + } + + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/FangornAnimal.java b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornAnimal.java new file mode 100644 index 0000000..e13fc52 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornAnimal.java @@ -0,0 +1,85 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRAchievement; +import lotr.common.LOTRFoods; +import lotr.common.LOTRMod; +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.ai.LOTREntityAIFollowHiringPlayer; +import lotr.common.entity.ai.LOTREntityAIHiredRemainStill; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.fac.LOTRFaction; +import lotr.common.quest.LOTRMiniQuest; +import lotr.common.quest.LOTRMiniQuestFactory; +import lotr.common.world.LOTRWorldChunkManager; +import lotr.common.world.biome.LOTRBiome; +import lotr.common.world.biome.variant.LOTRBiomeVariant; +import lotr.common.world.structure.LOTRChestContents; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIOpenDoor; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.EntityAIWatchClosest2; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; + +public abstract class FangornAnimal extends LOTREntityNPC { + public FangornAnimal(World world) { + super(world); + setSize(1.6F, 1.8F); + getNavigator().setAvoidsWater(true); + ((EntityLiving)this).tasks.addTask(0, (EntityAIBase)new EntityAISwimming((EntityLiving)this)); + ((EntityLiving)this).tasks.addTask(1, (EntityAIBase)new LOTREntityAIHiredRemainStill(this)); + ((EntityLiving)this).tasks.addTask(2, (EntityAIBase)new LOTREntityAIAttackOnCollide(this, 1.6D, false)); + ((EntityLiving)this).tasks.addTask(3, (EntityAIBase)new LOTREntityAIFollowHiringPlayer(this)); + ((EntityLiving)this).tasks.addTask(4, (EntityAIBase)new EntityAIWander(this, 1.0D)); + ((EntityLiving)this).tasks.addTask(5, (EntityAIBase)new EntityAIWatchClosest2((EntityLiving)this, EntityPlayer.class, 8.0F, 0.02F)); + ((EntityLiving)this).tasks.addTask(6, (EntityAIBase)new EntityAIWatchClosest2((EntityLiving)this, LOTREntityNPC.class, 5.0F, 0.02F)); + ((EntityLiving)this).tasks.addTask(7, (EntityAIBase)new EntityAIWatchClosest((EntityLiving)this, EntityLiving.class, 8.0F, 0.02F)); + ((EntityLiving)this).tasks.addTask(8, (EntityAIBase)new EntityAILookIdle((EntityLiving)this)); + addTargetTasks(true); + } + + public boolean canWorldGenSpawnAt(int i, int j, int k, LOTRBiome biome, LOTRBiomeVariant variant) { + int trees = biome.decorator.getVariantTreesPerChunk(variant); + return (trees >= 1); + } + + public LOTRFaction getFaction() { + return LOTRFaction.FANGORN; + } + + public float getAlignmentBonus() { + return 0.0F; + } + + public boolean getCanSpawnHere() { + WorldChunkManager worldChunkMgr = ((Entity)this).worldObj.getWorldChunkManager(); + if (worldChunkMgr instanceof LOTRWorldChunkManager) { + int i = MathHelper.floor_double(((Entity)this).posX); + int j = MathHelper.floor_double(((Entity)this).boundingBox.minY); + int k = MathHelper.floor_double(((Entity)this).posZ); + LOTRBiome biome = (LOTRBiome)((Entity)this).worldObj.getBiomeGenForCoords(i, k); + LOTRBiomeVariant variant = ((LOTRWorldChunkManager)worldChunkMgr).getBiomeVariantAt(i, k); + return (super.getCanSpawnHere() && canWorldGenSpawnAt(i, j, k, biome, variant)); + } + return super.getCanSpawnHere(); + } + + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/FangornAuroch.java b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornAuroch.java new file mode 100644 index 0000000..4bc6a30 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornAuroch.java @@ -0,0 +1,79 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import net.minecraft.util.MovingObjectPosition; + +import java.util.List; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.entity.FangornAnimal; + +public class FangornAuroch extends FangornAnimal { + public FangornAuroch(World world) { + super(world); + setSize(1.5F, 1.7F); + } + + public void entityInit() { + super.entityInit(); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D); + getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(8.0D); + } + + public boolean attackEntityAsMob(Entity entity) { + float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + return entity.attackEntityFrom(DamageSource.causeMobDamage((EntityLivingBase)this), f); + } + + protected void dropFewItems(boolean flag, int i) { + int hides = 2 + rand.nextInt(3) + rand.nextInt(1 + i); + for (int l = 0; l < hides; l++) + dropItem(Items.leather, 1); + int meats = 2 + rand.nextInt(3) + rand.nextInt(1 + i); + for (int j = 0; j < meats; j++) { + if (isBurning()) { + dropItem(Items.cooked_beef, 1); + } else { + dropItem(Items.beef, 1); + } + } + dropItem(LOTRMod.horn, 1); + } + + protected String getLivingSound() { + return "lotr:aurochs.say"; + } + + protected String getHurtSound() { + return "lotr:aurochs.hurt"; + } + + protected String getDeathSound() { + return "lotr:aurochs.hurt"; + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { + // No ranged attack implemented + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.fangornAurochSpawnEgg, 1); + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/FangornBear.java b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornBear.java new file mode 100644 index 0000000..8ab23b0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornBear.java @@ -0,0 +1,148 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import lotr.common.entity.animal.LOTREntityBear; +import lotr.common.entity.animal.LOTREntityBear.BearType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import java.util.List; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.entity.FangornAnimal; + +public class FangornBear extends FangornAnimal { + public FangornBear(World world) { + super(world); + setSize(1.6F, 1.8F); + } + private int hostileTick = 0; + + public void entityInit() { + super.entityInit(); + dataWatcher.addObject(18, Byte.valueOf((byte)0)); + dataWatcher.addObject(20, Byte.valueOf((byte)0)); + setBearType(LOTREntityBear.BearType.forID(rand.nextInt((BearType.values()).length))); + } + + public BearType getBearType() { + int i = dataWatcher.getWatchableObjectByte(18); + return BearType.forID(i); + } + + public void setBearType(BearType t) { + dataWatcher.updateObject(18, Byte.valueOf((byte)t.bearID)); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D); + getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(8.0D); + } + + public static class BearGroupSpawnData implements IEntityLivingData { + private BearGroupSpawnData() {} + + public int numSpawned = 0; + } + + public boolean attackEntityAsMob(Entity entity) { + float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + return entity.attackEntityFrom(DamageSource.causeMobDamage((EntityLivingBase)this), f); + } + public boolean attackEntityFrom(DamageSource damagesource, float f) { + boolean flag = super.attackEntityFrom(damagesource, f); + if (flag) { + Entity attacker = damagesource.getEntity(); + if (attacker instanceof EntityLivingBase) + if (isChild()) { + double range = 12.0D; + List list = ((Entity)this).worldObj.getEntitiesWithinAABBExcludingEntity((Entity)this, ((Entity)this).boundingBox.expand(range, range, range)); + for (Object obj : list) { + Entity entity = (Entity)obj; + if (entity instanceof FangornBear) { + FangornBear bear = (FangornBear)entity; + if (!bear.isChild()) + bear.becomeAngryAt((EntityLivingBase)attacker); + } + } + } else { + becomeAngryAt((EntityLivingBase)attacker); + } + } + return flag; + } + + private void becomeAngryAt(EntityLivingBase entity) { + setAttackTarget(entity); + this.hostileTick = 200; + } + + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setByte("BearType", (byte)(getBearType()).bearID); + nbt.setInteger("Angry", this.hostileTick); + } + + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + if (nbt.hasKey("BearType")) + setBearType(BearType.forID(nbt.getByte("BearType"))); + this.hostileTick = nbt.getInteger("Angry"); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + if (data == null) { + data = new BearGroupSpawnData(); + ((BearGroupSpawnData)data).numSpawned = 1; + } else if (data instanceof BearGroupSpawnData) { + BearGroupSpawnData bgsd = (BearGroupSpawnData)data; + bgsd.numSpawned++; + } + if (rand.nextInt(10000) == 0) setCustomNameTag("Wojtek"); + return data; + } + + protected void dropFewItems(boolean flag, int i) { + int furs = 1 + rand.nextInt(3) + rand.nextInt(i + 1); + for (int l = 0; l < furs; l++) + dropItem(LOTRMod.fur, 1); + if (flag) { + int rugChance = 30 - i * 5; + rugChance = Math.max(rugChance, 1); + if (rand.nextInt(rugChance) == 0) + entityDropItem(new ItemStack(LOTRMod.bearRug, 1, (getBearType()).bearID), 0.0F); + } + } + protected String getLivingSound() { + return "lotr:bear.say"; + } + + protected String getHurtSound() { + return "lotr:bear.hurt"; + } + + protected String getDeathSound() { + return "lotr:bear.death"; + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { + // No ranged attack implemented + } + + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.fangornBearSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/FangornElk.java b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornElk.java new file mode 100644 index 0000000..aff8ddc --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornElk.java @@ -0,0 +1,83 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import java.util.List; +import java.util.UUID; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.entity.FangornAnimal; + +public class FangornElk extends FangornAnimal { + public FangornElk(World world) { + super(world); + setSize(1.6F, 1.8F); + } + + public void entityInit() { + super.entityInit(); + } + + public void setUniqueID(UUID uuid) { + entityUniqueID = uuid; + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(35.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D); + getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(8.0D); + } + + public boolean attackEntityAsMob(Entity entity) { + float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + return entity.attackEntityFrom(DamageSource.causeMobDamage((EntityLivingBase)this), f); + } + + protected void dropFewItems(boolean flag, int i) { + int hide = rand.nextInt(3) + rand.nextInt(1 + i); + for (int l = 0; l < hide; l++) + dropItem(Items.leather, 1); + int meat = rand.nextInt(3) + rand.nextInt(1 + i); + for (int j = 0; j < meat; j++) { + if (isBurning()) { + dropItem(LOTRMod.deerCooked, 1); + } else { + dropItem(LOTRMod.deerRaw, 1); + } + } + } + + protected String getLivingSound() { + return "lotr:elk.say"; + } + + protected String getHurtSound() { + return "lotr:elk.hurt"; + } + + protected String getDeathSound() { + return "lotr:elk.death"; + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { + // No ranged attack implemented + } + + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.fangornElkSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/FangornWildBoar.java b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornWildBoar.java new file mode 100644 index 0000000..239ec53 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornWildBoar.java @@ -0,0 +1,74 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import java.util.List; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.entity.FangornAnimal; + +public class FangornWildBoar extends FangornAnimal { + public FangornWildBoar(World world) { + super(world); + setSize(0.9F, 0.8F); + } + + public void entityInit() { + super.entityInit(); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D); + getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(8.0D); + } + + public boolean attackEntityAsMob(Entity entity) { + float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + return entity.attackEntityFrom(DamageSource.causeMobDamage((EntityLivingBase)this), f); + } + + protected void dropFewItems(boolean flag, int i) { + int meat = rand.nextInt(3) + 1 + rand.nextInt(1 + i); + for (int l = 0; l < meat; l++) { + if (isBurning()) { + dropItem(Items.cooked_porkchop, 1); + } else { + dropItem(Items.porkchop, 1); + } + } + } + protected String getLivingSound() { + return "mob.pig.say"; + } + + protected String getHurtSound() { + return "mob.pig.say"; + } + + protected String getDeathSound() { + return "mob.pig.death"; + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { + // No ranged attack implemented + } + + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.fangornWildBoarSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/FangornWolf.java b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornWolf.java new file mode 100644 index 0000000..a71243e --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/FangornWolf.java @@ -0,0 +1,70 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +import java.util.List; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.entity.FangornAnimal; + +public class FangornWolf extends FangornAnimal { + public FangornWolf(World world) { + super(world); + setSize(0.6F, 0.8F); + } + + public void entityInit() { + super.entityInit(); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); + } + + public boolean attackEntityAsMob(Entity entity) { + float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + return entity.attackEntityFrom(DamageSource.causeMobDamage((EntityLivingBase)this), f); + } + + protected void dropFewItems(boolean flag, int i) { + int meat = rand.nextInt(3) + 1 + rand.nextInt(1 + i); + for (int l = 0; l < meat; l++) { + if (isBurning()) { + dropItem(Items.cooked_porkchop, 1); + } else { + dropItem(Items.porkchop, 1); + } + } + } + protected String getLivingSound() { + return "mob.wolf.growl"; + } + + protected String getHurtSound() { + return "mob.wolf.hurt"; + } + + protected String getDeathSound() { + return "mob.wolf.death"; + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { + // No ranged attack implemented + } + + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/Limwaith.java b/src/src/main/java/com/zivilon/cinder_loe/entity/Limwaith.java new file mode 100644 index 0000000..8c7bad8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/Limwaith.java @@ -0,0 +1,70 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.npc.LOTREntityMoredain; +import lotr.common.entity.npc.LOTRNPCMount; +import lotr.common.LOTRAchievement; +import lotr.common.LOTRFoods; +import lotr.common.LOTRMod; +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.ai.LOTREntityAIDrink; +import lotr.common.entity.ai.LOTREntityAIEat; +import lotr.common.entity.ai.LOTREntityAIFollowHiringPlayer; +import lotr.common.entity.ai.LOTREntityAIHiredRemainStill; +import lotr.common.entity.animal.LOTREntityZebra; +import lotr.common.fac.LOTRFaction; +import lotr.common.quest.LOTRMiniQuest; +import lotr.common.quest.LOTRMiniQuestFactory; +import lotr.common.world.structure.LOTRChestContents; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIOpenDoor; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.EntityAIWatchClosest2; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import com.zivilon.cinder_loe.CinderLoE; + +public class Limwaith extends LOTREntityMoredain { + public Limwaith(World world) { + super(world); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.daggerLimwaith)); + this.npcItemsInv.setIdleItem(null); + return data; + } + + protected LOTRAchievement getKillAchievement() { + return null; + } + + public LOTRNPCMount createMountToRide() { + return null; +// return (LOTRNPCMount)new LimwaithCrocodile(((Entity)this).worldObj); + } + + public String getSpeechBank(EntityPlayer entityplayer) { + if (isFriendlyAndAligned(entityplayer)) { + if (this.hiredNPCInfo.getHiringPlayer() == entityplayer) + return "limwaith/moredain/hired"; + return "limwaith/moredain/friendly"; + } + return "limwaith/moredain/hostile"; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBannerBearer.java b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBannerBearer.java new file mode 100644 index 0000000..a7645da --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBannerBearer.java @@ -0,0 +1,24 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.npc.LOTRBannerBearer; +import lotr.common.item.LOTRItemBanner; +import net.minecraft.world.World; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.item.ItemStack; + +import com.zivilon.cinder_loe.entity.LimwaithWarrior; +import com.zivilon.cinder_loe.CinderLoE; + +public class LimwaithBannerBearer extends LimwaithWarrior implements LOTRBannerBearer { + public LimwaithBannerBearer(World world) { + super(world); + } + + public LOTRItemBanner.BannerType getBannerType() { + return LOTRItemBanner.BannerType.MOREDAIN; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.limwaithBannerBearerSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBlowgunner.java b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBlowgunner.java new file mode 100644 index 0000000..3b1f43b --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBlowgunner.java @@ -0,0 +1,74 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import lotr.common.entity.ai.LOTREntityAIRangedAttack; +import lotr.common.entity.projectile.LOTREntityDart; +import lotr.common.item.LOTRItemBlowgun; +import lotr.common.item.LOTRItemDart; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.entity.Limwaith; + +public class LimwaithBlowgunner extends Limwaith { + public LimwaithBlowgunner(World world) { + super(world); + } + + public EntityAIBase createHaradrimAttackAI() { + return (EntityAIBase)new LOTREntityAIRangedAttack(this, 1.5D, 10, 30, 16.0F); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(24.0D); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.blowgunLimwaith)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsLimwaith)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsLimwaith)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyLimwaith)); + return data; + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float f) { + ItemStack heldItem = getHeldItem(); + float str = 1.0F + getDistanceToEntity((Entity)target) / 16.0F * 0.015F; + str *= LOTRItemBlowgun.getBlowgunLaunchSpeedFactor(heldItem); + LOTREntityDart dart = ((LOTRItemDart)LOTRMod.tauredainDart).createDart(((Entity)this).worldObj, (EntityLivingBase)this, target, new ItemStack(LOTRMod.tauredainDart), str, 1.0F); + if (heldItem != null) + LOTRItemBlowgun.applyBlowgunModifiers(dart, heldItem); + playSound("lotr:item.dart", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 1.2F) + 0.5F); + ((Entity)this).worldObj.spawnEntityInWorld((Entity)dart); + } + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + dropNPCAmmo(LOTRMod.tauredainDart, i); + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.limwaithBlowgunnerSpawnEgg, 1); + } + +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBoneWarrior.java b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBoneWarrior.java new file mode 100644 index 0000000..7d00cfb --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithBoneWarrior.java @@ -0,0 +1,46 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRShields; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class LimwaithBoneWarrior extends Limwaith { + public LimwaithBoneWarrior(World world) { + super(world); + this.npcShield = LOTRShields.ALIGNMENT_MOREDAIN; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = rand.nextInt(6); + if (i == 0) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.truncheonLimwaith)); + } else if (i == 1 || i == 2) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.tridentLimwaith)); + } else if (i == 3 || i == 4) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearLimwaith)); + } else { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.battleaxeLimwaith)); + } + + if (rand.nextInt(6) == 0) { + this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon()); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearLimwaith)); + } + + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsboneLimwaith)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsboneLimwaith)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyboneLimwaith)); + if (rand.nextInt(10) != 0) + setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetboneLimwaith)); + return data; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.limwaithBoneWarriorSpawnEgg, 1); + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithChieftain.java b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithChieftain.java new file mode 100644 index 0000000..b3d0823 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithChieftain.java @@ -0,0 +1,62 @@ +package com.zivilon.cinder_loe.entity; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.world.World; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; + +import lotr.common.LOTRLevelData; +import lotr.common.entity.npc.LOTRUnitTradeable; +import lotr.common.entity.npc.LOTRUnitTradeEntries; +import lotr.common.world.spawning.LOTRInvasions; + +import com.zivilon.cinder_loe.entity.LimwaithWarrior; +import com.zivilon.cinder_loe.CinderLoE; + +public class LimwaithChieftain extends LimwaithBoneWarrior implements LOTRUnitTradeable { + public LimwaithChieftain(World world) { + super(world); + addTargetTasks(false); + } + + public float getAlignmentBonus() { + return 5.0F; + } + + public LOTRUnitTradeEntries getUnits() { + return CinderLoE.LIMWAITH_COMMANDER; + } + + public LOTRInvasions getWarhorn() { + return LOTRInvasions.MOREDAIN; + } + + public void onUnitTrade(EntityPlayer entityplayer) { + } + @Override + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.truncheonLimwaith)); + + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsboneLimwaith)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsboneLimwaith)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyboneLimwaith)); + setCurrentItemOrArmor(4, null); + return data; + } + public boolean canTradeWith(EntityPlayer entityplayer) { + return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 150.0F && isFriendlyAndAligned(entityplayer)); + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.limwaithChieftainSpawnEgg, 1); + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithFishmonger.java b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithFishmonger.java new file mode 100644 index 0000000..e1b61d8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithFishmonger.java @@ -0,0 +1,69 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.entity.npc.LOTREntityDwarf; +import lotr.common.entity.npc.LOTRTradeEntries; +import lotr.common.entity.npc.LOTRTradeEntries.TradeType; +import lotr.common.entity.npc.LOTRTradeEntry; +import lotr.common.entity.npc.LOTRTradeable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import static lotr.common.entity.npc.LOTRTradeEntries.HARAD_FISHMONGER_BUY; +import static lotr.common.entity.npc.LOTRTradeEntries.HARAD_FISHMONGER_SELL; + +public class LimwaithFishmonger extends Limwaith implements LOTRTradeable { + + public LimwaithFishmonger(World world) { + super(world); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.tridentLimwaith)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + return data; + } + + public LOTRTradeEntries getBuyPool() { + return HARAD_FISHMONGER_BUY; + } + + public LOTRTradeEntries getSellPool() { + return HARAD_FISHMONGER_SELL; + } + + public float getAlignmentBonus() { + return 2.0F; + } + + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + dropItem(getLimwaithTraderDrop(), 1 + rand.nextInt(3) + rand.nextInt(i + 1)); + } + protected Item getLimwaithTraderDrop() { + return LOTRMod.pearl; + } + + public boolean canTradeWith(EntityPlayer entityplayer) { + return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 100.0F && isFriendlyAndAligned(entityplayer)); + } + + @Override + public void onPlayerTrade(EntityPlayer entityplayer, TradeType type, ItemStack itemstack) { + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + } + + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithShaman.java b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithShaman.java new file mode 100644 index 0000000..d5b0b96 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithShaman.java @@ -0,0 +1,113 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRFoods; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.entity.npc.LOTREntityDwarf; +import lotr.common.entity.npc.LOTRTradeEntries; +import lotr.common.entity.npc.LOTRTradeEntries.TradeType; +import lotr.common.entity.npc.LOTRTradeEntry; +import lotr.common.entity.npc.LOTRTradeable; +import lotr.common.item.LOTRItemMug; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class LimwaithShaman extends Limwaith implements LOTRTradeable.Smith { + public static LOTRTradeEntries LIMWAITH_SHAMAN_BUY; + public static LOTRTradeEntries LIMWAITH_SHAMAN_SELL; + + public LimwaithShaman(World world) { + super(world); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.daggerLimwaithPoisoned)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + return data; + } + + public LOTRTradeEntries getBuyPool() { + return LIMWAITH_SHAMAN_BUY; + } + + public LOTRTradeEntries getSellPool() { + return LIMWAITH_SHAMAN_SELL; + } + + public float getAlignmentBonus() { + return 2.0F; + } + + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + dropItem(getLimwaithTraderDrop(), 1 + rand.nextInt(2) + rand.nextInt(i + 1)); + } + + public boolean canTradeWith(EntityPlayer entityplayer) { + return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 100.0F && isFriendlyAndAligned(entityplayer)); + } + + + static { + LIMWAITH_SHAMAN_BUY = new LOTRTradeEntries(TradeType.BUY, + new LOTRTradeEntry(new ItemStack(CinderLoE.daggerLimwaith), 12), + new LOTRTradeEntry(new ItemStack(CinderLoE.daggerLimwaithPoisoned), 20), + new LOTRTradeEntry(new ItemStack(CinderLoE.blowgunLimwaith), 25), + new LOTRTradeEntry(new ItemStack(LOTRMod.tauredainDart, 4), 5), + new LOTRTradeEntry(new ItemStack(LOTRMod.tauredainDartPoisoned, 4), 10), + new LOTRTradeEntry(new ItemStack(CinderLoE.bonemold, 2), 4), + new LOTRTradeEntry(new ItemStack(Items.bone, 1), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.bottlePoison), 10)); + + LIMWAITH_SHAMAN_SELL = new LOTRTradeEntries(TradeType.SELL, + new LOTRTradeEntry(new ItemStack(Items.gold_nugget), 2), + new LOTRTradeEntry(new ItemStack(LOTRMod.emerald), 15), + new LOTRTradeEntry(new ItemStack(LOTRMod.amber), 10), + new LOTRTradeEntry(new ItemStack(Items.glass_bottle), 2), + new LOTRTradeEntry(new ItemStack(LOTRMod.mug), 1), + new LOTRTradeEntry(new ItemStack(Items.bone), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.rhinoHorn), 5), + new LOTRTradeEntry(new ItemStack(Items.dye, 3, 15), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.gemsbokHorn), 4), + new LOTRTradeEntry(new ItemStack(LOTRMod.doubleFlower, 2, 2), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.doubleFlower, 2, 3), 1), + new LOTRTradeEntry(new ItemStack(Blocks.red_mushroom, 1, 0), 2), + new LOTRTradeEntry(new ItemStack(Blocks.brown_mushroom, 1, 0), 2), + new LOTRTradeEntry(new ItemStack(CinderLoE.bonemold, 2), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.mango), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.banana), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.corn, 2), 1)); + } + + @Override + public void onPlayerTrade(EntityPlayer entityplayer, TradeType type, ItemStack itemstack) { + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + } + + protected Item getLimwaithTraderDrop() { + return LOTRMod.pearl; + } + + @Override + public String getSpeechBank(EntityPlayer entityplayer) { + if (this.isFriendlyAndAligned(entityplayer)) { + if (this.canTradeWith(entityplayer)) { + return "limwaith/shaman/friendly"; + } + return "limwaith/shaman/neutral"; + } + return "limwaith/shaman/hostile"; + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithWarrior.java b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithWarrior.java new file mode 100644 index 0000000..981dfcc --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/LimwaithWarrior.java @@ -0,0 +1,86 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.npc.LOTREntityMoredain; +import lotr.common.entity.npc.LOTRNPCMount; +import lotr.common.LOTRAchievement; +import lotr.common.LOTRFoods; +import lotr.common.LOTRMod; +import lotr.common.LOTRShields; +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.ai.LOTREntityAIDrink; +import lotr.common.entity.ai.LOTREntityAIEat; +import lotr.common.entity.ai.LOTREntityAIFollowHiringPlayer; +import lotr.common.entity.ai.LOTREntityAIHiredRemainStill; +import lotr.common.entity.animal.LOTREntityZebra; +import lotr.common.fac.LOTRFaction; +import lotr.common.quest.LOTRMiniQuest; +import lotr.common.quest.LOTRMiniQuestFactory; +import lotr.common.world.structure.LOTRChestContents; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIOpenDoor; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.EntityAIWatchClosest2; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.entity.Limwaith; + +public class LimwaithWarrior extends Limwaith { + public LimwaithWarrior(World world) { + super(world); + this.npcShield = LOTRShields.ALIGNMENT_MOREDAIN; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = rand.nextInt(7); + if (i == 0) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.truncheonLimwaith)); + } else if (i == 1 || i == 2) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.tridentLimwaith)); + } else if (i == 3 || i == 4) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearLimwaith)); + } else if (i == 5) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.battleaxeLimwaith)); + } else if (i == 6) { + if (rand.nextInt(2) == 0) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.daggerLimwaith)); + } else { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.daggerLimwaithPoisoned)); + } + } + + if (rand.nextInt(6) == 0) { + this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon()); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearLimwaith)); + } + + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsLimwaith)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsLimwaith)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyLimwaith)); + if (rand.nextInt(10) != 0) + setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetLimwaith)); + return data; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.limwaithWarriorSpawnEgg, 1); + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfArbalest.java b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfArbalest.java new file mode 100644 index 0000000..775b33b --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfArbalest.java @@ -0,0 +1,46 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.npc.LOTREntityDwarfAxeThrower; +import lotr.common.LOTRMod; +import lotr.common.entity.ai.LOTREntityAIRangedAttack; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.init.Items; +import net.minecraft.util.MovingObjectPosition; + +import com.zivilon.cinder_loe.CinderLoE; + +public class RedDwarfArbalest extends LOTREntityDwarfAxeThrower { + public RedDwarfArbalest(World world) { + super(world); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = rand.nextInt(5); + this.npcItemsInv.setRangedWeapon(new ItemStack(CinderLoE.crossbowRedDwarf)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getRangedWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsRedDwarf)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsRedDwarf)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyRedDwarf)); + setCurrentItemOrArmor(4, null); + if (rand.nextInt(10) != 0) + setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetRedDwarf)); + return data; + } + public void attackEntityWithRangedAttack(EntityLivingBase target, float f) { + npcCrossbowAttack(target, f); + } + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + dropNPCCrossbowBolts(i); + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.redDwarfArbalestSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfBannerBearer.java b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfBannerBearer.java new file mode 100644 index 0000000..7df9cff --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfBannerBearer.java @@ -0,0 +1,25 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import lotr.common.item.LOTRItemBanner; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import lotr.common.entity.npc.LOTRBannerBearer; +import net.minecraft.util.MovingObjectPosition; + +import com.zivilon.cinder_loe.CinderLoE; + +public class RedDwarfBannerBearer extends RedDwarfWarrior implements LOTRBannerBearer { + public RedDwarfBannerBearer(World world) { + super(world); + } + + public LOTRItemBanner.BannerType getBannerType() { + return LOTRItemBanner.BannerType.DWARF; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.redDwarfBannerBearerSpawnEgg, 1); + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfCommander.java b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfCommander.java new file mode 100644 index 0000000..dfba8a2 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfCommander.java @@ -0,0 +1,51 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.LOTRMod; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import lotr.common.entity.npc.LOTREntityDwarfCommander; +import lotr.common.entity.npc.LOTRUnitTradeable; +import lotr.common.entity.npc.LOTRUnitTradeEntries; +import net.minecraft.util.MovingObjectPosition; + +import com.zivilon.cinder_loe.CinderLoE; + +public class RedDwarfCommander extends LOTREntityDwarfCommander implements LOTRUnitTradeable { + public RedDwarfCommander(World world) { + super(world); + addTargetTasks(false); + } + + public LOTRUnitTradeEntries getUnits() { + return CinderLoE.RED_DWARF_COMMANDER; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = rand.nextInt(5); + if (i == 0) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.swordRedDwarf)); + } else if (i == 1 || i == 2) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.battleaxeRedDwarf)); + } else if (i == 3 || i == 4) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearRedDwarf)); + } + if (rand.nextInt(6) == 0) { + this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon()); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearRedDwarf)); + } + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsRedDwarf)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsRedDwarf)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyRedDwarf)); + setCurrentItemOrArmor(4, null); + if (rand.nextInt(10) != 0) + setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetRedDwarf)); + return data; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.redDwarfCommanderSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfSmith.java b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfSmith.java new file mode 100644 index 0000000..a02002d --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfSmith.java @@ -0,0 +1,127 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.npc.LOTRTradeEntries; +import lotr.common.entity.npc.LOTRTradeEntries.TradeType; +import lotr.common.entity.npc.LOTRTradeable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; +import lotr.common.LOTRMod; +import lotr.common.fac.LOTRFaction; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Item; +import lotr.common.entity.npc.LOTRTradeEntry; +import net.minecraft.init.Items; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import lotr.common.LOTRLevelData; +import lotr.common.entity.npc.LOTREntityDwarf; + +import com.zivilon.cinder_loe.CinderLoE; + +public class RedDwarfSmith extends LOTREntityDwarf implements LOTRTradeable.Smith { + public static LOTRTradeEntries RED_DWARF_SMITH_BUY; + public static LOTRTradeEntries RED_DWARF_SMITH_SELL; + + public RedDwarfSmith(World world) { + super(world); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.blacksmithHammer)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + return data; + } + + public LOTRTradeEntries getBuyPool() { + return RED_DWARF_SMITH_BUY; + } + + public LOTRTradeEntries getSellPool() { + return RED_DWARF_SMITH_SELL; + } + + public float getAlignmentBonus() { + return 2.0F; + } + + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + dropItem(getDwarfSteelDrop(), 1 + rand.nextInt(3) + rand.nextInt(i + 1)); + } + + public boolean canTradeWith(EntityPlayer entityplayer) { + return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 100.0F && isFriendlyAndAligned(entityplayer)); + } + + static { + RED_DWARF_SMITH_BUY = new LOTRTradeEntries(TradeType.BUY, + new LOTRTradeEntry[] { + new LOTRTradeEntry(new ItemStack(LOTRMod.dwarvenTable), 100), + new LOTRTradeEntry(new ItemStack(LOTRMod.blacksmithHammer), 18), + new LOTRTradeEntry(new ItemStack(LOTRMod.dwarvenRing), 20), + new LOTRTradeEntry(new ItemStack(CinderLoE.swordRedDwarf), 16), + new LOTRTradeEntry(new ItemStack(CinderLoE.spearRedDwarf), 18), + new LOTRTradeEntry(new ItemStack(CinderLoE.battleaxeRedDwarf), 18), + new LOTRTradeEntry(new ItemStack(CinderLoE.hammerRedDwarf), 18), + new LOTRTradeEntry(new ItemStack(CinderLoE.pikeRedDwarf), 18), + new LOTRTradeEntry(new ItemStack(CinderLoE.daggerRedDwarf), 13), + new LOTRTradeEntry(new ItemStack(CinderLoE.crossbowRedDwarf), 15), + new LOTRTradeEntry(new ItemStack(CinderLoE.helmetRedDwarf), 25), + new LOTRTradeEntry(new ItemStack(CinderLoE.bodyRedDwarf), 36), + new LOTRTradeEntry(new ItemStack(CinderLoE.legsRedDwarf), 30), + new LOTRTradeEntry(new ItemStack(CinderLoE.bootsRedDwarf), 22), + new LOTRTradeEntry(new ItemStack(CinderLoE.boarArmorRedDwarf), 25), + new LOTRTradeEntry(new ItemStack(CinderLoE.barsRedDwarf, 8), 20) + } + ); + + RED_DWARF_SMITH_SELL = new LOTRTradeEntries(TradeType.SELL, + new LOTRTradeEntry[] { + new LOTRTradeEntry(new ItemStack(Items.iron_ingot), 3), + new LOTRTradeEntry(new ItemStack(CinderLoE.redDwarfSteel), 3), + new LOTRTradeEntry(new ItemStack(Items.coal, 2, 32767), 1), + new LOTRTradeEntry(new ItemStack(Items.gold_ingot), 15), + new LOTRTradeEntry(new ItemStack(LOTRMod.copper), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.tin), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.bronze), 3), + new LOTRTradeEntry(new ItemStack(Items.string, 3), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.diamond), 25), + new LOTRTradeEntry(new ItemStack(LOTRMod.emerald), 15), + new LOTRTradeEntry(new ItemStack(LOTRMod.sapphire), 12), + new LOTRTradeEntry(new ItemStack(LOTRMod.ruby), 12), + new LOTRTradeEntry(new ItemStack(LOTRMod.opal), 10), + new LOTRTradeEntry(new ItemStack(LOTRMod.amber), 10), + new LOTRTradeEntry(new ItemStack(LOTRMod.amethyst), 8), + new LOTRTradeEntry(new ItemStack(LOTRMod.topaz), 8), + new LOTRTradeEntry(new ItemStack(LOTRMod.pearl), 25), + new LOTRTradeEntry(new ItemStack(Items.cooked_beef), 3), + new LOTRTradeEntry(new ItemStack(Items.cooked_porkchop), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.muttonCooked), 3), + new LOTRTradeEntry(new ItemStack(Items.cooked_chicken), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.gammon), 3), + new LOTRTradeEntry(new ItemStack(Items.cooked_fished), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.rabbitCooked), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.deerCooked), 3), + new LOTRTradeEntry(new ItemStack(Items.bread), 2), + new LOTRTradeEntry(new ItemStack(Items.lava_bucket), 16) + + } + ); + } + + @Override + public void onPlayerTrade(EntityPlayer entityplayer, LOTRTradeEntries.TradeType type, ItemStack itemstack) { + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + } + + @Override + protected Item getDwarfSteelDrop() { + return CinderLoE.redDwarfSteel; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfWarrior.java b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfWarrior.java new file mode 100644 index 0000000..d423e4d --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/RedDwarfWarrior.java @@ -0,0 +1,55 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.npc.LOTREntityDwarfWarrior; +import lotr.common.LOTRMod; +import lotr.common.LOTRShields; +import net.minecraft.entity.Entity; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraft.item.Item; + +import com.zivilon.cinder_loe.CinderLoE; + +public class RedDwarfWarrior extends LOTREntityDwarfWarrior { + public RedDwarfWarrior(World world) { + super(world); + this.npcShield = LOTRShields.ALIGNMENT_DWARF; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + int i = rand.nextInt(6); + if (i == 0) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.swordRedDwarf)); + } else if (i == 1 || i == 2) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.battleaxeRedDwarf)); + } else if (i == 3 || i == 4) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.pikeRedDwarf)); + } else if (i == 5) { + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.hammerRedDwarf)); + } + if (rand.nextInt(6) == 0) { + this.npcItemsInv.setSpearBackup(this.npcItemsInv.getMeleeWeapon()); + this.npcItemsInv.setMeleeWeapon(new ItemStack(CinderLoE.spearRedDwarf)); + } + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + setCurrentItemOrArmor(1, new ItemStack(CinderLoE.bootsRedDwarf)); + setCurrentItemOrArmor(2, new ItemStack(CinderLoE.legsRedDwarf)); + setCurrentItemOrArmor(3, new ItemStack(CinderLoE.bodyRedDwarf)); + setCurrentItemOrArmor(4, null); + if (rand.nextInt(10) != 0) + setCurrentItemOrArmor(4, new ItemStack(CinderLoE.helmetRedDwarf)); + return data; + } + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.redDwarfWarriorSpawnEgg, 1); + } + + @Override + protected Item getDwarfSteelDrop() { + return CinderLoE.redDwarfSteel; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/Renegade.java b/src/src/main/java/com/zivilon/cinder_loe/entity/Renegade.java new file mode 100644 index 0000000..dc67a5f --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/Renegade.java @@ -0,0 +1,193 @@ +package com.zivilon.cinder_loe.entity; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIOpenDoor; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.EntityAIWatchClosest2; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import lotr.common.LOTRFoods; +import lotr.common.LOTRMod; +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.ai.LOTREntityAIDrink; +import lotr.common.entity.ai.LOTREntityAIEat; +import lotr.common.entity.ai.LOTREntityAIFollowHiringPlayer; +import lotr.common.entity.ai.LOTREntityAIHiredRemainStill; +import lotr.common.entity.animal.LOTREntityHorse; +import lotr.common.entity.npc.LOTREntityMan; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.npc.LOTRNPCMount; +import lotr.common.entity.npc.LOTRNames; +import lotr.common.fac.LOTRFaction; + +import com.zivilon.cinder_loe.CinderLoE; + +public class Renegade extends LOTREntityMan { + + public Renegade(World world) { + super(world); + setSize(0.6F, 1.8F); + getNavigator().setAvoidsWater(true); + getNavigator().setBreakDoors(true); + ((EntityLiving) this).tasks.addTask(0, (EntityAIBase) new EntityAISwimming((EntityLiving) this)); + ((EntityLiving) this).tasks.addTask(1, (EntityAIBase) new LOTREntityAIHiredRemainStill(this)); + ((EntityLiving) this).tasks.addTask(2, (EntityAIBase) new LOTREntityAIAttackOnCollide(this, 1.3D, false)); + ((EntityLiving) this).tasks.addTask(3, (EntityAIBase) new LOTREntityAIFollowHiringPlayer(this)); + ((EntityLiving) this).tasks.addTask(4, (EntityAIBase) new EntityAIOpenDoor((EntityLiving) this, true)); + ((EntityLiving) this).tasks.addTask(6, (EntityAIBase) new LOTREntityAIEat(this, LOTRFoods.DUNLENDING, 8000)); + ((EntityLiving) this).tasks.addTask(6, (EntityAIBase) new LOTREntityAIDrink(this, LOTRFoods.DUNLENDING_DRINK, 8000)); + ((EntityLiving) this).tasks.addTask(7, (EntityAIBase) new EntityAIWatchClosest2((EntityLiving) this, EntityPlayer.class, 8.0F, 0.02F)); + ((EntityLiving) this).tasks.addTask(7, (EntityAIBase) new EntityAIWatchClosest2((EntityLiving) this, LOTREntityNPC.class, 5.0F, 0.02F)); + ((EntityLiving) this).tasks.addTask(8, (EntityAIBase) new EntityAIWatchClosest((EntityLiving) this, EntityLiving.class, 8.0F, 0.02F)); + ((EntityLiving) this).tasks.addTask(9, (EntityAIBase) new EntityAILookIdle((EntityLiving) this)); + addTargetTasks(true); + } + + public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { + // Do nothing + } + + public LOTRNPCMount createMountToRide() { + LOTREntityHorse horse = (LOTREntityHorse) super.createMountToRide(); + horse.setMountArmor(new ItemStack(LOTRMod.horseArmorIron)); + return (LOTRNPCMount) horse; + } + + public void setupNPCGender() { + this.familyInfo.setMale(this.rand.nextBoolean()); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D); + } + + public LOTRFaction getFaction() { + return LOTRFaction.UTUMNO; + } + + public String getNPCName() { + return this.familyInfo.getName(); + } + + public String getNPCFormattedName(String npcName, String entityName) { + if (getClass() == Renegade.class) return StatCollector + .translateToLocalFormatted("entity.cinder_loe.Renegade.entityName", new Object[] { npcName }); + return super.getNPCFormattedName(npcName, entityName); + } + + protected void onAttackModeChange(LOTREntityNPC.AttackMode mode, boolean mounted) { + if (mode == LOTREntityNPC.AttackMode.IDLE) { + setCurrentItemOrArmor(0, this.npcItemsInv.getIdleItem()); + } else { + setCurrentItemOrArmor(0, this.npcItemsInv.getMeleeWeapon()); + ((EntityLiving) this).tasks.addTask(5, (EntityAIBase) new EntityAIWander(this, 1.0D)); + } + } + + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + int bones = this.rand.nextInt(2) + this.rand.nextInt(i + 1); + for (int l = 0; l < bones; l++) dropItem(Items.bone, 1); + } + + public boolean getCanSpawnHere() { + return false; + } + + public String getSpeechBank(EntityPlayer entityplayer) { + if (isDrunkard()) return "renegade/drunkard/neutral"; + return "renegade/man/hostile"; + } + + List codeOptions = Arrays.asList(() -> { + this.familyInfo.setName(LOTRNames.getGondorName(this.rand, this.familyInfo.isMale())); + }, () -> { + this.familyInfo.setName(LOTRNames.getBreeName(this.rand, this.familyInfo.isMale())); + }, () -> { + this.familyInfo.setName(LOTRNames.getRhudaurName(this.rand, this.familyInfo.isMale())); + }, () -> { + this.familyInfo.setName(LOTRNames.getRohirricName(this.rand, this.familyInfo.isMale())); + }, + /* + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getDunlendingName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getDorwinionName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getDalishName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getRhunicName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getUmbarName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getHarnennorName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getSouthronCoastName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getNomadName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getGulfHaradName(this.rand, this.familyInfo.isMale())), + * } + * () -> { + * System.out.println("[CinderCore] Executing GondorName"); + * this.familyInfo.setName(LOTRNames.getMoredainName(this.rand, this.familyInfo.isMale())), + * } + */ + () -> { + this.familyInfo.setName(LOTRNames.getTauredainName(this.rand, this.familyInfo.isMale())); + }); + + public void setupNPCName() { + if (this.familyInfo == null) System.out.println("[CinderCore] Family info is null"); + if (this.rand == null) System.out.println("[CinderCore] rand is null"); + Boolean gender = this.familyInfo.isMale(); + if (gender == null) System.out.println("[CinderCore] Gender is null"); + /* + * int randomIndex = this.rand.nextInt(codeOptions.size()); + * codeOptions.get(randomIndex) + * .run();; + */ + this.familyInfo.setName(LOTRNames.getDorwinionName(this.rand, this.familyInfo.isMale())); + } + + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.renegadeSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/RenegadeCaptain.java b/src/src/main/java/com/zivilon/cinder_loe/entity/RenegadeCaptain.java new file mode 100644 index 0000000..36adb59 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/RenegadeCaptain.java @@ -0,0 +1,37 @@ +package com.zivilon.cinder_loe.entity; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRFoods; +import lotr.common.LOTRMod; +import lotr.common.entity.ai.*; +import lotr.common.entity.animal.LOTREntityHorse; +import lotr.common.entity.npc.LOTREntityMan; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.npc.LOTRNPCMount; +import lotr.common.entity.npc.LOTRNames; +import lotr.common.fac.LOTRFaction; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import java.util.Arrays; +import java.util.List; + +public class RenegadeCaptain extends Renegade { + + public RenegadeCaptain(World world) { + super(world); + } + + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.renegadeCaptainSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/SarumanFireball.java b/src/src/main/java/com/zivilon/cinder_loe/entity/SarumanFireball.java new file mode 100644 index 0000000..7f7fab7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/SarumanFireball.java @@ -0,0 +1,102 @@ +package com.zivilon.cinder_loe.entity; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; + +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.animal.LOTREntityHorse; +import lotr.common.entity.projectile.LOTREntityGandalfFireball; +import lotr.common.fac.LOTRFaction; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; + +public class SarumanFireball extends LOTREntityGandalfFireball { + public SarumanFireball(World world) { + super(world); + } + + public SarumanFireball(World world, EntityLivingBase entityliving) { + super(world, entityliving); + } + + public SarumanFireball(World world, double d, double d1, double d2) { + super(world, d, d1, d2); + } + + protected void onImpact(MovingObjectPosition m) { + if (!((Entity)this).worldObj.isRemote) + if (m.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + explode((Entity)null); + } else if (m.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) { + explode(m.entityHit); + } + } + + private void explode(Entity target) { + if (((Entity)this).worldObj.isRemote) + return; + ((Entity)this).worldObj.playSoundAtEntity((Entity)this, "lotr:item.gandalfFireball", 4.0F, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); + + List entities = ((Entity)this).worldObj.getEntitiesWithinAABB(EntityLiving.class, ((Entity)this).boundingBox.expand(6.0D, 6.0D, 6.0D)); + + if (!entities.isEmpty()) + for (int i = 0; i < entities.size(); i++) { + Entity entity = entities.get(i); + if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer) && !(entity instanceof LOTREntityHorse && ((LOTREntityHorse)entity).getBelongsToNPC() == true)) { + targetRandomEntity((EntityLiving)entity); + } + } + setDead(); + } + + public void targetRandomEntity(EntityLiving npc) { + LOTRFaction faction = null; + if (npc instanceof LOTREntityNPC) { + LOTREntityNPC lotrNpc = (LOTREntityNPC) npc; + faction = lotrNpc.getFaction(); + } + + // Define the search area based on the npc's location + IAttributeInstance followRangeAttribute = npc.getEntityAttribute(SharedMonsterAttributes.followRange); + double range = followRangeAttribute != null ? followRangeAttribute.getAttributeValue() : 12.0D; // Default to 12 if attribute is not found + + AxisAlignedBB searchArea = npc.boundingBox.expand(range, 4.0D, range); + + // Filter potential targets to not include hiring player or NPCs from same faction + List allTargets = npc.worldObj.getEntitiesWithinAABB(EntityLiving.class, searchArea); + List validTargets = new ArrayList<>(); + + for (EntityLiving potentialTarget : allTargets) { + Entity entity = (Entity)potentialTarget; // Because for some reason I can't directly check if EntityLiving is instance of EntityPlayer + if (entity != npc && + !(entity instanceof EntityPlayer) && + !(entity instanceof LOTREntityNPC && faction != null && ((LOTREntityNPC)entity).getFaction() == faction) && + !(entity instanceof LOTREntityHorse && ((LOTREntityHorse)entity).getBelongsToNPC() == true)) { + validTargets.add(potentialTarget); + } + } + + // Randomly select a new target from the filtered list + if (!validTargets.isEmpty()) { + EntityLiving newTarget = validTargets.get(npc.getRNG().nextInt(validTargets.size())); + npc.setAttackTarget(newTarget); // Set the new attack target + } + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/SpeechBankModifier.java b/src/src/main/java/com/zivilon/cinder_loe/entity/SpeechBankModifier.java new file mode 100644 index 0000000..30386ed --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/SpeechBankModifier.java @@ -0,0 +1,108 @@ +package com.zivilon.cinder_loe.entity; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import com.zivilon.cinder_loe.CinderLoE; + +import cpw.mods.fml.common.ModContainer; + +public class SpeechBankModifier { + + public static List loadSpeechLines(String speechBankName) { + String speechPath = "assets/cinder_loe/speech/" + speechBankName + ".txt"; + List lines = new ArrayList<>(); + ZipFile zip = null; + + try { + ModContainer modContainer = CinderLoE.getModContainer(); + zip = new ZipFile(modContainer.getSource()); + + Enumeration entries = zip.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + if (entry.getName() + .startsWith(speechPath) + && entry.getName() + .endsWith(".txt")) { + InputStream inputStream = zip.getInputStream(entry); + BufferedReader reader = new BufferedReader( + new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + + String line; + while ((line = reader.readLine()) != null) { + lines.add(line); + } + reader.close(); + } + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (zip != null) { + try { + zip.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return lines; + } + + public static Map> loadSpeechBanks() { + Map> speechBanks = new HashMap<>(); + speechBanks.put("renegade/man/hostile", loadSpeechLines("renegade/man/hostile")); + speechBanks.put("renegade/drunkard/neutral", loadSpeechLines("renegade/drunkard/neutral")); + speechBanks.put("limwaith/moredain/friendly", loadSpeechLines("limwaith/moredain/friendly")); + speechBanks.put("limwaith/moredain/hired", loadSpeechLines("limwaith/moredain/hired")); + speechBanks.put("limwaith/moredain/hostile", loadSpeechLines("limwaith/moredain/hostile")); + speechBanks.put("limwaith/chieftain/friendly", loadSpeechLines("limwaith/chieftain/friendly")); + speechBanks.put("limwaith/chieftain/neutral", loadSpeechLines("limwaith/chieftain/neutral")); + speechBanks.put("arnorSoldier/captain/friendly", loadSpeechLines("arnorSoldier/captain/friendly")); + speechBanks.put("arnorSoldier/captain/neutral", loadSpeechLines("arnorSoldier/captain/neutral")); + speechBanks.put("arnorSoldier/soldier/friendly", loadSpeechLines("arnorSoldier/soldier/friendly")); + speechBanks.put("arnorSoldier/soldier/hired", loadSpeechLines("arnorSoldier/soldier/hired")); + speechBanks.put("arnorSoldier/soldier/hostile", loadSpeechLines("arnorSoldier/soldier/hostile")); + return speechBanks; + } + + + public static void insertSpeechBanks() { + Map> speechBanks = loadSpeechBanks(); + + try { + Class lotrSpeechClass = Class.forName("lotr.common.entity.npc.LOTRSpeech"); + Class speechBankClass = Class.forName("lotr.common.entity.npc.LOTRSpeech$SpeechBank"); + + Constructor speechBankConstructor = speechBankClass.getDeclaredConstructor(String.class, boolean.class, List.class); + speechBankConstructor.setAccessible(true); + + Field allSpeechBanksField = lotrSpeechClass.getDeclaredField("allSpeechBanks"); + allSpeechBanksField.setAccessible(true); + + Map allSpeechBanks = (Map) allSpeechBanksField.get(null); + + for (Map.Entry> entry : speechBanks.entrySet()) { + Object speechBank = speechBankConstructor.newInstance(entry.getKey(), true, entry.getValue()); + allSpeechBanks.put(entry.getKey(), speechBank); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/UtumnoSlaveTrader.java b/src/src/main/java/com/zivilon/cinder_loe/entity/UtumnoSlaveTrader.java new file mode 100644 index 0000000..4d46daa --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/UtumnoSlaveTrader.java @@ -0,0 +1,160 @@ +package com.zivilon.cinder_loe.entity; + +import lotr.common.entity.ai.LOTREntityAIEat; +import lotr.common.entity.npc.LOTREntityMan; +import lotr.common.entity.npc.LOTRTradeEntries; +import lotr.common.entity.npc.LOTRTradeEntries.TradeType; +import lotr.common.entity.npc.LOTRTradeable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import lotr.common.LOTRFoods; +import lotr.common.LOTRMod; +import lotr.common.fac.LOTRFaction; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.item.ItemStack; +import lotr.common.entity.npc.LOTRTradeEntry; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.init.Items; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAIPanic; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIAvoidEntity; +import lotr.common.entity.ai.LOTREntityAIEat; +import lotr.common.entity.ai.LOTREntityAIDrink; +import net.minecraft.entity.ai.EntityAIWatchClosest2; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.EntityAILookIdle; +import lotr.common.entity.npc.LOTREntityNPC; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.util.StatCollector; +import net.minecraft.nbt.NBTTagCompound; + +public class UtumnoSlaveTrader extends LOTREntityMan implements LOTRTradeable.Smith { + public static LOTRTradeEntries UTUMNO_SLAVE_BUY; + public static LOTRTradeEntries UTUMNO_SLAVE_SELL; + + public boolean bound = true; + + public UtumnoSlaveTrader(World world) { + super(world); + setSize(0.6F, 1.8F); + ((EntityLiving)this).tasks.addTask(1, (EntityAIBase)new EntityAIPanic(this, 1.6D)); + ((EntityLiving)this).tasks.addTask(2, (EntityAIBase)new EntityAIWander(this, 1.0D)); + ((EntityLiving)this).tasks.addTask(3, (EntityAIBase)new EntityAIAvoidEntity(this, EntityPlayer.class, 12.0F, 1.5D, 1.8D)); + ((EntityLiving)this).tasks.addTask(4, (EntityAIBase)new LOTREntityAIEat(this, LOTRFoods.NURN_SLAVE, 8000)); + ((EntityLiving)this).tasks.addTask(4, (EntityAIBase)new LOTREntityAIDrink(this, LOTRFoods.NURN_SLAVE_DRINK, 8000)); + ((EntityLiving)this).tasks.addTask(5, (EntityAIBase)new EntityAIWatchClosest2((EntityLiving)this, EntityPlayer.class, 10.0F, 0.1F)); + ((EntityLiving)this).tasks.addTask(5, (EntityAIBase)new EntityAIWatchClosest2((EntityLiving)this, LOTREntityNPC.class, 5.0F, 0.05F)); + ((EntityLiving)this).tasks.addTask(6, (EntityAIBase)new EntityAIWatchClosest((EntityLiving)this, EntityLiving.class, 8.0F, 0.02F)); + ((EntityLiving)this).tasks.addTask(7, (EntityAIBase)new EntityAILookIdle((EntityLiving)this)); + addTargetTasks(false); + } + + public LOTRFaction getFaction() { + if (bound) return LOTRFaction.UTUMNO; + return LOTRFaction.UNALIGNED; + } + + @Override + public String getNPCFormattedName(String npcName, String entityName) { + if (bound) entityName = "entity.cinder_loe.UtumnoSlaveTrader.bound.name"; + return StatCollector.translateToLocal(entityName); + } + + public boolean interact(EntityPlayer entityplayer) { + boolean flag = super.interact(entityplayer); + if (bound) { + bound = false; + return false; + } + return flag; + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D); + } + + public boolean canTradeWith(EntityPlayer entityplayer) { + return !bound; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + data = super.onSpawnWithEgg(data); + this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.pouch)); + this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon()); + return data; + } + + public LOTRTradeEntries getBuyPool() { + return UTUMNO_SLAVE_BUY; + } + + public LOTRTradeEntries getSellPool() { + return UTUMNO_SLAVE_SELL; + } + + // Replace with correct speechbanks + public String getSpeechBank(EntityPlayer entityplayer) { + if (isFriendlyAndAligned(entityplayer)) { + if (canTradeWith(entityplayer)) + return "utumno/slaveTrader/friendly"; + return "utumno/slaveTrader/neutral"; + } + return "utumno/slaveTrader/hostile"; + } + + static { + UTUMNO_SLAVE_BUY = new LOTRTradeEntries(TradeType.BUY, + new LOTRTradeEntry[] { + new LOTRTradeEntry(new ItemStack(Items.arrow), 1), + new LOTRTradeEntry(new ItemStack(Items.iron_ingot), 6), + new LOTRTradeEntry(new ItemStack(LOTRMod.orcSteel), 6), + new LOTRTradeEntry(new ItemStack(LOTRMod.mugOrcDraught, 1, 4), 20), + new LOTRTradeEntry(new ItemStack(LOTRMod.modTemplate), 20) + } + ); + + + UTUMNO_SLAVE_SELL = new LOTRTradeEntries(TradeType.SELL, + new LOTRTradeEntry[] { + new LOTRTradeEntry(new ItemStack(Items.bread), 3), + new LOTRTradeEntry(new ItemStack(Items.iron_ingot), 5), + new LOTRTradeEntry(new ItemStack(Items.gold_ingot), 17), + new LOTRTradeEntry(new ItemStack(Items.stick, 4), 1), + new LOTRTradeEntry(new ItemStack(LOTRMod.bronze), 5), + new LOTRTradeEntry(new ItemStack(LOTRMod.orcSteel), 5), + new LOTRTradeEntry(new ItemStack(LOTRMod.amber), 15), + new LOTRTradeEntry(new ItemStack(LOTRMod.ruby), 15), + new LOTRTradeEntry(new ItemStack(LOTRMod.amethyst), 12), + new LOTRTradeEntry(new ItemStack(LOTRMod.mugWater), 5), + new LOTRTradeEntry(new ItemStack(LOTRMod.wargBone), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.orcBone), 3), + new LOTRTradeEntry(new ItemStack(LOTRMod.trollBone), 4) + } + ); + } + + @Override + public void onPlayerTrade(EntityPlayer entityplayer, LOTRTradeEntries.TradeType type, ItemStack itemstack) { + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + } + + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setByte("Bound", (byte)(bound ? 1 : 0)); + } + + + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + bound = nbt.getByte("Bound") != 0; + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/entity/Wraith.java b/src/src/main/java/com/zivilon/cinder_loe/entity/Wraith.java new file mode 100644 index 0000000..c633e2c --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/entity/Wraith.java @@ -0,0 +1,178 @@ +package com.zivilon.cinder_loe.entity; + +import java.util.UUID; + +import lotr.common.LOTRAchievement; +import lotr.common.enchant.LOTREnchantment; +import lotr.common.enchant.LOTREnchantmentHelper; +import lotr.common.entity.ai.LOTREntityAIAttackOnCollide; +import lotr.common.entity.ai.LOTREntityAIDrink; +import lotr.common.entity.ai.LOTREntityAIEat; +import lotr.common.entity.ai.LOTREntityAIFollowHiringPlayer; +import lotr.common.entity.ai.LOTREntityAIHiredRemainStill; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.projectile.LOTREntityMarshWraithBall; +import lotr.common.fac.LOTRFaction; +import lotr.common.world.structure.LOTRChestContents; + + + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.CinderLoE; + +public class Wraith extends LOTREntityNPC { + + public Wraith(World world) { + super(world); + setSize(0.8F, 2.5F); + ((EntityLiving) this).tasks.addTask(1, (EntityAIBase) new LOTREntityAIHiredRemainStill(this)); + ((EntityLiving) this).tasks.addTask(2, (EntityAIBase) new LOTREntityAIAttackOnCollide(this, 1.3D, false)); + ((EntityLiving) this).tasks.addTask(3, (EntityAIBase) new LOTREntityAIFollowHiringPlayer(this)); + ((EntityLiving) this).tasks.addTask(5, (EntityAIBase) new EntityAIWander(this, 1.0D)); + ((EntityLiving) this).tasks.addTask(9, (EntityAIBase) new EntityAILookIdle((EntityLiving) this)); + addTargetTasks(true); + } + + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(17, Integer.valueOf(0)); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50.0D); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D); + } + + public int getDeathFadeTime() { + return this.dataWatcher.getWatchableObjectInt(17); + } + + public void setDeathFadeTime(int i) { + this.dataWatcher.updateObject(17, Integer.valueOf(i)); + } + + public LOTRFaction getFaction() { + return LOTRFaction.HOSTILE; + } + + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setInteger("DeathFadeTime", getDeathFadeTime()); + } + + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + setDeathFadeTime(nbt.getInteger("DeathFadeTime")); + } + + @Override + public void moveEntityWithHeading(float strafe, float forward) { + // First, call the super method to preserve normal movement behavior + super.moveEntityWithHeading(strafe, forward); + + // Check for water at the entity's feet + int x = MathHelper.floor_double(this.posX); + int y = MathHelper.floor_double(this.posY); + int z = MathHelper.floor_double(this.posZ); + + boolean isWater = this.worldObj.getBlock(x, y, z).getMaterial() == Material.water || + this.worldObj.getBlock(x, y - 1, z).getMaterial() == Material.water; // Check below the entity too + + if (isWater) { + this.onGround = true; // Treat water as solid ground + this.motionY = 0.0; // Stop falling/sinking + this.setPosition(this.posX, y + 1, this.posZ); // Adjust position to stay on top of the water + } + } + + + public void setInWeb() {} + + public void onLivingUpdate() { + super.onLivingUpdate(); + if (rand.nextBoolean()) + ((Entity)this).worldObj.spawnParticle("smoke", ((Entity)this).posX + (rand.nextDouble() - 0.5D) * ((Entity)this).width, ((Entity)this).posY + rand.nextDouble() * ((Entity)this).height, ((Entity)this).posZ + (rand.nextDouble() - 0.5D) * ((Entity)this).width, 0.0D, 0.0D, 0.0D); + if (!((Entity)this).worldObj.isRemote) { + if (getDeathFadeTime() > 0) + setDeathFadeTime(getDeathFadeTime() - 1); + if (getDeathFadeTime() == 1) + setDead(); + } + } + + public boolean attackEntityFrom(DamageSource damagesource, float f) { + boolean vulnerable = false; + Entity entity = damagesource.getEntity(); + if (entity instanceof EntityLivingBase && entity == damagesource.getSourceOfDamage()) { + ItemStack itemstack = ((EntityLivingBase)entity).getHeldItem(); + if (itemstack != null && LOTREnchantmentHelper.hasEnchant(itemstack, LOTREnchantment.baneWraith)) + vulnerable = true; + } + if (vulnerable && getDeathFadeTime() == 0) { + boolean flag = super.attackEntityFrom(damagesource, f); + return flag; + } + return false; + } + + public void onDeath(DamageSource damagesource) { + super.onDeath(damagesource); + if (!((Entity)this).worldObj.isRemote) + setDeathFadeTime(30); + } + + protected void dropFewItems(boolean flag, int i) { + super.dropFewItems(flag, i); + int flesh = 1 + rand.nextInt(3) + rand.nextInt(i + 1); + for (int l = 0; l < flesh; l++) + dropItem(Items.rotten_flesh, 1); + dropChestContents(LOTRChestContents.MARSH_REMAINS, 1, 3 + i); + } + + public EnumCreatureAttribute getCreatureAttribute() { + return EnumCreatureAttribute.UNDEAD; + } + + protected String getHurtSound() { + return "lotr:wight.hurt"; + } + + protected String getDeathSound() { + return "lotr:wight.death"; + } + + public boolean handleWaterMovement() { + return false; + } + + protected void func_145780_a(int i, int j, int k, Block block) {} + + public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { + // Do nothing + } + + @Override + public ItemStack getPickedResult(MovingObjectPosition target) { + return new ItemStack(CinderLoE.wraithSpawnEgg, 1); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/items/AlatarStaff.java b/src/src/main/java/com/zivilon/cinder_loe/items/AlatarStaff.java new file mode 100644 index 0000000..751b1d4 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/items/AlatarStaff.java @@ -0,0 +1,71 @@ +package com.zivilon.cinder_loe.items; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import java.util.List; +import lotr.common.LOTRCreativeTabs; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.fac.LOTRFaction; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.Potion; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.items.WizardStaff; + +public class AlatarStaff extends WizardStaff { + public AlatarStaff() { + super(); + } + + public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) { + entityplayer.swingItem(); + itemstack.damageItem(2, (EntityLivingBase)entityplayer); + world.playSoundAtEntity((Entity)entityplayer, "lotr:elf.woodElf_teleport", 2.0F, (Item.itemRand.nextFloat() - Item.itemRand.nextFloat()) * 0.2F + 1.0F); + LOTRFaction faction = getFaction(entityplayer); + if (!world.isRemote) { + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, ((Entity)entityplayer).boundingBox.expand(12.0D, 8.0D, 12.0D)); + if (!entities.isEmpty()) + for (int i = 0; i < entities.size(); i++) { + EntityLivingBase entity = entities.get(i); + if (entity != entityplayer) { + if (entity instanceof EntityLiving) { + EntityLiving entityliving = (EntityLiving)entity; + if (!faction.isGoodRelation(LOTRMod.getNPCFaction((Entity)entityliving))) + continue; + } + if (entity instanceof EntityPlayer) + if (!MinecraftServer.getServer().isPVPEnabled() || LOTRLevelData.getData((EntityPlayer)entity).getAlignment(faction) < 0.0F) + continue; + + entity.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 1200, 0)); + entity.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 1200, 0)); + } + } + LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.MACE_SAURON, (Entity)entityplayer); + LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entityplayer, 64.0D)); + } + return itemstack; + } + + private LOTRFaction getFaction(EntityPlayer player) { + LOTRFaction faction = LOTRLevelData.getData(player).getPledgeFaction(); + if (faction == null) { + faction = LOTRFaction.DORWINION; + } + return faction; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/items/CinderLoESpawnEgg.java b/src/src/main/java/com/zivilon/cinder_loe/items/CinderLoESpawnEgg.java new file mode 100644 index 0000000..1854254 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/items/CinderLoESpawnEgg.java @@ -0,0 +1,66 @@ +package com.zivilon.cinder_loe.items; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.CinderLoE; + +public class CinderLoESpawnEgg extends Item { + private Class entityClass; + + public CinderLoESpawnEgg(Class entityClass) { + this.entityClass = entityClass; + this.setUnlocalizedName("spawn_egg_" + entityClass.getSimpleName().toLowerCase()); + this.setTextureName("spawn_egg"); + this.setCreativeTab(CreativeTabs.tabMisc); // Or any other tab you prefer + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + if (!world.isRemote) { + // Perform a ray trace to find the block the player is looking at + MovingObjectPosition target = getMovingObjectPositionFromPlayer(world, player, true); + + if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int x = target.blockX; + int y = target.blockY; + int z = target.blockZ; + + // Adjust the y coordinate to spawn the entity on top of the block clicked + y += 1; + + try { + Entity entity = entityClass.getConstructor(World.class).newInstance(world); + entity.setLocationAndAngles(x + 0.5, y, z + 0.5, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); + spawnCustomCreature(world, entity); + } catch (Exception e) { + e.printStackTrace(); // Log any exceptions + } + } + } + if (!player.capabilities.isCreativeMode) { + --itemStack.stackSize; + } + return itemStack; + } + + + public static void spawnCustomCreature(World world, Entity entity) { + if (entity instanceof EntityLiving) { + EntityLiving entityLiving = (EntityLiving)entity; + + // The entity's location is already set, so we directly apply custom properties and spawn + entityLiving.onSpawnWithEgg(null); // Applies custom armor and equipment + + world.spawnEntityInWorld(entity); + entityLiving.playLivingSound(); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/items/PallandoStaff.java b/src/src/main/java/com/zivilon/cinder_loe/items/PallandoStaff.java new file mode 100644 index 0000000..6c06934 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/items/PallandoStaff.java @@ -0,0 +1,71 @@ +package com.zivilon.cinder_loe.items; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import java.util.List; +import lotr.common.LOTRCreativeTabs; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.fac.LOTRFaction; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.Potion; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.items.WizardStaff; + +public class PallandoStaff extends WizardStaff { + public PallandoStaff() { + super(); + } + + public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) { + entityplayer.swingItem(); + itemstack.damageItem(2, (EntityLivingBase)entityplayer); + world.playSoundAtEntity((Entity)entityplayer, "lotr:elf.woodElf_teleport", 2.0F, (Item.itemRand.nextFloat() - Item.itemRand.nextFloat()) * 0.2F + 1.0F); + LOTRFaction faction = getFaction(entityplayer); + if (!world.isRemote) { + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, ((Entity)entityplayer).boundingBox.expand(12.0D, 8.0D, 12.0D)); + if (!entities.isEmpty()) + for (int i = 0; i < entities.size(); i++) { + EntityLivingBase entity = entities.get(i); + if (entity != entityplayer) { + if (entity instanceof EntityLiving) { + EntityLiving entityliving = (EntityLiving)entity; + if (faction.isGoodRelation(LOTRMod.getNPCFaction((Entity)entityliving))) + continue; + } + if (entity instanceof EntityPlayer) + if (!MinecraftServer.getServer().isPVPEnabled() || LOTRLevelData.getData((EntityPlayer)entity).getAlignment(faction) > 0.0F) + continue; + + entity.addPotionEffect(new PotionEffect(Potion.weakness.id, 1200, 0)); + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200, 0)); + } + } + LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.MACE_SAURON, (Entity)entityplayer); + LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entityplayer, 64.0D)); + } + return itemstack; + } + + private LOTRFaction getFaction(EntityPlayer player) { + LOTRFaction faction = LOTRLevelData.getData(player).getPledgeFaction(); + if (faction == null) { + faction = LOTRFaction.RHUDEL; + } + return faction; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/items/RadagastStaff.java b/src/src/main/java/com/zivilon/cinder_loe/items/RadagastStaff.java new file mode 100644 index 0000000..b13c219 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/items/RadagastStaff.java @@ -0,0 +1,93 @@ +package com.zivilon.cinder_loe.items; + + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import lotr.common.LOTRCreativeTabs; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.util.BlockPos; +import com.zivilon.cinder_loe.items.WizardStaff; +import com.zivilon.cinder_loe.entity.FangornBear; +import com.zivilon.cinder_loe.entity.FangornWildBoar; +import com.zivilon.cinder_loe.entity.FangornAuroch; +import com.zivilon.cinder_loe.entity.FangornElk; +import com.zivilon.cinder_loe.entity.FangornAnimal; + +import lotr.common.item.LOTRMaterial; +import java.util.Random; + + +import java.util.List; + +public class RadagastStaff extends WizardStaff { + public RadagastStaff() { + super(); + } + + public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) { + entityplayer.swingItem(); + itemstack.damageItem(2, (EntityLivingBase)entityplayer); + if (!world.isRemote) { + BlockPos location = BlockPos.findSafeSpawnLocation(world, entityplayer); + if (location != null && !isAreaCrowded(world, entityplayer)) { + world.playSoundAtEntity((Entity)entityplayer, "lotr:ent.mallorn.summonEnt", 2.0F, (Item.itemRand.nextFloat() - Item.itemRand.nextFloat()) * 0.2F + 1.0F); + spawnAnimal(location, world); + } else { + world.playSoundAtEntity((Entity)entityplayer, "lotr:item.puff", 1.0F, 2.0F); + } + } + return itemstack; + } + + public boolean isAreaCrowded(World world, EntityPlayer player) { + int radius = 30; // Check within 30 blocks + int maxEntities = 10; // Maximum allowed nearby entities + + AxisAlignedBB checkArea = AxisAlignedBB.getBoundingBox( + player.posX - radius, player.posY - radius, player.posZ - radius, + player.posX + radius, player.posY + radius, player.posZ + radius + ); + List listAnimals = world.getEntitiesWithinAABB(EntityAnimal.class, checkArea); + List listFangornBear = world.getEntitiesWithinAABB(FangornAnimal.class, checkArea); + + // Combine counts from both lists + int totalAnimals = listAnimals.size() + listFangornBear.size(); + + return totalAnimals >= maxEntities; + } + + public void spawnAnimal(BlockPos location, World world) { + Random rand = new Random(); + int choice = rand.nextInt(4); // Generate a random number between 0 and 2 + + EntityLivingBase entity = null; + switch (choice) { + case 0: + entity = new FangornBear(world); // Assuming FangornBear is your entity class for bears + break; + case 1: + entity = new FangornWildBoar(world); // Replace with your wild boar entity class + break; + case 2: + entity = new FangornAuroch(world); // Replace with your auroch entity class + break; + case 3: + entity = new FangornElk(world); // Replace with your auroch entity class + break; + } + + if (entity != null) { + entity.setPosition(location.x + 0.5, location.y, location.z + 0.5); // Center the entity on the block + world.spawnEntityInWorld(entity); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/items/SarumanStaff.java b/src/src/main/java/com/zivilon/cinder_loe/items/SarumanStaff.java new file mode 100644 index 0000000..46f3878 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/items/SarumanStaff.java @@ -0,0 +1,46 @@ +package com.zivilon.cinder_loe.items; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import java.util.List; +import lotr.common.LOTRCreativeTabs; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.fac.LOTRFaction; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.Potion; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.items.WizardStaff; +import com.zivilon.cinder_loe.entity.SarumanFireball; + +public class SarumanStaff extends WizardStaff { + public SarumanStaff() { + super(); + } + + public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) { + entityplayer.swingItem(); + itemstack.damageItem(2, (EntityLivingBase)entityplayer); + world.playSoundAtEntity((Entity)entityplayer, "mob.ghast.fireball", 2.0F, (Item.itemRand.nextFloat() - Item.itemRand.nextFloat()) * 0.2F + 1.0F); + if (!world.isRemote) { + world.spawnEntityInWorld((Entity)new SarumanFireball(world, ((EntityLivingBase)entityplayer))); + LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.MACE_SAURON, (Entity)entityplayer); + LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entityplayer, 64.0D)); + } + return itemstack; + } +} \ No newline at end of file diff --git a/src/src/main/java/com/zivilon/cinder_loe/items/Whip.java b/src/src/main/java/com/zivilon/cinder_loe/items/Whip.java new file mode 100644 index 0000000..2ef6db8 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/items/Whip.java @@ -0,0 +1,59 @@ +package com.zivilon.cinder_loe.items; + +import java.util.ArrayList; +import java.util.List; + +import lotr.common.LOTRBannerProtection; +import lotr.common.LOTRMod; +import lotr.common.enchant.LOTREnchantment; +import lotr.common.enchant.LOTREnchantmentHelper; +import lotr.common.item.LOTRItemSword; +import lotr.common.item.LOTRMaterial; +import lotr.common.item.LOTRWeaponStats; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class Whip extends LOTRItemSword { + public Whip() { + super(LOTRMaterial.FUR); + this.lotrWeaponDamage = 4.0F; + LOTRWeaponStats.registerMeleeReach(Whip.class, 1.5F); + } + + public boolean func_77644_a(ItemStack itemstack, EntityLivingBase hitEntity, EntityLivingBase user) { + super.hitEntity(itemstack, hitEntity, user); + launchWhip(user, hitEntity); + return true; + } + + public EnumAction getItemUseAction(ItemStack itemstack) { + return EnumAction.none; + } + + private void launchWhip(EntityLivingBase user, EntityLivingBase hitEntity) { + World world = ((Entity)user).worldObj; + world.playSoundAtEntity((Entity)user, "lotr:item.balrogWhip", 2.0F, 0.7F + Item.itemRand.nextFloat() * 0.6F); + } + + public boolean getIsRepairable(ItemStack itemstack, ItemStack repairItem) { + return (repairItem.getItem() == Items.leather); + } + + private void checkIncompatibleModifiers(ItemStack itemstack) {} +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/items/WizardStaff.java b/src/src/main/java/com/zivilon/cinder_loe/items/WizardStaff.java new file mode 100644 index 0000000..e65b292 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/items/WizardStaff.java @@ -0,0 +1,40 @@ +package com.zivilon.cinder_loe.items; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import lotr.common.LOTRCreativeTabs; +import lotr.common.entity.projectile.LOTREntityGandalfFireball; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import lotr.common.item.LOTRItemSword; +import lotr.common.item.LOTRStoryItem; + +import com.zivilon.cinder_loe.CinderLoE; + +public class WizardStaff extends LOTRItemSword implements LOTRStoryItem { + public WizardStaff() { + super(CinderLoE.getLOTRMaterialByName("WIZARD")); + setCreativeTab((CreativeTabs)LOTRCreativeTabs.tabStory); + } + + public int getMaxItemUseDuration(ItemStack itemstack) { + return 40; + } + + public EnumAction getItemUseAction(ItemStack itemstack) { + return EnumAction.bow; + } + + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); + return itemstack; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinItemBlock.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinItemBlock.java new file mode 100644 index 0000000..ef530a7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinItemBlock.java @@ -0,0 +1,39 @@ +package com.zivilon.cinder_loe.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +@Mixin(ItemBlock.class) +public abstract class MixinItemBlock { + + @Shadow + public final Block field_150939_a; + + public MixinItemBlock(Block block) { + this.field_150939_a = block; + } + + @Overwrite(remap = false) + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { + + System.out.println("Placing block with metadata " + metadata); + if (!world.setBlock(x, y, z, field_150939_a, metadata, 3)) { + return false; + } + + if (world.getBlock(x, y, z) == field_150939_a) { + field_150939_a.onBlockPlacedBy(world, x, y, z, player, stack); + field_150939_a.onPostBlockPlaced(world, x, y, z, metadata); + } + + return true; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinItemRenderer.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinItemRenderer.java new file mode 100644 index 0000000..70fdd28 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinItemRenderer.java @@ -0,0 +1,275 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import com.zivilon.cinder_loe.util.Utilities; +import com.zivilon.cinder_loe.CinderLoE_Config; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.MapData; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; +import net.minecraftforge.client.MinecraftForgeClient; + +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*; + +@Mixin(ItemRenderer.class) +public abstract class MixinItemRenderer { + + @Shadow + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + + @Shadow + private RenderBlocks renderBlocksIr; + + @Shadow + private Minecraft mc; + + @Overwrite(remap = false) + public void renderItem(EntityLivingBase p_78443_1_, ItemStack p_78443_2_, int p_78443_3_, ItemRenderType type) { + GL11.glPushMatrix(); + TextureManager texturemanager = this.mc.getTextureManager(); + Item item = p_78443_2_.getItem(); + Block block = Block.getBlockFromItem(item); + + if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(p_78443_2_, type); + if (customRenderer != null) { + texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber())); + ForgeHooksClient.renderEquippedItem(type, customRenderer, renderBlocksIr, p_78443_1_, p_78443_2_); + } + else + if (p_78443_2_.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) { + texturemanager.bindTexture(texturemanager.getResourceLocation(0)); + + if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) { + GL11.glDepthMask(false); + this.renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F); + GL11.glDepthMask(true); + } + else { + this.renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F); + } + } + else { + IIcon iicon = p_78443_1_.getItemIcon(p_78443_2_, p_78443_3_); + + if (iicon == null) { + GL11.glPopMatrix(); + return; + } + + texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber())); + TextureUtil.func_152777_a(false, false, 1.0F); + Tessellator tessellator = Tessellator.instance; + float f = iicon.getMinU(); + float f1 = iicon.getMaxU(); + float f2 = iicon.getMinV(); + float f3 = iicon.getMaxV(); + float f4 = 0.0F; + float f5 = 0.3F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(-f4, -f5, 0.0F); + float f6 = 1.5F; + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F, false); + + if (p_78443_2_.hasEffect(p_78443_3_)) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + texturemanager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(768, 1, 1, 0); + GL11.glColor4f(CinderLoE_Config.enchantment_color_red, CinderLoE_Config.enchantment_color_green, CinderLoE_Config.enchantment_color_blue, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.125F; + GL11.glScalef(f8, f8, f8); + float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f9, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + + RenderHelper.customRenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, true); + + + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + + RenderHelper.customRenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, true); + + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber())); + TextureUtil.func_147945_b(); + } + + if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) { + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glPopMatrix(); + } + + private void customRenderItemIn2D(Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int p_78439_5_, int p_78439_6_, float p_78439_7_, boolean enchant) { + if (!enchant) GL11.glPushMatrix(); // Save the current OpenGL state + if (!enchant) GL11.glEnable(GL11.GL_BLEND); // Enable blending + if (!enchant) OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); // Apply your custom blend function for semi-transparency + + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.draw(); + + + float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)p_78439_5_; + float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)p_78439_6_; + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + + for (k = 0; k < p_78439_5_; ++k) { + f7 = (float)k / (float)p_78439_5_; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(1.0F, 0.0F, 0.0F); + float f9; + + for (k = 0; k < p_78439_5_; ++k) { + f7 = (float)k / (float)p_78439_5_; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + f9 = f7 + 1.0F / (float)p_78439_5_; + p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 1.0F, 0.0F); + + for (k = 0; k < p_78439_6_; ++k) { + f7 = (float)k / (float)p_78439_6_; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + f9 = f7 + 1.0F / (float)p_78439_6_; + p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, -1.0F, 0.0F); + + for (k = 0; k < p_78439_6_; ++k) { + f7 = (float)k / (float)p_78439_6_; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + } + + p_78439_0_.draw(); + if (!enchant) GL11.glPopMatrix(); // Restore the saved OpenGL state + } + + @Overwrite + public static void renderItemIn2D(Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int p_78439_5_, int p_78439_6_, float p_78439_7_) { + // Redirect to new custom renderer. This should not be necessary but works as failsafe + RenderHelper.customRenderItemIn2D(p_78439_0_, p_78439_1_, p_78439_2_, p_78439_3_, p_78439_4_, p_78439_5_, p_78439_6_, p_78439_7_, false); + +/* DEBUG + System.out.println("Printing stacktrace from original render method"); + Utilities.writeLog("Printing stacktrace from original render method"); + StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); + for (StackTraceElement element : stackTraceElements) { + Utilities.writeLog(element.toString()); + } + Utilities.writeLog(""); +*/ + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRArmorModels.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRArmorModels.java new file mode 100644 index 0000000..6505b59 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRArmorModels.java @@ -0,0 +1,111 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.CinderLoE; +import com.zivilon.cinder_loe.client.model.ModelRedDwarfHelmet; +import com.zivilon.cinder_loe.client.model.ModelBreeHelmet; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.HashMap; +import java.util.Map; + +import lotr.client.model.LOTRArmorModels; +import lotr.client.model.LOTRModelArnorHelmet; +import lotr.client.model.LOTRModelBlackNumenoreanHelmet; +import lotr.client.model.LOTRModelBlackUrukHelmet; +import lotr.client.model.LOTRModelDorwinionElfHelmet; +import lotr.client.model.LOTRModelEasterlingHelmet; +import lotr.client.model.LOTRModelGaladhrimHelmet; +import lotr.client.model.LOTRModelGemsbokHelmet; +import lotr.client.model.LOTRModelGondolinHelmet; +import lotr.client.model.LOTRModelGondorHelmet; +import lotr.client.model.LOTRModelGulfChestplate; +import lotr.client.model.LOTRModelGundabadUrukHelmet; +import lotr.client.model.LOTRModelHaradRobes; +import lotr.client.model.LOTRModelHaradTurban; +import lotr.client.model.LOTRModelHarnedorChestplate; +import lotr.client.model.LOTRModelHarnedorHelmet; +import lotr.client.model.LOTRModelHeadPlate; +import lotr.client.model.LOTRModelHighElvenHelmet; +import lotr.client.model.LOTRModelHighElvenHelmet; +import lotr.client.model.LOTRModelHighElvenHelmet; +import lotr.client.model.LOTRModelLeatherHat; +import lotr.client.model.LOTRModelMoredainLionHelmet; +import lotr.client.model.LOTRModelMorgulHelmet; +import lotr.client.model.LOTRModelNearHaradWarlordHelmet; +import lotr.client.model.LOTRModelPartyHat; +import lotr.client.model.LOTRModelRohanMarshalHelmet; +import lotr.client.model.LOTRModelSwanChestplate; +import lotr.client.model.LOTRModelSwanHelmet; +import lotr.client.model.LOTRModelTauredainChieftainHelmet; +import lotr.client.model.LOTRModelTauredainGoldHelmet; +import lotr.client.model.LOTRModelUmbarHelmet; +import lotr.client.model.LOTRModelUrukHelmet; +import lotr.client.model.LOTRModelUrukHelmet; +import lotr.client.model.LOTRModelWingedHelmet; +import lotr.common.LOTRMod; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.item.Item; + +@Mixin(LOTRArmorModels.class) +public class MixinLOTRArmorModels { + + @Shadow + private Map> specialArmorModels; + + @Shadow + public void copyModelRotations(ModelBiped target, ModelBiped src) { + } + + private Map getSpecialModels(ModelBiped key) { + Map map = this.specialArmorModels.get(key); + if (map == null) { + map = new HashMap(); + map.put(LOTRMod.leatherHat, new LOTRModelLeatherHat()); + map.put(LOTRMod.helmetGondor, new LOTRModelGondorHelmet(1.0F)); + map.put(LOTRMod.helmetElven, new LOTRModelGaladhrimHelmet(1.0F)); + map.put(LOTRMod.helmetGondorWinged, new LOTRModelWingedHelmet(1.0F)); + map.put(LOTRMod.helmetMorgul, new LOTRModelMorgulHelmet(1.0F)); + map.put(LOTRMod.helmetGemsbok, new LOTRModelGemsbokHelmet(1.0F)); + map.put(LOTRMod.helmetHighElven, new LOTRModelHighElvenHelmet(1.0F)); + map.put(LOTRMod.helmetBlackUruk, new LOTRModelBlackUrukHelmet(1.0F)); + map.put(LOTRMod.helmetUruk, new LOTRModelUrukHelmet(1.0F)); + map.put(LOTRMod.helmetNearHaradWarlord, new LOTRModelNearHaradWarlordHelmet(1.0F)); + map.put(LOTRMod.helmetDolAmroth, new LOTRModelSwanHelmet(1.0F)); + map.put(LOTRMod.bodyDolAmroth, new LOTRModelSwanChestplate(1.0F)); + map.put(LOTRMod.helmetMoredainLion, new LOTRModelMoredainLionHelmet(1.0F)); + map.put(LOTRMod.helmetHaradRobes, new LOTRModelHaradTurban()); + map.put(LOTRMod.bodyHaradRobes, new LOTRModelHaradRobes(1.0F)); + map.put(LOTRMod.legsHaradRobes, new LOTRModelHaradRobes(0.5F)); + map.put(LOTRMod.bootsHaradRobes, new LOTRModelHaradRobes(1.0F)); + map.put(LOTRMod.helmetGondolin, new LOTRModelGondolinHelmet(1.0F)); + map.put(LOTRMod.helmetRohanMarshal, new LOTRModelRohanMarshalHelmet(1.0F)); + map.put(LOTRMod.helmetTauredainChieftain, new LOTRModelTauredainChieftainHelmet(1.0F)); + map.put(LOTRMod.helmetTauredainGold, new LOTRModelTauredainGoldHelmet(1.0F)); + map.put(LOTRMod.helmetGundabadUruk, new LOTRModelGundabadUrukHelmet(1.0F)); + map.put(LOTRMod.helmetUrukBerserker, new LOTRModelUrukHelmet(1.0F)); + map.put(LOTRMod.helmetDorwinionElf, new LOTRModelDorwinionElfHelmet(1.0F)); + map.put(LOTRMod.partyHat, new LOTRModelPartyHat(0.6F)); + map.put(LOTRMod.helmetArnor, new LOTRModelArnorHelmet(1.0F)); + map.put(LOTRMod.helmetRhunGold, new LOTRModelEasterlingHelmet(1.0F, false)); + map.put(LOTRMod.helmetRhunWarlord, new LOTRModelEasterlingHelmet(1.0F, true)); + map.put(LOTRMod.helmetRivendell, new LOTRModelHighElvenHelmet(1.0F)); + map.put(LOTRMod.bodyGulfHarad, new LOTRModelGulfChestplate(1.0F)); + map.put(LOTRMod.helmetUmbar, new LOTRModelUmbarHelmet(1.0F)); + map.put(LOTRMod.helmetHarnedor, new LOTRModelHarnedorHelmet(1.0F)); + map.put(LOTRMod.bodyHarnedor, new LOTRModelHarnedorChestplate(1.0F)); + map.put(LOTRMod.helmetBlackNumenorean, new LOTRModelBlackNumenoreanHelmet(1.0F)); + map.put(CinderLoE.helmetRedDwarf, new ModelRedDwarfHelmet(1.0F)); + map.put(CinderLoE.helmetBree, new ModelBreeHelmet()); + map.put(LOTRMod.plate, new LOTRModelHeadPlate()); + map.put(LOTRMod.woodPlate, new LOTRModelHeadPlate()); + map.put(LOTRMod.ceramicPlate, new LOTRModelHeadPlate()); + for (ModelBiped armorModel : map.values()) + copyModelRotations(armorModel, key); + this.specialArmorModels.put(key, map); + } + return map; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRClientProxy.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRClientProxy.java new file mode 100644 index 0000000..a81f479 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRClientProxy.java @@ -0,0 +1,55 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import com.zivilon.cinder_loe.CinderLoE_Config; +import org.lwjgl.opengl.GL11; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.LOTRClientProxy; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.util.ResourceLocation; + +@Mixin(LOTRClientProxy.class) +public abstract class MixinLOTRClientProxy { + @Shadow + public static final ResourceLocation enchantmentTexture = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + + @Overwrite(remap = false) + public static void renderEnchantmentEffect() { + Tessellator tessellator = Tessellator.instance; + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + GL11.glDepthFunc(514); + GL11.glDisable(2896); + texturemanager.bindTexture(enchantmentTexture); + GL11.glEnable(3042); + GL11.glBlendFunc(768, 1); + GL11.glColor4f(CinderLoE_Config.enchantment_color_red, CinderLoE_Config.enchantment_color_green, CinderLoE_Config.enchantment_color_blue, 1.0F); + GL11.glMatrixMode(5890); + GL11.glPushMatrix(); + float scale = 0.125F; + GL11.glScalef(scale, scale, scale); + float randomShift = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(randomShift, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + RenderHelper.customRenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, true); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(scale, scale, scale); + randomShift = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-randomShift, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + RenderHelper.customRenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, true); + GL11.glPopMatrix(); + GL11.glMatrixMode(5888); + GL11.glDisable(3042); + GL11.glEnable(2896); + GL11.glDepthFunc(515); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRContainerAnvil.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRContainerAnvil.java new file mode 100644 index 0000000..d58d501 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRContainerAnvil.java @@ -0,0 +1,78 @@ +package com.zivilon.cinder_loe.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +import lotr.common.inventory.LOTRContainerAnvil; +import lotr.common.LOTRMod; +import lotr.common.item.LOTRMaterial; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.item.ItemTool; + +import com.zivilon.cinder_loe.CinderLoE; + +import java.util.Objects; + +@Mixin(LOTRContainerAnvil.class) +public class MixinLOTRContainerAnvil { + + /** + * @author Shinare + * @reason KeyLime + */ + @Overwrite(remap = false) + public boolean isRepairMaterial(ItemStack inputItem, ItemStack materialItem) { + if (inputItem.getItem().getIsRepairable(inputItem, materialItem)) + return true; + Item item = inputItem.getItem(); + if (item == Items.bow && LOTRMod.rohanBow.getIsRepairable(inputItem, materialItem)) + return true; + if (item instanceof net.minecraft.item.ItemFishingRod && materialItem.getItem() == Items.string) + return true; + if (item instanceof net.minecraft.item.ItemShears && materialItem.getItem() == Items.iron_ingot) + return true; + if (item instanceof lotr.common.item.LOTRItemChisel && materialItem.getItem() == Items.iron_ingot) + return true; + if (item instanceof net.minecraft.item.ItemEnchantedBook && materialItem.getItem() == Items.paper) + return true; + Item.ToolMaterial material = null; + if (item instanceof ItemTool) { + material = Item.ToolMaterial.valueOf(((ItemTool)item).getToolMaterialName()); + } else if (item instanceof ItemSword) { + material = Item.ToolMaterial.valueOf(((ItemSword)item).getToolMaterialName()); + } + if (material == Item.ToolMaterial.WOOD || material == LOTRMaterial.MOREDAIN_WOOD.toToolMaterial()) + return LOTRMod.isOreNameEqual(materialItem, "plankWood"); + if (material == LOTRMaterial.MALLORN.toToolMaterial()) + return (materialItem.getItem() == Item.getItemFromBlock(LOTRMod.planks) && materialItem.getItemDamage() == 1); + if (material == LOTRMaterial.MALLORN_MACE.toToolMaterial()) + return (materialItem.getItem() == Item.getItemFromBlock(LOTRMod.wood) && materialItem.getItemDamage() == 1); + if (material == CinderLoE.MATERIAL_RED_DWARF.toToolMaterial()) + return (materialItem.getItem() == CinderLoE.redDwarfSteel); + if (material == CinderLoE.MATERIAL_LIMWAITH_BONE.toToolMaterial()) + return LOTRMod.isOreNameEqual(materialItem, "bone"); + if (material == CinderLoE.EVENT.toToolMaterial()) + return LOTRMod.isOreNameEqual(materialItem, "ice"); + if (material == CinderLoE.MATERIAL_BREE.toToolMaterial()) + return (materialItem.getItem() == Items.iron_ingot); + if (item instanceof ItemArmor armor) { + ItemArmor.ArmorMaterial armorMaterial = armor.getArmorMaterial(); + if (armorMaterial == LOTRMaterial.BONE.toArmorMaterial()) + return LOTRMod.isOreNameEqual(materialItem, "bone"); + if (armorMaterial == CinderLoE.MATERIAL_RED_DWARF.toArmorMaterial()) + return (materialItem.getItem() == CinderLoE.redDwarfSteel); + if (armorMaterial == CinderLoE.MATERIAL_LIMWAITH_WOOD.toArmorMaterial()) + return (materialItem.getItem() == Item.getItemFromBlock(LOTRMod.planks) && materialItem.getItemDamage() == 15); + if (armorMaterial == CinderLoE.MATERIAL_BREE.toArmorMaterial()) + return (materialItem.getItem() == Items.iron_ingot); + if (armorMaterial == CinderLoE.MATERIAL_BATTLENUN.toArmorMaterial()) + return (materialItem.getItem() == Items.iron_ingot); + } + + return false; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREntitySauron.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREntitySauron.java new file mode 100644 index 0000000..e0cba86 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREntitySauron.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.npc.LOTREntitySauron; + +import net.minecraft.world.World; + +@Mixin(LOTREntitySauron.class) +public abstract class MixinLOTREntitySauron extends LOTREntityNPC { + MixinLOTREntitySauron(World world) { + super(world); + } + + public void setupNPCName() { + this.familyInfo.setName("Sauron"); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRIntCache.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRIntCache.java new file mode 100644 index 0000000..b3d5d36 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRIntCache.java @@ -0,0 +1,76 @@ +package com.zivilon.cinder_loe.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import net.minecraft.world.gen.layer.GenLayer; +import cpw.mods.fml.common.FMLLog; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import lotr.common.LOTRDimension; +import lotr.common.world.biome.LOTRBiome; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import java.util.Random; + +import lotr.common.world.genlayer.LOTRGenLayerRemoveMapRivers; +import lotr.common.world.genlayer.LOTRGenLayer; +import lotr.common.world.genlayer.LOTRIntCache; +import com.zivilon.cinder_loe.util.Utilities; + +@Mixin(LOTRIntCache.class) +public abstract class MixinLOTRIntCache { + + @Shadow + private static LOTRIntCache SERVER; + @Shadow + private static LOTRIntCache CLIENT; + @Shadow + private int intCacheSize = 256; + @Shadow + private List freeSmallArrays; + @Shadow + private List inUseSmallArrays; + @Shadow + private List freeLargeArrays; + @Shadow + private List inUseLargeArrays; + + @Overwrite(remap = false) + public int[] getIntArray(int size) { + if (size <= 256) { + if (this.freeSmallArrays.isEmpty()) { + int[] arrayOfInt1 = new int[256]; + this.inUseSmallArrays.add(arrayOfInt1); + return arrayOfInt1 == null ? Utilities.LOTRIntCache : cacheInts(arrayOfInt1); + } + int[] arrayOfInt = this.freeSmallArrays.remove(this.freeSmallArrays.size() - 1); + this.inUseSmallArrays.add(arrayOfInt); + return arrayOfInt == null ? Utilities.LOTRIntCache : cacheInts(arrayOfInt); + } + if (size > this.intCacheSize) { + this.intCacheSize = size; + this.freeLargeArrays.clear(); + this.inUseLargeArrays.clear(); + int[] arrayOfInt = new int[this.intCacheSize]; + this.inUseLargeArrays.add(arrayOfInt); + return arrayOfInt == null ? Utilities.LOTRIntCache : cacheInts(arrayOfInt); + } + if (this.freeLargeArrays.isEmpty()) { + int[] arrayOfInt = new int[this.intCacheSize]; + this.inUseLargeArrays.add(arrayOfInt); + return arrayOfInt == null ? Utilities.LOTRIntCache : cacheInts(arrayOfInt); + } + int[] ints = this.freeLargeArrays.remove(this.freeLargeArrays.size() - 1); + this.inUseLargeArrays.add(ints); + return ints == null ? Utilities.LOTRIntCache : cacheInts(ints); + } + + private int[] cacheInts(int[] ints) { + Utilities.LOTRIntCache = ints; + return ints; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRItemRendererManager.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRItemRendererManager.java new file mode 100644 index 0000000..4e1403b --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRItemRendererManager.java @@ -0,0 +1,120 @@ +package com.zivilon.cinder_loe.mixins; + +import lotr.client.LOTRItemRendererManager; +import lotr.client.render.item.LOTRRenderLargeItem; + +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.item.Item; + +import java.lang.reflect.Field; + +import org.objectweb.asm.Opcodes; + +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import lotr.client.render.item.LOTRRenderBannerItem; +import lotr.client.render.item.LOTRRenderBlownItem; +import lotr.client.render.item.LOTRRenderBow; +import lotr.client.render.item.LOTRRenderCrossbow; +import lotr.client.render.item.LOTRRenderElvenBlade; +import lotr.client.render.item.LOTRRenderInvTableCommand; +import lotr.client.render.item.LOTRRenderLargeItem; +import lotr.client.render.item.LOTRRenderSkullStaff; +import lotr.client.render.tileentity.LOTRRenderAnimalJar; +import lotr.common.LOTRMod; +import lotr.common.item.LOTRItemSword; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.IReloadableResourceManager; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.item.Item; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.MinecraftForge; + +@Mixin(LOTRItemRendererManager.class) +public abstract class MixinLOTRItemRendererManager { + +/* @Inject(method = "func_110549_a(Lnet/minecraft/client/resources/IResourceManager;)V", + at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 0, shift = At.Shift.BEFORE), + locals = LocalCapture.CAPTURE_FAILSOFT, + remap = false) + private void afterIsLargeSet(IResourceManager resourceManager, CallbackInfo ci, int i, Field[] fields, Field field, Item item, LOTRRenderLargeItem largeItemRenderer, boolean isLarge) { + System.out.println("\u001B[35mVerifying item in renderer manager..."); + System.out.println("Name of item is " + item.getUnlocalizedName()); + System.out.println("Is crossbow: " + (item instanceof lotr.common.item.LOTRItemCrossbow)); + System.out.println("Is bow: " + (item instanceof lotr.common.item.LOTRItemBow)); + System.out.println("Is sword: " + (item instanceof lotr.common.item.LOTRItemSword)); + System.out.println("Is large: " + isLarge); + }*/ + @Shadow + private static List largeItemRenderers; + + @Overwrite + public void onResourceManagerReload(IResourceManager resourceManager) { + largeItemRenderers.clear(); + try { + for (Field field : LOTRMod.class.getFields()) { + System.out.println("Found field " + field.getName() + " of type " + field.getType().getName()); + if (field.getName().equals("spearRedDwarf")) { + System.out.println("Found spearRedDwarf"); + System.out.println("Is type Item: " + (field.get(null) instanceof Item)); + } + if (field.get(null) instanceof Item) { + Item item = (Item)field.get(null); + MinecraftForgeClient.registerItemRenderer(item, null); + LOTRRenderLargeItem largeItemRenderer = LOTRRenderLargeItem.getRendererIfLarge(item); + boolean isLarge = (largeItemRenderer != null); + System.out.println("\u001B[35mVerifying item in renderer manager..."); + System.out.println("Name of item is " + item.getUnlocalizedName()); + System.out.println("Is crossbow: " + (item instanceof lotr.common.item.LOTRItemCrossbow)); + System.out.println("Is bow: " + (item instanceof lotr.common.item.LOTRItemBow)); + System.out.println("Is sword: " + (item instanceof lotr.common.item.LOTRItemSword)); + System.out.println("Is large: " + isLarge); + if (item instanceof lotr.common.item.LOTRItemCrossbow) { + MinecraftForgeClient.registerItemRenderer(item, (IItemRenderer)new LOTRRenderCrossbow()); + } else if (item instanceof lotr.common.item.LOTRItemBow) { + MinecraftForgeClient.registerItemRenderer(item, (IItemRenderer)new LOTRRenderBow(largeItemRenderer)); + } else if (item instanceof LOTRItemSword && ((LOTRItemSword)item).isElvenBlade()) { + double d = 24.0D; + if (item == LOTRMod.sting) + d = 40.0D; + MinecraftForgeClient.registerItemRenderer(item, (IItemRenderer)new LOTRRenderElvenBlade(d, largeItemRenderer)); + } else if (isLarge) { + MinecraftForgeClient.registerItemRenderer(item, (IItemRenderer)largeItemRenderer); + } + if (largeItemRenderer != null) + largeItemRenderers.add(largeItemRenderer); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(LOTRMod.commandTable), (IItemRenderer)new LOTRRenderInvTableCommand()); + MinecraftForgeClient.registerItemRenderer(LOTRMod.hobbitPipe, (IItemRenderer)new LOTRRenderBlownItem()); + MinecraftForgeClient.registerItemRenderer(LOTRMod.commandHorn, (IItemRenderer)new LOTRRenderBlownItem()); + MinecraftForgeClient.registerItemRenderer(LOTRMod.conquestHorn, (IItemRenderer)new LOTRRenderBlownItem()); + MinecraftForgeClient.registerItemRenderer(LOTRMod.banner, (IItemRenderer)new LOTRRenderBannerItem()); + MinecraftForgeClient.registerItemRenderer(LOTRMod.orcSkullStaff, (IItemRenderer)new LOTRRenderSkullStaff()); + Iterator itItems = Item.itemRegistry.iterator(); + while (itItems.hasNext()) { + Item item = itItems.next(); + if (item instanceof lotr.common.item.LOTRItemAnimalJar) + MinecraftForgeClient.registerItemRenderer(item, (IItemRenderer)new LOTRRenderAnimalJar()); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRMaterial.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRMaterial.java new file mode 100644 index 0000000..030695b --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRMaterial.java @@ -0,0 +1,61 @@ +package com.zivilon.cinder_loe.mixins; + +import net.minecraft.item.Item; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import lotr.common.item.LOTRMaterial; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Field; + +import com.zivilon.cinder_loe.CinderLoE; + +@Mixin(LOTRMaterial.class) +public class MixinLOTRMaterial { + static { + try { + Class lotrMaterialClass = Class.forName("lotr.common.item.LOTRMaterial"); + Field redDwarfSteelField = lotrMaterialClass.getField("RED_DWARF_STEEL"); + + // Reflection to access and instantiate the private constructor of LOTRMaterial + Constructor constructor = lotrMaterialClass.getDeclaredConstructor(String.class); + constructor.setAccessible(true); + Object redDwarfSteelMaterial = constructor.newInstance("RED_DWARF_STEEL"); + + // Reflection to call the private methods on the new instance + Method setUses = lotrMaterialClass.getDeclaredMethod("setUses", int.class); + Method setDamage = lotrMaterialClass.getDeclaredMethod("setDamage", float.class); + Method setProtection = lotrMaterialClass.getDeclaredMethod("setProtection", float.class); + Method setHarvestLevel = lotrMaterialClass.getDeclaredMethod("setHarvestLevel", int.class); + Method setSpeed = lotrMaterialClass.getDeclaredMethod("setSpeed", float.class); + Method setEnchantability = lotrMaterialClass.getDeclaredMethod("setEnchantability", int.class); + + setUses.setAccessible(true); + setDamage.setAccessible(true); + setProtection.setAccessible(true); + setHarvestLevel.setAccessible(true); + setSpeed.setAccessible(true); + setEnchantability.setAccessible(true); + + setUses.invoke(redDwarfSteelMaterial, 700); + setDamage.invoke(redDwarfSteelMaterial, 3.0F); + setProtection.invoke(redDwarfSteelMaterial, 0.7F); + setHarvestLevel.invoke(redDwarfSteelMaterial, 3); + setSpeed.invoke(redDwarfSteelMaterial, 7.0F); + setEnchantability.invoke(redDwarfSteelMaterial, 10); + + // Assuming a public method to set the crafting item exists + Method setCraftingItem = lotrMaterialClass.getDeclaredMethod("setCraftingItem", Item.class); + setCraftingItem.setAccessible(true); + setCraftingItem.invoke(redDwarfSteelMaterial, CinderLoE.redDwarfSteel); + + // Now, assign the created and configured LOTRMaterial instance to the static field + redDwarfSteelField.set(null, redDwarfSteelMaterial); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRNPCRendering.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRNPCRendering.java new file mode 100644 index 0000000..24b7fcd --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRNPCRendering.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.entity.LOTRNPCRendering; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRNPCRendering.class) +public abstract class MixinLOTRNPCRendering { + @Redirect(method = "renderQuestBook(Llotr/common/entity/npc/LOTREntityNPC;DDD)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private static void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderArmorStand.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderArmorStand.java new file mode 100644 index 0000000..0d3960f --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderArmorStand.java @@ -0,0 +1,150 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.CinderLoE_Config; +import org.lwjgl.opengl.GL11; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import io.gitlab.dwarfyassassin.lotrucp.client.util.FakeArmorStandEntity; + +import lotr.client.LOTRClientProxy; +import lotr.client.model.LOTRArmorModels; +import lotr.client.model.LOTRModelBiped; +import lotr.client.render.tileentity.LOTRRenderArmorStand; +import lotr.common.tileentity.LOTRTileEntityArmorStand; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.entity.RenderBiped; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; + +@Mixin(LOTRRenderArmorStand.class) +public abstract class MixinLOTRRenderArmorStand extends TileEntitySpecialRenderer { + + @Shadow + private static ModelBase standModel; + @Shadow + private static ResourceLocation standTexture; + + @Shadow + private static ModelBiped modelBipedMain; + @Shadow + private static ModelBiped modelBiped1; + @Shadow + private static ModelBiped modelBiped2; + @Shadow + private static float BIPED_ARM_ROTATION; + @Shadow + private static float BIPED_TICKS_EXISTED; + + @Overwrite(remap = false) + public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) { + LOTRTileEntityArmorStand armorStand = (LOTRTileEntityArmorStand)tileentity; + FakeArmorStandEntity fakeArmorStandEntity = FakeArmorStandEntity.INSTANCE; + GL11.glPushMatrix(); + GL11.glDisable(2884); + GL11.glEnable(32826); + GL11.glEnable(3008); + GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); + switch (armorStand.getBlockMetadata() & 0x3) { + case 0: + GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F); + break; + case 1: + GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); + break; + case 2: + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + break; + } + GL11.glScalef(-1.0F, -1.0F, 1.0F); + float scale = 0.0625F; + bindTexture(standTexture); + standModel.render((Entity)fakeArmorStandEntity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, scale); + LOTRArmorModels.INSTANCE.setupModelForRender(modelBipedMain, null, (EntityLivingBase)fakeArmorStandEntity); + GL11.glTranslatef(0.0F, -0.1875F, 0.0F); + for (int slot = 0; slot < 4; slot++) { + ItemStack itemstack = armorStand.func_70301_a(slot); + if (itemstack != null && (itemstack.getItem() instanceof ItemArmor || itemstack.getItem() instanceof lotr.common.item.LOTRItemPlate)) { + boolean isArmor = itemstack.getItem() instanceof ItemArmor; + if (isArmor) + bindTexture(RenderBiped.getArmorResource((Entity)fakeArmorStandEntity, itemstack, slot, null)); + ModelBiped armorModel = (slot == 2) ? modelBiped2 : modelBiped1; + LOTRArmorModels.INSTANCE.setupArmorForSlot(armorModel, slot); + armorModel = ForgeHooksClient.getArmorModel((EntityLivingBase)fakeArmorStandEntity, itemstack, slot, armorModel); + ModelBiped specialModel = LOTRArmorModels.INSTANCE.getSpecialArmorModel(itemstack, slot, (EntityLivingBase)fakeArmorStandEntity, modelBipedMain); + if (specialModel != null) + armorModel = specialModel; + LOTRArmorModels.INSTANCE.setupModelForRender(armorModel, null, (EntityLivingBase)fakeArmorStandEntity); + float f1 = 1.0F; + boolean isColoredArmor = false; + if (isArmor) { + int j = ((ItemArmor)itemstack.getItem()).getColor(itemstack); + if (j != -1) { + float f2 = (j >> 16 & 0xFF) / 255.0F; + float f3 = (j >> 8 & 0xFF) / 255.0F; + float f4 = (j & 0xFF) / 255.0F; + GL11.glColor3f(f1 * f2, f1 * f3, f1 * f4); + isColoredArmor = true; + } else { + GL11.glColor3f(f1, f1, f1); + } + } else { + GL11.glColor3f(f1, f1, f1); + } + armorModel.render((Entity)fakeArmorStandEntity, BIPED_ARM_ROTATION, 0.0F, BIPED_TICKS_EXISTED, 0.0F, 0.0F, scale); + if (isColoredArmor) { + bindTexture(RenderBiped.getArmorResource(null, itemstack, slot, "overlay")); + f1 = 1.0F; + GL11.glColor3f(f1, f1, f1); + armorModel.render((Entity)fakeArmorStandEntity, BIPED_ARM_ROTATION, 0.0F, BIPED_TICKS_EXISTED, 0.0F, 0.0F, scale); + } + if (itemstack.isItemEnchanted()) { + float f2 = armorStand.ticksExisted + f; + bindTexture(LOTRClientProxy.enchantmentTexture); + GL11.glEnable(3042); + float f3 = 0.5F; + GL11.glColor4f(f3, f3, f3, 1.0F); + GL11.glDepthFunc(514); + GL11.glDepthMask(false); + for (int k = 0; k < 2; k++) { + GL11.glDisable(2896); + GL11.glColor4f(CinderLoE_Config.enchantment_color_red, CinderLoE_Config.enchantment_color_green, CinderLoE_Config.enchantment_color_blue, 1.0F); + GL11.glBlendFunc(768, 1); + GL11.glMatrixMode(5890); + GL11.glLoadIdentity(); + float f5 = 0.33333334F; + GL11.glScalef(f5, f5, f5); + GL11.glRotatef(30.0F - k * 60.0F, 0.0F, 0.0F, 1.0F); + float f6 = f2 * (0.001F + k * 0.003F) * 20.0F; + GL11.glTranslatef(0.0F, f6, 0.0F); + GL11.glMatrixMode(5888); + armorModel.render((Entity)fakeArmorStandEntity, BIPED_ARM_ROTATION, 0.0F, BIPED_TICKS_EXISTED, 0.0F, 0.0F, scale); + } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glMatrixMode(5890); + GL11.glDepthMask(true); + GL11.glLoadIdentity(); + GL11.glMatrixMode(5888); + GL11.glEnable(2896); + GL11.glDisable(3042); + GL11.glDepthFunc(515); + } + } + } + GL11.glEnable(2884); + GL11.glDisable(32826); + GL11.glPopMatrix(); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderBlownItem.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderBlownItem.java new file mode 100644 index 0000000..3a426f7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderBlownItem.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.item.LOTRRenderBlownItem; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderBlownItem.class) +public abstract class MixinLOTRRenderBlownItem { + @Redirect(method = "renderItem(Lnet/minecraftforge/client/IItemRenderer$ItemRenderType;Lnet/minecraft/item/ItemStack;[Ljava/lang/Object;)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderBow.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderBow.java new file mode 100644 index 0000000..5733c81 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderBow.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.item.LOTRRenderBow; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderBow.class) +public abstract class MixinLOTRRenderBow { + @Redirect(method = "renderItem(Lnet/minecraftforge/client/IItemRenderer$ItemRenderType;Lnet/minecraft/item/ItemStack;[Ljava/lang/Object;)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderCrossbow.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderCrossbow.java new file mode 100644 index 0000000..73300bb --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderCrossbow.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.item.LOTRRenderCrossbow; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderCrossbow.class) +public abstract class MixinLOTRRenderCrossbow { + @Redirect(method = "renderItem(Lnet/minecraftforge/client/IItemRenderer$ItemRenderType;Lnet/minecraft/item/ItemStack;[Ljava/lang/Object;)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderDart.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderDart.java new file mode 100644 index 0000000..57502ae --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderDart.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.entity.LOTRRenderDart; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderDart.class) +public abstract class MixinLOTRRenderDart { + @Redirect(method = "func_76986_a(Lnet/minecraft/entity/Entity;DDDFF)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderElf.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderElf.java new file mode 100644 index 0000000..0c98d8d --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderElf.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.entity.LOTRRenderElf; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderElf.class) +public abstract class MixinLOTRRenderElf { + @Redirect(method = "func_77029_c(Lnet/minecraft/entity/EntityLivingBase;F)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderElvenBlade.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderElvenBlade.java new file mode 100644 index 0000000..02d86b7 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderElvenBlade.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.item.LOTRRenderElvenBlade; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderElvenBlade.class) +public abstract class MixinLOTRRenderElvenBlade { + @Redirect(method = "renderItem(Lnet/minecraftforge/client/IItemRenderer$ItemRenderType;Lnet/minecraft/item/ItemStack;[Ljava/lang/Object;)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderLargeItem.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderLargeItem.java new file mode 100644 index 0000000..f19a2dc --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderLargeItem.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.item.LOTRRenderLargeItem; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderLargeItem.class) +public abstract class MixinLOTRRenderLargeItem { + @Redirect(method = "renderLargeItem(Lnet/minecraft/util/IIcon;)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderNPCRespawner.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderNPCRespawner.java new file mode 100644 index 0000000..4e99bd0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderNPCRespawner.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.entity.LOTRRenderNPCRespawner; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderNPCRespawner.class) +public abstract class MixinLOTRRenderNPCRespawner { + @Redirect(method = "func_76986_a(Lnet/minecraft/entity/Entity;DDDFF)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderPlateFood.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderPlateFood.java new file mode 100644 index 0000000..697587c --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderPlateFood.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.tileentity.LOTRRenderPlateFood; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderPlateFood.class) +public abstract class MixinLOTRRenderPlateFood { + @Redirect(method = "func_147500_a(Lnet/minecraft/tileentity/TileEntity;DDDF)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderThrowingAxe.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderThrowingAxe.java new file mode 100644 index 0000000..94929d2 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderThrowingAxe.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.entity.LOTRRenderThrowingAxe; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderThrowingAxe.class) +public abstract class MixinLOTRRenderThrowingAxe { + @Redirect(method = "func_76986_a(Lnet/minecraft/entity/Entity;DDDFF)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderTraderRespawn.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderTraderRespawn.java new file mode 100644 index 0000000..dabe6e2 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRRenderTraderRespawn.java @@ -0,0 +1,21 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import lotr.client.render.entity.LOTRRenderTraderRespawn; + +import net.minecraft.client.renderer.Tessellator; + +@Mixin(LOTRRenderTraderRespawn.class) +public abstract class MixinLOTRRenderTraderRespawn { + @Redirect(method = "func_76986_a(Lnet/minecraft/entity/Entity;DDDFF)V", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/ItemRenderer;func_78439_a(Lnet/minecraft/client/renderer/Tessellator;FFFFIIF)V")) + private void onRenderItemIn2D(Tessellator tessellator, float f1, float f2, float f, float f3, int width, int height, float thickness) { + RenderHelper.customRenderItemIn2D(tessellator, f1, f2, f, f3, width, height, thickness, false); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRTileEntityDwarvenForge.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRTileEntityDwarvenForge.java new file mode 100644 index 0000000..4631a3e --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRTileEntityDwarvenForge.java @@ -0,0 +1,59 @@ +package com.zivilon.cinder_loe.mixins; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.init.Items; + +import net.minecraftforge.oredict.OreDictionary; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Overwrite; + +import lotr.common.tileentity.LOTRTileEntityDwarvenForge; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Field; + +import com.zivilon.cinder_loe.CinderLoE; +import lotr.common.LOTRMod; + +@Mixin(LOTRTileEntityDwarvenForge.class) +public abstract class MixinLOTRTileEntityDwarvenForge { + protected boolean isCopper(ItemStack itemstack) { + return (LOTRMod.isOreNameEqual(itemstack, "oreCopper") || LOTRMod.isOreNameEqual(itemstack, "ingotCopper")); + } + + protected boolean isTin(ItemStack itemstack) { + return (LOTRMod.isOreNameEqual(itemstack, "oreTin") || LOTRMod.isOreNameEqual(itemstack, "ingotTin")); + } + + protected boolean isIron(ItemStack itemstack) { + return (LOTRMod.isOreNameEqual(itemstack, "oreIron") || LOTRMod.isOreNameEqual(itemstack, "ingotIron")); + } + + protected boolean isCoal(ItemStack itemstack) { + return (itemstack.getItem() == Items.coal); + } + + protected boolean isGoldNugget(ItemStack itemstack) { + return (itemstack.getItem() == Items.gold_nugget); + } + + @Overwrite(remap = false) + protected ItemStack getAlloySmeltingResult(ItemStack itemstack, ItemStack alloyItem) { + if (isIron(itemstack) && isCoal(alloyItem)) + return new ItemStack(LOTRMod.dwarfSteel); + if (isIron(itemstack) && alloyItem.getItem() == LOTRMod.quenditeCrystal) + return new ItemStack(LOTRMod.galvorn); + if (isIron(itemstack) && alloyItem.getItem() == Item.getItemFromBlock(LOTRMod.rock) && alloyItem.getItemDamage() == 3) + return new ItemStack(LOTRMod.blueDwarfSteel); + if (isCopper(itemstack) && alloyItem.getItem() == Item.getItemById(371)) + return new ItemStack(CinderLoE.redDwarfSteel); + if ((isCopper(itemstack) && isTin(alloyItem)) || (isTin(itemstack) && isCopper(alloyItem))) + return new ItemStack(LOTRMod.bronze, 2); + return null; + } +} + diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRWorldGenMumakSkeleton.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRWorldGenMumakSkeleton.java new file mode 100644 index 0000000..76786c0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTRWorldGenMumakSkeleton.java @@ -0,0 +1,29 @@ +package com.zivilon.cinder_loe.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import lotr.common.world.structure2.LOTRWorldGenMumakSkeleton; + +import net.minecraft.block.Block; + +import java.util.Random; + +import com.zivilon.cinder_loe.CinderLoE; + +@Mixin(LOTRWorldGenMumakSkeleton.class) +public class MixinLOTRWorldGenMumakSkeleton { + + @Shadow + protected Block boneBlock; + + @Shadow + protected int boneMeta; + + @Overwrite(remap = false) + protected void setupRandomBlocks(Random random) { + this.boneBlock = CinderLoE.ivoryBlock; + this.boneMeta = 3; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinRenderItem.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinRenderItem.java new file mode 100644 index 0000000..396b349 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinRenderItem.java @@ -0,0 +1,228 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.CinderLoE_Config; +import com.zivilon.cinder_loe.client.render.item.RenderHelper; +import com.zivilon.cinder_loe.util.Utilities; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Random; +import java.util.concurrent.Callable; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; + +@Mixin(RenderItem.class) +public abstract class MixinRenderItem extends Render { + @Shadow + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + + @Shadow + private Random random; + + @Shadow + public static boolean renderInFrame; + + @Shadow + public byte getMiniBlockCount(ItemStack stack, byte original) { + return 0; + } + + @Shadow + public byte getMiniItemCount(ItemStack stack, byte original) { + return 0; + } + + @Shadow + public boolean shouldSpreadItems() { + return false; + } + + @Shadow + private void renderGlint(int p_77018_1_, int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_) {} + + @Overwrite(remap = false) + private void renderDroppedItem(EntityItem p_77020_1_, IIcon p_77020_2_, int p_77020_3_, float p_77020_4_, float p_77020_5_, float p_77020_6_, float p_77020_7_, int pass) { + Tessellator tessellator = Tessellator.instance; + + if (p_77020_2_ == null) { + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + ResourceLocation resourcelocation = texturemanager.getResourceLocation(p_77020_1_.getEntityItem().getItemSpriteNumber()); + p_77020_2_ = ((TextureMap)texturemanager.getTexture(resourcelocation)).getAtlasSprite("missingno"); + } + + float f14 = ((IIcon)p_77020_2_).getMinU(); + float f15 = ((IIcon)p_77020_2_).getMaxU(); + float f4 = ((IIcon)p_77020_2_).getMinV(); + float f5 = ((IIcon)p_77020_2_).getMaxV(); + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.25F; + float f10; + + if (this.renderManager.options.fancyGraphics) { + GL11.glPushMatrix(); + + if (renderInFrame) { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + else { + GL11.glRotatef((((float)p_77020_1_.age + p_77020_4_) / 20.0F + p_77020_1_.hoverStart) * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + float f9 = 0.0625F; + f10 = 0.021875F; + ItemStack itemstack = p_77020_1_.getEntityItem(); + int j = itemstack.stackSize; + byte b0; + + if (j < 2) { + b0 = 1; + } + else if (j < 16) { + b0 = 2; + } + else if (j < 32) { + b0 = 3; + } + else { + b0 = 4; + } + + b0 = getMiniItemCount(itemstack, b0); + + GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F)); + + for (int k = 0; k < b0; ++k) { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + if (k > 0 && shouldSpreadItems()) { + float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + GL11.glTranslatef(x, y, f9 + f10); + } + else { + GL11.glTranslatef(0f, 0f, f9 + f10); + } + + if (itemstack.getItemSpriteNumber() == 0) { + this.bindTexture(TextureMap.locationBlocksTexture); + } + else { + this.bindTexture(TextureMap.locationItemsTexture); + } + + GL11.glColor4f(p_77020_5_, p_77020_6_, p_77020_7_, 1.0F); + RenderHelper.customRenderItemIn2D(tessellator, f15, f4, f14, f5, ((IIcon)p_77020_2_).getIconWidth(), ((IIcon)p_77020_2_).getIconHeight(), f9, false); + + if (itemstack.hasEffect(pass)) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + this.renderManager.renderEngine.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + GL11.glColor4f(CinderLoE_Config.enchantment_color_red, CinderLoE_Config.enchantment_color_green, CinderLoE_Config.enchantment_color_blue, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f12 = 0.125F; + GL11.glScalef(f12, f12, f12); + float f13 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f13, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + RenderHelper.customRenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9, true); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f12, f12, f12); + f13 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f13, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + RenderHelper.customRenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9, true); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } + else { + for (int l = 0; l < p_77020_3_; ++l) { + GL11.glPushMatrix(); + + if (l > 0) { + f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(f10, f16, f17); + } + + if (!renderInFrame) { + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + } + + GL11.glColor4f(p_77020_5_, p_77020_6_, p_77020_7_, 1.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f14, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f15, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f15, (double)f4); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f14, (double)f4); + tessellator.draw(); + GL11.glPopMatrix(); + } + } + } + + @Overwrite(remap = false) + public void renderEffect(TextureManager manager, int x, int y) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(CinderLoE_Config.enchantment_color_red, CinderLoE_Config.enchantment_color_green, CinderLoE_Config.enchantment_color_blue, 1.0F); + this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinRendererLivingEntity.java b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinRendererLivingEntity.java new file mode 100644 index 0000000..9c31081 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/mixins/MixinRendererLivingEntity.java @@ -0,0 +1,302 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.CinderLoE_Config; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderLivingEvent; +import net.minecraftforge.common.MinecraftForge; + +@Mixin(RendererLivingEntity.class) +public abstract class MixinRendererLivingEntity extends Render { + + @Shadow + protected ModelBase renderPassModel; + + @Shadow + protected ModelBase mainModel; + + @Shadow + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + + @Shadow + private static final Logger logger = LogManager.getLogger(); + + @Shadow + protected int inheritRenderPass(EntityLivingBase p_77035_1_, int p_77035_2_, float p_77035_3_) { + return 0; + } + + @Shadow + protected int getColorMultiplier(EntityLivingBase p_77030_1_, float p_77030_2_, float p_77030_3_) { + return 0; + } + + @Shadow + protected void func_82408_c(EntityLivingBase p_82408_1_, int p_82408_2_, float p_82408_3_) {} + + @Shadow + protected void renderEquippedItems(EntityLivingBase p_77029_1_, float p_77029_2_) {} + + @Shadow + protected float handleRotationFloat(EntityLivingBase p_77044_1_, float p_77044_2_) { + return 0.0F; + } + + @Shadow + protected void rotateCorpse(EntityLivingBase p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) {} + + @Shadow + protected void renderLivingAt(EntityLivingBase p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_) {} + + @Shadow + protected void passSpecialRender(EntityLivingBase p_77033_1_, double p_77033_2_, double p_77033_4_, double p_77033_6_) {} + + @Shadow + protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_) { + return 0; + } + + @Shadow + protected void preRenderCallback(EntityLivingBase p_77041_1_, float p_77041_2_) {} + + @Shadow + private float interpolateRotation(float p_77034_1_, float p_77034_2_, float p_77034_3_) { + return 0.0F; + } + + @Shadow + protected void renderModel(EntityLivingBase p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_) {} + + @Shadow + protected float renderSwingProgress(EntityLivingBase p_77040_1_, float p_77040_2_) { + return 0.0F; + } + + @Overwrite + public void doRender(EntityLivingBase p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) + { + if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(p_76986_1_, (RendererLivingEntity)(Object)this, p_76986_2_, p_76986_4_, p_76986_6_))) return; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + this.mainModel.onGround = this.renderSwingProgress(p_76986_1_, p_76986_9_); + + if (this.renderPassModel != null) + { + this.renderPassModel.onGround = this.mainModel.onGround; + } + + this.mainModel.isRiding = p_76986_1_.isRiding(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isRiding = this.mainModel.isRiding; + } + + this.mainModel.isChild = p_76986_1_.isChild(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isChild = this.mainModel.isChild; + } + + try + { + float f2 = this.interpolateRotation(p_76986_1_.prevRenderYawOffset, p_76986_1_.renderYawOffset, p_76986_9_); + float f3 = this.interpolateRotation(p_76986_1_.prevRotationYawHead, p_76986_1_.rotationYawHead, p_76986_9_); + float f4; + + if (p_76986_1_.isRiding() && p_76986_1_.ridingEntity instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase1 = (EntityLivingBase)p_76986_1_.ridingEntity; + f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, p_76986_9_); + f4 = MathHelper.wrapAngleTo180_float(f3 - f2); + + if (f4 < -85.0F) + { + f4 = -85.0F; + } + + if (f4 >= 85.0F) + { + f4 = 85.0F; + } + + f2 = f3 - f4; + + if (f4 * f4 > 2500.0F) + { + f2 += f4 * 0.2F; + } + } + + float f13 = p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_; + this.renderLivingAt(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_); + f4 = this.handleRotationFloat(p_76986_1_, p_76986_9_); + this.rotateCorpse(p_76986_1_, f4, f2, p_76986_9_); + float f5 = 0.0625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.preRenderCallback(p_76986_1_, p_76986_9_); + GL11.glTranslatef(0.0F, -24.0F * f5 - 0.0078125F, 0.0F); + float f6 = p_76986_1_.prevLimbSwingAmount + (p_76986_1_.limbSwingAmount - p_76986_1_.prevLimbSwingAmount) * p_76986_9_; + float f7 = p_76986_1_.limbSwing - p_76986_1_.limbSwingAmount * (1.0F - p_76986_9_); + + if (p_76986_1_.isChild()) + { + f7 *= 3.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.mainModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_); + this.renderModel(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + int j; + float f8; + float f9; + float f10; + + for (int i = 0; i < 4; ++i) + { + j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_); + + if (j > 0) + { + this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + + if ((j & 240) == 16) + { + this.func_82408_c(p_76986_1_, i, p_76986_9_); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + + if ((j & 15) == 15) + { + f8 = (float)p_76986_1_.ticksExisted + p_76986_9_; + this.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + f9 = 0.5F; + GL11.glColor4f(f9, f9, f9, 1.0F); + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDepthMask(false); + + for (int k = 0; k < 2; ++k) + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glColor4f(CinderLoE_Config.enchantment_color_red, CinderLoE_Config.enchantment_color_green, CinderLoE_Config.enchantment_color_blue, 1.0F); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float f11 = f8 * (0.001F + (float)k * 0.003F) * 20.0F; + float f12 = 0.33333334F; + GL11.glScalef(f12, f12, f12); + GL11.glRotatef(30.0F - (float)k * 60.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, f11, 0.0F); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glDepthMask(true); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + GL11.glDepthMask(true); + this.renderEquippedItems(p_76986_1_, p_76986_9_); + float f14 = p_76986_1_.getBrightness(p_76986_9_); + j = this.getColorMultiplier(p_76986_1_, f14, p_76986_9_); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + + if ((j >> 24 & 255) > 0 || p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); + + if (p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) + { + GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F); + this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + + for (int l = 0; l < 4; ++l) + { + if (this.inheritRenderPass(p_76986_1_, l, p_76986_9_) >= 0) + { + GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + } + } + + if ((j >> 24 & 255) > 0) + { + f8 = (float)(j >> 16 & 255) / 255.0F; + f9 = (float)(j >> 8 & 255) / 255.0F; + float f15 = (float)(j & 255) / 255.0F; + f10 = (float)(j >> 24 & 255) / 255.0F; + GL11.glColor4f(f8, f9, f15, f10); + this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + + for (int i1 = 0; i1 < 4; ++i1) + { + if (this.inheritRenderPass(p_76986_1_, i1, p_76986_9_) >= 0) + { + GL11.glColor4f(f8, f9, f15, f10); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + } + } + + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + catch (Exception exception) + { + logger.error("Couldn\'t render entity", exception); + } + + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glEnable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + this.passSpecialRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_); + MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(p_76986_1_, (RendererLivingEntity)(Object)this, p_76986_2_, p_76986_4_, p_76986_6_)); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/recipes.java b/src/src/main/java/com/zivilon/cinder_loe/recipes.java new file mode 100644 index 0000000..09ccea0 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/recipes.java @@ -0,0 +1,143 @@ +package com.zivilon.cinder_loe; + +import com.zivilon.cinder_loe.CinderLoE; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraftforge.oredict.ShapedOreRecipe; +import lotr.common.LOTRMod; +import lotr.common.recipe.LOTRRecipes; +import lotr.common.recipe.LOTRRecipePoisonWeapon; + +public class recipes { + + public static void registerRecipes() { + // Register a block recipe + System.out.println("[CinderLoE] Registering recipes..."); + registerGeneralRecipes(); + registerRedDwarvenRecipes(); + registerLimwaithRecipes(); + registerBreeRecipes(); + registerArnorRecipes(); + } + public static void registerGeneralRecipes() { + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.cinderBlock), new Object[] { "XXX", "XYX", "XXX", + Character.valueOf('X'), Blocks.stone, Character.valueOf('Y'), LOTRMod.balrogFire })); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.reedBale), new Object[] { "XXX", "XXX", "XXX", + Character.valueOf('X'), LOTRMod.reeds})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.leatherBundle), new Object[] { "XXX", "XXX", "XXX", + Character.valueOf('X'), Items.leather})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.furBundle), new Object[] { "XXX", "XXX", "XXX", + Character.valueOf('X'), LOTRMod.fur})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.fishBarrel), new Object[] { "XXX", "XXX", "XXX", + Character.valueOf('X'), Items.fish})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.silverChain, 8), new Object[] { "X", "X", "X", + Character.valueOf('X'), LOTRMod.silver})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.goldChain, 8), new Object[] { "X", "X", "X", + Character.valueOf('X'), Items.gold_ingot})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.ironChain, 8), new Object[] { "X", "X", "X", + Character.valueOf('X'), Items.iron_ingot})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.bronzeChain, 8), new Object[] { "X", "X", "X", + Character.valueOf('X'), LOTRMod.bronze})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.cobbleDrystone, 4), new Object[] { "XX", "XX", + Character.valueOf('X'), LOTRMod.cobblebrick})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.cutDrystone, 4), new Object[] { "XX", "XX", + Character.valueOf('X'), CinderLoE.cobbleDrystone})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(LOTRMod.cobblebrick, 4), new Object[] { "XX", "XX", + Character.valueOf('X'), CinderLoE.cutDrystone})); + GameRegistry.addRecipe((IRecipe)new ShapedOreRecipe(new ItemStack(CinderLoE.reeflessCoral, 1), new Object[] { "X", + Character.valueOf('X'), LOTRMod.coralReef})); + } + public static void registerRedDwarvenRecipes() { + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.helmetRedDwarf), new Object[] { "XXX", "X X", + Character.valueOf('X'), CinderLoE.redDwarfSteel })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bodyRedDwarf), new Object[] { "X X", "XXX", "XXX", + Character.valueOf('X'), CinderLoE.redDwarfSteel })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.legsRedDwarf), new Object[] { "XXX", "X X", "X X", + Character.valueOf('X'), CinderLoE.redDwarfSteel })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bootsRedDwarf), new Object[] { "X X", "X X", + Character.valueOf('X'), CinderLoE.redDwarfSteel })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.spearRedDwarf), new Object[] { " X", " Y ", "Y ", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.swordRedDwarf), new Object[] { " X ", " X ", " Y ", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.battleaxeRedDwarf), new Object[] { "XXX", "XYX", " Y ", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.pikeRedDwarf), new Object[] { " X", " YX", "Y ", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.hammerRedDwarf), new Object[] { "XYX", "XYX", " Y ", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.daggerRedDwarf), new Object[] { "X ", "Y ", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.crossbowRedDwarf), new Object[] { "XXY", "ZYX", "YZX", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "stickWood", Character.valueOf('Z'), "string" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.boarArmorRedDwarf), new Object[] { "X ", "XYX", "XXX", + Character.valueOf('X'), CinderLoE.redDwarfSteel, Character.valueOf('Y'), "leather" })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.blockRedDwarfSteel), new Object[] { "XXX", "XXX", "XXX", + Character.valueOf('X'), CinderLoE.redDwarfSteel })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.redDwarfSteel), new Object[] { "X ", " ", + Character.valueOf('X'), CinderLoE.redDwarfSteel })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.chandelierRedDwarf, 2), new Object[] { " X ", "ZYZ", " ", + Character.valueOf('X'), "stickWood", Character.valueOf('Y'), CinderLoE.redDwarfSteel, Character.valueOf('Z'), Blocks.torch })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.barsRedDwarf, 16), new Object[] { "XXX", "XXX", " ", + Character.valueOf('X'), CinderLoE.redDwarfSteel })); + LOTRRecipes.dwarvenRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.dwarvenBrickRuned, 4), new Object[] { " X ", "XYX", " X ", + Character.valueOf('X'), new ItemStack(LOTRMod.brick, 1, 6), Character.valueOf('Y'), Items.gold_nugget})); + GameRegistry.addShapelessRecipe(new ItemStack(CinderLoE.redDwarfSteel, 9), new Object[] { new ItemStack(CinderLoE.blockRedDwarfSteel) }); + GameRegistry.addRecipe(new ItemStack(CinderLoE.blockRedDwarfSteel, 1), new Object[] { "XXX", "XXX", "XXX", + Character.valueOf('X'), CinderLoE.redDwarfSteel }); + GameRegistry.addRecipe(new LOTRRecipePoisonWeapon(CinderLoE.daggerRedDwarf, CinderLoE.daggerRedDwarfPoisoned)); + } + + public static void registerLimwaithRecipes() { + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.helmetLimwaith), new Object[] { "XXX", "Y Y", + Character.valueOf('X'), LOTRMod.driedReeds, Character.valueOf('Y'), new ItemStack(LOTRMod.planks, 1, 15)})); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bodyLimwaith), new Object[] { "X X", "YYY", "XXX", + Character.valueOf('X'), LOTRMod.driedReeds, Character.valueOf('Y'), new ItemStack(LOTRMod.planks, 1, 15)})); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.legsLimwaith), new Object[] { "XXX", "Y Y", "X X", + Character.valueOf('X'), LOTRMod.driedReeds, Character.valueOf('Y'), new ItemStack(LOTRMod.planks, 1, 15)})); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bootsLimwaith), new Object[] { "Y Y", "X X", + Character.valueOf('X'), LOTRMod.driedReeds, Character.valueOf('Y'), new ItemStack(LOTRMod.planks, 1, 15)})); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.spearLimwaith), new Object[] { " X", " Y ", "Y ", + Character.valueOf('X'), Items.bone, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.truncheonLimwaith), new Object[] { " X ", " X ", " Y ", + Character.valueOf('X'), Items.bone, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.battleaxeLimwaith), new Object[] { "XXX", "XYX", " Y ", + Character.valueOf('X'), Items.bone, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.tridentLimwaith), new Object[] { " XX", " YX", "Y ", + Character.valueOf('X'), Items.bone, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.daggerLimwaith), new Object[] { "X ", "Y ", + Character.valueOf('X'), Items.bone, Character.valueOf('Y'), "stickWood" })); + LOTRRecipes.moredainRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.blowgunLimwaith), new Object[] { "YXX", " ", " ", + Character.valueOf('X'), LOTRMod.reeds, Character.valueOf('Y'), "stickWood" })); + GameRegistry.addRecipe(new LOTRRecipePoisonWeapon(CinderLoE.daggerLimwaith, CinderLoE.daggerLimwaithPoisoned)); + } + + public static void registerBreeRecipes() { + LOTRRecipes.breeRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.helmetBree), new Object[] { "XXX", "X X", + Character.valueOf('X'), Items.iron_ingot})); + LOTRRecipes.breeRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bodyBree), new Object[] { "X X", "XXX", "XXX", + Character.valueOf('X'), Items.iron_ingot })); + LOTRRecipes.breeRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.legsBree), new Object[] { "XXX", "X X", "X X", + Character.valueOf('X'), Items.iron_ingot })); + LOTRRecipes.breeRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bootsBree), new Object[] { "X X", "X X", + Character.valueOf('X'), Items.iron_ingot })); + LOTRRecipes.breeRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.swordBree), new Object[] { " X ", " X ", " Y ", + Character.valueOf('X'), Items.iron_ingot, Character.valueOf('Y'), "stickWood" })); + } + + public static void registerArnorRecipes() { + LOTRRecipes.rangerRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.helmetArnorBanner), new Object[] { "YYY", "Y Y", + Character.valueOf('X'), Items.iron_ingot, Character.valueOf('Y'), Items.leather })); + LOTRRecipes.rangerRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bodyArnorBanner), new Object[] { "Y Y", "XXX", "YYY", + Character.valueOf('X'), Items.iron_ingot, Character.valueOf('Y'), Items.leather })); + LOTRRecipes.rangerRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.legsArnorBanner), new Object[] { "YYY", "X X", "Y Y", + Character.valueOf('X'), Items.iron_ingot, Character.valueOf('Y'), Items.leather })); + LOTRRecipes.rangerRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.bootsArnorBanner), new Object[] { "X X", "X X", + Character.valueOf('X'), Items.iron_ingot, Character.valueOf('Y'), Items.leather })); + LOTRRecipes.rangerRecipes.add(new ShapedOreRecipe(new ItemStack(CinderLoE.maceArnor), new Object[] { " XX", " XX", "Y ", + Character.valueOf('X'), Items.iron_ingot, Character.valueOf('Y'), "stickWood" })); + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/tileentity/TileEntityMistBlock.java b/src/src/main/java/com/zivilon/cinder_loe/tileentity/TileEntityMistBlock.java new file mode 100644 index 0000000..0f2f3c2 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/tileentity/TileEntityMistBlock.java @@ -0,0 +1,66 @@ +package com.zivilon.cinder_loe.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.List; + +import lotr.common.LOTRDimension; +import lotr.common.LOTRGuiMessageTypes; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.tileentity.LOTRTileEntityUtumnoPortal; +import lotr.common.world.LOTRTeleporterUtumno; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.Teleporter; +import net.minecraft.world.World; + +public class TileEntityMistBlock extends LOTRTileEntityUtumnoPortal { + public float color_red; + public float color_green; + public float color_blue; + + public TileEntityMistBlock() { + this(0.0F, 0.0F, 0.0F); + } + + public TileEntityMistBlock(float r, float g, float b) { + color_red = r; + color_green = g; + color_blue = b; + } + + public void func_149670_a(World world, int i, int j, int k, Entity entity) {} + + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setFloat("red", this.color_red); + nbt.setFloat("green", this.color_green); + nbt.setFloat("blue", this.color_blue); + } + + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.color_red = nbt.getFloat("red"); + this.color_green = nbt.getFloat("green"); + this.color_blue = nbt.getFloat("blue"); + } + + @Override + public void func_145845_h() {} + + @Override + public void transferEntity(Entity entity) {} + + private LOTRTileEntityUtumnoPortal findActingTargetingPortal() { + return null; + } +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/util/BlockPos.java b/src/src/main/java/com/zivilon/cinder_loe/util/BlockPos.java new file mode 100644 index 0000000..61c6ac9 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/util/BlockPos.java @@ -0,0 +1,50 @@ +package com.zivilon.cinder_loe.util; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockBush; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import java.util.ArrayList; +import java.util.Random; + +public class BlockPos { + public int x, y, z; + + public BlockPos(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public static BlockPos findSafeSpawnLocation(World world, EntityPlayer entityPlayer) { + Random rand = new Random(); + ArrayList validPositions = new ArrayList(); + int radius = 5; // 5-block radius + + int originX = MathHelper.floor_double(entityPlayer.posX); + int originY = MathHelper.floor_double(entityPlayer.posY); + int originZ = MathHelper.floor_double(entityPlayer.posZ); + + for (int x = originX - radius; x <= originX + radius; x++) { + for (int z = originZ - radius; z <= originZ + radius; z++) { + for (int y = originY - radius; y <= originY + radius; y++) { + Block block = world.getBlock(x, y, z); + Block blockAbove = world.getBlock(x, y + 1, z); + + // Check if the block is solid and there's air above it + if (!block.isAir(world, x, y, z) && !(block instanceof BlockBush) && (blockAbove.isAir(world, x, y + 1, z) || (blockAbove instanceof BlockBush))) { + validPositions.add(new BlockPos(x, y + 1, z)); // Add the position above the solid block + } + } + } + } + if (validPositions.isEmpty()) { + return null; // No valid position found + } + + // Select a random valid position + return validPositions.get(rand.nextInt(validPositions.size())); + } + +} diff --git a/src/src/main/java/com/zivilon/cinder_loe/util/Utilities.java b/src/src/main/java/com/zivilon/cinder_loe/util/Utilities.java new file mode 100644 index 0000000..167f904 --- /dev/null +++ b/src/src/main/java/com/zivilon/cinder_loe/util/Utilities.java @@ -0,0 +1,125 @@ +package com.zivilon.cinder_loe.util; + +import com.zivilon.cinder_loe.client.render.item.RenderHelper; + +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.UUID; +import java.util.Vector; + +import lotr.common.LOTRCreativeTabs; +import lotr.common.world.biome.LOTRBiome; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; + +public class Utilities { + + public static int[] LOTRIntCache = null; + public static LOTRBiome reflected_river; + public static LOTRCreativeTabs reflected_tab_block; + + public static void initialize_reflects() { + try { + Field riverField = LOTRBiome.class.getField("river"); + reflected_river = (LOTRBiome)riverField.get(null); + + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + public static void pre_init_reflects() { + try { + Field tabBlockField = LOTRCreativeTabs.class.getField("tabBlock"); + reflected_tab_block = (LOTRCreativeTabs)tabBlockField.get(null); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + public static EntityPlayerMP getPlayerByUUID(UUID playerUUID) { + MinecraftServer server = MinecraftServer.getServer(); // Get the server instance + if (server == null) { + return null; // Server instance is not available + } + + // Iterate through the list of online players and match UUID + for (Object obj : server.getConfigurationManager().playerEntityList) { + if (obj instanceof EntityPlayerMP) { + EntityPlayerMP player = (EntityPlayerMP) obj; + if (player.getUniqueID().equals(playerUUID)) { + return player; + } + } else { + System.err.println("[CinderCore] Player list having non-players, WHAT?!?!?!"); + } + } + return null; // Player not found or not online + } + + public static String toSnakeCase(String input) { + if (input == null || input.isEmpty()) { + return input; + } + + StringBuilder builder = new StringBuilder(); + char[] chars = input.toCharArray(); + + builder.append(Character.toLowerCase(chars[0])); + for (int i = 1; i < chars.length; i++) { + char c = chars[i]; + if (Character.isUpperCase(c)) { + builder.append('_').append(Character.toLowerCase(c)); + } else { + builder.append(c); + } + } + + return builder.toString(); + } + + public static void dumpClass(String className, String outputFilePath, Class contextClass) { + // Convert class name to a resource path + String resourcePath = className.replace('.', '/') + ".class"; + // Use the class loader of the context class to find the resource + try (InputStream classStream = contextClass.getClassLoader().getResourceAsStream(resourcePath)) { + if (classStream == null) { + System.err.println("Class " + className + " could not be found."); + return; + } + try (OutputStream outputStream = new FileOutputStream(outputFilePath)) { + // Copy the class stream to the output file + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = classStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + System.out.println("Dumped " + className + " to " + outputFilePath); + } catch (IOException e) { + System.err.println("Failed to write class file: " + e.getMessage()); + } + } catch (IOException e) { + System.err.println("Failed to read class file: " + e.getMessage()); + } + } + + public static void writeLog(String message) { + try (BufferedWriter writer = new BufferedWriter(new FileWriter("custom_log.txt", true))) { + LocalDateTime now = LocalDateTime.now(); + String timestamp = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + writer.write(timestamp + " - " + message + "\n"); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/src/main/resources/LICENSE b/src/src/main/resources/LICENSE new file mode 100644 index 0000000..be08a1d --- /dev/null +++ b/src/src/main/resources/LICENSE @@ -0,0 +1,88 @@ +Code of CinderLoE is marked with CC0 1.0 Universal. To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 +License not applicable to graphics contained within the package. + +Graphics: +KeyLime17 & cleric_red: (All rights reserved) +- assets/cinder_loe/mob/limwaith/* +- assets/lotr/armor/* +- assets/lotr/item/banner/banner_redDwarf.png +- assets/lotr/textures/blocks/bars_red_dwarf.png +- assets/lotr/textures/blocks/chandelier_red_dwarf.png +- assets/lotr/textures/blocks/red_dwarf_steel.png +- assets/lotr/textures/items/alatarStaff.png +- assets/lotr/textures/items/pallandoStaff.png +- assets/lotr/textures/items/radagastStaff.png +- assets/lotr/textures/items/sarumanStaff.png +- assets/lotr/textures/items/banner_redDwarf.png +- assets/lotr/textures/items/battleaxeLimwaith.png +- assets/lotr/textures/items/blowgunLimwaith.png +- assets/lotr/textures/items/daggerLimwaith.png +- assets/lotr/textures/items/daggerLimwaithPoisoned.png +- assets/lotr/textures/items/tridentLimwaith.png +- assets/lotr/textures/items/truncheonLimwaith.png +- assets/lotr/textures/items/spearLimwaith.png +- assets/lotr/textures/items/helmetLimwaith.png +- assets/lotr/textures/items/bodyLimwaith.png +- assets/lotr/textures/items/legsLimwaith.png +- assets/lotr/textures/items/bootsLimwaith.png +- assets/lotr/textures/items/battleaxeRedDwarf.png +- assets/lotr/textures/items/crossbowRedDwarf.png +- assets/lotr/textures/items/crossbowRedDwarf_pull_0.png +- assets/lotr/textures/items/crossbowRedDwarf_pull_1.png +- assets/lotr/textures/items/crossbowRedDwarf_pull_2.png +- assets/lotr/textures/items/daggerRedDwarf.png +- assets/lotr/textures/items/daggerRedDwarfPoisoned.png +- assets/lotr/textures/items/hammerRedDwarf.png +- assets/lotr/textures/items/pikeRedDwarf.png +- assets/lotr/textures/items/spearRedDwarf.png +- assets/lotr/textures/items/swordRedDwarf.png +- assets/lotr/textures/items/redDwarfSteel.png +- assets/lotr/textures/items/helmetRedDwarf.png +- assets/lotr/textures/items/bodyRedDwarf.png +- assets/lotr/textures/items/legsRedDwarf.png +- assets/lotr/textures/items/bootsRedDwarf.png +- assets/lotr/textures/items/boarArmorRedDwarf.png +- assets/lotr/textures/items/large/alatarStaff.png +- assets/lotr/textures/items/large/pallandoStaff.png +- assets/lotr/textures/items/large/radagastStaff.png +- assets/lotr/textures/items/large/sarumanStaff.png +- assets/lotr/textures/items/large/battleaxeLimwaith.png +- assets/lotr/textures/items/large/tridentLimwaith.png +- assets/lotr/textures/items/large/spearLimwaith.png +- assets/lotr/textures/items/large/spearRedDwarf.png +- assets/lotr/textures/items/large2/pikeRedDwarf.png +- assets/lotr/textures/shield/alignment_RedDwarf.png + +LOTRMod team: (All rights reserved) +- assets/lotr/textures/blocks/fur_bundle_bottom.png +- assets/lotr/textures/blocks/fur_bundle_top.png +- assets/lotr/textures/blocks/fur_bundle_side_0.png +- assets/lotr/textures/blocks/fur_bundle_side_90.png +- assets/lotr/textures/blocks/fur_bundle_side_180.png +- assets/lotr/textures/blocks/fur_bundle_side_270.png +- assets/lotr/textures/blocks/leather_bundle_bottom.png +- assets/lotr/textures/blocks/leather_bundle_top.png +- assets/lotr/textures/blocks/leather_bundle_side_0.png +- assets/lotr/textures/blocks/leather_bundle_side_90.png +- assets/lotr/textures/blocks/leather_bundle_side_180.png +- assets/lotr/textures/blocks/leather_bundle_side_270.png +- assets/lotr/textures/blocks/reed_bale_bottom.png +- assets/lotr/textures/blocks/reed_bale_top.png +- assets/lotr/textures/blocks/reed_bale_side_0.png +- assets/lotr/textures/blocks/reed_bale_side_90.png +- assets/lotr/textures/blocks/reed_bale_side_180.png +- assets/lotr/textures/blocks/reed_bale_side_270.png +- assets/lotr/textures/items/gandalfStaffGrey.png +- assets/lotr/textures/items/gandalfStaffWhite.png +- assets/lotr/textures/items/large/gandalfStaffGrey.png +- assets/lotr/textures/items/large/gandalfStaffWhite.png + + +Mojang: (All rights reserved) +- assets/lotr/textures/items/spawn_egg.png + +Unidentified: (Assume all rights reserved) +- assets/lotr/textures/blocks/cinder_block.png +- assets/lotr/textures/blocks/ivory_block_top.png +- assets/lotr/textures/blocks/ivory_block_side_0.png +- assets/lotr/textures/blocks/ivory_block_side_90.png diff --git a/src/src/main/resources/mcmod.info b/src/src/main/resources/mcmod.info new file mode 100644 index 0000000..360f3c8 --- /dev/null +++ b/src/src/main/resources/mcmod.info @@ -0,0 +1,21 @@ +{ + "modListVersion": 2, + "modList": [{ + "modid": "${modId}", + "name": "${modName}", + "description": "CINDER MOD.\nMod designed to add blocks to The Lord of Embers Minecraft server.", + "version": "${modVersion}", + "mcversion": "${minecraftVersion}", + "url": "thelordofembers.com", + "updateUrl": "", + "authorList": ["Shinare"], + "credits": "", + "logoFile": "", + "screenshots": [], + "parent": "", + "requiredMods": [], + "dependencies": [], + "dependants": [], + "useDependencyInformation": true + }] +} diff --git a/src/src/main/resources/mixins.cinder_loe.json b/src/src/main/resources/mixins.cinder_loe.json new file mode 100644 index 0000000..aae8119 --- /dev/null +++ b/src/src/main/resources/mixins.cinder_loe.json @@ -0,0 +1,34 @@ +{ + "required": true, + "minVersion": "0.7.11", + "package": "com.zivilon.cinder_loe.mixins", + "refmap": "mixins.cinder_loe.refmap.json", + "target": "@env(DEFAULT)", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "MixinLOTRTileEntityDwarvenForge", + "MixinLOTRIntCache", + "MixinLOTRWorldGenMumakSkeleton", + "MixinItemRenderer", + "MixinRenderItem", + "MixinLOTRClientProxy", + "MixinLOTRContainerAnvil", + "MixinLOTRArmorModels", + "MixinLOTRRenderElvenBlade", + "MixinLOTRRenderLargeItem", + "MixinLOTRRenderCrossbow", + "MixinLOTRRenderThrowingAxe", + "MixinLOTRRenderPlateFood", + "MixinLOTRRenderBlownItem", + "MixinLOTRRenderBow", + "MixinLOTRRenderElf", + "MixinLOTRNPCRendering", + "MixinLOTRRenderDart", + "MixinLOTRRenderTraderRespawn", + "MixinLOTRRenderNPCRespawner", + "MixinRendererLivingEntity", + "MixinLOTRRenderArmorStand", + "MixinLOTREntitySauron" + ], + "client": [] +}