From 871e5009a9252b18e6ebef7b929d6acd93023469 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 27 Sep 2024 15:45:50 -0500 Subject: [PATCH] massive inventory code rework. all inventory code, including that of tenders and trains, is now handled by the Freight class to improve overall code consistency, simplify a significant number of things, and improve some crashes related to add-ons --- src/main/java/train/client/gui/GuiLoco2.java | 6 +- .../java/train/common/api/AbstractTrains.java | 2 +- .../java/train/common/api/DieselTrain.java | 39 ++-- .../java/train/common/api/ElectricTrain.java | 18 +- src/main/java/train/common/api/Freight.java | 41 ++-- .../java/train/common/api/Locomotive.java | 215 +----------------- .../java/train/common/api/SteamTrain.java | 43 ++-- src/main/java/train/common/api/Tender.java | 8 +- .../EntityLocoDiesel44TonSwitcher.java | 52 ----- .../rollingStock/EntityLocoDieselBamboo.java | 49 ---- .../rollingStock/EntityLocoDieselCD742.java | 52 ----- .../rollingStock/EntityLocoDieselChME3.java | 52 ----- .../rollingStock/EntityLocoDieselClass66.java | 52 ----- .../rollingStock/EntityLocoDieselDD35A.java | 49 ---- .../rollingStock/EntityLocoDieselDeltic.java | 49 ---- .../rollingStock/EntityLocoDieselEMDF3.java | 49 ---- .../rollingStock/EntityLocoDieselEMDF7.java | 49 ---- .../rollingStock/EntityLocoDieselFOLM1.java | 49 ---- .../rollingStock/EntityLocoDieselFOLM1B.java | 50 ---- .../rollingStock/EntityLocoDieselGP7Red.java | 52 ----- .../EntityLocoDieselIC4_DSB_MG.java | 52 ----- .../rollingStock/EntityLocoDieselKof_DB.java | 52 ----- .../EntityLocoDieselMILW_H1044.java | 52 ----- .../rollingStock/EntityLocoDieselSD40.java | 52 ----- .../rollingStock/EntityLocoDieselSD70.java | 49 ---- .../rollingStock/EntityLocoDieselShunter.java | 49 ---- .../rollingStock/EntityLocoDieselV60_DB.java | 52 ----- .../rollingStock/EntityLocoDieselWLs40.java | 49 ---- .../rollingStock/EntityLocoElectricBP4.java | 38 ---- .../rollingStock/EntityLocoElectricBR185.java | 38 ---- .../EntityLocoElectricBR_E69.java | 38 ---- .../rollingStock/EntityLocoElectricCD151.java | 38 ---- .../EntityLocoElectricClass85.java | 38 ---- .../rollingStock/EntityLocoElectricE103.java | 38 ---- .../EntityLocoElectricE10_DB.java | 38 ---- .../EntityLocoElectricHighSpeedZeroED.java | 38 ---- .../rollingStock/EntityLocoElectricICE1.java | 38 ---- .../EntityLocoElectricMinetrain.java | 38 ---- .../EntityLocoElectricTramNY.java | 38 ---- .../EntityLocoElectricTramWood.java | 38 ---- .../rollingStock/EntityLocoElectricVL10.java | 37 --- .../rollingStock/EntityLocoSteam040VB.java | 50 ---- .../rollingStock/EntityLocoSteam262T.java | 53 ----- .../rollingStock/EntityLocoSteam4_4_0.java | 53 ----- .../rollingStock/EntityLocoSteamAdler.java | 50 ---- .../rollingStock/EntityLocoSteamAlcoSC4.java | 53 ----- .../EntityLocoSteamAlice0_4_0.java | 53 ----- .../rollingStock/EntityLocoSteamBR01_DB.java | 53 ----- .../rollingStock/EntityLocoSteamBR80_DB.java | 50 ---- .../rollingStock/EntityLocoSteamBerk1225.java | 53 ----- .../rollingStock/EntityLocoSteamBerk765.java | 53 ----- .../rollingStock/EntityLocoSteamC41.java | 53 ----- .../rollingStock/EntityLocoSteamC41T.java | 53 ----- .../rollingStock/EntityLocoSteamC41_080.java | 53 ----- .../rollingStock/EntityLocoSteamC62Class.java | 53 ----- .../EntityLocoSteamCherepanov.java | 50 ---- .../rollingStock/EntityLocoSteamClimax.java | 53 ----- .../EntityLocoSteamCoranationClass.java | 53 ----- .../rollingStock/EntityLocoSteamD51.java | 53 ----- .../rollingStock/EntityLocoSteamD51Long.java | 53 ----- .../rollingStock/EntityLocoSteamEr_Ussr.java | 53 ----- .../EntityLocoSteamForneyRed.java | 59 +---- .../rollingStock/EntityLocoSteamFowler.java | 53 ----- .../rollingStock/EntityLocoSteamGLYN042T.java | 53 ----- .../rollingStock/EntityLocoSteamGS4.java | 53 ----- .../EntityLocoSteamHallClass.java | 53 ----- .../rollingStock/EntityLocoSteamHeavy.java | 53 ----- .../EntityLocoSteamKingClass.java | 53 ----- .../rollingStock/EntityLocoSteamLSSP7.java | 53 ----- .../EntityLocoSteamMILWClassA.java | 53 ----- .../EntityLocoSteamMallardA4.java | 53 ----- .../EntityLocoSteamMogulBlue.java | 53 ----- .../rollingStock/EntityLocoSteamPannier.java | 53 ----- .../rollingStock/EntityLocoSteamShay.java | 53 ----- .../rollingStock/EntityLocoSteamSmall.java | 53 ----- .../rollingStock/EntityLocoSteamSnowPlow.java | 76 ++----- .../EntityLocoSteamSouthern1102.java | 53 ----- .../rollingStock/EntityLocoSteamUSATCUK.java | 53 ----- .../rollingStock/EntityLocoSteamUSATCUS.java | 53 ----- .../rollingStock/EntityLocoSteamVBShay.java | 53 ----- .../common/inventory/InventoryForney.java | 2 +- .../train/common/inventory/InventoryLoco.java | 13 +- .../common/library/TraincraftRegistry.java | 4 +- 83 files changed, 127 insertions(+), 3852 deletions(-) diff --git a/src/main/java/train/client/gui/GuiLoco2.java b/src/main/java/train/client/gui/GuiLoco2.java index 26f4f3d038..a698def1ad 100644 --- a/src/main/java/train/client/gui/GuiLoco2.java +++ b/src/main/java/train/client/gui/GuiLoco2.java @@ -402,15 +402,15 @@ protected void drawGuiContainerBackgroundLayer(float f, int t, int g) { drawTexturedModalRect(j + 10, (k + 36 + 13) - l, 178, 12 - l, 14, l + 2); } } else { - for (int i1 = loco.numCargoSlots; i1 < 5; i1++) { + for (int i1 = loco instanceof ElectricTrain?5:3; i1 < 5; i1++) { drawTexturedModalRect(j + 79 + 18 * i1, k + 17, 190, 0, 18, 18); } - for (int j1 = loco.numCargoSlots1; j1 < 5; j1++) { + for (int j1 = loco instanceof ElectricTrain?5:3; j1 < 5; j1++) { drawTexturedModalRect(j + 79 + 18 * j1, k + 35, 190, 0, 18, 18); } - for (int k1 = loco.numCargoSlots2; k1 < 5; k1++) { + for (int k1 = loco instanceof ElectricTrain?5:3; k1 < 5; k1++) { drawTexturedModalRect(j + 79 + 18 * k1, k + 53, 190, 0, 18, 18); } diff --git a/src/main/java/train/common/api/AbstractTrains.java b/src/main/java/train/common/api/AbstractTrains.java index f0e0749f43..8f8409e811 100644 --- a/src/main/java/train/common/api/AbstractTrains.java +++ b/src/main/java/train/common/api/AbstractTrains.java @@ -728,7 +728,7 @@ public String transportFuelType(){ /**defines the size of the inventory row by row, not counting any special slots like for fuel. * end result number of slots is this times 9. plus any crafting/fuel slots * may not return null*/ - public int getInventoryRows(){return Math.max((int)(getSpec().getCargoCapacity()*0.1111111111112),1);} + public int getInventoryRows(){return 0;} /**defines the capacity of the fluidTank tank. * each value defibes another tank. diff --git a/src/main/java/train/common/api/DieselTrain.java b/src/main/java/train/common/api/DieselTrain.java index 16c8f2d000..8d791cfeb8 100644 --- a/src/main/java/train/common/api/DieselTrain.java +++ b/src/main/java/train/common/api/DieselTrain.java @@ -17,7 +17,6 @@ public abstract class DieselTrain extends Locomotive implements IFluidHandler { - public int fuelSlot = 1; private int maxTank = 7 * 1000; private int update = 8; private StandardTank theTank; @@ -45,23 +44,24 @@ private DieselTrain(World world, FluidStack filter, String[] multiFilter) { this.theTank = LiquidManager.getInstance().new FilteredTank(maxTank, multiFilter); } dataWatcher.addObject(4, 0); - numCargoSlots = 3; - numCargoSlots1 = 3; - numCargoSlots2 = 3; - inventorySize = numCargoSlots + numCargoSlots2 + numCargoSlots1 + fuelSlot; - this.dataWatcher.addObject(23, 0); + this.dataWatcher.addObject(27, 0); this.dataWatcher.addObject(5, ""); } public DieselTrain(World world, double d, double d1, double d2) { super(world, d, d1, d2); } + @Override + public int getSizeInventory() { + return 10+(getInventoryRows()*9); + } + @Override public void onUpdate() { super.onUpdate(); if (!worldObj.isRemote) { - if (theTank.getFluidAmount() != this.dataWatcher.getWatchableObjectInt(23)){ - this.dataWatcher.updateObject(23, theTank.getFluidAmount()); + if (theTank.getFluidAmount() != this.dataWatcher.getWatchableObjectInt(27)){ + this.dataWatcher.updateObject(27, theTank.getFluidAmount()); fuelTrain = theTank.getFluidAmount(); this.dataWatcher.updateObject(4, theTank.getFluid()!=null?theTank.getFluid().getFluidID():0); this.dataWatcher.updateObject(5, theTank.getFluid()!=null?theTank.getFluid().getUnlocalizedName():""); @@ -72,11 +72,12 @@ public void onUpdate() { motionZ *= 0.94; } } + checkInvent(cargoItems[0]); } } public int getDiesel() { - return getFuel()==0?(this.dataWatcher.getWatchableObjectInt(23)):getFuel(); + return getFuel()==0?(this.dataWatcher.getWatchableObjectInt(27)):getFuel(); } public String getLiquidName(){ return this.dataWatcher.getWatchableObjectString(5);} @@ -92,14 +93,12 @@ public StandardTank getTank() { protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); this.theTank.writeToNBT(nbttagcompound); - nbttagcompound.setBoolean("canBeAdjusted", canBeAdjusted); } @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); this.theTank.readFromNBT(nbttagcompound); - canBeAdjusted = nbttagcompound.getBoolean("canBeAdjusted"); } public int getCartTankCapacity() { @@ -107,23 +106,23 @@ public int getCartTankCapacity() { } private void placeInInvent(ItemStack itemstack1) { - for (int i = 1; i < locoInvent.length; i++) { - if (locoInvent[i] == null) { - locoInvent[i] = itemstack1; + for (int i = 1; i < cargoItems.length; i++) { + if (cargoItems[i] == null) { + cargoItems[i] = itemstack1; return; } - else if (locoInvent[i] != null && locoInvent[i].getItem() == itemstack1.getItem() && itemstack1.isStackable() && (!itemstack1.getHasSubtypes() || locoInvent[i].getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(locoInvent[i], itemstack1)) { - int var9 = locoInvent[i].stackSize + itemstack1.stackSize; + else if (cargoItems[i] != null && cargoItems[i].getItem() == itemstack1.getItem() && itemstack1.isStackable() && (!itemstack1.getHasSubtypes() || cargoItems[i].getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(cargoItems[i], itemstack1)) { + int var9 = cargoItems[i].stackSize + itemstack1.stackSize; if (var9 <= itemstack1.getMaxStackSize()) { - locoInvent[i].stackSize = var9; + cargoItems[i].stackSize = var9; } - else if (locoInvent[i].stackSize < itemstack1.getMaxStackSize()) { - locoInvent[i].stackSize += 1; + else if (cargoItems[i].stackSize < itemstack1.getMaxStackSize()) { + cargoItems[i].stackSize += 1; } return; } - else if (i == locoInvent.length - 1) { + else if (i == cargoItems.length - 1) { entityDropItem(itemstack1,1); return; } diff --git a/src/main/java/train/common/api/ElectricTrain.java b/src/main/java/train/common/api/ElectricTrain.java index 4d949de174..7e931f9c21 100644 --- a/src/main/java/train/common/api/ElectricTrain.java +++ b/src/main/java/train/common/api/ElectricTrain.java @@ -22,12 +22,6 @@ public abstract class ElectricTrain extends Locomotive { public ElectricTrain(World world) { super(world); fuelTrain = 0; - - numCargoSlots = 5; - numCargoSlots1 = 5; - numCargoSlots2 = 5; - inventorySize = numCargoSlots + numCargoSlots2 + numCargoSlots1 + 1; - locoInvent = new ItemStack[inventorySize]; //hasUranium = false; //reduceExplosionChance = 1000; Ignite = false; @@ -36,6 +30,12 @@ public ElectricTrain(World world) { public ElectricTrain(World world, double x, double y, double z){ super(world,x,y,z); } + + @Override//todo:why was this so much? + public int getSizeInventory() { + return 16+(getInventoryRows()*9); + } + @Override public void onUpdate() { super.onUpdate(); @@ -52,9 +52,9 @@ public void onUpdate() { if(!this.canCheckInvent)return; /* if the loco has fuel */ - if (getFuel() < maxEnergy && locoInvent[0] != null) + if (getFuel() < maxEnergy && cargoItems[0] != null) { - Item item = locoInvent[0].getItem(); + Item item = cargoItems[0].getItem(); if (item == Items.redstone && ((getFuel() + 2000) <= maxEnergy)) { fuelTrain += 2000; @@ -67,7 +67,7 @@ public void onUpdate() { }else if (item instanceof IEnergyContainerItem) { int draw = MathHelper.floor_double(Math.min(200, maxEnergy - getFuel()) * 0.1); // amount of energy to attempt to draw this tick - fuelTrain += ((IEnergyContainerItem) item).extractEnergy(locoInvent[0], draw, false) * 10; + fuelTrain += ((IEnergyContainerItem) item).extractEnergy(cargoItems[0], draw, false) * 10; } /*else if ((PluginIndustrialCraft.getItems().containsKey(PluginIndustrialCraft.getNames()[4]) && PluginIndustrialCraft.getItems().containsKey(PluginIndustrialCraft.getNames()[3])) && (item == PluginIndustrialCraft.getItems().get(PluginIndustrialCraft.getNames()[4]).getItem())) { diff --git a/src/main/java/train/common/api/Freight.java b/src/main/java/train/common/api/Freight.java index 4de6de474c..b266900dc7 100644 --- a/src/main/java/train/common/api/Freight.java +++ b/src/main/java/train/common/api/Freight.java @@ -14,16 +14,16 @@ public abstract class Freight extends EntityRollingStock implements IInventory { public ItemStack[] cargoItems; protected double itemInsideCount = 0; - private int slotsFilled = 0; + public int slotsFilled = 0; public Freight(World world) { super(world); dataWatcher.addObject(22, 0); - cargoItems = new ItemStack[getInventoryRows()*9]; + cargoItems = new ItemStack[getSizeInventory()]; } public Freight(World world, double d, double d1, double d2) { super(world, d, d1, d2); - cargoItems = new ItemStack[getInventoryRows()*9]; + cargoItems = new ItemStack[getSizeInventory()]; } @Override @@ -130,7 +130,7 @@ public String getInventoryName() { } @Override - public int getSizeInventory(){return getInventoryRows()*9;} + public int getSizeInventory(){return getSpec()==null?getInventoryRows()*9:getSpec().getCargoCapacity();} /** * Returns true if this cart is a storage cart Some carts may have inventories but not be storage carts and some carts without inventories may be storage carts. @@ -188,27 +188,36 @@ public int getAmmountOfCargo() { @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); - ItemStack[] cargoItemsCount; - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - cargoItemsCount = new ItemStack[getSizeInventory()]; + slotsFilled = 0; + NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); + cargoItems = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j < cargoItemsCount.length) { - cargoItemsCount[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + if (j >= 0 && j < cargoItems.length) { + cargoItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + if(cargoItems[j]!=null){ + slotsFilled++; + } } } + this.dataWatcher.updateObject(22, slotsFilled); + } - slotsFilled = 0; - - for (int i = 0; i < getSizeInventory(); i++) { - ItemStack itemstack = cargoItemsCount[i]; - if (itemstack != null) { - slotsFilled++; + @Override + protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { + super.writeEntityToNBT(nbttagcompound); + NBTTagList nbttaglist = new NBTTagList(); + for (int i = 0; i < cargoItems.length; i++) { + if (cargoItems[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + cargoItems[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); } } - this.dataWatcher.updateObject(22, slotsFilled); + nbttagcompound.setTag("Items", nbttaglist); } @Override diff --git a/src/main/java/train/common/api/Locomotive.java b/src/main/java/train/common/api/Locomotive.java index 8f7361e556..8d083c3b25 100644 --- a/src/main/java/train/common/api/Locomotive.java +++ b/src/main/java/train/common/api/Locomotive.java @@ -39,23 +39,17 @@ import java.util.List; import java.util.Random; -public abstract class Locomotive extends EntityRollingStock implements IInventory, WirelessTransmitter, IRollingStockLightControls +public abstract class Locomotive extends Freight implements WirelessTransmitter, IRollingStockLightControls { - public int inventorySize; - protected ItemStack[] locoInvent; private int soundPosition = 0; public boolean parkingBrake = false; private int whistleDelay = 0; private int blowUpDelay = 0; private String lastRider = ""; private Entity lastEntityRider; - public int numCargoSlots; - public int numCargoSlots1; - public int numCargoSlots2; private boolean hasDrowned = false; protected boolean canCheckInvent = true; - private int slotsFilled = 0; public boolean isLocoTurnedOn = false; public boolean forwardPressed = false; public boolean backwardPressed = false; @@ -141,13 +135,12 @@ public Locomotive(World world) { super(world); if(world==null){return;} setFuelConsumption(0); - inventorySize = numCargoSlots + numCargoSlots2 + numCargoSlots1; dataWatcher.addObject(2, 0); this.setDefaultMass(0); this.setCustomSpeed(transportTopSpeed()); dataWatcher.addObject(3, destination); dataWatcher.addObject(15, (float) Math.round((getCustomSpeed() * 3.6f))); - dataWatcher.addObject(22, locoState); + dataWatcher.addObject(23, locoState); dataWatcher.addObject(24, fuelTrain); dataWatcher.addObject(25, (int) convertSpeed(Math.sqrt(Math.abs(motionX * motionX) + Math.abs(motionZ * motionZ))));//convertSpeed((Math.abs(this.motionX) + Math.abs(this.motionZ)) dataWatcher.addObject(26, guiDetailsJSON()); @@ -172,13 +165,10 @@ public Locomotive(World world) { } fuelTrain = 0; - locoInvent = new ItemStack[getSizeInventory()]; } public Locomotive(World world, double d, double d1, double d2) { super(world, d, d1, d2); - inventorySize = numCargoSlots + numCargoSlots2 + numCargoSlots1; - locoInvent = new ItemStack[getSizeInventory()]; fuelTrain = 0; } @@ -429,6 +419,8 @@ protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setBoolean("isConnected", isConnected); nbttagcompound.setBoolean("stationStop", stationStop); nbttagcompound.setString(DataMemberName.lightingDetailsJSONString.AsString(), lightingDetailsJSONString()); + nbttagcompound.setShort("fuelTrain", (short) fuelTrain); + nbttagcompound.setBoolean("canBeAdjusted", canBeAdjusted); } @Override @@ -483,6 +475,8 @@ protected void readEntityFromNBT(NBTTagCompound ntc) { stationStop = ntc.getBoolean("stationStop"); dataWatcher.updateObject(28, lightingDetailsJSONString()); + fuelTrain = ntc.getShort("fuelTrain"); + canBeAdjusted = ntc.getBoolean("canBeAdjusted"); } /** @@ -1004,7 +998,7 @@ public void onUpdate() dataWatcher.updateObject(25, (int) convertSpeed(Math.sqrt(motionX * motionX + motionZ * motionZ))); dataWatcher.updateObject(24, fuelTrain); dataWatcher.updateObject(20, overheatLevel); - dataWatcher.updateObject(22, locoState); + dataWatcher.updateObject(23, locoState); dataWatcher.updateObject(3, destination); //dataWatcher.updateObject(31, ("1c/" + castToString((int) (currentFuelConsumptionChange)) + " per tick")); @@ -1108,7 +1102,7 @@ public int getOverheatLevel() { * @return cold warm hot very hot too hot broken */ public String getState() { - return (this.dataWatcher.getWatchableObjectString(22)); + return (this.dataWatcher.getWatchableObjectString(23)); } /** @@ -1119,7 +1113,7 @@ public String getState() { */ public void setState(String state) { locoState = state; - this.dataWatcher.updateObject(22, state); + this.dataWatcher.updateObject(23, state); } /** @@ -1271,90 +1265,6 @@ public void setPacketDitchLightsMode(byte ditchLightMode) this.ditchLightMode = ditchLightMode; } - public void setLocomotiveBeaconTick(byte beaconCycleIndex) - { - beaconCycleIndex = beaconCycleIndex; - } - - // private int placeInSpecialInvent(ItemStack itemstack1, int i, boolean doAdd) { - // if (locoInvent[i] == null) { - // if (doAdd) locoInvent[i] = itemstack1; - // return itemstack1.stackSize; - // } - // else if (locoInvent[i] != null && locoInvent[i] == itemstack1 && itemstack1.isStackable() && - // (!itemstack1.getHasSubtypes() || locoInvent[i].getItemDamage() == itemstack1.getItemDamage()) - // && ItemStack.areItemStackTagsEqual(locoInvent[i], itemstack1)) { - // - // int var9 = locoInvent[i].stackSize + itemstack1.stackSize; - // if (var9 <= itemstack1.getMaxStackSize()) { - // if (doAdd) locoInvent[i].stackSize = var9; - // return var9; - // } - // else if (locoInvent[i].stackSize < itemstack1.getMaxStackSize()) { - // if (doAdd) locoInvent[i].stackSize = locoInvent[i].getMaxStackSize(); - // return Math.abs(locoInvent[i].getMaxStackSize() - locoInvent[i].stackSize - - // itemstack1.stackSize); - // - // } - // } - // return itemstack1.stackSize; - // - // } - - - //TODO Fix ISided Inventory buildcraft support - /* - /** - * Offers an ItemStack for addition to the inventory. - * - * @param stack - * ItemStack offered for addition. Do not manipulate this! - * @param doAdd - * If false no actual addition should take place. - * @param from - * Orientation the ItemStack is offered from. - * @return Amount of items used from the passed stack. - */ - /* - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - if (stack == null) { return 0; } - //FuelHandler.steamFuelLast(itemstack) > 0 || LiquidManager.getInstance().isDieselLocoFuel(itemstack)||(itemstack.getItem().shiftedIndex==Item.redstone.shiftedIndex) || (itemstack.getItem() instanceof IElectricItem) - //LiquidManager.getInstance().isContainer(itemstack1)&&loco instanceof SteamTrain - if (this instanceof SteamTrain) { - //System.out.println("is fuel? "+(FuelHandler.steamFuelLast(stack) > 0) + "return "+placeInSpecialInvent(stack,0,false)); - if (FuelHandler.steamFuelLast(stack) > 0) return placeInSpecialInvent(stack, 0, doAdd); - if (LiquidManager.getInstance().isContainer(stack)) return placeInSpecialInvent(stack, 1, doAdd); - } - if (this instanceof DieselTrain) { - //System.out.println("is diesel? "+(LiquidManager.getInstance().isDieselLocoFuel(stack)) + "return "+placeInSpecialInvent(stack,0,false)); - if (LiquidManager.getInstance().isDieselLocoFuel(stack)) return placeInSpecialInvent(stack, 0, doAdd); - } - if (this instanceof ElectricTrain) { - if ((stack.getItem() == Item.itemRegistry.getObject("redstone")) || (stack.getItem() instanceof IElectricItem)) return placeInSpecialInvent(stack, 0, doAdd); - } - return 0; - - } - */ - - // Quoted out as it doesn't seem to have any use nor to be called at all. - // /** - // * Requests items to be extracted from the inventory - // * - // * @param doRemove - // * If false no actual extraction may occur. - // * @param from - // * Orientation the ItemStack is requested from. - // * @param maxItemCount - // * Maximum amount of items to extract (spread over all returned - // * item stacks) - // * @return Array of item stacks extracted from the inventory - // */ - // @Override - // public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - // return null; - // } @Override public boolean attackEntityFrom(DamageSource damagesource, float i) { @@ -1389,18 +1299,6 @@ public boolean attackEntityFrom(DamageSource damagesource, float i) { return true; } - @Override - public void dropCartAsItem(boolean isCreative) { - if (!itemdropped) { - super.dropCartAsItem(isCreative); - for (ItemStack stack : locoInvent) { - if (stack != null) { - entityDropItem(stack, 0); - } - } - } - } - /** RC routing integration */ @Override public boolean setDestination(ItemStack ticket) { @@ -1411,95 +1309,19 @@ public boolean setDestination(ItemStack ticket) { return false; } - /* IInventory implements */ - @Override - public ItemStack getStackInSlot(int i) { - return locoInvent[i]; - } - - @Override - public ItemStack getStackInSlotOnClosing(int par1) { - if (this.locoInvent[par1] != null) { - ItemStack var2 = this.locoInvent[par1]; - this.locoInvent[par1] = null; - return var2; - } else { - return null; - } - } - - @Override - public ItemStack decrStackSize(int i, int j) { - if (locoInvent[i] != null) { - if (locoInvent[i].stackSize <= j) { - ItemStack itemstack = locoInvent[i]; - locoInvent[i] = null; - return itemstack; - } - - ItemStack itemstack1 = locoInvent[i].splitStack(j); - - if (locoInvent[i].stackSize == 0) { - locoInvent[i] = null; - } - return itemstack1; - - } else { - return null; - } - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - locoInvent[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } @Override public void markDirty() { + super.markDirty(); if (!worldObj.isRemote) { - this.slotsFilled = 0; - - for (int i = 0; i < getSizeInventory(); i++) { - ItemStack itemstack = getStackInSlot(i); - - if (itemstack != null) { - slotsFilled++; - } - } - Traincraft.slotschannel.sendToAllAround(new PacketSlotsFilled(this, slotsFilled), new TargetPoint(this.worldObj.provider.dimensionId, this.posX, this.posY, this.posZ, 150.0D)); } } - public int getAmmountOfCargo() { - return slotsFilled; - } - public void recieveSlotsFilled(int amount) { this.slotsFilled = amount; } - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public ItemStack[] getInventory() { - return locoInvent; - } - /** For MTC's Automatic Train Operation system */ public void accel(Integer desiredSpeed) { @@ -1664,21 +1486,4 @@ public void disconnectFromServer() { isConnected = false; } } - - - @Override - public int getSizeInventory() { - return inventorySize; - } - - - @Override - public String getInventoryName() { - return getTrainName(); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } } diff --git a/src/main/java/train/common/api/SteamTrain.java b/src/main/java/train/common/api/SteamTrain.java index ef62edfd29..e7a15ecde7 100644 --- a/src/main/java/train/common/api/SteamTrain.java +++ b/src/main/java/train/common/api/SteamTrain.java @@ -12,8 +12,6 @@ public abstract class SteamTrain extends Locomotive implements IFluidHandler { - public int fuelSlot = 1; - public int waterSlot = 1; protected int maxTank; private int maxFuel = 20000; private int update = 8; @@ -39,16 +37,17 @@ public SteamTrain(World world, FluidStack filter) { } tankArray[0] = theTank; dataWatcher.addObject(4, 0); - numCargoSlots = 3; - numCargoSlots1 = 3; - numCargoSlots2 = 3; - inventorySize = numCargoSlots + numCargoSlots2 + numCargoSlots1 + fuelSlot + waterSlot;// - this.dataWatcher.addObject(23, 0); + this.dataWatcher.addObject(27, 0); } public SteamTrain(World world, double d, double d1, double d2) { super(world, d, d1, d2); } + @Override + public int getSizeInventory() { + return 11+(getInventoryRows()*9); + } + /** * returns the waterConsumption for each steam loco default is 200: rand.nextInt(200)==0 * @@ -68,7 +67,7 @@ public void onUpdate() { return; } if (theTank != null && theTank.getFluid() != null) { - this.dataWatcher.updateObject(23, theTank.getFluid().amount); + this.dataWatcher.updateObject(27, theTank.getFluid().amount); this.dataWatcher.updateObject(4, theTank.getFluid().getFluidID()); } @@ -79,12 +78,14 @@ public void onUpdate() { } } else if (theTank != null && theTank.getFluid() == null) { - this.dataWatcher.updateObject(23, 0); + this.dataWatcher.updateObject(27, 0); this.dataWatcher.updateObject(4, 0); } if (rand.nextInt(100) == 0 && getWater() > 0 && getIsFuelled()) { drain(ForgeDirection.UNKNOWN, getWaterConsumption() / 5, true); } + + checkInvent(cargoItems[0], cargoItems[1], this); } /** @@ -93,7 +94,7 @@ else if (theTank != null && theTank.getFluid() == null) { * @return */ public int getWater() { - return (this.dataWatcher.getWatchableObjectInt(23)); + return (this.dataWatcher.getWatchableObjectInt(27)); } /** @@ -113,14 +114,12 @@ public StandardTank getTank() { protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); this.theTank.writeToNBT(nbttagcompound); - nbttagcompound.setBoolean("canBeAdjusted", canBeAdjusted); } @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); this.theTank.readFromNBT(nbttagcompound); - canBeAdjusted = nbttagcompound.getBoolean("canBeAdjusted"); } public int getCartTankCapacity() { @@ -128,24 +127,24 @@ public int getCartTankCapacity() { } private void placeInInvent(ItemStack itemstack1, SteamTrain loco) { - for (int i = 2; i < loco.locoInvent.length; i++) { - if (loco.locoInvent[i] == null) { - loco.locoInvent[i] = itemstack1; + for (int i = 2; i < loco.cargoItems.length; i++) { + if (loco.cargoItems[i] == null) { + loco.cargoItems[i] = itemstack1; return; } - else if (loco.locoInvent[i] != null && loco.locoInvent[i].getItem() == itemstack1.getItem() && itemstack1.isStackable() && - (!itemstack1.getHasSubtypes() || locoInvent[i].getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(locoInvent[i], itemstack1)) { - int var9 = locoInvent[i].stackSize + itemstack1.stackSize; + else if (loco.cargoItems[i] != null && loco.cargoItems[i].getItem() == itemstack1.getItem() && itemstack1.isStackable() && + (!itemstack1.getHasSubtypes() || cargoItems[i].getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(cargoItems[i], itemstack1)) { + int var9 = cargoItems[i].stackSize + itemstack1.stackSize; if (var9 <= itemstack1.getMaxStackSize()) { - loco.locoInvent[i].stackSize = var9; + loco.cargoItems[i].stackSize = var9; return; } - else if (locoInvent[i].stackSize < locoInvent[i].getMaxStackSize()) { - loco.locoInvent[i].stackSize += 1; + else if (cargoItems[i].stackSize < cargoItems[i].getMaxStackSize()) { + loco.cargoItems[i].stackSize += 1; return; } } - else if (i == loco.locoInvent.length - 1) { + else if (i == loco.cargoItems.length - 1) { entityDropItem(itemstack1,1); return; } diff --git a/src/main/java/train/common/api/Tender.java b/src/main/java/train/common/api/Tender.java index 6a1e157abc..ff1b18edde 100644 --- a/src/main/java/train/common/api/Tender.java +++ b/src/main/java/train/common/api/Tender.java @@ -49,7 +49,7 @@ private Tender(FluidStack fluid, World world, FluidStack filter) { IFluidTank[] tankArray = new IFluidTank[1]; tankArray[0] = theTank; dataWatcher.addObject(4, 0); - this.dataWatcher.addObject(23, 0); + this.dataWatcher.addObject(27, 0); } @Override @@ -73,10 +73,10 @@ public void onUpdate() { if (worldObj.isRemote) return; if (theTank != null && theTank.getFluid() != null) { - this.dataWatcher.updateObject(23, theTank.getFluid().amount); + this.dataWatcher.updateObject(27, theTank.getFluid().amount); this.dataWatcher.updateObject(4, theTank.getFluid().getFluidID()); } else if (theTank != null && theTank.getFluid() == null) { - this.dataWatcher.updateObject(23, 0); + this.dataWatcher.updateObject(27, 0); this.dataWatcher.updateObject(4, 0); } } @@ -109,7 +109,7 @@ protected void handleMass() { * @return */ public int getWater() { - return (this.dataWatcher.getWatchableObjectInt(23)); + return (this.dataWatcher.getWatchableObjectInt(27)); } /** diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDiesel44TonSwitcher.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDiesel44TonSwitcher.java index 846d1ae32b..1998ff6ede 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDiesel44TonSwitcher.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDiesel44TonSwitcher.java @@ -16,12 +16,7 @@ public class EntityLocoDiesel44TonSwitcher extends DieselTrain { public EntityLocoDiesel44TonSwitcher(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDiesel44TonSwitcher(World world, double d, double d1, double d2) { @@ -83,53 +78,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "GE 44 Ton Switcher"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselBamboo.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselBamboo.java index f495299d69..d34248010b 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselBamboo.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselBamboo.java @@ -17,12 +17,7 @@ public class EntityLocoDieselBamboo extends DieselTrain { public EntityLocoDieselBamboo(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselBamboo(World world, double d, double d1, double d2) { @@ -54,50 +49,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Bamboo Flatcar With Engine"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselCD742.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselCD742.java index 7af33ffd5a..325d8e474e 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselCD742.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselCD742.java @@ -16,12 +16,7 @@ public class EntityLocoDieselCD742 extends DieselTrain { public EntityLocoDieselCD742(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselCD742(World world, double d, double d1, double d2) { @@ -83,53 +78,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "CD742"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselChME3.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselChME3.java index 007109baaa..a713dda60d 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselChME3.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselChME3.java @@ -16,12 +16,7 @@ public class EntityLocoDieselChME3 extends DieselTrain { public EntityLocoDieselChME3(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselChME3(World world, double d, double d1, double d2) { @@ -54,53 +49,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "ChME3"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselClass66.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselClass66.java index e3bdd295e8..9f1b4b3e14 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselClass66.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselClass66.java @@ -16,12 +16,7 @@ public class EntityLocoDieselClass66 extends DieselTrain { public EntityLocoDieselClass66(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselClass66(World world, double d, double d1, double d2) { @@ -82,53 +77,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Class 66"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDD35A.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDD35A.java index 9edaa3ea68..6e87dd909f 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDD35A.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDD35A.java @@ -16,12 +16,7 @@ public class EntityLocoDieselDD35A extends DieselTrain { public EntityLocoDieselDD35A(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselDD35A(World world, double d, double d1, double d2) { @@ -82,50 +77,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "DD35A"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDeltic.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDeltic.java index d02cda1cdf..1195ef1e29 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDeltic.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselDeltic.java @@ -16,12 +16,7 @@ public class EntityLocoDieselDeltic extends DieselTrain { public EntityLocoDieselDeltic(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselDeltic(World world, double d, double d1, double d2) { @@ -82,50 +77,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Deltic"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF3.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF3.java index afd19120bc..944bc14411 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF3.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF3.java @@ -17,12 +17,7 @@ public class EntityLocoDieselEMDF3 extends DieselTrain { public EntityLocoDieselEMDF3(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselEMDF3(World world, double d, double d1, double d2) { @@ -55,50 +50,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "EMD F3"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF7.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF7.java index a1d5fed80f..c2e1e3cd97 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF7.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselEMDF7.java @@ -17,12 +17,7 @@ public class EntityLocoDieselEMDF7 extends DieselTrain { public EntityLocoDieselEMDF7(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselEMDF7(World world, double d, double d1, double d2) { @@ -55,50 +50,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "EMD F7"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1.java index abbba21ec5..e1c8f44a3a 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1.java @@ -17,12 +17,7 @@ public class EntityLocoDieselFOLM1 extends DieselTrain { public EntityLocoDieselFOLM1(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselFOLM1(World world, double d, double d1, double d2) { @@ -54,50 +49,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "FOL M1"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1B.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1B.java index e3e31d8595..e18ce5ec02 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1B.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselFOLM1B.java @@ -17,12 +17,6 @@ public class EntityLocoDieselFOLM1B extends DieselTrain { public EntityLocoDieselFOLM1B(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselFOLM1B(World world, double d, double d1, double d2) { @@ -54,50 +48,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "FOL-M1B"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselGP7Red.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselGP7Red.java index 8ef8fb31ed..6a670302e5 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselGP7Red.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselGP7Red.java @@ -16,12 +16,7 @@ public class EntityLocoDieselGP7Red extends DieselTrain { public EntityLocoDieselGP7Red(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselGP7Red(World world, double d, double d1, double d2) { @@ -82,53 +77,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "GP7"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselIC4_DSB_MG.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselIC4_DSB_MG.java index 280091f3eb..63403226a1 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselIC4_DSB_MG.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselIC4_DSB_MG.java @@ -17,12 +17,7 @@ public class EntityLocoDieselIC4_DSB_MG extends DieselTrain { public EntityLocoDieselIC4_DSB_MG(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselIC4_DSB_MG(World world, double d, double d1, double d2) { @@ -55,53 +50,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "IC4MG"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselKof_DB.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselKof_DB.java index d0b3862fc6..542597ecfa 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselKof_DB.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselKof_DB.java @@ -16,12 +16,7 @@ public class EntityLocoDieselKof_DB extends DieselTrain { public EntityLocoDieselKof_DB(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselKof_DB(World world, double d, double d1, double d2) { @@ -54,53 +49,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Kof"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselMILW_H1044.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselMILW_H1044.java index b4ff33427c..2a92f0a4c2 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselMILW_H1044.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselMILW_H1044.java @@ -16,12 +16,7 @@ public class EntityLocoDieselMILW_H1044 extends DieselTrain { public EntityLocoDieselMILW_H1044(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselMILW_H1044(World world, double d, double d1, double d2) { @@ -53,53 +48,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "MILW H10-44"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD40.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD40.java index 94202659f1..bd9adc8dc4 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD40.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD40.java @@ -17,12 +17,7 @@ public class EntityLocoDieselSD40 extends DieselTrain { public EntityLocoDieselSD40(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselSD40(World world, double d, double d1, double d2) { @@ -54,53 +49,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "SD40-2"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD70.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD70.java index 7854b03229..f7f9b50ec9 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD70.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselSD70.java @@ -17,12 +17,7 @@ public class EntityLocoDieselSD70 extends DieselTrain { public EntityLocoDieselSD70(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselSD70(World world, double d, double d1, double d2) { @@ -48,50 +43,6 @@ public void setDead() { isDead = true; } - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "SD70M"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselShunter.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselShunter.java index 79c6cff2ad..0a3dda82f6 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselShunter.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselShunter.java @@ -16,12 +16,7 @@ public class EntityLocoDieselShunter extends DieselTrain { public EntityLocoDieselShunter(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselShunter(World world, double d, double d1, double d2) { @@ -53,50 +48,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Class 08 Shunter"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselV60_DB.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselV60_DB.java index 878965a103..4505fc8338 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselV60_DB.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselV60_DB.java @@ -16,12 +16,7 @@ public class EntityLocoDieselV60_DB extends DieselTrain { public EntityLocoDieselV60_DB(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselV60_DB(World world, double d, double d1, double d2) { @@ -53,53 +48,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0]); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "V60"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselWLs40.java b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselWLs40.java index d77046fb09..805158363a 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoDieselWLs40.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoDieselWLs40.java @@ -17,12 +17,7 @@ public class EntityLocoDieselWLs40 extends DieselTrain { public EntityLocoDieselWLs40(World world) { super(world, LiquidManager.dieselFilter()); - initLoco(); - } - public void initLoco() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoDieselWLs40(World world, double d, double d1, double d2) { @@ -54,50 +49,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0]); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "WLs40"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBP4.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBP4.java index 12b0aed739..402dc14e85 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBP4.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBP4.java @@ -46,44 +46,6 @@ public void pressKey(int i) { } } - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "BP4"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR185.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR185.java index 8913e964b7..a258b57c4d 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR185.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR185.java @@ -74,44 +74,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "BR 185"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR_E69.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR_E69.java index 9e935de240..343ad828e3 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR_E69.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricBR_E69.java @@ -46,44 +46,6 @@ public void pressKey(int i) { } } - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "BR E69"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricCD151.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricCD151.java index f614cc7421..61b8ab9295 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricCD151.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricCD151.java @@ -45,44 +45,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "CD 151"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricClass85.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricClass85.java index c7abd30cdb..2d97da76e7 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricClass85.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricClass85.java @@ -74,44 +74,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Class 85"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE103.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE103.java index a48d9313a5..1a3bcea5c7 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE103.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE103.java @@ -45,44 +45,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "E103"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE10_DB.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE10_DB.java index 4f2fc92973..ed046898ff 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE10_DB.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricE10_DB.java @@ -45,44 +45,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "E10 (DB)"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricHighSpeedZeroED.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricHighSpeedZeroED.java index 7f7cc698a0..3399e7940c 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricHighSpeedZeroED.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricHighSpeedZeroED.java @@ -38,44 +38,6 @@ public void setDead() { super.setDead(); isDead = true; } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "High Speed"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricICE1.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricICE1.java index 05681d78b4..bbbbbe48f6 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricICE1.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricICE1.java @@ -74,44 +74,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "ICB 1"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricMinetrain.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricMinetrain.java index 7443ddd394..a380eaeec1 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricMinetrain.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricMinetrain.java @@ -46,44 +46,6 @@ public void pressKey(int i) { } } - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Cart hauler"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramNY.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramNY.java index b33aec5b44..bea2fa72e6 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramNY.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramNY.java @@ -74,44 +74,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Kawasaki PA4"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramWood.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramWood.java index 8cb020410a..f6fd70d3d5 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramWood.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricTramWood.java @@ -78,44 +78,6 @@ public void pressKey(int i) { } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Tram"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricVL10.java b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricVL10.java index 125e9ba2b3..0f9fe025d5 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoElectricVL10.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoElectricVL10.java @@ -72,43 +72,6 @@ public void pressKey(int i) { } } @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - @Override - /** return the loco inventory size **/ - public int getSizeInventory() { - - return inventorySize; - } - @Override public String getInventoryName() { return "VL10"; } diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteam040VB.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteam040VB.java index 389efd771b..950edc4049 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteam040VB.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteam040VB.java @@ -16,12 +16,6 @@ public class EntityLocoSteam040VB extends SteamTrain { public EntityLocoSteam040VB(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteam040VB(World world, double d, double d1, double d2) { @@ -56,50 +50,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0], locoInvent[1], this); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "0-4-0 Vertical Boiler"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteam262T.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteam262T.java index 0ae3deb9c5..6de294b781 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteam262T.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteam262T.java @@ -16,12 +16,6 @@ public class EntityLocoSteam262T extends SteamTrain { public EntityLocoSteam262T(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteam262T(World world, double d, double d1, double d2) { @@ -55,53 +49,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "2-6-2T"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteam4_4_0.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteam4_4_0.java index 0cde4e8300..f7096962df 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteam4_4_0.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteam4_4_0.java @@ -16,12 +16,6 @@ public class EntityLocoSteam4_4_0 extends SteamTrain { public EntityLocoSteam4_4_0(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteam4_4_0(World world, double d, double d1, double d2) { @@ -53,53 +47,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "4-4-0 (US)"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAdler.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAdler.java index b51bc26c28..417267d955 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAdler.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAdler.java @@ -16,12 +16,6 @@ public class EntityLocoSteamAdler extends SteamTrain { public EntityLocoSteamAdler(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamAdler(World world, double d, double d1, double d2) { @@ -71,50 +65,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0], locoInvent[1], this); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Adler"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlcoSC4.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlcoSC4.java index cc85005608..9a23a62d7f 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlcoSC4.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlcoSC4.java @@ -16,12 +16,6 @@ public class EntityLocoSteamAlcoSC4 extends SteamTrain { public EntityLocoSteamAlcoSC4(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamAlcoSC4(World world, double d, double d1, double d2) { @@ -83,53 +77,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Alco SC4"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlice0_4_0.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlice0_4_0.java index e6d406841f..d593a76b0c 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlice0_4_0.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamAlice0_4_0.java @@ -16,12 +16,6 @@ public class EntityLocoSteamAlice0_4_0 extends SteamTrain { public EntityLocoSteamAlice0_4_0(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamAlice0_4_0(World world, double d, double d1, double d2) { @@ -55,53 +49,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "0-4-0 Alice"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR01_DB.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR01_DB.java index 7a31b5693a..b86e8bcb1e 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR01_DB.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR01_DB.java @@ -16,12 +16,6 @@ public class EntityLocoSteamBR01_DB extends SteamTrain { public EntityLocoSteamBR01_DB(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamBR01_DB(World world, double d, double d1, double d2) { this(world); @@ -52,53 +46,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "BR01"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR80_DB.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR80_DB.java index d1626abf8f..77218ce7b5 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR80_DB.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBR80_DB.java @@ -16,12 +16,6 @@ public class EntityLocoSteamBR80_DB extends SteamTrain { public EntityLocoSteamBR80_DB(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamBR80_DB(World world, double d, double d1, double d2) { this(world); @@ -72,50 +66,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - checkInvent(locoInvent[0], locoInvent[1], this); - super.onUpdate(); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "BR80"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk1225.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk1225.java index 55221a91be..e6e644defa 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk1225.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk1225.java @@ -17,12 +17,6 @@ public class EntityLocoSteamBerk1225 extends SteamTrain { public EntityLocoSteamBerk1225(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamBerk1225(World world, double d, double d1, double d2) { @@ -53,53 +47,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >=0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Berkshire 1225"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk765.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk765.java index 8ec51c6284..1fc3223eef 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk765.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamBerk765.java @@ -17,12 +17,6 @@ public class EntityLocoSteamBerk765 extends SteamTrain { public EntityLocoSteamBerk765(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamBerk765(World world, double d, double d1, double d2) { @@ -53,53 +47,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >=0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Berkshire 765"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41.java index 90dc8bd9f7..1919c52681 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41.java @@ -15,12 +15,6 @@ public class EntityLocoSteamC41 extends SteamTrain { public EntityLocoSteamC41(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamC41(World world, double d, double d1, double d2) { @@ -51,53 +45,6 @@ public void setDead() { isDead = true; } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "C41"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41T.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41T.java index 9ece7894c6..57e919d01a 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41T.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41T.java @@ -16,12 +16,6 @@ public class EntityLocoSteamC41T extends SteamTrain { public EntityLocoSteamC41T(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamC41T(World world, double d, double d1, double d2) { @@ -83,53 +77,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "C41T"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41_080.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41_080.java index 4fee6c0bdf..dd3d71bfa0 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41_080.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC41_080.java @@ -16,12 +16,6 @@ public class EntityLocoSteamC41_080 extends SteamTrain { public EntityLocoSteamC41_080(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamC41_080(World world, double d, double d1, double d2) { @@ -83,53 +77,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "C41"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC62Class.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC62Class.java index dc64408d1e..2325c932fd 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC62Class.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamC62Class.java @@ -16,12 +16,6 @@ public class EntityLocoSteamC62Class extends SteamTrain { public EntityLocoSteamC62Class(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamC62Class(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "C62 Class [JNR]"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCherepanov.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCherepanov.java index 49f755fa04..ec79ee5316 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCherepanov.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCherepanov.java @@ -16,12 +16,6 @@ public class EntityLocoSteamCherepanov extends SteamTrain { public EntityLocoSteamCherepanov(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamCherepanov(World world, double d, double d1, double d2) { @@ -41,11 +35,6 @@ public void updateRiderPosition() { riddenByEntity.setPosition(posX, posY + getMountedYOffset() + riddenByEntity.getYOffset() + 0.154, posZ); } - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public void setDead() { super.setDead(); @@ -58,45 +47,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - @Override public String getInventoryName() { return "Cherepanov"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamClimax.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamClimax.java index 00e5356e17..5b7149a8af 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamClimax.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamClimax.java @@ -16,12 +16,6 @@ public class EntityLocoSteamClimax extends SteamTrain { public EntityLocoSteamClimax(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamClimax(World world, double d, double d1, double d2) { @@ -56,53 +50,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "4-0-4 Climax"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCoranationClass.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCoranationClass.java index 7bb8c6ac3f..49557d9e2b 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCoranationClass.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamCoranationClass.java @@ -16,12 +16,6 @@ public class EntityLocoSteamCoranationClass extends SteamTrain { public EntityLocoSteamCoranationClass(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamCoranationClass(World world, double d, double d1, double d2) { @@ -82,53 +76,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Coranation Class"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51.java index af5fc4d9e4..9f30a2aad5 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51.java @@ -16,12 +16,6 @@ public class EntityLocoSteamD51 extends SteamTrain { public EntityLocoSteamD51(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamD51(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "D51 [JNR]"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51Long.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51Long.java index 506550177f..9bdae16310 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51Long.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamD51Long.java @@ -16,12 +16,6 @@ public class EntityLocoSteamD51Long extends SteamTrain { public EntityLocoSteamD51Long(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamD51Long(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "D51 [JNR]"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamEr_Ussr.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamEr_Ussr.java index 7fb7a53979..77df3fe1e0 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamEr_Ussr.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamEr_Ussr.java @@ -16,12 +16,6 @@ public class EntityLocoSteamEr_Ussr extends SteamTrain { public EntityLocoSteamEr_Ussr(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamEr_Ussr(World world, double d, double d1, double d2) { @@ -54,53 +48,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "USSR 0-5-0"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamForneyRed.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamForneyRed.java index e948e42380..11fb0e881e 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamForneyRed.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamForneyRed.java @@ -18,16 +18,15 @@ public class EntityLocoSteamForneyRed extends SteamTrain { public EntityLocoSteamForneyRed(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); textureDescriptionMap.put("Default", new TextureDescription(null, "Forney locomotives are considered as a type of tank engine, small and powerful! The characteristics of this locomotive consisted of a pilot truck (if built with it), four drivers with the second set without flanges for tight turns, and a trailing truck/bogie of two sets of wheels. This little puppy was created to make tight turns conventional locomotives couldn’t. These mainly operated on commuter lines in New York, Chicago, & Boston. The most recognizable ones are from Disneyland No. 3 and the Maine Narrow Gauge Railroad Co. locomotives which the TC models are based off.\n")); textureDescriptionMap.put("Yellow", new TextureDescription(null, "Special texture description for yellow Forney.")); } - public void initLocoSteam() { - fuelTrain = 0; - this.inventorySize = 17; - locoInvent = new ItemStack[inventorySize]; + @Override//todo:why was this so much? + public int getSizeInventory() { + return 17; } + public EntityLocoSteamForneyRed(World world, double d, double d1, double d2) { this(world); setPosition(d, d1 + (double) yOffset, d2); @@ -64,19 +63,19 @@ public void onUpdate() { if (worldObj.isRemote) { return; } - checkInvent(locoInvent[0], locoInvent[1], this); - for (int h = 0; h < this.locoInvent.length; h++) { - if (this.locoInvent[h] != null && steamFuelLast(this.locoInvent[h]) != 0) { + checkInvent(cargoItems[0], cargoItems[1], this); + for (int h = 0; h < this.cargoItems.length; h++) { + if (this.cargoItems[h] != null && steamFuelLast(this.cargoItems[h]) != 0) { if (fuelTrain <= 0 && !worldObj.isRemote) { - fuelTrain = steamFuelLast(this.locoInvent[h]); + fuelTrain = steamFuelLast(this.cargoItems[h]); if (!worldObj.isRemote) { this.decrStackSize(h, 1); } } } - else if (this.locoInvent[h] != null && steamFuelLast(this.locoInvent[h]) != 0) { + else if (this.cargoItems[h] != null && steamFuelLast(this.cargoItems[h]) != 0) { if (fuelTrain <= 0 && !worldObj.isRemote) { - fuelTrain = steamFuelLast(this.locoInvent[h]); + fuelTrain = steamFuelLast(this.cargoItems[h]); if (!worldObj.isRemote) { this.decrStackSize(h, 1); } @@ -84,44 +83,6 @@ else if (this.locoInvent[h] != null && steamFuelLast(this.locoInvent[h]) != 0) { } } } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Forney"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamFowler.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamFowler.java index 4216b8c122..42e2315b47 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamFowler.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamFowler.java @@ -17,12 +17,6 @@ public class EntityLocoSteamFowler extends SteamTrain { public EntityLocoSteamFowler(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamFowler(World world, double d, double d1, double d2) { @@ -54,53 +48,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >=0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Fowler 4F"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGLYN042T.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGLYN042T.java index 66500d1fe0..d8f92e2141 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGLYN042T.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGLYN042T.java @@ -16,12 +16,6 @@ public class EntityLocoSteamGLYN042T extends SteamTrain { public EntityLocoSteamGLYN042T(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamGLYN042T(World world, double d, double d1, double d2) { @@ -55,53 +49,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "0-4-2 GLYN"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGS4.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGS4.java index 8efab35dab..df15923758 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGS4.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamGS4.java @@ -16,12 +16,6 @@ public class EntityLocoSteamGS4 extends SteamTrain { public EntityLocoSteamGS4(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamGS4(World world, double d, double d1, double d2) { this(world); @@ -52,53 +46,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Daylight"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHallClass.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHallClass.java index 14031d83e6..0147d34c9e 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHallClass.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHallClass.java @@ -16,12 +16,6 @@ public class EntityLocoSteamHallClass extends SteamTrain { public EntityLocoSteamHallClass(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamHallClass(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >=0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Hall Class"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHeavy.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHeavy.java index 30ae3305a3..fed0b1c630 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHeavy.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamHeavy.java @@ -16,12 +16,6 @@ public class EntityLocoSteamHeavy extends SteamTrain { public EntityLocoSteamHeavy(World world) { super(world,LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamHeavy(World world, double d, double d1, double d2) { @@ -54,53 +48,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Heavy Steam Locomotive"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamKingClass.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamKingClass.java index 5a332a4ad3..e42b3f0a08 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamKingClass.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamKingClass.java @@ -16,12 +16,6 @@ public class EntityLocoSteamKingClass extends SteamTrain { public EntityLocoSteamKingClass(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamKingClass(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >=0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "King Class"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamLSSP7.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamLSSP7.java index 2f605819ca..710564c7c6 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamLSSP7.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamLSSP7.java @@ -16,12 +16,6 @@ public class EntityLocoSteamLSSP7 extends SteamTrain { public EntityLocoSteamLSSP7(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamLSSP7(World world, double d, double d1, double d2) { @@ -53,53 +47,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "LSSP 7"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMILWClassA.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMILWClassA.java index 1e97da610e..c9b0032179 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMILWClassA.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMILWClassA.java @@ -16,12 +16,6 @@ public class EntityLocoSteamMILWClassA extends SteamTrain { public EntityLocoSteamMILWClassA(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamMILWClassA(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "MILW Class A"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMallardA4.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMallardA4.java index e039d23e8c..ec66f56fc4 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMallardA4.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMallardA4.java @@ -16,12 +16,6 @@ public class EntityLocoSteamMallardA4 extends SteamTrain { public EntityLocoSteamMallardA4(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamMallardA4(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "A4 Mallard"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMogulBlue.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMogulBlue.java index 70c22cca71..49e0e90601 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMogulBlue.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamMogulBlue.java @@ -16,12 +16,6 @@ public class EntityLocoSteamMogulBlue extends SteamTrain { public EntityLocoSteamMogulBlue(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamMogulBlue(World world, double d, double d1, double d2) { this(world); @@ -52,53 +46,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Mogul"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamPannier.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamPannier.java index 4c22258618..0155de9469 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamPannier.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamPannier.java @@ -17,12 +17,6 @@ public class EntityLocoSteamPannier extends SteamTrain { public EntityLocoSteamPannier(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamPannier(World world, double d, double d1, double d2) { @@ -58,53 +52,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "0-6-0 Pannier"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamShay.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamShay.java index af067f42d8..a552274b4c 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamShay.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamShay.java @@ -16,12 +16,6 @@ public class EntityLocoSteamShay extends SteamTrain { public EntityLocoSteamShay(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamShay(World world, double d, double d1, double d2) { @@ -54,53 +48,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Shay"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSmall.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSmall.java index 324d02f75b..a6a1774698 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSmall.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSmall.java @@ -16,12 +16,6 @@ public class EntityLocoSteamSmall extends SteamTrain { public EntityLocoSteamSmall(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamSmall(World world, double d, double d1, double d2) { @@ -53,53 +47,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Small steam Locomotive"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSnowPlow.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSnowPlow.java index f8e61a9e00..89a2fa370b 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSnowPlow.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSnowPlow.java @@ -25,12 +25,6 @@ public class EntityLocoSteamSnowPlow extends SteamTrain { public EntityLocoSteamSnowPlow(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamSnowPlow(World world, double d, double d1, double d2) { @@ -104,7 +98,7 @@ public void onUpdate() { if (worldObj.isRemote || bogieFront==null || bogieBack==null) { return; } - checkInvent(locoInvent[0], locoInvent[1], this); + checkInvent(cargoItems[0], cargoItems[1], this); if (fakePlayer == null){ fakePlayer = new FakePlayer(worldObj); } @@ -114,31 +108,31 @@ public void onUpdate() { point1 = rotateVec3(blockpos[0], getPitch(), rotation); point1[0] += posX;point1[1] += posY;point1[2] += posZ; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); point1[1]++; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); point1[1]++; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); point1 = rotateVec3(blockpos[1], getPitch(), rotation); point1[0] += posX;point1[1] += posY;point1[2] += posZ; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); point1[1]++; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); point1[1]++; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); point1 = rotateVec3(blockpos[2], getPitch(), rotation); point1[0] += posX;point1[1] += posY+1;point1[2] += posZ; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); point1[1]++; - mineSnow(worldObj, point1, locoInvent, fakePlayer); + mineSnow(worldObj, point1, cargoItems, fakePlayer); } - private static void mineSnow(World worldObj, double[] point, ItemStack[] locoInvent, FakePlayer fakePlayer){ + private static void mineSnow(World worldObj, double[] point, ItemStack[] cargoItems, FakePlayer fakePlayer){ Block b = worldObj.getBlock(MathHelper.floor_double(point[0]),MathHelper.floor_double(point[1]),MathHelper.floor_double(point[2])); int blockMeta = worldObj.getBlockMetadata(MathHelper.floor_double(point[0]), MathHelper.floor_double(point[1]), MathHelper.floor_double(point[2])); @@ -146,13 +140,13 @@ private static void mineSnow(World worldObj, double[] point, ItemStack[] locoInv if((b == Blocks.snow || b == Blocks.snow_layer) && b.canHarvestBlock(fakePlayer, blockMeta)){ worldObj.setBlockToAir(MathHelper.floor_double(point[0]),MathHelper.floor_double(point[1]),MathHelper.floor_double(point[2])); int snowballs = new Random().nextInt(9); - for(int i=2; i0; i++){ - if (locoInvent[i] == null){ - locoInvent[i] = new ItemStack(Items.snowball, snowballs); + for(int i=2; i0; i++){ + if (cargoItems[i] == null){ + cargoItems[i] = new ItemStack(Items.snowball, snowballs); snowballs--; - } else if (locoInvent[i].getItem() == Items.snowball && locoInvent[i].stackSize < Items.snowball.getItemStackLimit()){ - while (locoInvent[i].stackSize < locoInvent[i].getMaxStackSize() && snowballs >0){ - locoInvent[i].stackSize++; + } else if (cargoItems[i].getItem() == Items.snowball && cargoItems[i].stackSize < Items.snowball.getItemStackLimit()){ + while (cargoItems[i].stackSize < cargoItems[i].getMaxStackSize() && snowballs >0){ + cargoItems[i].stackSize++; snowballs--; } } @@ -190,44 +184,6 @@ private static double[] rotateVec3(double[] offset, float pitch, float yaw) { return xyz; } - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Steam Snow Plow"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSouthern1102.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSouthern1102.java index bd3287123b..8ad74f24c8 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSouthern1102.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamSouthern1102.java @@ -16,12 +16,6 @@ public class EntityLocoSteamSouthern1102 extends SteamTrain { public EntityLocoSteamSouthern1102(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamSouthern1102(World world, double d, double d1, double d2) { @@ -83,53 +77,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "Southern 1102"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUK.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUK.java index 882286e560..b1e845578e 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUK.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUK.java @@ -16,12 +16,6 @@ public class EntityLocoSteamUSATCUK extends SteamTrain { public EntityLocoSteamUSATCUK(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamUSATCUK(World world, double d, double d1, double d2) { @@ -83,53 +77,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "S100 USATCUK"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUS.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUS.java index 3446bdd954..1cb29c9fec 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUS.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamUSATCUS.java @@ -16,12 +16,6 @@ public class EntityLocoSteamUSATCUS extends SteamTrain { public EntityLocoSteamUSATCUS(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamUSATCUS(World world, double d, double d1, double d2) { @@ -83,53 +77,6 @@ public void pressKey(int i) { } } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } - @Override public String getInventoryName() { return "S100 USATCUS"; diff --git a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamVBShay.java b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamVBShay.java index 1fedaf93b1..d634a46328 100644 --- a/src/main/java/train/common/entity/rollingStock/EntityLocoSteamVBShay.java +++ b/src/main/java/train/common/entity/rollingStock/EntityLocoSteamVBShay.java @@ -16,12 +16,6 @@ public class EntityLocoSteamVBShay extends SteamTrain { public EntityLocoSteamVBShay(World world) { super(world, LiquidManager.WATER_FILTER); - initLocoSteam(); - } - - public void initLocoSteam() { - fuelTrain = 0; - locoInvent = new ItemStack[inventorySize]; } public EntityLocoSteamVBShay(World world, double d, double d1, double d2) { @@ -55,53 +49,6 @@ public void pressKey(int i) { ((EntityPlayer) riddenByEntity).openGui(Traincraft.instance, GuiIDs.LOCO, worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } } - - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - return; - } - checkInvent(locoInvent[0], locoInvent[1], this); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - super.writeEntityToNBT(nbttagcompound); - - nbttagcompound.setShort("fuelTrain", (short) fuelTrain); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < locoInvent.length; i++) { - if (locoInvent[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - locoInvent[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - super.readEntityFromNBT(nbttagcompound); - - fuelTrain = nbttagcompound.getShort("fuelTrain"); - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND); - locoInvent = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 0xff; - if (j >= 0 && j < locoInvent.length) { - locoInvent[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - } - - @Override - public int getSizeInventory() { - return inventorySize; - } @Override public String getInventoryName() { return "Vertical Boiler Shay"; diff --git a/src/main/java/train/common/inventory/InventoryForney.java b/src/main/java/train/common/inventory/InventoryForney.java index a7c9228b16..233ae82bb9 100644 --- a/src/main/java/train/common/inventory/InventoryForney.java +++ b/src/main/java/train/common/inventory/InventoryForney.java @@ -22,7 +22,7 @@ public class InventoryForney extends Container { public InventoryForney(InventoryPlayer iinventory, EntityRollingStock entityminecart) { player = iinventory; loco = (Locomotive) entityminecart; - inventorySize = loco.inventorySize; + inventorySize = loco.getSizeInventory(); int i = 2; int numCargoSlots = 5; addSlotToContainer(new Slot((IInventory) entityminecart, 0, 8, 34)); diff --git a/src/main/java/train/common/inventory/InventoryLoco.java b/src/main/java/train/common/inventory/InventoryLoco.java index 98d0e76797..4c3cf1b15e 100644 --- a/src/main/java/train/common/inventory/InventoryLoco.java +++ b/src/main/java/train/common/inventory/InventoryLoco.java @@ -7,10 +7,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import train.common.api.EntityRollingStock; -import train.common.api.LiquidManager; -import train.common.api.Locomotive; -import train.common.api.SteamTrain; +import train.common.api.*; import train.common.core.handlers.FuelHandler; import train.common.slots.SpecialSlots; @@ -22,7 +19,7 @@ public class InventoryLoco extends Container { private SpecialSlots specialSlots = SpecialSlots.getInstance(); public InventoryLoco(InventoryPlayer iinventory, EntityRollingStock entityminecart) { - inventorySize = ((Locomotive) entityminecart).inventorySize; + inventorySize = ((Locomotive) entityminecart).getSizeInventory(); player = iinventory; loco = (Locomotive) entityminecart; int i = 1; @@ -32,15 +29,15 @@ public InventoryLoco(InventoryPlayer iinventory, EntityRollingStock entitymineca addSlotToContainer(specialSlots.new SlotLiquid((IInventory) entityminecart, 1, 32, 53)); i = 2; } - for (int j = 0; j < loco.numCargoSlots; j++) { + for (int j = 0; j < (loco instanceof ElectricTrain ?5:3); j++) { addSlotToContainer(new Slot((IInventory) entityminecart, i, 80 + j * 18, 18)); i++; } - for (int k = 0; k < loco.numCargoSlots1; k++) { + for (int k = 0; k < (loco instanceof ElectricTrain ?5:3); k++) { addSlotToContainer(new Slot((IInventory) entityminecart, i, 80 + k * 18, 36)); i++; } - for (int l = 0; l < loco.numCargoSlots2; l++) { + for (int l = 0; l < (loco instanceof ElectricTrain ?5:3); l++) { addSlotToContainer(new Slot((IInventory) entityminecart, i, 80 + l * 18, 54)); i++; } diff --git a/src/main/java/train/common/library/TraincraftRegistry.java b/src/main/java/train/common/library/TraincraftRegistry.java index 1864f7845d..09fe9da47e 100644 --- a/src/main/java/train/common/library/TraincraftRegistry.java +++ b/src/main/java/train/common/library/TraincraftRegistry.java @@ -137,7 +137,9 @@ public void registerTrainRecord(TrainRecord record) { public void registerTrainRenderRecord(TrainRenderRecord record) { trainRenderRecords.put(record.getEntityClass(), record); - SkinRegistry.liveryMap.put(record.getEntityClass(),getTrainRecord(record.getEntityClass()).getColors()); + if(getTrainRecord(record.getEntityClass())!=null) { + SkinRegistry.liveryMap.put(record.getEntityClass(), getTrainRecord(record.getEntityClass()).getColors()); + } } public void registerTrainSoundRecord(TrainSoundRecord sound) {