From a1ecb870e3a30a5c511e676b28df6503e0a101c4 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Sat, 22 Oct 2022 17:45:53 +0200 Subject: [PATCH] feat: random bugfixes --- build.gradle | 4 +- .../java/atomicscience/AtomicScience.java | 4 + .../java/atomicscience/TAtomicAssembler.java | 2 +- .../java/atomicscience/fanwusu/EMatter.java | 11 +- .../atomicscience/fanwusu/TAccelerator.java | 2 +- .../atomicscience/fenlie/TNuclearBoiler.java | 431 +++++++++--------- .../atomicscience/hecheng/BElectromagnet.java | 1 - .../atomicscience/hecheng/CNuclearBoiler.java | 173 +++---- .../atomicscience/jiqi/BBaseRotatable.java | 29 ++ .../atomicscience/shimian/GAccelerator.java | 2 +- 10 files changed, 348 insertions(+), 311 deletions(-) diff --git a/build.gradle b/build.gradle index 6c93b29..82e0d10 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 version = "1.0" -group= "modgroup" -archivesBaseName = "modid" +group = "universalelectricity" +archivesBaseName = "atomicscience" minecraft { version = "1.7.10-10.13.4.1614-1.7.10" diff --git a/src/main/java/atomicscience/AtomicScience.java b/src/main/java/atomicscience/AtomicScience.java index a564383..8dc2559 100644 --- a/src/main/java/atomicscience/AtomicScience.java +++ b/src/main/java/atomicscience/AtomicScience.java @@ -140,6 +140,7 @@ public class AtomicScience { public static Block bAtomicAssembler; public static Block bFissionReactor; public static Block bReactorTap; + public static Block bSuperConductor; public static final int ITEM_ID_PREFIX = 13768; public static Item itCell; public static Item itCellUranium; @@ -228,6 +229,7 @@ public class AtomicScience { bFulminationGenerator = new BFulminationGenerator(); bAtomicAssembler = new BAtomicAssembler(); bReactorTap = new BReactorTap(); + bSuperConductor = new BSuperconductor(); itHazmatHelmet = (new ItHazmatSuite( @@ -306,6 +308,7 @@ public class AtomicScience { GameRegistry.registerBlock(bAtomicAssembler, "bAtomicAssembler"); GameRegistry.registerBlock(bToxicWaste, "bToxicWaste"); GameRegistry.registerBlock(bReactorTap, "bReactorTap"); + GameRegistry.registerBlock(bSuperConductor, "bSuperConductor"); uraniumOreGeneration = new OreGenReplaceStone("Uranium Ore", "oreUranium", new ItemStack(bUraniumOre), 0, 25, 9, 3, "pickaxe", 2); @@ -366,6 +369,7 @@ public class AtomicScience { GameRegistry.registerTileEntity(TAutoBuilder.class, "ASAutoBuilder"); GameRegistry.registerTileEntity(TFissionReactor.class, "ASFissionReactor"); GameRegistry.registerTileEntity(TReactorTap.class, "ASReactorTap"); + GameRegistry.registerTileEntity(TSuperconductor.class, "ASSuperconductor"); proxy.preInit(); channel = NetworkRegistry.INSTANCE.newSimpleChannel("AtomicScience"); diff --git a/src/main/java/atomicscience/TAtomicAssembler.java b/src/main/java/atomicscience/TAtomicAssembler.java index b74e04a..59025cd 100644 --- a/src/main/java/atomicscience/TAtomicAssembler.java +++ b/src/main/java/atomicscience/TAtomicAssembler.java @@ -138,7 +138,7 @@ public class TAtomicAssembler extends TInventory { public void work() { if (this.canWork()) { - for (int i = 0; i < 5; ++i) { + for (int i = 0; i <= 5; ++i) { if (super.containingItems[i] != null) { super.containingItems[i].setItemDamage( super.containingItems[i].getItemDamage() + 1); diff --git a/src/main/java/atomicscience/fanwusu/EMatter.java b/src/main/java/atomicscience/fanwusu/EMatter.java index a9d7f93..ac000d5 100644 --- a/src/main/java/atomicscience/fanwusu/EMatter.java +++ b/src/main/java/atomicscience/fanwusu/EMatter.java @@ -6,7 +6,6 @@ import atomicscience.api.IElectromagnet; import atomicscience.api.poison.PoisonRadiation; import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; import io.netty.buffer.ByteBuf; - import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; @@ -47,7 +46,7 @@ public class EMatter extends Entity implements IEntityAdditionalSpawnData { } public EMatter(World par1World, Vector3 diDian, Vector3 jiQi, - ForgeDirection direction) { + ForgeDirection direction) { this(par1World); this.setPosition(diDian.x, diDian.y, diDian.z); this.jiQi = jiQi; @@ -139,7 +138,7 @@ public class EMatter extends Entity implements IEntityAdditionalSpawnData { } --this.lastTurn; - if (canCunZai(super.worldObj, new Vector3(this), this.fangXiang) && + if (canExist(super.worldObj, new Vector3(this), this.fangXiang) && !super.isCollided) { Vector3 dongLi = new Vector3(); dongLi.modifyPositionFromSide(this.fangXiang); @@ -274,14 +273,16 @@ public class EMatter extends Entity implements IEntityAdditionalSpawnData { Math.abs(super.motionZ); } - public static boolean canCunZai(World worldObj, Vector3 position, - ForgeDirection facing) { + public static boolean canExist(World worldObj, Vector3 position, + ForgeDirection facing) { if (position.getBlock(worldObj) != Blocks.air) { + AtomicScience.LOGGER.info("block not air " + position); return false; } else { for (int i = 0; i <= 1; ++i) { ForgeDirection dir = ForgeDirection.getOrientation(i); if (!isElectromagnet(worldObj, position, dir)) { + AtomicScience.LOGGER.info("not alectromagnet " + position); return false; } } diff --git a/src/main/java/atomicscience/fanwusu/TAccelerator.java b/src/main/java/atomicscience/fanwusu/TAccelerator.java index 27b6eb5..e58b190 100644 --- a/src/main/java/atomicscience/fanwusu/TAccelerator.java +++ b/src/main/java/atomicscience/fanwusu/TAccelerator.java @@ -89,7 +89,7 @@ public class TAccelerator this.zCoord) .getOpposite()); i$1.add(0.5D); - if (EMatter.canCunZai( + if (EMatter.canExist( this.worldObj, i$1, this.getDirection(this.worldObj, this.xCoord, this.yCoord, this.zCoord) diff --git a/src/main/java/atomicscience/fenlie/TNuclearBoiler.java b/src/main/java/atomicscience/fenlie/TNuclearBoiler.java index 6cc3b9d..6f7d461 100644 --- a/src/main/java/atomicscience/fenlie/TNuclearBoiler.java +++ b/src/main/java/atomicscience/fenlie/TNuclearBoiler.java @@ -21,241 +21,242 @@ import universalelectricity.core.item.ElectricItemHelper; import universalelectricity.prefab.implement.IRotatable; public class TNuclearBoiler - extends TInventory implements ISidedInventory, IFluidHandler, IRotatable { + extends TInventory implements ISidedInventory, IFluidHandler, IRotatable { - public final int SHI_JIAN = 300; - public final float DIAN = 800.0F; - public int smeltingTicks = 0; - public float rotation = 0.0F; - public final FluidTank waterTank; - public final FluidTank gasTank; + public final int SHI_JIAN = 300; + public final float DIAN = 800.0F; + public int smeltingTicks = 0; + public float rotation = 0.0F; + public final FluidTank waterTank; + public final FluidTank gasTank; - public TNuclearBoiler() { - this.waterTank = new FluidTank(FluidRegistry.WATER, 0, 5000); - this.gasTank = new FluidTank(AtomicScience.FLUID_URANIUM_HEXAFLOURIDE, 0, 5000); - // TODO: WTF - // this.waterTank.setTankPressure(-10); - // this.gasTank.setTankPressure(10); - } + public TNuclearBoiler() { + this.waterTank = new FluidTank(FluidRegistry.WATER, 0, 5000); + this.gasTank = + new FluidTank(AtomicScience.FLUID_URANIUM_HEXAFLOURIDE, 0, 5000); + // TODO: WTF + // this.waterTank.setTankPressure(-10); + // this.gasTank.setTankPressure(10); + } - @Override - public ElectricityPack getRequest() { - return this.canWork() - ? new ElectricityPack(800.0D / this.getVoltage(), this.getVoltage()) - : new ElectricityPack(); - } + @Override + public ElectricityPack getRequest() { + return this.canWork() + ? new ElectricityPack(800.0D / this.getVoltage(), this.getVoltage()) + : new ElectricityPack(); + } - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.worldObj.isRemote && !this.isDisabled()) { - if (super.containingItems[1] != null && - FluidContainerRegistry.isFilledContainer(super.containingItems[1])) { - if (FluidContainerRegistry - .getFluidForFilledItem(super.containingItems[1]) - .getFluid() == FluidRegistry.WATER && - this.fill(ForgeDirection.UNKNOWN, - FluidContainerRegistry.getFluidForFilledItem( - super.containingItems[1]), - false) > 0) { - ItemStack player = super.containingItems[1].getItem().getContainerItem( - super.containingItems[1]); - if (player == null && super.containingItems[1].stackSize > 1) { - --super.containingItems[1].stackSize; - } else { - super.containingItems[1] = player; - } + @Override + public void updateEntity() { + super.updateEntity(); + if (!this.worldObj.isRemote && !this.isDisabled()) { + if (super.containingItems[1] != null && + FluidContainerRegistry.isFilledContainer(super.containingItems[1])) { + if (FluidContainerRegistry + .getFluidForFilledItem(super.containingItems[1]) + .getFluid() == FluidRegistry.WATER && + this.fill(ForgeDirection.UNKNOWN, + FluidContainerRegistry.getFluidForFilledItem( + super.containingItems[1]), + false) > 0) { + ItemStack player = + super.containingItems[1].getItem().getContainerItem( + super.containingItems[1]); + this.waterTank.fill(FluidContainerRegistry.getFluidForFilledItem( + super.containingItems[1]), + true); + if (player == null && super.containingItems[1].stackSize > 1) { + --super.containingItems[1].stackSize; + } else { + super.containingItems[1] = player; + } + } + } - this.waterTank.fill(FluidContainerRegistry.getFluidForFilledItem( - super.containingItems[1]), - true); - } + if (this.canWork()) { + super.wattsReceived += ElectricItemHelper.dechargeItem( + super.containingItems[0], 800.0D, this.getVoltage()); + double var10000 = super.wattsReceived; + this.getClass(); + if (var10000 >= (double)(800.0F / 2.0F)) { + if (this.smeltingTicks == 0) { + this.smeltingTicks = 300; + } + + if (this.smeltingTicks > 0) { + --this.smeltingTicks; + if (this.smeltingTicks < 1) { + this.work(); + this.smeltingTicks = 0; } + } else { + this.smeltingTicks = 0; + } - if (this.canWork()) { - super.wattsReceived += ElectricItemHelper.dechargeItem( - super.containingItems[0], 800.0D, this.getVoltage()); - double var10000 = super.wattsReceived; - this.getClass(); - if (var10000 >= (double) (800.0F / 2.0F)) { - if (this.smeltingTicks == 0) { - this.smeltingTicks = 300; - } - - if (this.smeltingTicks > 0) { - --this.smeltingTicks; - if (this.smeltingTicks < 1) { - this.work(); - this.smeltingTicks = 0; - } - } else { - this.smeltingTicks = 0; - } - - super.wattsReceived = 0.0D; - } - } else { - this.smeltingTicks = 0; - } - - if (super.ticks % 10L == 0L) { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } + super.wattsReceived = 0.0D; } + } else { + this.smeltingTicks = 0; + } + + if (super.ticks % 10L == 0L) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + } + } + + @Override + public void onDataPacket(NetworkManager arg0, + S35PacketUpdateTileEntity arg1) { + NBTTagCompound nbt = arg1.func_148857_g(); + this.smeltingTicks = nbt.getInteger("smeltingTicks"); + this.waterTank.setFluid( + new FluidStack(FluidRegistry.WATER, nbt.getInteger("waterAmount"))); + this.gasTank.setFluid( + new FluidStack(AtomicScience.FLUID_URANIUM_HEXAFLOURIDE, + nbt.getInteger("uraniumHexaflourideAmount"))); + super.disabledTicks = nbt.getInteger("disabledTicks"); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setInteger("smeltingTicks", this.smeltingTicks); + nbt.setInteger("waterAmount", this.waterTank.getFluidAmount()); + nbt.setInteger("uraniumHexaflourideAmount", this.gasTank.getFluidAmount()); + nbt.setInteger("disabledTicks", super.disabledTicks); + + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, + this.getBlockMetadata(), nbt); + } + + @Override + public void openInventory() { + if (!this.worldObj.isRemote) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + } + + public boolean canWork() { + return !this.isDisabled() && this.waterTank.getFluid() != null && + this.waterTank.getFluid().getFluid() != null && + this.waterTank.getFluidAmount() >= 1000 && + super.containingItems[3] != null && + (AtomicScience.itYellowcake == super.containingItems[3].getItem() || + AtomicScience.isUraniumOre(super.containingItems[3])) && + this.gasTank.getFluidAmount() < this.gasTank.getCapacity(); + } + + public void work() { + if (this.canWork()) { + this.waterTank.drain(1000, true); + // FluidStack liquid = AtomicScience.FLUID_URANIUM_HEXAFLOURIDE.copy(); + // liquid.amount = AtomicScience.URANIUM_HEXAFLOURIDE_RATIO * 2; + this.gasTank.fill( + new FluidStack(AtomicScience.FLUID_URANIUM_HEXAFLOURIDE, + AtomicScience.URANIUM_HEXAFLOURIDE_RATIO * 2), + true); + this.decrStackSize(3, 1); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.smeltingTicks = nbt.getInteger("smeltingTicks"); + NBTTagCompound waterCompound = nbt.getCompoundTag("water"); + this.waterTank.setFluid(FluidStack.loadFluidStackFromNBT(waterCompound)); + NBTTagCompound gasCompound = nbt.getCompoundTag("gas"); + this.gasTank.setFluid(FluidStack.loadFluidStackFromNBT(gasCompound)); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("smeltingTicks", this.smeltingTicks); + NBTTagCompound compound; + if (this.waterTank.getFluid() != null) { + compound = new NBTTagCompound(); + this.waterTank.getFluid().writeToNBT(compound); + nbt.setTag("water", compound); } - @Override - public void onDataPacket(NetworkManager arg0, - S35PacketUpdateTileEntity arg1) { - NBTTagCompound nbt = arg1.func_148857_g(); - this.smeltingTicks = nbt.getInteger("smeltingTicks"); - this.waterTank.setFluid( - new FluidStack(FluidRegistry.WATER, nbt.getInteger("waterAmount"))); - this.gasTank.setFluid( - new FluidStack(AtomicScience.FLUID_URANIUM_HEXAFLOURIDE, - nbt.getInteger("uraniumHexaflourideAmount"))); - super.disabledTicks = nbt.getInteger("disabledTicks"); + if (this.gasTank.getFluid() != null) { + compound = new NBTTagCompound(); + this.gasTank.getFluid().writeToNBT(compound); + nbt.setTag("gas", compound); + } + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) { + if (arg1 == FluidRegistry.WATER) { + return this.waterTank.getFluidAmount() < this.waterTank.getCapacity(); + } else if (arg1 == AtomicScience.FLUID_URANIUM_HEXAFLOURIDE) { + return this.gasTank.getFluidAmount() < this.waterTank.getCapacity(); } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setInteger("smeltingTicks", this.smeltingTicks); - nbt.setInteger("waterAmount", this.waterTank.getFluidAmount()); - nbt.setInteger("uraniumHexaflourideAmount", this.gasTank.getFluidAmount()); - nbt.setInteger("disabledTicks", super.disabledTicks); + return false; + } - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, - this.getBlockMetadata(), nbt); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return FluidRegistry.WATER == resource.getFluid() + ? this.waterTank.fill(resource, doFill) + : (AtomicScience.FLUID_URANIUM_HEXAFLOURIDE == resource.getFluid() + ? this.gasTank.fill(resource, doFill) + : 0); + } - @Override - public void openInventory() { - if (!this.worldObj.isRemote) { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return this.gasTank.drain(maxDrain, doDrain); + } - public boolean canWork() { - return !this.isDisabled() && this.waterTank.getFluid().getFluid() != null && - this.waterTank.getFluidAmount() >= 1000 && - super.containingItems[3] != null && - (AtomicScience.itYellowcake == super.containingItems[3].getItem() || - AtomicScience.isUraniumOre(super.containingItems[3])) - && - this.gasTank.getFluidAmount() < this.gasTank.getCapacity(); - } + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return arg1.getFluid() == AtomicScience.FLUID_URANIUM_HEXAFLOURIDE + ? this.gasTank.drain(arg1.amount, true) + : null; + } - public void work() { - if (this.canWork()) { - this.waterTank.drain(1000, true); - // FluidStack liquid = AtomicScience.FLUID_URANIUM_HEXAFLOURIDE.copy(); - // liquid.amount = AtomicScience.URANIUM_HEXAFLOURIDE_RATIO * 2; - this.gasTank.fill( - new FluidStack(AtomicScience.FLUID_URANIUM_HEXAFLOURIDE, - AtomicScience.URANIUM_HEXAFLOURIDE_RATIO * 2), - true); - this.decrStackSize(3, 1); - } - } + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return arg1 == AtomicScience.FLUID_URANIUM_HEXAFLOURIDE && + this.gasTank.getFluidAmount() > 0; + } - @Override - public void readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbt); - this.smeltingTicks = nbt.getInteger("smeltingTicks"); - NBTTagCompound waterCompound = nbt.getCompoundTag("water"); - this.waterTank.setFluid(FluidStack.loadFluidStackFromNBT(waterCompound)); - NBTTagCompound gasCompound = nbt.getCompoundTag("gas"); - this.gasTank.setFluid(FluidStack.loadFluidStackFromNBT(gasCompound)); - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {new FluidTankInfo(this.waterTank), + new FluidTankInfo(this.gasTank)}; + } - @Override - public void writeToNBT(NBTTagCompound nbt) { - super.writeToNBT(nbt); - nbt.setInteger("smeltingTicks", this.smeltingTicks); - NBTTagCompound compound; - if (this.waterTank.getFluid() != null) { - compound = new NBTTagCompound(); - this.waterTank.getFluid().writeToNBT(compound); - nbt.setTag("water", compound); - } + @Override + public int getSizeInventory() { + return 4; + } - if (this.gasTank.getFluid() != null) { - compound = new NBTTagCompound(); - this.gasTank.getFluid().writeToNBT(compound); - nbt.setTag("gas", compound); - } - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemStack) { + return slotID == 1 + ? AtomicScience.isCellWater(itemStack) + : (slotID == 3 ? itemStack.getItem() == AtomicScience.itYellowcake + : false); + } - @Override - public boolean canFill(ForgeDirection arg0, Fluid arg1) { - if (arg1 == FluidRegistry.WATER) { - return this.waterTank.getFluidAmount() < this.waterTank.getCapacity(); - } else if (arg1 == AtomicScience.FLUID_URANIUM_HEXAFLOURIDE) { - return this.gasTank.getFluidAmount() < this.waterTank.getCapacity(); - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return side == 0 ? new int[] {2} : new int[] {1, 3}; + } - return false; - } + @Override + public boolean canInsertItem(int slotID, ItemStack itemStack, int side) { + return this.isItemValidForSlot(slotID, itemStack); + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - return FluidRegistry.WATER == resource.getFluid() - ? this.waterTank.fill(resource, doFill) - : (AtomicScience.FLUID_URANIUM_HEXAFLOURIDE == resource.getFluid() - ? this.gasTank.fill(resource, doFill) - : 0); - } - - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return this.gasTank.drain(maxDrain, doDrain); - } - - @Override - public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) { - return arg1.getFluid() == AtomicScience.FLUID_URANIUM_HEXAFLOURIDE - ? this.gasTank.drain(arg1.amount, true) - : null; - } - - @Override - public boolean canDrain(ForgeDirection arg0, Fluid arg1) { - return arg1 == AtomicScience.FLUID_URANIUM_HEXAFLOURIDE && - this.gasTank.getFluidAmount() > 0; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { - return new FluidTankInfo[] { new FluidTankInfo(this.waterTank), - new FluidTankInfo(this.gasTank) }; - } - - @Override - public int getSizeInventory() { - return 4; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemStack) { - return slotID == 1 - ? AtomicScience.isCellWater(itemStack) - : (slotID == 3 ? itemStack.getItem() == AtomicScience.itYellowcake - : false); - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return side == 0 ? new int[] { 2 } : new int[] { 1, 3 }; - } - - @Override - public boolean canInsertItem(int slotID, ItemStack itemStack, int side) { - return this.isItemValidForSlot(slotID, itemStack); - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int j) { - return slotID == 2; - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int j) { + return slotID == 2; + } } diff --git a/src/main/java/atomicscience/hecheng/BElectromagnet.java b/src/main/java/atomicscience/hecheng/BElectromagnet.java index a1c9a23..16ad7f3 100644 --- a/src/main/java/atomicscience/hecheng/BElectromagnet.java +++ b/src/main/java/atomicscience/hecheng/BElectromagnet.java @@ -1,7 +1,6 @@ package atomicscience.hecheng; import atomicscience.api.IElectromagnet; -import atomicscience.hecheng.TElectromagnet; import atomicscience.jiqi.BBase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; diff --git a/src/main/java/atomicscience/hecheng/CNuclearBoiler.java b/src/main/java/atomicscience/hecheng/CNuclearBoiler.java index cd1b830..8317ef3 100644 --- a/src/main/java/atomicscience/hecheng/CNuclearBoiler.java +++ b/src/main/java/atomicscience/hecheng/CNuclearBoiler.java @@ -13,96 +13,99 @@ import universalelectricity.core.item.IItemElectric; import universalelectricity.prefab.SlotSpecific; public class CNuclearBoiler extends Container { - // private static final int slotCount = 4; - private TNuclearBoiler tileEntity; + // private static final int slotCount = 4; + private TNuclearBoiler tileEntity; - public CNuclearBoiler(InventoryPlayer par1InventoryPlayer, - TNuclearBoiler tileEntity) { - this.tileEntity = tileEntity; - this.addSlotToContainer( - new SlotSpecific(tileEntity, 0, 56, 26, IItemElectric.class)); - this.addSlotToContainer(new Slot(tileEntity, 1, 25, 50)); - this.addSlotToContainer(new Slot(tileEntity, 2, 136, 50)); - this.addSlotToContainer(new SlotSpecific( - tileEntity, 3, 81, 26, - new ItemStack[] { new ItemStack(AtomicScience.itYellowcake), - new ItemStack(AtomicScience.bUraniumOre) })); + public CNuclearBoiler(InventoryPlayer par1InventoryPlayer, + TNuclearBoiler tileEntity) { + this.tileEntity = tileEntity; + this.addSlotToContainer( + new SlotSpecific(tileEntity, 0, 56, 26, IItemElectric.class)); + this.addSlotToContainer(new Slot(tileEntity, 1, 25, 50)); + this.addSlotToContainer(new Slot(tileEntity, 2, 136, 50)); + this.addSlotToContainer(new SlotSpecific( + tileEntity, 3, 81, 26, + new ItemStack[] {new ItemStack(AtomicScience.itYellowcake), + new ItemStack(AtomicScience.bUraniumOre)})); - int var3; - for (var3 = 0; var3 < 3; ++var3) { - for (int var4 = 0; var4 < 9; ++var4) { - this.addSlotToContainer(new Slot(par1InventoryPlayer, - var4 + var3 * 9 + 9, 8 + var4 * 18, - 84 + var3 * 18)); - } + int var3; + for (var3 = 0; var3 < 3; ++var3) { + for (int var4 = 0; var4 < 9; ++var4) { + this.addSlotToContainer(new Slot(par1InventoryPlayer, + var4 + var3 * 9 + 9, 8 + var4 * 18, + 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) { + this.addSlotToContainer( + new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + + this.tileEntity.players.add(par1InventoryPlayer.player); + tileEntity.openInventory(); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); + this.tileEntity.players.remove(entityplayer); + } + + @Override + public boolean canInteractWith(EntityPlayer par1EntityPlayer) { + return this.tileEntity.isUseableByPlayer(par1EntityPlayer); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, + int slotID) { + ItemStack var2 = null; + Slot slot = (Slot)super.inventorySlots.get(slotID); + if (slot != null && slot.getHasStack()) { + ItemStack itemStack = slot.getStack(); + var2 = itemStack.copy(); + if (slotID >= 4) { + if (itemStack.getItem() instanceof IItemElectric) { + if (!this.mergeItemStack(itemStack, 0, 1, false)) { + return null; + } + } else if (FluidContainerRegistry.isContainer(itemStack) && + FluidRegistry.WATER == + FluidContainerRegistry.getFluidForFilledItem(itemStack) + .getFluid()) { + if (!this.mergeItemStack(itemStack, 1, 2, false)) { + return null; + } + } else if (this.getSlot(3).isItemValid(itemStack)) { + if (!this.mergeItemStack(itemStack, 3, 4, false)) { + return null; + } + } else if (slotID < 31) { + if (!this.mergeItemStack(itemStack, 31, 40, false)) { + return null; + } + } else if (slotID >= 31 && slotID < 40 && + !this.mergeItemStack(itemStack, 4, 30, false)) { + return null; } + } else if (!this.mergeItemStack(itemStack, 4, 40, false)) { + return null; + } - for (var3 = 0; var3 < 9; ++var3) { - this.addSlotToContainer( - new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); - } + if (itemStack.stackSize == 0) { + slot.putStack((ItemStack)null); + } else { + slot.onSlotChanged(); + } - this.tileEntity.players.add(par1InventoryPlayer.player); - tileEntity.openInventory(); + if (itemStack.stackSize == var2.stackSize) { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemStack); } - @Override - public void onContainerClosed(EntityPlayer entityplayer) { - super.onContainerClosed(entityplayer); - this.tileEntity.players.remove(entityplayer); - } - - @Override - public boolean canInteractWith(EntityPlayer par1EntityPlayer) { - return this.tileEntity.isUseableByPlayer(par1EntityPlayer); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, - int slotID) { - ItemStack var2 = null; - Slot slot = (Slot) super.inventorySlots.get(slotID); - if (slot != null && slot.getHasStack()) { - ItemStack itemStack = slot.getStack(); - var2 = itemStack.copy(); - if (slotID >= 4) { - if (itemStack.getItem() instanceof IItemElectric) { - if (!this.mergeItemStack(itemStack, 0, 1, false)) { - return null; - } - } else if (FluidRegistry.WATER == FluidContainerRegistry.getFluidForFilledItem(itemStack).getFluid()) { - if (!this.mergeItemStack(itemStack, 1, 2, false)) { - return null; - } - } else if (this.getSlot(3).isItemValid(itemStack)) { - if (!this.mergeItemStack(itemStack, 3, 4, false)) { - return null; - } - } else if (slotID < 31) { - if (!this.mergeItemStack(itemStack, 31, 40, false)) { - return null; - } - } else if (slotID >= 31 && slotID < 40 && - !this.mergeItemStack(itemStack, 4, 30, false)) { - return null; - } - } else if (!this.mergeItemStack(itemStack, 4, 40, false)) { - return null; - } - - if (itemStack.stackSize == 0) { - slot.putStack((ItemStack) null); - } else { - slot.onSlotChanged(); - } - - if (itemStack.stackSize == var2.stackSize) { - return null; - } - - slot.onPickupFromSlot(par1EntityPlayer, itemStack); - } - - return var2; - } + return var2; + } } diff --git a/src/main/java/atomicscience/jiqi/BBaseRotatable.java b/src/main/java/atomicscience/jiqi/BBaseRotatable.java index bd6904d..7590a13 100644 --- a/src/main/java/atomicscience/jiqi/BBaseRotatable.java +++ b/src/main/java/atomicscience/jiqi/BBaseRotatable.java @@ -5,14 +5,43 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import universalelectricity.core.UniversalElectricity; import universalelectricity.prefab.block.BlockRotatable; public abstract class BBaseRotatable extends BlockRotatable { protected String textureName; + // TODO: tilera failed porting this in BlockRotatable + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, + EntityLivingBase entityLiving, ItemStack itemStack) { + int angle = MathHelper.floor_double( + (double)(entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & + 3; + byte change = 3; + switch (angle) { + case 0: + change = 2; + break; + case 1: + change = 5; + break; + case 2: + change = 3; + break; + case 3: + change = 4; + } + + this.setDirection(world, x, y, z, ForgeDirection.getOrientation(change)); + } + public BBaseRotatable(String name, Material material) { super(material); this.textureName = "atomicscience:machine"; diff --git a/src/main/java/atomicscience/shimian/GAccelerator.java b/src/main/java/atomicscience/shimian/GAccelerator.java index 730f4af..6bba559 100644 --- a/src/main/java/atomicscience/shimian/GAccelerator.java +++ b/src/main/java/atomicscience/shimian/GAccelerator.java @@ -34,7 +34,7 @@ public class GAccelerator extends GuiContainer { .getOpposite()); if (this.tileEntity.isDisabled()) { status = "Disabled"; - } else if (!EMatter.canCunZai( + } else if (!EMatter.canExist( this.tileEntity.getWorldObj(), position, this.tileEntity .getDirection(this.tileEntity.getWorldObj(),