2
0
Fork 0

Making Objective NPC's and other stuff

frozen
KeyLime17 1 year ago
parent 38f3d9b7be
commit 0766b0eb9e

@ -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==

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

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

@ -1,9 +0,0 @@
package com.zivilon.cinder_loe.mixins.overrides;
import lotr.common.entity.npc.LOTRUnitTradeEntry;
public interface ILOTRUnitTradeEntry {
LOTRUnitTradeEntry setObjective(String objectiveKey);
}

@ -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),

@ -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<Boolean> 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);
}
}
}

@ -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
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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

@ -45,7 +45,6 @@
"overrides.MixinLOTRHiredNPCInfo",
"overrides.MixinLOTRReplacedMethods",
"overrides.MixinLOTRUnitTradeEntries",
"overrides.MixinLOTRUnitTradeEntry"
],
"client": []
}

Loading…
Cancel
Save