2
0
Fork 0

Moved traders to their own directories

main
KeyLime17 5 months ago
parent 585a81ad0c
commit 8ac0c074e2

@ -23,14 +23,17 @@ import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfArbalest;
import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfBannerBearer; import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfBannerBearer;
import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfCommander; import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfCommander;
import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfWarrior; import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfWarrior;
import com.zivilon.cinder_loe.entity.npc.dwarf.trader.RedDwarfSmith;
import com.zivilon.cinder_loe.entity.npc.elf.Sirrandrai; import com.zivilon.cinder_loe.entity.npc.elf.Sirrandrai;
import com.zivilon.cinder_loe.entity.npc.elf.trader.BladorthinSmith;
import com.zivilon.cinder_loe.entity.npc.evil_human.*; import com.zivilon.cinder_loe.entity.npc.evil_human.*;
import com.zivilon.cinder_loe.entity.npc.evil_human.trader.LimwaithFishmonger;
import com.zivilon.cinder_loe.entity.npc.evil_human.trader.LimwaithShaman;
import com.zivilon.cinder_loe.entity.npc.good_human.*; import com.zivilon.cinder_loe.entity.npc.good_human.*;
import com.zivilon.cinder_loe.entity.npc.orc.MorgulOrc; import com.zivilon.cinder_loe.entity.npc.orc.MorgulOrc;
import com.zivilon.cinder_loe.entity.npc.orc.NorthernOrc; import com.zivilon.cinder_loe.entity.npc.orc.NorthernOrc;
import com.zivilon.cinder_loe.entity.npc.radagast.*; import com.zivilon.cinder_loe.entity.npc.radagast.*;
import com.zivilon.cinder_loe.entity.projectile.*; import com.zivilon.cinder_loe.entity.projectile.*;
import com.zivilon.cinder_loe.entity.trader.*;
import com.zivilon.cinder_loe.items.*; import com.zivilon.cinder_loe.items.*;
import com.zivilon.cinder_loe.items.specials.*; import com.zivilon.cinder_loe.items.specials.*;
import com.zivilon.cinder_loe.network.*; import com.zivilon.cinder_loe.network.*;

@ -50,7 +50,7 @@ public class CarriageDestinationsData extends WorldSavedData {
tag.setInteger("Y", dest.y); tag.setInteger("Y", dest.y);
tag.setInteger("Z", dest.z); tag.setInteger("Z", dest.z);
tag.setInteger("Dim", dest.dimension); tag.setInteger("Dim", dest.dimension);
String road = tag.getString("Road"); tag.setString("Road", dest.road);
list.appendTag(tag); list.appendTag(tag);
} }
nbt.setTag("Destinations", list); nbt.setTag("Destinations", list);

@ -23,7 +23,7 @@ public class CommandOpenCarriageMenu extends CommandBase {
@Override @Override
public String getCommandUsage(ICommandSender sender) { public String getCommandUsage(ICommandSender sender) {
return "/open_carriage_menu"; return "/open_carriage_menu [roadId]";
} }
@Override @Override
@ -39,36 +39,40 @@ public class CommandOpenCarriageMenu extends CommandBase {
throw new CommandException("Carriage data unavailable."); throw new CommandException("Carriage data unavailable.");
} }
// 1) first get the absolute nearest stops, ignoring roads // decide startRoad:
List<CarriageDestination> rawNearby = data.getNearestFour(player.posX, player.posZ, "", CarriageRoadRegistry.INSTANCE); String startRoad;
if (rawNearby.isEmpty()) { if (args.length > 0) {
throw new CommandException("No nearby carriage stops found."); // user explicitly specified a road
startRoad = args[0];
if (CarriageRoadRegistry.getRoad(startRoad) == null) {
throw new CommandException("Unknown road ID: " + startRoad);
}
} else {
// no road given, pick the very nearest destination and use its road
List<CarriageDestination> rawNearby =
data.getNearestFour(player.posX, player.posZ, "", CarriageRoadRegistry.INSTANCE);
if (rawNearby.isEmpty()) {
throw new CommandException("No nearby carriage stops found.");
}
startRoad = rawNearby.get(0).road;
} }
// 2) grab the road of the very nearest // now grab up to 4 stops on that road + its neighbors
String startRoad = rawNearby.get(0).road; List<CarriageDestination> nearest =
data.getNearestFour(player.posX, player.posZ, startRoad, CarriageRoadRegistry.INSTANCE);
// 3) now get up to 4 stops on that road and its neighbors
List<CarriageDestination> nearest = data.getNearestFour(
player.posX, player.posZ,
startRoad,
/* pass your registry singleton, not `new` */ CarriageRoadRegistry.INSTANCE
);
// if you dont have an instance() method, just call the static methods inside getNearestFour
if (nearest.isEmpty()) { if (nearest.isEmpty()) {
throw new CommandException("No stops on your road or its neighbors."); throw new CommandException(
"No stops found on road '" + startRoad + "' or its neighbors.");
} }
// 4) build your packet // build the packet
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
List<Integer> costs = new ArrayList<>(); List<Integer> costs = new ArrayList<>();
List<String> roads = new ArrayList<>(); List<String> roads = new ArrayList<>();
for (CarriageDestination d : nearest) { for (CarriageDestination d : nearest) {
double dx = d.x - player.posX; double dx = d.x - player.posX;
double dz = d.z - player.posZ; double dz = d.z - player.posZ;
int cost = Math.max(1, (int)(Math.hypot(dx, dz) / 50)); int cost = Math.max(1, (int)(Math.hypot(dx, dz) / 50));
names .add(d.name); names .add(d.name);
costs .add(cost); costs .add(cost);
roads .add(d.road); roads .add(d.road);
@ -78,3 +82,4 @@ public class CommandOpenCarriageMenu extends CommandBase {
.sendTo(new PacketOpenCarriageGui(names, costs, roads), player); .sendTo(new PacketOpenCarriageGui(names, costs, roads), player);
} }
} }

@ -1,4 +1,4 @@
package com.zivilon.cinder_loe.entity.trader; package com.zivilon.cinder_loe.entity.npc.dwarf.trader;
import com.zivilon.cinder_loe.CinderLoE; import com.zivilon.cinder_loe.CinderLoE;
@ -6,16 +6,13 @@ import lotr.common.entity.npc.LOTRTradeEntries;
import lotr.common.entity.npc.LOTRTradeEntries.TradeType; import lotr.common.entity.npc.LOTRTradeEntries.TradeType;
import lotr.common.entity.npc.LOTRTradeable; import lotr.common.entity.npc.LOTRTradeable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.Entity;
import net.minecraft.world.World; import net.minecraft.world.World;
import lotr.common.LOTRMod; import lotr.common.LOTRMod;
import lotr.common.fac.LOTRFaction;
import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.IEntityLivingData;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import lotr.common.entity.npc.LOTRTradeEntry; import lotr.common.entity.npc.LOTRTradeEntry;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import lotr.common.LOTRLevelData; import lotr.common.LOTRLevelData;
import lotr.common.entity.npc.LOTREntityDwarf; import lotr.common.entity.npc.LOTREntityDwarf;

@ -1,8 +1,7 @@
package com.zivilon.cinder_loe.entity.trader; package com.zivilon.cinder_loe.entity.npc.elf.trader;
import com.zivilon.cinder_loe.CinderLoE; import com.zivilon.cinder_loe.CinderLoE;
import lotr.common.LOTRFoods;
import lotr.common.LOTRLevelData; import lotr.common.LOTRLevelData;
import lotr.common.LOTRMod; import lotr.common.LOTRMod;
import lotr.common.entity.npc.*; import lotr.common.entity.npc.*;
@ -12,7 +11,6 @@ import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;

@ -1,4 +1,4 @@
package com.zivilon.cinder_loe.entity.trader; package com.zivilon.cinder_loe.entity.npc.evil_human.trader;
import com.zivilon.cinder_loe.CinderLoE; import com.zivilon.cinder_loe.CinderLoE;

@ -1,4 +1,4 @@
package com.zivilon.cinder_loe.entity.trader; package com.zivilon.cinder_loe.entity.npc.evil_human.trader;
import com.zivilon.cinder_loe.CinderLoE; import com.zivilon.cinder_loe.CinderLoE;

@ -0,0 +1,115 @@
package com.zivilon.cinder_loe.entity.npc.orc.trader;
import com.zivilon.cinder_loe.CinderLoE;
import com.zivilon.cinder_loe.entity.npc.evil_human.Limwaith;
import lotr.common.LOTRLevelData;
import lotr.common.LOTRMod;
import lotr.common.entity.npc.*;
import lotr.common.entity.npc.LOTRTradeEntries.TradeType;
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.util.MovingObjectPosition;
import net.minecraft.world.World;
public class AngmarOrcButcher extends LOTREntityAngmarOrcTrader implements LOTRTradeable {
public static LOTRTradeEntries ANGMAR_BUTCHER_BUY;
public static LOTRTradeEntries ANGMAR_BUTCHER_SELL;
public AngmarOrcButcher(World world) {
super(world);
}
public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) {
data = super.onSpawnWithEgg(data);
this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.daggerAngmarPoisoned));
this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
return data;
}
public LOTRTradeEntries getBuyPool() {
return ANGMAR_BUTCHER_BUY;
}
public LOTRTradeEntries getSellPool() {
return ANGMAR_BUTCHER_SELL;
}
public IEntityLivingData func_110161_a(IEntityLivingData data) {
data = super.func_110161_a(data);
this.npcItemsInv.setMeleeWeapon(new ItemStack(LOTRMod.daggerAngmarPoisoned));
this.npcItemsInv.setIdleItem(this.npcItemsInv.getMeleeWeapon());
this.setCurrentItemOrArmor(1, new ItemStack(LOTRMod.bootsFur));
this.setCurrentItemOrArmor(2, new ItemStack(LOTRMod.legsFur));
this.setCurrentItemOrArmor(3, new ItemStack(LOTRMod.bodyBone));
this.setCurrentItemOrArmor(4, new ItemStack(LOTRMod.helmetBone));
return data;
}
public float getAlignmentBonus() {
return 2.0F;
}
public boolean canTradeWith(EntityPlayer entityplayer) {
return (LOTRLevelData.getData(entityplayer).getAlignment(getFaction()) >= 100.0F && isFriendlyAndAligned(entityplayer));
}
static {
ANGMAR_BUTCHER_BUY = new LOTRTradeEntries(TradeType.BUY,
new LOTRTradeEntry(new ItemStack(CinderLoE.flatbread), 2), //maggotless bread
new LOTRTradeEntry(new ItemStack(CinderLoE.daggerLimwaithPoisoned), 20), // flesh, meats, and maybe new cuisine, spice ingredeint?
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));
ANGMAR_BUTCHER_SELL = new LOTRTradeEntries(TradeType.SELL,
new LOTRTradeEntry(new ItemStack(Items.wheat, 2), 1),
new LOTRTradeEntry(new ItemStack(LOTRMod.elfBone), 1),
new LOTRTradeEntry(new ItemStack(LOTRMod.dwarfBone), 1),
new LOTRTradeEntry(new ItemStack(Items.bone), 1),
new LOTRTradeEntry(new ItemStack(LOTRMod.hobbitBone), 1),
new LOTRTradeEntry(new ItemStack(LOTRMod.maggotyBread, 2), 2), // Check price going down
new LOTRTradeEntry(new ItemStack(Items.rotten_flesh, 3, 15), 1), // man flesh
new LOTRTradeEntry(new ItemStack(LOTRMod.gemsbokHorn), 4), // angmar axe and daggers
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;
}
public String getSpeechBank(EntityPlayer entityplayer) {
if (this.isFriendlyAndAligned(entityplayer)) {
return this.canTradeWith(entityplayer) ? "angmar/trader/friendly" : "angmar/trader/neutral";
} else {
return "angmar/orc/hostile";
}
}
@Override
public ItemStack getPickedResult(MovingObjectPosition target) {
return null;
}
}

@ -8,10 +8,13 @@ import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfArbalest;
import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfBannerBearer; import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfBannerBearer;
import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfCommander; import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfCommander;
import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfWarrior; import com.zivilon.cinder_loe.entity.npc.dwarf.RedDwarfWarrior;
import com.zivilon.cinder_loe.entity.npc.dwarf.trader.RedDwarfSmith;
import com.zivilon.cinder_loe.entity.npc.elf.trader.BladorthinSmith;
import com.zivilon.cinder_loe.entity.npc.evil_human.*; import com.zivilon.cinder_loe.entity.npc.evil_human.*;
import com.zivilon.cinder_loe.entity.npc.evil_human.trader.LimwaithFishmonger;
import com.zivilon.cinder_loe.entity.npc.evil_human.trader.LimwaithShaman;
import com.zivilon.cinder_loe.entity.npc.good_human.*; import com.zivilon.cinder_loe.entity.npc.good_human.*;
import com.zivilon.cinder_loe.entity.npc.radagast.*; import com.zivilon.cinder_loe.entity.npc.radagast.*;
import com.zivilon.cinder_loe.entity.trader.*;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;

Loading…
Cancel
Save