From 0766b0eb9e171d538d715175b699d0202284d2aa Mon Sep 17 00:00:00 2001 From: KeyLime17 Date: Tue, 10 Sep 2024 15:20:15 -0400 Subject: [PATCH] Making Objective NPC's and other stuff --- .../com/zivilon/cinder_loe/CinderLoE.java | 9 ++- .../zivilon/cinder_loe/CinderLoE_Config.java | 14 ++-- .../cinder_loe/CinderUnitTradeEntry.java | 74 ++++++++++++++++++ .../mixins/overrides/ILOTRUnitTradeEntry.java | 9 --- .../overrides/MixinLOTRUnitTradeEntries.java | 3 +- .../overrides/MixinLOTRUnitTradeEntry.java | 40 ---------- .../assets/cinder_loe/lang/en_US.lang | 5 +- .../lotr/textures/items/doner_kebab.png | Bin 0 -> 5565 bytes src/main/resources/mixins.cinder_loe.json | 1 - 9 files changed, 94 insertions(+), 61 deletions(-) create mode 100644 src/main/java/com/zivilon/cinder_loe/CinderUnitTradeEntry.java delete mode 100644 src/main/java/com/zivilon/cinder_loe/mixins/overrides/ILOTRUnitTradeEntry.java delete mode 100644 src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntry.java create mode 100644 src/main/resources/assets/lotr/textures/items/doner_kebab.png diff --git a/src/main/java/com/zivilon/cinder_loe/CinderLoE.java b/src/main/java/com/zivilon/cinder_loe/CinderLoE.java index f015d3a..8030cc6 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderLoE.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderLoE.java @@ -162,6 +162,7 @@ public class CinderLoE { //Food Crop blocks public static Block onionCrop; public static Block cabbageCrop; + //Food! Yum :P public static Item onion; public static Item cabbage; @@ -178,6 +179,7 @@ public class CinderLoE { public static Item pretzel; public static Item halva; // public static Item honey; + public static Item doner_kebab; // Event/special public static Item frostblade; @@ -380,7 +382,7 @@ public class CinderLoE { event.registerServerCommand(new CommandCinderCharacter()); } - public void registerEntities() { // Last ID added: 53 + public void registerEntities() { // Last ID added: 54 ///GameRegistry.registerTileEntity(TileEntityMistBlock.class, "TileEntityMistBlock"); /* GameRegistry.registerTileEntity(TileEntityShadowTile.class, "TileEntityShadowTile"); GameRegistry.registerTileEntity(TileEntityForgingStation.class, "TileEntityForgingStation");*/ @@ -447,6 +449,7 @@ public class CinderLoE { EntityRegistry.registerModEntity(HobbitBannerBearer.class, "HobbitBannerBearer", (entityID + 52), this, 64, 1, true); EntityRegistry.registerModEntity(MorgulOrc.class, "MorgulOrc", (entityID + 53), this, 64, 1, true); + // EntityRegistry.registerModEntity(MorgulOrc.class, "MorgulOrc", (entityID + 54), this, 64, 1, true); // Frozen Dungeon /* EntityRegistry.registerModEntity(Nex.class, "Nex", (entityID + 45), this, 64, 1, true); @@ -585,6 +588,7 @@ public class CinderLoE { pasta = new LOTRItemFood(2,0.0f, false).setPotionEffect(Potion.hunger.id, 5,0,100).setUnlocalizedName("lotr:pasta").setTextureName("lotr:pasta"); pretzel = new LOTRItemFood(4,1.0f, false).setUnlocalizedName("lotr:pretzel").setTextureName("lotr:pretzel"); halva = new LOTRItemFood (7, 4.0f, false).setUnlocalizedName("lotr:halva").setTextureName("lotr:halva"); + doner_kebab = new LOTRItemFood (6, 6.0f, false).setUnlocalizedName("lotr:doner_kebab").setTextureName("lotr:doner_kebab"); // honey = new LOTRItemFood(3, 0.4f, false).setPotionEffect(Potion.regeneration.id, 5, 0, 100).setUnlocalizedName("lotr:honey").setTextureName("lotr:honey"); spawnEgg = new CinderLoESpawnEgg(); @@ -617,7 +621,7 @@ public class CinderLoE { ItemRegistration.registerItem(pasta, "pasta", 88); ItemRegistration.registerItem(pretzel, "pretzel", 89); ItemRegistration.registerItem(halva, "halva", 94); - // ItemRegistration.registerItem(honey, "honey", 95); + ItemRegistration.registerItem(doner_kebab, "doner_kebab", 95); ItemRegistration.registerItem(spawnEgg, "spawnEgg", 42); @@ -1187,6 +1191,7 @@ public class CinderLoE { CinderCore.registerItemFallback(Item.getIdFromItem(pasta),Item.getIdFromItem(Items.wheat), "cinder_loe", "1.2.5"); CinderCore.registerItemFallback(Item.getIdFromItem(pretzel),Item.getIdFromItem(Items.bread), "cinder_loe", "1.2.5"); CinderCore.registerItemFallback(Item.getIdFromItem(halva),Item.getIdFromItem(Items.bread),"cinder_loe", "1.2.5"); + CinderCore.registerItemFallback(Item.getIdFromItem(doner_kebab),Item.getIdFromItem(Items.bread),"cinder_loe", "1.2.5"); // CinderCore.registerItemFallback(Item.getIdFromItem(honey),Item.getIdFromItem(LOTRMod.mapleSyrup), "cinder_loe", "1.2.5"); //== Blocks== diff --git a/src/main/java/com/zivilon/cinder_loe/CinderLoE_Config.java b/src/main/java/com/zivilon/cinder_loe/CinderLoE_Config.java index 25832ab..ae33bce 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderLoE_Config.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderLoE_Config.java @@ -41,13 +41,13 @@ public class CinderLoE_Config { corrupt_faction = config.getString("CorruptFaction", Configuration.CATEGORY_GENERAL, "MORDOR", "Configure the alignment the Corrupt npcs follow"); - objective_lindon = config.getBoolean("Lindon Objective", Configuration.CATEGORY_GENERAL, false, "set true if Lindon Objective Complete"); - objective_arnor = config.getBoolean("Arnor Objective", Configuration.CATEGORY_GENERAL, false,"set true if Arnor Objective Complete"); - objective_angmar = config.getBoolean("Angmar Objective", Configuration.CATEGORY_GENERAL, false, "set true if Angmar Objective Complete"); - objective_durin = config.getBoolean("Durin Objective", Configuration.CATEGORY_GENERAL, false, "set true if Durin Objective Complete"); - objective_dolguldur = config.getBoolean("Dol Guldur Objective", Configuration.CATEGORY_GENERAL, false,"set true if Dol Guldur Objective Complete"); - objective_woodelf = config.getBoolean("Wood Elf Objective", Configuration.CATEGORY_GENERAL, false, "set true if Wood Elf Objective Complete"); - objective_lothlorien = config.getBoolean("Lothlorien Objective", Configuration.CATEGORY_GENERAL, false, "set true if Lothlorien Objective Complete"); + objective_lindon = config.getBoolean("Lindon", Configuration.CATEGORY_GENERAL, false, "set true if Lindon Objective Complete"); + objective_arnor = config.getBoolean("Arnor", Configuration.CATEGORY_GENERAL, false,"set true if Arnor Objective Complete"); + objective_angmar = config.getBoolean("Angmar", Configuration.CATEGORY_GENERAL, false, "set true if Angmar Objective Complete"); + objective_durin = config.getBoolean("Durin", Configuration.CATEGORY_GENERAL, false, "set true if Durin Objective Complete"); + objective_dolguldur = config.getBoolean("Dol_Guldur", Configuration.CATEGORY_GENERAL, false,"set true if Dol Guldur Objective Complete"); + objective_woodelf = config.getBoolean("Wood_Elf", Configuration.CATEGORY_GENERAL, false, "set true if Wood Elf Objective Complete"); + objective_lothlorien = config.getBoolean("Lothlorien", Configuration.CATEGORY_GENERAL, false, "set true if Lothlorien Objective Complete"); // Save the configuration if it has changed if (config.hasChanged()) { diff --git a/src/main/java/com/zivilon/cinder_loe/CinderUnitTradeEntry.java b/src/main/java/com/zivilon/cinder_loe/CinderUnitTradeEntry.java new file mode 100644 index 0000000..8625814 --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/CinderUnitTradeEntry.java @@ -0,0 +1,74 @@ +package com.zivilon.cinder_loe; + +import lotr.common.LOTRLevelData; +import lotr.common.entity.npc.LOTRBannerBearer; +import lotr.common.entity.npc.LOTRHireableBase; +import lotr.common.entity.npc.LOTRUnitTradeEntry; +import lotr.common.fac.LOTRFaction; +import lotr.common.item.LOTRItemCoin; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.config.Configuration; + +import java.io.File; + +public class CinderUnitTradeEntry extends LOTRUnitTradeEntry { + + public Class entityClass; + private String name; + private PledgeType pledgeType = PledgeType.NONE; + private String objectivename; + private static Configuration config; + + static { + config = new Configuration(new File("CinderLoE.cfg")); + config.load(); + } + + public CinderUnitTradeEntry(Class c, int cost, float alignment) { + super(c, cost, alignment); + this.entityClass = c; // Set entityClass to the passed class + + if (LOTRBannerBearer.class.isAssignableFrom(this.entityClass)) { + this.setExtraInfo("Banner"); + } + } + + public CinderUnitTradeEntry(Class c, Class c1, String s, int cost, float alignment) { + super(c, cost, alignment); + this.entityClass = c; // Set entityClass to the passed class + this.mountClass = c1; + this.name = s; + } + + public boolean isObjectiveComplete(String objective) { + return config.getBoolean(objective, Configuration.CATEGORY_GENERAL, false, "Set true if " + objective + " is complete"); + } + + @Override + public boolean hasRequiredCostAndAlignment(EntityPlayer entityplayer, LOTRHireableBase trader) { + int coins = LOTRItemCoin.getInventoryValue(entityplayer, false); + if (coins < this.getCost(entityplayer, trader)) { + return false; + } + LOTRFaction fac = trader.getFaction(); + if (!this.pledgeType.canAcceptPlayer(entityplayer, fac)) { + return false; + } + if (objectivename != null && !isObjectiveComplete(objectivename)) { + return false; + } + float alignment = LOTRLevelData.getData(entityplayer).getAlignment(fac); + return alignment >= this.alignmentRequired; + } + + public CinderUnitTradeEntry setObjective(String objective) { + this.objectivename = objective; + return this; + } + + public String getFormattedExtraInfo() { + return StatCollector.translateToLocal((String) "lotr.unitinfo." + this.objectivename); + } + +} diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/ILOTRUnitTradeEntry.java b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/ILOTRUnitTradeEntry.java deleted file mode 100644 index 7477d09..0000000 --- a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/ILOTRUnitTradeEntry.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.zivilon.cinder_loe.mixins.overrides; - -import lotr.common.entity.npc.LOTRUnitTradeEntry; - -public interface ILOTRUnitTradeEntry { - LOTRUnitTradeEntry setObjective(String objectiveKey); - -} - diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntries.java b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntries.java index c642eb2..20223f3 100644 --- a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntries.java +++ b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntries.java @@ -1,5 +1,6 @@ package com.zivilon.cinder_loe.mixins.overrides; +import com.zivilon.cinder_loe.CinderUnitTradeEntry; import com.zivilon.cinder_loe.entity.npc.HobbitBannerBearer; import com.zivilon.cinder_loe.entity.npc.orc.MorgulOrc; import lotr.common.LOTRMod; @@ -101,7 +102,7 @@ public class MixinLOTRUnitTradeEntries { @Shadow public static LOTRUnitTradeEntries ANGMAR_ORC_MERCENARY_CAPTAIN = new LOTRUnitTradeEntries(150.0f, new LOTRUnitTradeEntry(LOTREntityAngmarOrc.class, 150, 0.0f), - ((ILOTRUnitTradeEntry) new LOTRUnitTradeEntry(LOTREntityNurnSlave.class, 100, 0.0f).setTask(LOTRHiredNPCInfo.Task.FARMER)).setObjective("Angmar Objective"), + new CinderUnitTradeEntry(MorgulOrc.class, null, "TestMob", 100, 0.0f).setObjective("Angmar").setExtraInfo("Angmar"), new LOTRUnitTradeEntry(LOTREntityAngmarOrcArcher.class, 150, 50.0f), new LOTRUnitTradeEntry(LOTREntityAngmarOrcBombardier.class, 250, 100.0f).setPledgeExclusive(), new LOTRUnitTradeEntry(LOTREntityAngmarWarg.class, 100, 0.0f), diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntry.java b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntry.java deleted file mode 100644 index 5af27a5..0000000 --- a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRUnitTradeEntry.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.zivilon.cinder_loe.mixins.overrides; - -import lotr.common.entity.npc.LOTRHireableBase; -import lotr.common.entity.npc.LOTRUnitTradeEntry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.common.config.Configuration; -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.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.io.File; - -@Mixin(LOTRUnitTradeEntry.class) -public class MixinLOTRUnitTradeEntry implements ILOTRUnitTradeEntry { - @Shadow private LOTRUnitTradeEntry.PledgeType pledgeType; - - @Override - public LOTRUnitTradeEntry setObjective(String objective) { - Configuration config = new Configuration(new File("CinderLoE.cfg")); - boolean isObjectiveComplete = config.getBoolean(objective, Configuration.CATEGORY_GENERAL, false, "Set true if " + objective + " is complete"); - - if (!isObjectiveComplete) { - this.pledgeType = LOTRUnitTradeEntry.PledgeType.NONE; - } - return (LOTRUnitTradeEntry) (Object) this; - } - - @Inject(method = "hasRequiredCostAndAlignment", at = @At("HEAD"), cancellable = true, remap = false) - private void checkObjectiveBeforeHiring(EntityPlayer entityPlayer, LOTRHireableBase trader, CallbackInfoReturnable cir) { - Configuration config = new Configuration(new File("CinderLoE.cfg")); - boolean isObjectiveComplete = config.getBoolean("objective_key", Configuration.CATEGORY_GENERAL, false, "Set true if the objective is complete"); - - if (!isObjectiveComplete) { - cir.setReturnValue(false); - } - } - -} diff --git a/src/main/resources/assets/cinder_loe/lang/en_US.lang b/src/main/resources/assets/cinder_loe/lang/en_US.lang index cc1cf6d..fac6f1b 100644 --- a/src/main/resources/assets/cinder_loe/lang/en_US.lang +++ b/src/main/resources/assets/cinder_loe/lang/en_US.lang @@ -271,4 +271,7 @@ lotr.enchant.weak4=Bent lotr.enchant.rangedWeak3=Cracked lotr.unit.Banner_Warg=Warg Rider Banner -lotr.unit.Banner_Horse=Mounted Banner Bearer \ No newline at end of file +lotr.unit.Banner_Horse=Mounted Banner Bearer +lotr.unit.TestMob=Test Mob + +lotr.unitinfo.Angmar=To Hire this unit you must have the Angmar Objective complete. \ No newline at end of file diff --git a/src/main/resources/assets/lotr/textures/items/doner_kebab.png b/src/main/resources/assets/lotr/textures/items/doner_kebab.png new file mode 100644 index 0000000000000000000000000000000000000000..e16f1b2231137daf49e99b670a2c9de178a20aa3 GIT binary patch literal 5565 zcmeHKdpJ~U7ax_o7~NAcM!BT9&zLb8<1%6nBi9r<%w^A*Ff(R`8I)`3CKX)}rEuyf ziilE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vH1i~iXCKf>me|!oC8!ucklRaTX!i)eo_>T75TIZRjm0C-Bm@rQg~5ZFC1Xi&)MT(I#hU&atrhBj_^=umn9>A5 zy@@ffxq!V2^{rV=@};2gU;Itx;a{`>LjN-IQ~ds->la-=#lTMq|EjKEbo~?qKPCLD zy8dr;X?#EK00M9aBm)mK(ZfdB;6X@*y+4UMT(=V@UJ>Z!c-nb}KH4HMSFXlg`S z(;6taT^`nca*7Dmo;kC{{QCKPz3Ht6U-CI31+5E&_ zG$f)mpZV@ohRWqgc(gxfQ?*ODP{UiD~1iav*&f=9DlfOXxMqEt>58g2Oswgok?jgP3ma&G0nR)dP`5(>f?3E`&8S) z5}CxR?;7+;dCdpX%(9n3dc%d0SmNo5qLs6jj5u}MJ!;sZ6`OEB12^mN==LLr@%?qh cgI~7k^abu;lxn#77RWh-?%+x*vI|W3FH%LA%m4rY literal 0 HcmV?d00001 diff --git a/src/main/resources/mixins.cinder_loe.json b/src/main/resources/mixins.cinder_loe.json index 659f3d0..f8a3df1 100644 --- a/src/main/resources/mixins.cinder_loe.json +++ b/src/main/resources/mixins.cinder_loe.json @@ -45,7 +45,6 @@ "overrides.MixinLOTRHiredNPCInfo", "overrides.MixinLOTRReplacedMethods", "overrides.MixinLOTRUnitTradeEntries", - "overrides.MixinLOTRUnitTradeEntry" ], "client": [] }