Auto Format code
This commit is contained in:
parent
112b1657cf
commit
796df6c055
503 changed files with 12260 additions and 16291 deletions
src/main/java/techreborn/tiles
TileAesu.javaTileAlloyFurnace.javaTileAlloySmelter.javaTileAssemblingMachine.javaTileCentrifuge.javaTileChargeBench.javaTileChemicalReactor.javaTileChunkLoader.javaTileDigitalChest.javaTileIndustrialElectrolyzer.javaTileIronFurnace.javaTileMachineCasing.javaTileMatterFabricator.javaTilePlayerDectector.javaTilePump.javaTileQuantumChest.javaTileQuantumTank.javaTileRollingMachine.javaTileScrapboxinator.java
fusionReactor
generator
TileDieselGenerator.javaTileDragonEggSiphoner.javaTileGasTurbine.javaTileGenerator.javaTileHeatGenerator.javaTileLightningRod.javaTileSemifluidGenerator.javaTileSolarPanel.javaTileThermalGenerator.javaTileWaterMill.javaTileWindMill.java
idsu
lesu
multiblock
MultiblockChecker.javaTileBlastFurnace.javaTileImplosionCompressor.javaTileIndustrialGrinder.javaTileIndustrialSawmill.javaTileVacuumFreezer.java
storage
teir1
transformers
|
@ -1,18 +1,17 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileAesu extends TilePowerAcceptor implements IWrenchable
|
||||
{
|
||||
public class TileAesu extends TilePowerAcceptor implements IWrenchable {
|
||||
|
||||
public static final int MAX_OUTPUT = ConfigTechReborn.AesuMaxOutput;
|
||||
public static final int MAX_STORAGE = ConfigTechReborn.AesuMaxStorage;
|
||||
|
@ -22,26 +21,21 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable
|
|||
private double euChange;
|
||||
private int ticks;
|
||||
|
||||
public TileAesu()
|
||||
{
|
||||
public TileAesu() {
|
||||
super(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime)
|
||||
{
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
|
||||
euChange = -1;
|
||||
ticks = 0;
|
||||
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ticks++;
|
||||
euChange += getEnergy() - euLastTick;
|
||||
if (euLastTick == getEnergy())
|
||||
{
|
||||
if (euLastTick == getEnergy()) {
|
||||
euChange = 0;
|
||||
}
|
||||
}
|
||||
|
@ -50,79 +44,63 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return getDropWithNBT();
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleGuiInputFromClient(int id)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
public void handleGuiInputFromClient(int id) {
|
||||
if (id == 0) {
|
||||
OUTPUT += 256;
|
||||
}
|
||||
if (id == 1)
|
||||
{
|
||||
if (id == 1) {
|
||||
OUTPUT += 64;
|
||||
}
|
||||
if (id == 2)
|
||||
{
|
||||
if (id == 2) {
|
||||
OUTPUT -= 64;
|
||||
}
|
||||
if (id == 3)
|
||||
{
|
||||
if (id == 3) {
|
||||
OUTPUT -= 256;
|
||||
}
|
||||
if (OUTPUT > MAX_OUTPUT)
|
||||
{
|
||||
if (OUTPUT > MAX_OUTPUT) {
|
||||
OUTPUT = MAX_OUTPUT;
|
||||
}
|
||||
if (OUTPUT <= -1)
|
||||
{
|
||||
if (OUTPUT <= -1) {
|
||||
OUTPUT = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getEuChange()
|
||||
{
|
||||
if (euChange == -1)
|
||||
{
|
||||
public double getEuChange() {
|
||||
if (euChange == -1) {
|
||||
return -1;
|
||||
}
|
||||
return (euChange / ticks);
|
||||
}
|
||||
|
||||
public ItemStack getDropWithNBT()
|
||||
{
|
||||
public ItemStack getDropWithNBT() {
|
||||
NBTTagCompound tileEntity = new NBTTagCompound();
|
||||
ItemStack dropStack = new ItemStack(ModBlocks.Aesu, 1);
|
||||
writeToNBTWithoutCoords(tileEntity);
|
||||
|
@ -131,8 +109,7 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable
|
|||
return dropStack;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setDouble("euChange", euChange);
|
||||
tagCompound.setDouble("euLastTick", euLastTick);
|
||||
|
@ -141,8 +118,7 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
this.euChange = nbttagcompound.getDouble("euChange");
|
||||
this.euLastTick = nbttagcompound.getDouble("euLastTick");
|
||||
|
@ -151,38 +127,32 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return TileAesu.MAX_STORAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() == direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return OUTPUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 4096 * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.EXTREME;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -12,14 +11,14 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
|||
import reborncore.api.recipe.IBaseRecipeType;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventoryProvider
|
||||
{
|
||||
public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventoryProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this);
|
||||
|
@ -31,8 +30,7 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
int output = 2;
|
||||
int fuel = 3;
|
||||
|
||||
public TileAlloyFurnace()
|
||||
{
|
||||
public TileAlloyFurnace() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,31 +38,24 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
* Returns the number of ticks that the supplied fuel item will keep the
|
||||
* furnace burning, or 0 if the item isn't fuel
|
||||
*/
|
||||
public static int getItemBurnTime(ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
public static int getItemBurnTime(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR)
|
||||
{
|
||||
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) {
|
||||
Block block = Block.getBlockFromItem(item);
|
||||
|
||||
if (block == Blocks.WOODEN_SLAB)
|
||||
{
|
||||
if (block == Blocks.WOODEN_SLAB) {
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block.getMaterial(block.getDefaultState()) == Material.WOOD)
|
||||
{
|
||||
if (block.getMaterial(block.getDefaultState()) == Material.WOOD) {
|
||||
return 300;
|
||||
}
|
||||
|
||||
if (block == Blocks.COAL_BLOCK)
|
||||
{
|
||||
if (block == Blocks.COAL_BLOCK) {
|
||||
return 16000;
|
||||
}
|
||||
}
|
||||
|
@ -90,71 +81,54 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
boolean flag = this.burnTime > 0;
|
||||
boolean flag1 = false;
|
||||
if (this.burnTime > 0)
|
||||
{
|
||||
if (this.burnTime > 0) {
|
||||
--this.burnTime;
|
||||
}
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.burnTime != 0 || getStackInSlot(input1) != null && getStackInSlot(fuel) != null)
|
||||
{
|
||||
if (this.burnTime == 0 && this.canSmelt())
|
||||
{
|
||||
if (!this.worldObj.isRemote) {
|
||||
if (this.burnTime != 0 || getStackInSlot(input1) != null && getStackInSlot(fuel) != null) {
|
||||
if (this.burnTime == 0 && this.canSmelt()) {
|
||||
this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel));
|
||||
if (this.burnTime > 0)
|
||||
{
|
||||
if (this.burnTime > 0) {
|
||||
flag1 = true;
|
||||
if (this.getStackInSlot(fuel) != null)
|
||||
{
|
||||
if (this.getStackInSlot(fuel) != null) {
|
||||
decrStackSize(fuel, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.isBurning() && this.canSmelt())
|
||||
{
|
||||
if (this.isBurning() && this.canSmelt()) {
|
||||
++this.cookTime;
|
||||
if (this.cookTime == 200)
|
||||
{
|
||||
if (this.cookTime == 200) {
|
||||
this.cookTime = 0;
|
||||
this.smeltItem();
|
||||
flag1 = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.cookTime = 0;
|
||||
}
|
||||
}
|
||||
if (flag != this.burnTime > 0)
|
||||
{
|
||||
if (flag != this.burnTime > 0) {
|
||||
flag1 = true;
|
||||
// TODO sync on/off
|
||||
}
|
||||
}
|
||||
if (flag1)
|
||||
{
|
||||
if (flag1) {
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAllInputs(IBaseRecipeType recipeType)
|
||||
{
|
||||
if (recipeType == null)
|
||||
{
|
||||
public boolean hasAllInputs(IBaseRecipeType recipeType) {
|
||||
if (recipeType == null) {
|
||||
return false;
|
||||
}
|
||||
for (ItemStack input : recipeType.getInputs())
|
||||
{
|
||||
for (ItemStack input : recipeType.getInputs()) {
|
||||
Boolean hasItem = false;
|
||||
for (int inputslot = 0; inputslot < 2; inputslot++)
|
||||
{
|
||||
for (int inputslot = 0; inputslot < 2; inputslot++) {
|
||||
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputslot), true, true,
|
||||
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize)
|
||||
{
|
||||
recipeType.useOreDic()) && inventory.getStackInSlot(inputslot).stackSize >= input.stackSize) {
|
||||
hasItem = true;
|
||||
}
|
||||
}
|
||||
|
@ -164,18 +138,13 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean canSmelt()
|
||||
{
|
||||
if (this.getStackInSlot(input1) == null || this.getStackInSlot(input2) == null)
|
||||
{
|
||||
private boolean canSmelt() {
|
||||
if (this.getStackInSlot(input1) == null || this.getStackInSlot(input2) == null) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ItemStack itemstack = null;
|
||||
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
|
||||
{
|
||||
if (hasAllInputs(recipeType))
|
||||
{
|
||||
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
|
||||
if (hasAllInputs(recipeType)) {
|
||||
itemstack = recipeType.getOutput(0);
|
||||
break;
|
||||
}
|
||||
|
@ -189,13 +158,13 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
return false;
|
||||
int result = getStackInSlot(output).stackSize + itemstack.stackSize;
|
||||
return result <= getInventoryStackLimit() && result <= this.getStackInSlot(output).getMaxStackSize(); // Forge
|
||||
// BugFix:
|
||||
// Make
|
||||
// it
|
||||
// respect
|
||||
// stack
|
||||
// sizes
|
||||
// properly.
|
||||
// BugFix:
|
||||
// Make
|
||||
// it
|
||||
// respect
|
||||
// stack
|
||||
// sizes
|
||||
// properly.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,51 +172,37 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
* Turn one item from the furnace source stack into the appropriate smelted
|
||||
* item in the furnace result stack
|
||||
*/
|
||||
public void smeltItem()
|
||||
{
|
||||
if (this.canSmelt())
|
||||
{
|
||||
public void smeltItem() {
|
||||
if (this.canSmelt()) {
|
||||
ItemStack itemstack = null;
|
||||
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
|
||||
{
|
||||
if (hasAllInputs(recipeType))
|
||||
{
|
||||
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
|
||||
if (hasAllInputs(recipeType)) {
|
||||
itemstack = recipeType.getOutput(0);
|
||||
break;
|
||||
}
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getStackInSlot(output) == null)
|
||||
{
|
||||
if (this.getStackInSlot(output) == null) {
|
||||
setInventorySlotContents(output, itemstack.copy());
|
||||
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem())
|
||||
{
|
||||
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) {
|
||||
decrStackSize(output, -itemstack.stackSize);
|
||||
}
|
||||
|
||||
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe))
|
||||
{
|
||||
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.alloySmelteRecipe)) {
|
||||
boolean hasAllRecipes = true;
|
||||
if (hasAllInputs(recipeType))
|
||||
{
|
||||
if (hasAllInputs(recipeType)) {
|
||||
|
||||
} else
|
||||
{
|
||||
hasAllRecipes = false;
|
||||
}
|
||||
if (hasAllRecipes)
|
||||
{
|
||||
for (ItemStack input : recipeType.getInputs())
|
||||
{
|
||||
for (int inputSlot = 0; inputSlot < 2; inputSlot++)
|
||||
{
|
||||
} else {
|
||||
hasAllRecipes = false;
|
||||
}
|
||||
if (hasAllRecipes) {
|
||||
for (ItemStack input : recipeType.getInputs()) {
|
||||
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
|
||||
if (ItemUtils.isItemEqual(input, inventory.getStackInSlot(inputSlot), true, true,
|
||||
recipeType.useOreDic()))
|
||||
{
|
||||
recipeType.useOreDic())) {
|
||||
inventory.decrStackSize(inputSlot, input.stackSize);
|
||||
break;
|
||||
}
|
||||
|
@ -262,58 +217,48 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
/**
|
||||
* Furnace isBurning
|
||||
*/
|
||||
public boolean isBurning()
|
||||
{
|
||||
public boolean isBurning() {
|
||||
return this.burnTime > 0;
|
||||
}
|
||||
|
||||
public int getBurnTimeRemainingScaled(int scale)
|
||||
{
|
||||
if (this.currentItemBurnTime == 0)
|
||||
{
|
||||
public int getBurnTimeRemainingScaled(int scale) {
|
||||
if (this.currentItemBurnTime == 0) {
|
||||
this.currentItemBurnTime = 200;
|
||||
}
|
||||
|
||||
return this.burnTime * scale / this.currentItemBurnTime;
|
||||
}
|
||||
|
||||
public int getCookProgressScaled(int scale)
|
||||
{
|
||||
public int getCookProgressScaled(int scale) {
|
||||
return this.cookTime * scale / 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.AlloyFurnace, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -322,19 +267,19 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
|
|||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 1, 2};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 2;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ import techreborn.api.Reference;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.utils.upgrade.UpgradeHandler;
|
||||
|
||||
public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider
|
||||
{
|
||||
public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64, this);
|
||||
|
@ -25,8 +24,7 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
|
|||
public int capacity = 1000;
|
||||
UpgradeHandler upgrades;
|
||||
|
||||
public TileAlloySmelter()
|
||||
{
|
||||
public TileAlloySmelter() {
|
||||
super(1);
|
||||
// Input slots
|
||||
int[] inputs = new int[2];
|
||||
|
@ -47,51 +45,43 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.AlloySmelter, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
inventory.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
|
@ -107,70 +97,58 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
|
|||
// }
|
||||
// }
|
||||
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 2;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0 && crafter.currentNeededTicks != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0 && crafter.currentNeededTicks != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -9,6 +8,7 @@ import reborncore.api.power.EnumPowerTier;
|
|||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IContainerProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
|
@ -17,15 +17,13 @@ import techreborn.api.Reference;
|
|||
import techreborn.client.container.ContainerAssemblingMachine;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, ISidedInventory,IInventoryProvider, IRecipeCrafterProvider, IContainerProvider
|
||||
{
|
||||
public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, ISidedInventory, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64, this);
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileAssemblingMachine()
|
||||
{
|
||||
public TileAssemblingMachine() {
|
||||
super(2);
|
||||
// Input slots
|
||||
int[] inputs = new int[2];
|
||||
|
@ -37,45 +35,37 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
charge(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.AssemblyMachine, 1);
|
||||
}
|
||||
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -89,48 +79,40 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha
|
|||
// }
|
||||
// }
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
@ -149,19 +131,19 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha
|
|||
return RebornContainer.getContainerFromClass(ContainerAssemblingMachine.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 1, 2};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 2;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -11,6 +10,7 @@ import reborncore.api.power.IEnergyItemInfo;
|
|||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IContainerProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import reborncore.common.powerSystem.PoweredItem;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
|
@ -24,8 +24,7 @@ import techreborn.init.ModBlocks;
|
|||
import java.util.List;
|
||||
|
||||
public class TileCentrifuge extends TilePowerAcceptor
|
||||
implements IWrenchable,IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider
|
||||
{
|
||||
implements IWrenchable, IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this);
|
||||
|
@ -33,8 +32,7 @@ public class TileCentrifuge extends TilePowerAcceptor
|
|||
|
||||
public int euTick = ConfigTechReborn.CentrifugeInputTick;
|
||||
|
||||
public TileCentrifuge()
|
||||
{
|
||||
public TileCentrifuge() {
|
||||
super(2);
|
||||
// Input slots
|
||||
int[] inputs = new int[2];
|
||||
|
@ -50,20 +48,16 @@ public class TileCentrifuge extends TilePowerAcceptor
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
crafter.updateEntity();
|
||||
charge(6);
|
||||
if (inventory.getStackInSlot(6) != null)
|
||||
{
|
||||
if (inventory.getStackInSlot(6) != null) {
|
||||
ItemStack stack = inventory.getStackInSlot(6);
|
||||
if(stack.getItem() instanceof IEnergyItemInfo){
|
||||
if (stack.getItem() instanceof IEnergyItemInfo) {
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
|
||||
if (item.canProvideEnergy(stack))
|
||||
{
|
||||
if (getEnergy() != getMaxPower())
|
||||
{
|
||||
if (item.canProvideEnergy(stack)) {
|
||||
if (getEnergy() != getMaxPower()) {
|
||||
addEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
|
||||
}
|
||||
|
@ -73,104 +67,87 @@ public class TileCentrifuge extends TilePowerAcceptor
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.centrifuge, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
super.addInfo(info, isRealTile);
|
||||
info.add("Round and round it goes");
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -8,38 +7,32 @@ import net.minecraft.util.EnumFacing;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.IEnergyInterfaceItem;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
|
||||
{
|
||||
public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory {
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileChargeBench", 64, this);
|
||||
public int capacity = 100000;
|
||||
|
||||
public TileChargeBench()
|
||||
{
|
||||
public TileChargeBench() {
|
||||
super(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (inventory.getStackInSlot(i) != null)
|
||||
{
|
||||
if (getEnergy() > 0)
|
||||
{
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
if (getEnergy() > 0) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack.getItem() instanceof IEnergyInterfaceItem)
|
||||
{
|
||||
if (stack.getItem() instanceof IEnergyInterfaceItem) {
|
||||
IEnergyInterfaceItem interfaceItem = (IEnergyInterfaceItem) stack.getItem();
|
||||
double trans = Math.min(interfaceItem.getMaxPower(stack) - interfaceItem.getEnergy(stack),
|
||||
Math.min(interfaceItem.getMaxTransfer(stack), getEnergy()));
|
||||
Math.min(interfaceItem.getMaxTransfer(stack), getEnergy()));
|
||||
interfaceItem.setEnergy(trans + interfaceItem.getEnergy(stack), stack);
|
||||
useEnergy(trans);
|
||||
}
|
||||
|
@ -49,56 +42,47 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,II
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.chargeBench, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
// if (itemStack.getItem() instanceof IElectricItem) {
|
||||
// double CurrentCharge = ElectricItem.manager.getCharge(itemStack);
|
||||
// double MaxCharge = ((IElectricItem)
|
||||
|
@ -110,42 +94,35 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,II
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -9,21 +8,20 @@ import net.minecraft.util.EnumFacing;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider
|
||||
{
|
||||
public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64, this);
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileChemicalReactor()
|
||||
{
|
||||
public TileChemicalReactor() {
|
||||
super(2);
|
||||
// Input slots
|
||||
int[] inputs = new int[2];
|
||||
|
@ -35,58 +33,49 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
crafter.updateEntity();
|
||||
charge(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ChemicalReactor, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
|
@ -94,22 +83,19 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
|
|||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 2;
|
||||
}
|
||||
|
||||
|
@ -123,48 +109,40 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
|
|||
// }
|
||||
// }
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
|
||||
{
|
||||
public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, IInventoryProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(1, "TileChunkLoader", 64, this);
|
||||
|
||||
|
@ -20,83 +19,69 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable,II
|
|||
|
||||
public int euTick = 32;
|
||||
|
||||
public TileChunkLoader()
|
||||
{
|
||||
public TileChunkLoader() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ChunkLoader, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -17,8 +16,7 @@ import techreborn.init.ModBlocks;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileDigitalChest extends TileMachineBase implements IInventoryProvider, IWrenchable, IListInfoProvider
|
||||
{
|
||||
public class TileDigitalChest extends TileMachineBase implements IInventoryProvider, IWrenchable, IListInfoProvider {
|
||||
|
||||
// Slot 0 = Input
|
||||
// Slot 1 = Output
|
||||
|
@ -31,56 +29,43 @@ public class TileDigitalChest extends TileMachineBase implements IInventoryProvi
|
|||
public Inventory inventory = new Inventory(3, "TileDigitalChest", storage, this);
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (storedItem != null)
|
||||
{
|
||||
public void updateEntity() {
|
||||
if (!worldObj.isRemote) {
|
||||
if (storedItem != null) {
|
||||
ItemStack fakeStack = storedItem.copy();
|
||||
fakeStack.stackSize = 1;
|
||||
setInventorySlotContents(2, fakeStack);
|
||||
} else if (storedItem == null && getStackInSlot(1) != null)
|
||||
{
|
||||
} else if (storedItem == null && getStackInSlot(1) != null) {
|
||||
ItemStack fakeStack = getStackInSlot(1).copy();
|
||||
fakeStack.stackSize = 1;
|
||||
setInventorySlotContents(2, fakeStack);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
setInventorySlotContents(2, null);
|
||||
}
|
||||
|
||||
if (getStackInSlot(0) != null)
|
||||
{
|
||||
if (storedItem == null)
|
||||
{
|
||||
if (getStackInSlot(0) != null) {
|
||||
if (storedItem == null) {
|
||||
storedItem = getStackInSlot(0);
|
||||
setInventorySlotContents(0, null);
|
||||
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true))
|
||||
{
|
||||
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize)
|
||||
{
|
||||
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) {
|
||||
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize) {
|
||||
storedItem.stackSize += getStackInSlot(0).stackSize;
|
||||
decrStackSize(0, getStackInSlot(0).stackSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (storedItem != null && getStackInSlot(1) == null)
|
||||
{
|
||||
if (storedItem != null && getStackInSlot(1) == null) {
|
||||
ItemStack itemStack = storedItem.copy();
|
||||
itemStack.stackSize = itemStack.getMaxStackSize();
|
||||
setInventorySlotContents(1, itemStack);
|
||||
storedItem.stackSize -= itemStack.getMaxStackSize();
|
||||
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true))
|
||||
{
|
||||
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true)) {
|
||||
int wanted = getStackInSlot(1).getMaxStackSize() - getStackInSlot(1).stackSize;
|
||||
if (storedItem.stackSize >= wanted)
|
||||
{
|
||||
if (storedItem.stackSize >= wanted) {
|
||||
decrStackSize(1, -wanted);
|
||||
storedItem.stackSize -= wanted;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
decrStackSize(1, -storedItem.stackSize);
|
||||
storedItem = null;
|
||||
}
|
||||
|
@ -89,48 +74,40 @@ public class TileDigitalChest extends TileMachineBase implements IInventoryProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
readFromNBTWithoutCoords(tagCompound);
|
||||
}
|
||||
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
|
||||
storedItem = null;
|
||||
|
||||
if (tagCompound.hasKey("storedStack"))
|
||||
{
|
||||
if (tagCompound.hasKey("storedStack")) {
|
||||
storedItem = ItemStack.loadItemStackFromNBT((NBTTagCompound) tagCompound.getTag("storedStack"));
|
||||
}
|
||||
|
||||
if (storedItem != null)
|
||||
{
|
||||
if (storedItem != null) {
|
||||
storedItem.stackSize = tagCompound.getInteger("storedQuantity");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
writeToNBTWithoutCoords(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
if (storedItem != null)
|
||||
{
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
if (storedItem != null) {
|
||||
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setInteger("storedQuantity", storedItem.stackSize);
|
||||
} else
|
||||
|
@ -139,37 +116,31 @@ public class TileDigitalChest extends TileMachineBase implements IInventoryProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return getDropWithNBT();
|
||||
}
|
||||
|
||||
public ItemStack getDropWithNBT()
|
||||
{
|
||||
public ItemStack getDropWithNBT() {
|
||||
NBTTagCompound tileEntity = new NBTTagCompound();
|
||||
ItemStack dropStack = new ItemStack(ModBlocks.digitalChest, 1);
|
||||
writeToNBTWithoutCoords(tileEntity);
|
||||
|
@ -179,17 +150,14 @@ public class TileDigitalChest extends TileMachineBase implements IInventoryProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
int size = 0;
|
||||
String name = "of nothing";
|
||||
if (storedItem != null)
|
||||
{
|
||||
if (storedItem != null) {
|
||||
name = storedItem.getDisplayName();
|
||||
size += storedItem.stackSize;
|
||||
}
|
||||
if (getStackInSlot(1) != null)
|
||||
{
|
||||
if (getStackInSlot(1) != null) {
|
||||
name = getStackInSlot(1).getDisplayName();
|
||||
size += getStackInSlot(1).stackSize;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -9,21 +8,20 @@ import net.minecraft.util.EnumFacing;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider
|
||||
{
|
||||
public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(8, "TileIndustrialElectrolyzer", 64, this);
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileIndustrialElectrolyzer()
|
||||
{
|
||||
public TileIndustrialElectrolyzer() {
|
||||
super(2);
|
||||
// Input slots
|
||||
int[] inputs = new int[2];
|
||||
|
@ -38,58 +36,49 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
crafter.updateEntity();
|
||||
charge(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.IndustrialElectrolyzer, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
|
@ -107,67 +96,56 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
|
|||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex >= 1)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
||||
public class TileIronFurnace extends TileMachineBase implements IInventoryProvider
|
||||
{
|
||||
public class TileIronFurnace extends TileMachineBase implements IInventoryProvider {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(3, "TileIronFurnace", 64, this);
|
||||
|
@ -30,18 +22,14 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
|
|||
int fuelslot = 2;
|
||||
boolean active = false;
|
||||
|
||||
public int gaugeProgressScaled(int scale)
|
||||
{
|
||||
public int gaugeProgressScaled(int scale) {
|
||||
return (progress * scale) / fuelScale;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled(int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
public int gaugeFuelScaled(int scale) {
|
||||
if (fuelGague == 0) {
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
if (fuelGague == 0) {
|
||||
fuelGague = fuelScale;
|
||||
}
|
||||
}
|
||||
|
@ -49,88 +37,68 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (fuel > 0) {
|
||||
fuel--;
|
||||
updateState();
|
||||
}
|
||||
if (fuel <= 0 && canSmelt())
|
||||
{
|
||||
if (fuel <= 0 && canSmelt()) {
|
||||
fuel = fuelGague = (int) (TileEntityFurnace.getItemBurnTime(getStackInSlot(fuelslot)) * 1.25);
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (fuel > 0) {
|
||||
if (getStackInSlot(fuelslot).getItem().hasContainerItem()) // Fuel
|
||||
// slot
|
||||
// slot
|
||||
{
|
||||
setInventorySlotContents(fuelslot,
|
||||
new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem()));
|
||||
} else if (getStackInSlot(fuelslot).stackSize > 1)
|
||||
{
|
||||
new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem()));
|
||||
} else if (getStackInSlot(fuelslot).stackSize > 1) {
|
||||
decrStackSize(fuelslot, 1);
|
||||
} else if (getStackInSlot(fuelslot).stackSize == 1)
|
||||
{
|
||||
} else if (getStackInSlot(fuelslot).stackSize == 1) {
|
||||
setInventorySlotContents(fuelslot, null);
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canSmelt())
|
||||
{
|
||||
if (isBurning() && canSmelt()) {
|
||||
progress++;
|
||||
if (progress >= fuelScale)
|
||||
{
|
||||
if (progress >= fuelScale) {
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
progress = 0;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
if (burning != isBurning()) {
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
if (updateInventory) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems()
|
||||
{
|
||||
if (this.canSmelt())
|
||||
{
|
||||
public void cookItems() {
|
||||
if (this.canSmelt()) {
|
||||
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
||||
|
||||
if (getStackInSlot(output) == null)
|
||||
{
|
||||
if (getStackInSlot(output) == null) {
|
||||
setInventorySlotContents(output, itemstack.copy());
|
||||
} else if (getStackInSlot(output).isItemEqual(itemstack))
|
||||
{
|
||||
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
|
||||
getStackInSlot(output).stackSize += itemstack.stackSize;
|
||||
}
|
||||
if (getStackInSlot(input1).stackSize > 1)
|
||||
{
|
||||
if (getStackInSlot(input1).stackSize > 1) {
|
||||
this.decrStackSize(input1, 1);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
setInventorySlotContents(input1, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canSmelt()
|
||||
{
|
||||
if (getStackInSlot(input1) == null)
|
||||
{
|
||||
public boolean canSmelt() {
|
||||
if (getStackInSlot(input1) == null) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
|
@ -143,26 +111,21 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isBurning()
|
||||
{
|
||||
public boolean isBurning() {
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor(ItemStack stack)
|
||||
{
|
||||
public ItemStack getResultFor(ItemStack stack) {
|
||||
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
|
||||
if (result != null)
|
||||
{
|
||||
if (result != null) {
|
||||
return result.copy();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateState()
|
||||
{
|
||||
public void updateState() {
|
||||
IBlockState BlockStateContainer = worldObj.getBlockState(pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
|
||||
{
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != fuel > 0)
|
||||
blockMachineBase.setActive(fuel > 0, worldObj, pos);
|
||||
|
|
|
@ -5,71 +5,59 @@ import reborncore.common.multiblock.MultiblockValidationException;
|
|||
import reborncore.common.multiblock.rectangular.RectangularMultiblockTileEntityBase;
|
||||
import techreborn.multiblocks.MultiBlockCasing;
|
||||
|
||||
public class TileMachineCasing extends RectangularMultiblockTileEntityBase
|
||||
{
|
||||
public class TileMachineCasing extends RectangularMultiblockTileEntityBase {
|
||||
|
||||
@Override
|
||||
public void onMachineActivated()
|
||||
{
|
||||
public void onMachineActivated() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineDeactivated()
|
||||
{
|
||||
public void onMachineDeactivated() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiblockControllerBase createNewMultiblock()
|
||||
{
|
||||
public MultiblockControllerBase createNewMultiblock() {
|
||||
return new MultiBlockCasing(worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends MultiblockControllerBase> getMultiblockControllerType()
|
||||
{
|
||||
public Class<? extends MultiblockControllerBase> getMultiblockControllerType() {
|
||||
return MultiBlockCasing.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForFrame() throws MultiblockValidationException
|
||||
{
|
||||
public void isGoodForFrame() throws MultiblockValidationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForSides() throws MultiblockValidationException
|
||||
{
|
||||
public void isGoodForSides() throws MultiblockValidationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForTop() throws MultiblockValidationException
|
||||
{
|
||||
public void isGoodForTop() throws MultiblockValidationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForBottom() throws MultiblockValidationException
|
||||
{
|
||||
public void isGoodForBottom() throws MultiblockValidationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForInterior() throws MultiblockValidationException
|
||||
{
|
||||
public void isGoodForInterior() throws MultiblockValidationException {
|
||||
|
||||
}
|
||||
|
||||
public MultiBlockCasing getMultiblockController()
|
||||
{
|
||||
public MultiBlockCasing getMultiblockController() {
|
||||
return (MultiBlockCasing) super.getMultiblockController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
public void update() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -13,8 +13,7 @@ import techreborn.init.ModBlocks;
|
|||
import techreborn.init.ModItems;
|
||||
import techreborn.items.ItemParts;
|
||||
|
||||
public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
|
||||
{
|
||||
public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider {
|
||||
|
||||
public static int fabricationRate = 10000;
|
||||
public int tickTime;
|
||||
|
@ -22,90 +21,76 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
|
|||
public int progresstime = 0;
|
||||
private int amplifier = 0;
|
||||
|
||||
public TileMatterFabricator()
|
||||
{
|
||||
public TileMatterFabricator() {
|
||||
super(6);
|
||||
// TODO configs
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.MatterFabricator, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// // ISidedInventory
|
||||
// @Override
|
||||
// public int[] getSlotsForFace(EnumFacing side)
|
||||
// {
|
||||
// return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5, 6 } : new int[] { 0, 1, 2, 3, 4, 5, 6 };
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
// {
|
||||
// if (slotIndex == 6)
|
||||
// return false;
|
||||
// return isItemValidForSlot(slotIndex, itemStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
// {
|
||||
// return slotIndex == 6;
|
||||
// }
|
||||
// // ISidedInventory
|
||||
// @Override
|
||||
// public int[] getSlotsForFace(EnumFacing side)
|
||||
// {
|
||||
// return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5, 6 } : new int[] { 0, 1, 2, 3, 4, 5, 6 };
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
// {
|
||||
// if (slotIndex == 6)
|
||||
// return false;
|
||||
// return isItemValidForSlot(slotIndex, itemStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
// {
|
||||
// return slotIndex == 6;
|
||||
// }
|
||||
|
||||
public int maxProgresstime()
|
||||
{
|
||||
public int maxProgresstime() {
|
||||
return fabricationRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!super.worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (!super.worldObj.isRemote) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (this.amplifier < 10000 && stack != null)
|
||||
{
|
||||
if (this.amplifier < 10000 && stack != null) {
|
||||
int amp = (int) ((long) (getValue(stack) / 32));
|
||||
if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true))
|
||||
{
|
||||
if (canUseEnergy(1))
|
||||
{
|
||||
if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) {
|
||||
if (canUseEnergy(1)) {
|
||||
useEnergy(1);
|
||||
this.amplifier += amp;
|
||||
inventory.decrStackSize(i, 1);
|
||||
|
@ -114,22 +99,18 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
|
|||
}
|
||||
}
|
||||
|
||||
if (this.amplifier > 0)
|
||||
{
|
||||
if (this.amplifier > this.getEnergy())
|
||||
{
|
||||
if (this.amplifier > 0) {
|
||||
if (this.amplifier > this.getEnergy()) {
|
||||
this.progresstime += this.getEnergy();
|
||||
this.amplifier -= this.getEnergy();
|
||||
this.decreaseStoredEnergy(this.getEnergy(), true);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.progresstime += this.amplifier;
|
||||
this.decreaseStoredEnergy(this.amplifier, true);
|
||||
this.amplifier = 0;
|
||||
}
|
||||
}
|
||||
if (this.progresstime > this.maxProgresstime() && this.spaceForOutput())
|
||||
{
|
||||
if (this.progresstime > this.maxProgresstime() && this.spaceForOutput()) {
|
||||
this.progresstime -= this.maxProgresstime();
|
||||
this.addOutputProducts();
|
||||
}
|
||||
|
@ -138,52 +119,42 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
|
|||
|
||||
}
|
||||
|
||||
private boolean spaceForOutput()
|
||||
{
|
||||
private boolean spaceForOutput() {
|
||||
return inventory.getStackInSlot(6) == null
|
||||
|| ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)
|
||||
&& inventory.getStackInSlot(6).stackSize < 64;
|
||||
|| ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)
|
||||
&& inventory.getStackInSlot(6).stackSize < 64;
|
||||
}
|
||||
|
||||
private void addOutputProducts()
|
||||
{
|
||||
private void addOutputProducts() {
|
||||
|
||||
if (inventory.getStackInSlot(6) == null)
|
||||
{
|
||||
if (inventory.getStackInSlot(6) == null) {
|
||||
inventory.setInventorySlotContents(6, new ItemStack(ModItems.uuMatter));
|
||||
} else if (ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true))
|
||||
{
|
||||
} else if (ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)) {
|
||||
inventory.getStackInSlot(6).stackSize = Math.min(64, 1 + inventory.getStackInSlot(6).stackSize);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy)
|
||||
{
|
||||
if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy)
|
||||
{
|
||||
public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) {
|
||||
if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
setEnergy(this.getEnergy() - aEnergy);
|
||||
if (this.getEnergy() < 0)
|
||||
{
|
||||
if (this.getEnergy() < 0) {
|
||||
setEnergy(0);
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO ic2
|
||||
public int getValue(ItemStack itemStack)
|
||||
{
|
||||
public int getValue(ItemStack itemStack) {
|
||||
// int value = getValue(Recipes.matterAmplifier.getOutputFor(itemStack,
|
||||
// false));
|
||||
if(itemStack.getItem() == ModItems.parts && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()){
|
||||
if (itemStack.getItem() == ModItems.parts && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()) {
|
||||
return 5000;
|
||||
} else if (itemStack.getItem() == ModItems.scrapBox){
|
||||
} else if (itemStack.getItem() == ModItems.scrapBox) {
|
||||
return 45000;
|
||||
}
|
||||
return 0;
|
||||
|
@ -197,36 +168,32 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
|
|||
// }
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 100000000;
|
||||
}
|
||||
|
||||
@Override public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 4096;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.EXTREME;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,85 +10,67 @@ import reborncore.common.util.WorldUtils;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class TilePlayerDectector extends TilePowerAcceptor
|
||||
{
|
||||
public class TilePlayerDectector extends TilePowerAcceptor {
|
||||
|
||||
public String owenerUdid = "";
|
||||
boolean redstone = false;
|
||||
|
||||
public TilePlayerDectector()
|
||||
{
|
||||
public TilePlayerDectector() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0)
|
||||
{
|
||||
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) {
|
||||
boolean lastRedstone = redstone;
|
||||
redstone = false;
|
||||
if (canUseEnergy(10))
|
||||
{
|
||||
if (canUseEnergy(10)) {
|
||||
Iterator tIterator = super.worldObj.playerEntities.iterator();
|
||||
while (tIterator.hasNext())
|
||||
{
|
||||
while (tIterator.hasNext()) {
|
||||
EntityPlayer player = (EntityPlayer) tIterator.next();
|
||||
if (player.getDistanceSq((double) super.getPos().getX() + 0.5D,
|
||||
(double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D)
|
||||
{
|
||||
(double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) worldObj.getBlockState(pos).getBlock();
|
||||
int meta = blockMachineBase.getMetaFromState(worldObj.getBlockState(pos));
|
||||
if (meta == 0)
|
||||
{// ALL
|
||||
if (meta == 0) {// ALL
|
||||
redstone = true;
|
||||
} else if (meta == 1)
|
||||
{// Others
|
||||
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString()))
|
||||
{
|
||||
} else if (meta == 1) {// Others
|
||||
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString())) {
|
||||
redstone = true;
|
||||
}
|
||||
} else
|
||||
{// You
|
||||
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUniqueID().toString()))
|
||||
{
|
||||
} else {// You
|
||||
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUniqueID().toString())) {
|
||||
redstone = true;
|
||||
}
|
||||
}
|
||||
|
@ -97,29 +79,25 @@ public class TilePlayerDectector extends TilePowerAcceptor
|
|||
}
|
||||
useEnergy(10);
|
||||
}
|
||||
if (lastRedstone != redstone)
|
||||
{
|
||||
if (lastRedstone != redstone) {
|
||||
WorldUtils.updateBlock(worldObj, getPos());
|
||||
worldObj.notifyNeighborsOfStateChange(getPos(), worldObj.getBlockState(getPos()).getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isProvidingPower()
|
||||
{
|
||||
public boolean isProvidingPower() {
|
||||
return redstone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
owenerUdid = tag.getString("ownerID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tag.setString("ownerID", owenerUdid);
|
||||
return tag;
|
||||
|
|
|
@ -22,158 +22,148 @@ import java.util.List;
|
|||
*/
|
||||
public class TilePump extends TilePowerAcceptor implements IFluidHandler {
|
||||
|
||||
public Tank tank = new Tank("TilePump", 10000, this);
|
||||
public Tank tank = new Tank("TilePump", 10000, this);
|
||||
|
||||
public TilePump() {
|
||||
super(1);
|
||||
}
|
||||
public TilePump() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote && worldObj.getTotalWorldTime() % 10 == 0 && !tank.isFull() && tank.getCapacity() - tank.getFluidAmount() >= 1000 && canUseEnergy(ConfigTechReborn.pumpExtractEU)){
|
||||
FluidStack fluidStack = drainBlock(worldObj, pos.down(), false);
|
||||
if(fluidStack != null){
|
||||
tank.fill(drainBlock(worldObj, pos.down(), true), true);
|
||||
useEnergy(ConfigTechReborn.pumpExtractEU);
|
||||
}
|
||||
tank.compareAndUpdate();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote && worldObj.getTotalWorldTime() % 10 == 0 && !tank.isFull() && tank.getCapacity() - tank.getFluidAmount() >= 1000 && canUseEnergy(ConfigTechReborn.pumpExtractEU)) {
|
||||
FluidStack fluidStack = drainBlock(worldObj, pos.down(), false);
|
||||
if (fluidStack != null) {
|
||||
tank.fill(drainBlock(worldObj, pos.down(), true), true);
|
||||
useEnergy(ConfigTechReborn.pumpExtractEU);
|
||||
}
|
||||
tank.compareAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
super.addInfo(info, isRealTile);
|
||||
info.add(TextFormatting.LIGHT_PURPLE + "Eu per extract " + TextFormatting.GREEN
|
||||
+ PowerSystem.getLocaliszedPower(ConfigTechReborn.pumpExtractEU));
|
||||
info.add(TextFormatting.LIGHT_PURPLE + "Speed: " + TextFormatting.GREEN
|
||||
+ "1000mb/5 sec");
|
||||
}
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
super.addInfo(info, isRealTile);
|
||||
info.add(TextFormatting.LIGHT_PURPLE + "Eu per extract " + TextFormatting.GREEN
|
||||
+ PowerSystem.getLocaliszedPower(ConfigTechReborn.pumpExtractEU));
|
||||
info.add(TextFormatting.LIGHT_PURPLE + "Speed: " + TextFormatting.GREEN
|
||||
+ "1000mb/5 sec");
|
||||
}
|
||||
|
||||
public static FluidStack drainBlock(World world, BlockPos pos, boolean doDrain) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
public static FluidStack drainBlock(World world, BlockPos pos, boolean doDrain) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid != null && FluidRegistry.isFluidRegistered(fluid)) {
|
||||
if (block instanceof IFluidBlock) {
|
||||
IFluidBlock fluidBlock = (IFluidBlock) block;
|
||||
if (!fluidBlock.canDrain(world, pos)) {
|
||||
return null;
|
||||
}
|
||||
return fluidBlock.drain(world, pos, doDrain);
|
||||
} else {
|
||||
//Checks if source
|
||||
int level = state.getValue(BlockLiquid.LEVEL);
|
||||
if (level != 0) {
|
||||
return null;
|
||||
}
|
||||
if (doDrain) {
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
return new FluidStack(fluid, 1000);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (fluid != null && FluidRegistry.isFluidRegistered(fluid)) {
|
||||
if (block instanceof IFluidBlock) {
|
||||
IFluidBlock fluidBlock = (IFluidBlock) block;
|
||||
if (!fluidBlock.canDrain(world, pos)) {
|
||||
return null;
|
||||
}
|
||||
return fluidBlock.drain(world, pos, doDrain);
|
||||
} else {
|
||||
//Checks if source
|
||||
int level = state.getValue(BlockLiquid.LEVEL);
|
||||
if (level != 0) {
|
||||
return null;
|
||||
}
|
||||
if (doDrain) {
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
return new FluidStack(fluid, 1000);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
readFromNBTWithoutCoords(tagCompound);
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
readFromNBTWithoutCoords(tagCompound);
|
||||
}
|
||||
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
tank.readFromNBT(tagCompound);
|
||||
}
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
tank.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
writeToNBTWithoutCoords(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
writeToNBTWithoutCoords(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
tank.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
tank.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
// IFluidHandler
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
int fill = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return fill;
|
||||
}
|
||||
// IFluidHandler
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
int fill = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
FluidStack drain = tank.drain(resource.amount, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(resource.amount, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
FluidStack drain = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -19,8 +18,7 @@ import techreborn.init.ModBlocks;
|
|||
import java.util.List;
|
||||
|
||||
public class TileQuantumChest extends TileMachineBase
|
||||
implements IInventoryProvider, IWrenchable, IDeepStorageUnit, IListInfoProvider
|
||||
{
|
||||
implements IInventoryProvider, IWrenchable, IDeepStorageUnit, IListInfoProvider {
|
||||
|
||||
// Slot 0 = Input
|
||||
// Slot 1 = Output
|
||||
|
@ -33,56 +31,43 @@ public class TileQuantumChest extends TileMachineBase
|
|||
public Inventory inventory = new Inventory(3, "TileQuantumChest", storage, this);
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (storedItem != null)
|
||||
{
|
||||
public void updateEntity() {
|
||||
if (!worldObj.isRemote) {
|
||||
if (storedItem != null) {
|
||||
ItemStack fakeStack = storedItem.copy();
|
||||
fakeStack.stackSize = 1;
|
||||
setInventorySlotContents(2, fakeStack);
|
||||
} else if (storedItem == null && getStackInSlot(1) != null)
|
||||
{
|
||||
} else if (storedItem == null && getStackInSlot(1) != null) {
|
||||
ItemStack fakeStack = getStackInSlot(1).copy();
|
||||
fakeStack.stackSize = 1;
|
||||
setInventorySlotContents(2, fakeStack);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
setInventorySlotContents(2, null);
|
||||
}
|
||||
|
||||
if (getStackInSlot(0) != null)
|
||||
{
|
||||
if (storedItem == null)
|
||||
{
|
||||
if (getStackInSlot(0) != null) {
|
||||
if (storedItem == null) {
|
||||
storedItem = getStackInSlot(0);
|
||||
setInventorySlotContents(0, null);
|
||||
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true))
|
||||
{
|
||||
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize)
|
||||
{
|
||||
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) {
|
||||
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize) {
|
||||
storedItem.stackSize += getStackInSlot(0).stackSize;
|
||||
decrStackSize(0, getStackInSlot(0).stackSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (storedItem != null && getStackInSlot(1) == null)
|
||||
{
|
||||
if (storedItem != null && getStackInSlot(1) == null) {
|
||||
ItemStack itemStack = storedItem.copy();
|
||||
itemStack.stackSize = itemStack.getMaxStackSize();
|
||||
setInventorySlotContents(1, itemStack);
|
||||
storedItem.stackSize -= itemStack.getMaxStackSize();
|
||||
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true))
|
||||
{
|
||||
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true)) {
|
||||
int wanted = getStackInSlot(1).getMaxStackSize() - getStackInSlot(1).stackSize;
|
||||
if (storedItem.stackSize >= wanted)
|
||||
{
|
||||
if (storedItem.stackSize >= wanted) {
|
||||
decrStackSize(1, -wanted);
|
||||
storedItem.stackSize -= wanted;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
decrStackSize(1, -storedItem.stackSize);
|
||||
storedItem = null;
|
||||
}
|
||||
|
@ -91,51 +76,43 @@ public class TileQuantumChest extends TileMachineBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
readFromNBTWithoutCoords(tagCompound);
|
||||
}
|
||||
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
|
||||
storedItem = null;
|
||||
|
||||
if (tagCompound.hasKey("storedStack"))
|
||||
{
|
||||
if (tagCompound.hasKey("storedStack")) {
|
||||
storedItem = ItemStack.loadItemStackFromNBT((NBTTagCompound) tagCompound.getTag("storedStack"));
|
||||
}
|
||||
|
||||
if (storedItem != null)
|
||||
{
|
||||
if (storedItem != null) {
|
||||
storedItem.stackSize = tagCompound.getInteger("storedQuantity");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
writeToNBTWithoutCoords(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
if (storedItem != null)
|
||||
{
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
if (storedItem != null) {
|
||||
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setInteger("storedQuantity", storedItem.stackSize);
|
||||
} else{
|
||||
} else {
|
||||
tagCompound.setInteger("storedQuantity", 0);
|
||||
}
|
||||
|
||||
|
@ -143,37 +120,31 @@ public class TileQuantumChest extends TileMachineBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return getDropWithNBT();
|
||||
}
|
||||
|
||||
public ItemStack getDropWithNBT()
|
||||
{
|
||||
public ItemStack getDropWithNBT() {
|
||||
NBTTagCompound tileEntity = new NBTTagCompound();
|
||||
ItemStack dropStack = new ItemStack(ModBlocks.quantumChest, 1);
|
||||
writeToNBTWithoutCoords(tileEntity);
|
||||
|
@ -183,47 +154,39 @@ public class TileQuantumChest extends TileMachineBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStoredItemType()
|
||||
{
|
||||
public ItemStack getStoredItemType() {
|
||||
return this.storedItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredItemCount(int amount)
|
||||
{
|
||||
public void setStoredItemCount(int amount) {
|
||||
this.storedItem.stackSize = 0;
|
||||
this.storedItem.stackSize += (amount);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredItemType(ItemStack type, int amount)
|
||||
{
|
||||
public void setStoredItemType(ItemStack type, int amount) {
|
||||
this.storedItem = type;
|
||||
this.storedItem.stackSize = amount;
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStoredCount()
|
||||
{
|
||||
public int getMaxStoredCount() {
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
if (isRealTile)
|
||||
{
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
if (isRealTile) {
|
||||
int size = 0;
|
||||
String name = "of nothing";
|
||||
if (storedItem != null)
|
||||
{
|
||||
if (storedItem != null) {
|
||||
name = storedItem.getDisplayName();
|
||||
size += storedItem.stackSize;
|
||||
}
|
||||
if (getStackInSlot(1) != null)
|
||||
{
|
||||
if (getStackInSlot(1) != null) {
|
||||
name = getStackInSlot(1).getDisplayName();
|
||||
size += getStackInSlot(1).stackSize;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
@ -14,6 +12,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
|||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -23,59 +22,49 @@ import techreborn.init.ModBlocks;
|
|||
import java.util.List;
|
||||
|
||||
public class TileQuantumTank extends TileMachineBase
|
||||
implements IFluidHandler,IInventoryProvider, IWrenchable, IListInfoProvider
|
||||
{
|
||||
implements IFluidHandler, IInventoryProvider, IWrenchable, IListInfoProvider {
|
||||
|
||||
public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this);
|
||||
public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this);
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
readFromNBTWithoutCoords(tagCompound);
|
||||
}
|
||||
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
tank.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
writeToNBTWithoutCoords(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
|
||||
tank.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
FluidUtils.drainContainers(this, inventory, 0, 1);
|
||||
FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType());
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null)
|
||||
{
|
||||
// inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null)
|
||||
{
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
||||
// inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
|
||||
setInventorySlotContents(2, null);
|
||||
}
|
||||
tank.compareAndUpdate();
|
||||
|
@ -84,79 +73,67 @@ public class TileQuantumTank extends TileMachineBase
|
|||
|
||||
// IFluidHandler
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
int fill = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(resource.amount, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return getDropWithNBT();
|
||||
}
|
||||
|
||||
public ItemStack getDropWithNBT()
|
||||
{
|
||||
public ItemStack getDropWithNBT() {
|
||||
NBTTagCompound tileEntity = new NBTTagCompound();
|
||||
ItemStack dropStack = new ItemStack(ModBlocks.quantumTank, 1);
|
||||
writeToNBTWithoutCoords(tileEntity);
|
||||
|
@ -166,15 +143,11 @@ public class TileQuantumTank extends TileMachineBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
if (isRealTile)
|
||||
{
|
||||
if (tank.getFluid() != null)
|
||||
{
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
if (isRealTile) {
|
||||
if (tank.getFluid() != null) {
|
||||
info.add(tank.getFluidAmount() + " of " + tank.getFluidType().getName());
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
info.add("Empty");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
|
@ -9,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -16,8 +16,7 @@ import techreborn.api.RollingMachineRecipe;
|
|||
import techreborn.init.ModBlocks;
|
||||
|
||||
//TODO add tick and power bars.
|
||||
public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
|
||||
{
|
||||
public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable, IInventoryProvider {
|
||||
|
||||
public final InventoryCrafting craftMatrix = new InventoryCrafting(new RollingTileContainer(), 3, 3);
|
||||
public Inventory inventory = new Inventory(3, "TileRollingMachine", 64, this);
|
||||
|
@ -28,73 +27,58 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
|
|||
|
||||
public int euTick = 5;
|
||||
|
||||
public TileRollingMachine()
|
||||
{
|
||||
public TileRollingMachine() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 100000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
charge(2);
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj);
|
||||
if (currentRecipe != null && canMake())
|
||||
{
|
||||
if (tickTime >= runTime)
|
||||
{
|
||||
if (currentRecipe != null && canMake()) {
|
||||
if (tickTime >= runTime) {
|
||||
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj);
|
||||
if (currentRecipe != null)
|
||||
{
|
||||
if (currentRecipe != null) {
|
||||
boolean hasCrafted = false;
|
||||
if (inventory.getStackInSlot(0) == null)
|
||||
{
|
||||
if (inventory.getStackInSlot(0) == null) {
|
||||
inventory.setInventorySlotContents(0, currentRecipe);
|
||||
tickTime = -1;
|
||||
hasCrafted = true;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
if (inventory.getStackInSlot(0).stackSize + currentRecipe.stackSize <= currentRecipe
|
||||
.getMaxStackSize())
|
||||
{
|
||||
.getMaxStackSize()) {
|
||||
ItemStack stack = inventory.getStackInSlot(0);
|
||||
stack.stackSize = stack.stackSize + currentRecipe.stackSize;
|
||||
inventory.setInventorySlotContents(0, stack);
|
||||
|
@ -102,10 +86,8 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
|
|||
hasCrafted = true;
|
||||
}
|
||||
}
|
||||
if (hasCrafted)
|
||||
{
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++)
|
||||
{
|
||||
if (hasCrafted) {
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
craftMatrix.decrStackSize(i, 1);
|
||||
}
|
||||
currentRecipe = null;
|
||||
|
@ -113,69 +95,56 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
|
|||
}
|
||||
}
|
||||
}
|
||||
if (currentRecipe != null)
|
||||
{
|
||||
if (canUseEnergy(euTick) && tickTime < runTime)
|
||||
{
|
||||
if (currentRecipe != null) {
|
||||
if (canUseEnergy(euTick) && tickTime < runTime) {
|
||||
useEnergy(euTick);
|
||||
tickTime++;
|
||||
}
|
||||
}
|
||||
if (currentRecipe == null)
|
||||
{
|
||||
if (currentRecipe == null) {
|
||||
tickTime = -1;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj);
|
||||
if (currentRecipe != null)
|
||||
{
|
||||
if (currentRecipe != null) {
|
||||
inventory.setInventorySlotContents(1, currentRecipe);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
inventory.setInventorySlotContents(1, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canMake()
|
||||
{
|
||||
public boolean canMake() {
|
||||
return RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.RollingMachine, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound);
|
||||
isRunning = tagCompound.getBoolean("isRunning");
|
||||
|
@ -183,29 +152,25 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound);
|
||||
writeUpdateToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public void writeUpdateToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void writeUpdateToNBT(NBTTagCompound tagCompound) {
|
||||
tagCompound.setBoolean("isRunning", isRunning);
|
||||
tagCompound.setInteger("tickTime", tickTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
|
@ -214,12 +179,10 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
|
|||
return inventory;
|
||||
}
|
||||
|
||||
private static class RollingTileContainer extends Container
|
||||
{
|
||||
private static class RollingTileContainer extends Container {
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -8,6 +7,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -17,8 +17,7 @@ import techreborn.init.ModItems;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
|
||||
{
|
||||
public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory {
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileScrapboxinator", 64, this);
|
||||
public int capacity = 1000;
|
||||
|
@ -30,93 +29,74 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
|
|||
public int input1 = 0;
|
||||
public int output = 1;
|
||||
|
||||
public TileScrapboxinator()
|
||||
{
|
||||
public TileScrapboxinator() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
public int gaugeProgressScaled(int scale)
|
||||
{
|
||||
public int gaugeProgressScaled(int scale) {
|
||||
return (progress * scale) / time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (getEnergy() <= cost && canOpen())
|
||||
{
|
||||
if (getEnergy() > cost)
|
||||
{
|
||||
if (getEnergy() <= cost && canOpen()) {
|
||||
if (getEnergy() > cost) {
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canOpen())
|
||||
{
|
||||
if (isBurning() && canOpen()) {
|
||||
updateState();
|
||||
|
||||
progress++;
|
||||
if (progress >= time)
|
||||
{
|
||||
if (progress >= time) {
|
||||
progress = 0;
|
||||
recycleItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
progress = 0;
|
||||
updateState();
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
if (burning != isBurning()) {
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
if (updateInventory) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void recycleItems()
|
||||
{
|
||||
if (this.canOpen() && !worldObj.isRemote)
|
||||
{
|
||||
public void recycleItems() {
|
||||
if (this.canOpen() && !worldObj.isRemote) {
|
||||
int random = new Random().nextInt(ScrapboxList.stacks.size());
|
||||
ItemStack out = ScrapboxList.stacks.get(random).copy();
|
||||
if (getStackInSlot(output) == null)
|
||||
{
|
||||
if (getStackInSlot(output) == null) {
|
||||
useEnergy(cost);
|
||||
setInventorySlotContents(output, out);
|
||||
}
|
||||
|
||||
if (getStackInSlot(input1).stackSize > 1)
|
||||
{
|
||||
if (getStackInSlot(input1).stackSize > 1) {
|
||||
useEnergy(cost);
|
||||
this.decrStackSize(input1, 1);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
useEnergy(cost);
|
||||
setInventorySlotContents(input1, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canOpen()
|
||||
{
|
||||
public boolean canOpen() {
|
||||
return getStackInSlot(input1) != null && getStackInSlot(output) == null;
|
||||
}
|
||||
|
||||
public boolean isBurning()
|
||||
{
|
||||
public boolean isBurning() {
|
||||
return getEnergy() > cost;
|
||||
}
|
||||
|
||||
public void updateState()
|
||||
{
|
||||
public void updateState() {
|
||||
IBlockState blockState = worldObj.getBlockState(pos);
|
||||
if (blockState.getBlock() instanceof BlockMachineBase)
|
||||
{
|
||||
if (blockState.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock();
|
||||
if (blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0)
|
||||
blockMachineBase.setActive(progress > 0, worldObj, pos);
|
||||
|
@ -124,56 +104,46 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.scrapboxinator, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
if (slotIndex == 1)
|
||||
{
|
||||
if (itemStack.getItem() == ModItems.scrapBox)
|
||||
{
|
||||
if (slotIndex == 1) {
|
||||
if (itemStack.getItem() == ModItems.scrapBox) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -181,48 +151,40 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
|
|
|
@ -14,8 +14,7 @@ import techreborn.api.reactor.FusionReactorRecipe;
|
|||
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileEntityFusionController extends TilePowerAcceptor implements IInventoryProvider
|
||||
{
|
||||
public class TileEntityFusionController extends TilePowerAcceptor implements IInventoryProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(3, "TileEntityFusionController", 64, this);
|
||||
|
||||
|
@ -30,58 +29,48 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
FusionReactorRecipe currentRecipe = null;
|
||||
boolean hasStartedCrafting = false;
|
||||
|
||||
public TileEntityFusionController()
|
||||
{
|
||||
public TileEntityFusionController() {
|
||||
super(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 100000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return direction == EnumFacing.DOWN || direction == EnumFacing.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
if (!hasStartedCrafting)
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
if (!hasStartedCrafting) {
|
||||
return 0;
|
||||
}
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
if (hasStartedCrafting)
|
||||
{
|
||||
public double getMaxInput() {
|
||||
if (hasStartedCrafting) {
|
||||
return 0;
|
||||
}
|
||||
return 8192;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.EXTREME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafingTickTime = tagCompound.getInteger("crafingTickTime");
|
||||
finalTickTime = tagCompound.getInteger("finalTickTime");
|
||||
|
@ -90,20 +79,16 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
|
||||
if (crafingTickTime == -1)
|
||||
{
|
||||
if (crafingTickTime == -1) {
|
||||
crafingTickTime = 0;
|
||||
}
|
||||
if (finalTickTime == -1)
|
||||
{
|
||||
if (finalTickTime == -1) {
|
||||
finalTickTime = 0;
|
||||
}
|
||||
if (neededPower == -1)
|
||||
{
|
||||
if (neededPower == -1) {
|
||||
neededPower = 0;
|
||||
}
|
||||
tagCompound.setInteger("crafingTickTime", crafingTickTime);
|
||||
|
@ -113,34 +98,31 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
|
||||
public boolean checkCoils()
|
||||
{
|
||||
public boolean checkCoils() {
|
||||
if ((isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ()))
|
||||
&& (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ()))
|
||||
&& (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 3))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 3))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 3))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 3))
|
||||
&& (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() + 3))
|
||||
&& (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() - 3)))
|
||||
{
|
||||
&& (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ()))
|
||||
&& (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ()))
|
||||
&& (isCoil(this.getPos().getX() - 3, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() + 2, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
&& (isCoil(this.getPos().getX() - 2, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 3))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() + 1, this.getPos().getY(), this.getPos().getZ() - 3))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 3))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() + 2))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 3))
|
||||
&& (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() + 3))
|
||||
&& (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() - 3))) {
|
||||
coilStatus = 1;
|
||||
return true;
|
||||
}
|
||||
|
@ -148,48 +130,35 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean isCoil(int x, int y, int z)
|
||||
{
|
||||
private boolean isCoil(int x, int y, int z) {
|
||||
return worldObj.getBlockState(new BlockPos(x, y, z)).getBlock() == ModBlocks.FusionCoil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
// TODO improve this code a lot
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 20 == 0)
|
||||
{
|
||||
if (worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
checkCoils();
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (coilStatus == 1)
|
||||
{
|
||||
if (currentRecipe == null)
|
||||
{
|
||||
if (inventory.hasChanged || crafingTickTime != 0)
|
||||
{
|
||||
for (FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
if (coilStatus == 1) {
|
||||
if (currentRecipe == null) {
|
||||
if (inventory.hasChanged || crafingTickTime != 0) {
|
||||
for (FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) {
|
||||
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), reactorRecipe.getTopInput(), true,
|
||||
true, true))
|
||||
{
|
||||
if (reactorRecipe.getBottomInput() != null)
|
||||
{
|
||||
true, true)) {
|
||||
if (reactorRecipe.getBottomInput() != null) {
|
||||
if (!ItemUtils.isItemEqual(getStackInSlot(bottomStackSlot),
|
||||
reactorRecipe.getBottomInput(), true, true, true))
|
||||
{
|
||||
reactorRecipe.getBottomInput(), true, true, true)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (canFitStack(reactorRecipe.getOutput(), outputStackSlot, true))
|
||||
{
|
||||
if (canFitStack(reactorRecipe.getOutput(), outputStackSlot, true)) {
|
||||
currentRecipe = reactorRecipe;
|
||||
if (crafingTickTime != 0)
|
||||
{
|
||||
if (crafingTickTime != 0) {
|
||||
finalTickTime = currentRecipe.getTickTime();
|
||||
neededPower = (int) currentRecipe.getStartEU();
|
||||
}
|
||||
|
@ -202,59 +171,44 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (inventory.hasChanged)
|
||||
{
|
||||
if (!validateRecipe())
|
||||
{
|
||||
} else {
|
||||
if (inventory.hasChanged) {
|
||||
if (!validateRecipe()) {
|
||||
resetCrafter();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!hasStartedCrafting)
|
||||
{
|
||||
if (canUseEnergy(currentRecipe.getStartEU() + 64))
|
||||
{
|
||||
if (!hasStartedCrafting) {
|
||||
if (canUseEnergy(currentRecipe.getStartEU() + 64)) {
|
||||
useEnergy(currentRecipe.getStartEU());
|
||||
hasStartedCrafting = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (crafingTickTime < currentRecipe.getTickTime())
|
||||
{
|
||||
if (currentRecipe.getEuTick() > 0)
|
||||
{ // Power gen
|
||||
} else {
|
||||
if (crafingTickTime < currentRecipe.getTickTime()) {
|
||||
if (currentRecipe.getEuTick() > 0) { // Power gen
|
||||
addEnergy(currentRecipe.getEuTick()); // Waste
|
||||
// power
|
||||
// if it
|
||||
// has
|
||||
// no
|
||||
// where
|
||||
// to go
|
||||
// power
|
||||
// if it
|
||||
// has
|
||||
// no
|
||||
// where
|
||||
// to go
|
||||
crafingTickTime++;
|
||||
} else
|
||||
{ // Power user
|
||||
if (canUseEnergy(currentRecipe.getEuTick() * -1))
|
||||
{
|
||||
} else { // Power user
|
||||
if (canUseEnergy(currentRecipe.getEuTick() * -1)) {
|
||||
setEnergy(getEnergy() - (currentRecipe.getEuTick() * -1));
|
||||
crafingTickTime++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true))
|
||||
{
|
||||
if (getStackInSlot(outputStackSlot) == null)
|
||||
{
|
||||
} else {
|
||||
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) {
|
||||
if (getStackInSlot(outputStackSlot) == null) {
|
||||
setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy());
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
decrStackSize(outputStackSlot, -currentRecipe.getOutput().stackSize);
|
||||
}
|
||||
decrStackSize(topStackSlot, currentRecipe.getTopInput().stackSize);
|
||||
if (currentRecipe.getBottomInput() != null)
|
||||
{
|
||||
if (currentRecipe.getBottomInput() != null) {
|
||||
decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().stackSize);
|
||||
}
|
||||
resetCrafter();
|
||||
|
@ -262,43 +216,34 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (currentRecipe != null)
|
||||
{
|
||||
} else {
|
||||
if (currentRecipe != null) {
|
||||
resetCrafter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory.hasChanged)
|
||||
{
|
||||
if (inventory.hasChanged) {
|
||||
inventory.hasChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateRecipe()
|
||||
{
|
||||
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true))
|
||||
{
|
||||
if (currentRecipe.getBottomInput() != null)
|
||||
{
|
||||
private boolean validateRecipe() {
|
||||
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true)) {
|
||||
if (currentRecipe.getBottomInput() != null) {
|
||||
if (!ItemUtils.isItemEqual(getStackInSlot(bottomStackSlot), currentRecipe.getBottomInput(), true, true,
|
||||
true))
|
||||
{
|
||||
true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true))
|
||||
{
|
||||
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void resetCrafter()
|
||||
{
|
||||
private void resetCrafter() {
|
||||
currentRecipe = null;
|
||||
crafingTickTime = -1;
|
||||
finalTickTime = -1;
|
||||
|
@ -306,20 +251,15 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
hasStartedCrafting = false;
|
||||
}
|
||||
|
||||
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic)
|
||||
{// Checks to see if it can fit the stack
|
||||
if (stack == null)
|
||||
{
|
||||
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {// Checks to see if it can fit the stack
|
||||
if (stack == null) {
|
||||
return true;
|
||||
}
|
||||
if (inventory.getStackInSlot(slot) == null)
|
||||
{
|
||||
if (inventory.getStackInSlot(slot) == null) {
|
||||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic))
|
||||
{
|
||||
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize())
|
||||
{
|
||||
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) {
|
||||
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -327,20 +267,17 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
public boolean hasCustomName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
public ITextComponent getDisplayName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package techreborn.tiles.generator;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import reborncore.api.fuel.FluidPowerManager;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -19,61 +18,51 @@ import reborncore.common.util.Tank;
|
|||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider
|
||||
{
|
||||
public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider {
|
||||
|
||||
public static final int euTick = ConfigTechReborn.ThermalGeneratorOutput;
|
||||
public Tank tank = new Tank("TileDieselGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
|
||||
public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64, this);
|
||||
|
||||
public TileDieselGenerator()
|
||||
{
|
||||
public TileDieselGenerator() {
|
||||
super(ConfigTechReborn.ThermalGeneratorTier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.DieselGenerator, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
int filled = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return filled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource == null || !resource.isFluidEqual(tank.getFluid()))
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
if (resource == null || !resource.isFluidEqual(tank.getFluid())) {
|
||||
return null;
|
||||
}
|
||||
FluidStack fluidStack = tank.drain(resource.amount, doDrain);
|
||||
|
@ -82,78 +71,65 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
FluidStack drained = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return FluidPowerManager.fluidPowerValues.containsKey(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
FluidUtils.drainContainers(this, inventory, 0, 1);
|
||||
FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType());
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null)
|
||||
{
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
||||
inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
|
||||
syncWithAll();
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null)
|
||||
{
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
|
||||
setInventorySlotContents(2, null);
|
||||
syncWithAll();
|
||||
}
|
||||
|
||||
if (!tank.isEmpty() && tank.getFluidType() != null
|
||||
&& FluidPowerManager.fluidPowerValues.containsKey(tank.getFluidType()))
|
||||
{
|
||||
&& FluidPowerManager.fluidPowerValues.containsKey(tank.getFluidType())) {
|
||||
double powerIn = FluidPowerManager.fluidPowerValues.get(tank.getFluidType());
|
||||
if (getFreeSpace() >= powerIn)
|
||||
{
|
||||
if (getFreeSpace() >= powerIn) {
|
||||
addEnergy(powerIn, false);
|
||||
tank.drain(1, true);
|
||||
}
|
||||
|
@ -163,38 +139,32 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return ConfigTechReborn.ThermalGeneratorCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles.generator;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -8,105 +7,89 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
|
||||
{
|
||||
public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrenchable, IInventoryProvider {
|
||||
|
||||
public static final int euTick = ConfigTechReborn.DragonEggSiphonerOutput;
|
||||
public Inventory inventory = new Inventory(3, "TileAlloySmelter", 64, this);
|
||||
|
||||
public TileDragonEggSiphoner()
|
||||
{
|
||||
public TileDragonEggSiphoner() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
if (worldObj.getBlockState(new BlockPos(getPos().getX(), getPos().getY() + 1, getPos().getZ()))
|
||||
.getBlock() == Blocks.DRAGON_EGG)
|
||||
{
|
||||
.getBlock() == Blocks.DRAGON_EGG) {
|
||||
addEnergy(euTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.Dragoneggenergysiphoner, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return euTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.HIGH;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package techreborn.tiles.generator;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -21,8 +20,7 @@ import techreborn.init.ModBlocks;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
|
||||
{
|
||||
public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider {
|
||||
|
||||
// TODO: run this off config
|
||||
public static final int euTick = 16;
|
||||
|
@ -35,8 +33,7 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IF
|
|||
// amounts.
|
||||
double pendingWithdraw = 0.0;
|
||||
|
||||
public TileGasTurbine()
|
||||
{
|
||||
public TileGasTurbine() {
|
||||
super(ConfigTechReborn.ThermalGeneratorTier);
|
||||
// TODO: fix this to have Gas Turbine generator values
|
||||
|
||||
|
@ -45,116 +42,98 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IF
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.Gasturbine, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
int fill = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(resource.amount, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
if (fluid != null)
|
||||
{
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
if (fluid != null) {
|
||||
return fluids.containsKey(FluidRegistry.getFluidName(fluid));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
FluidUtils.drainContainers(this, inventory, 0, 1);
|
||||
tank.compareAndUpdate();
|
||||
}
|
||||
|
||||
if (tank.getFluidAmount() > 0 && getMaxPower() - getEnergy() >= euTick)
|
||||
{
|
||||
if (tank.getFluidAmount() > 0 && getMaxPower() - getEnergy() >= euTick) {
|
||||
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
|
||||
// float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8
|
||||
// eu per tick
|
||||
|
@ -163,55 +142,47 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IF
|
|||
pendingWithdraw += millibucketsPerTick;
|
||||
|
||||
int currentWithdraw = (int) pendingWithdraw; // float --> int
|
||||
// conversion floors
|
||||
// the float
|
||||
// conversion floors
|
||||
// the float
|
||||
pendingWithdraw -= currentWithdraw;
|
||||
|
||||
tank.drain(currentWithdraw, true);
|
||||
addEnergy(euTick);
|
||||
}
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null)
|
||||
{
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
||||
inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null)
|
||||
{
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
|
||||
setInventorySlotContents(2, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return ConfigTechReborn.ThermalGeneratorCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return euTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles.generator;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -8,68 +7,57 @@ import net.minecraft.tileentity.TileEntityFurnace;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileGenerator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
|
||||
{
|
||||
public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IInventoryProvider {
|
||||
public static int outputAmount = 10; // This is in line with BC engines rf,
|
||||
public Inventory inventory = new Inventory(2, "TileGenerator", 64, this);
|
||||
public int fuelSlot = 0;
|
||||
public int burnTime;
|
||||
public int totalBurnTime = 0;
|
||||
// sould properly use the conversion
|
||||
// ratio here.
|
||||
// sould properly use the conversion
|
||||
// ratio here.
|
||||
public boolean isBurning;
|
||||
public boolean lastTickBurning;
|
||||
ItemStack burnItem;
|
||||
|
||||
public TileGenerator()
|
||||
{
|
||||
public TileGenerator() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
public static int getItemBurnTime(ItemStack stack)
|
||||
{
|
||||
public static int getItemBurnTime(ItemStack stack) {
|
||||
return TileEntityFurnace.getItemBurnTime(stack) / 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
if (getEnergy() < getMaxPower())
|
||||
{
|
||||
if (burnTime > 0)
|
||||
{
|
||||
if (getEnergy() < getMaxPower()) {
|
||||
if (burnTime > 0) {
|
||||
burnTime--;
|
||||
addEnergy(outputAmount);
|
||||
isBurning = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
isBurning = false;
|
||||
}
|
||||
|
||||
if (burnTime == 0)
|
||||
{
|
||||
if (burnTime == 0) {
|
||||
updateState();
|
||||
burnTime = totalBurnTime = getItemBurnTime(getStackInSlot(fuelSlot));
|
||||
if (burnTime > 0)
|
||||
{
|
||||
if (burnTime > 0) {
|
||||
updateState();
|
||||
burnItem = getStackInSlot(fuelSlot);
|
||||
if (getStackInSlot(fuelSlot).stackSize == 1)
|
||||
{
|
||||
if (getStackInSlot(fuelSlot).stackSize == 1) {
|
||||
setInventorySlotContents(fuelSlot, null);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
decrStackSize(fuelSlot, 1);
|
||||
}
|
||||
}
|
||||
|
@ -78,11 +66,9 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable,IInv
|
|||
lastTickBurning = isBurning;
|
||||
}
|
||||
|
||||
public void updateState()
|
||||
{
|
||||
public void updateState() {
|
||||
IBlockState BlockStateContainer = worldObj.getBlockState(pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
|
||||
{
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != burnTime > 0)
|
||||
blockMachineBase.setActive(burnTime > 0, worldObj, pos);
|
||||
|
@ -90,68 +76,57 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable,IInv
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer p0)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer p0) {
|
||||
return new ItemStack(ModBlocks.Generator);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,52 +1,43 @@
|
|||
package techreborn.tiles.generator;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileHeatGenerator extends TilePowerAcceptor implements IWrenchable
|
||||
{
|
||||
public class TileHeatGenerator extends TilePowerAcceptor implements IWrenchable {
|
||||
|
||||
public static final int euTick = ConfigTechReborn.HeatGeneratorOutput;
|
||||
|
||||
public TileHeatGenerator()
|
||||
{
|
||||
public TileHeatGenerator() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
if (worldObj.getBlockState(new BlockPos(getPos().getX() + 1, getPos().getY(), getPos().getZ()))
|
||||
.getBlock() == Blocks.LAVA)
|
||||
{
|
||||
.getBlock() == Blocks.LAVA) {
|
||||
addEnergy(euTick);
|
||||
} else if (worldObj.getBlockState(new BlockPos(getPos().getX(), getPos().getY(), getPos().getZ() + 1))
|
||||
.getBlock() == Blocks.LAVA)
|
||||
{
|
||||
.getBlock() == Blocks.LAVA) {
|
||||
addEnergy(euTick);
|
||||
} else if (worldObj.getBlockState(new BlockPos(getPos().getX(), getPos().getY(), getPos().getZ() - 1))
|
||||
.getBlock() == Blocks.LAVA)
|
||||
{
|
||||
.getBlock() == Blocks.LAVA) {
|
||||
addEnergy(euTick);
|
||||
} else if (worldObj.getBlockState(new BlockPos(getPos().getX() - 1, getPos().getY(), getPos().getZ()))
|
||||
.getBlock() == Blocks.LAVA)
|
||||
{
|
||||
.getBlock() == Blocks.LAVA) {
|
||||
addEnergy(euTick);
|
||||
} else if (worldObj.getBlockState(new BlockPos(getPos().getX(), getPos().getY() - 1, getPos().getZ()))
|
||||
.getBlock() == Blocks.LAVA)
|
||||
{
|
||||
.getBlock() == Blocks.LAVA) {
|
||||
addEnergy(euTick);
|
||||
}
|
||||
|
||||
|
@ -54,73 +45,61 @@ public class TileHeatGenerator extends TilePowerAcceptor implements IWrenchable
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.heatGenerator, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,96 +13,97 @@ import techreborn.config.ConfigTechReborn;
|
|||
|
||||
public class TileLightningRod extends TilePowerAcceptor {
|
||||
|
||||
private int onStatusHoldTicks = -1;
|
||||
private int onStatusHoldTicks = -1;
|
||||
|
||||
public TileLightningRod() {
|
||||
super(2);
|
||||
}
|
||||
public TileLightningRod() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if(onStatusHoldTicks > 0)
|
||||
--onStatusHoldTicks;
|
||||
if (onStatusHoldTicks > 0)
|
||||
--onStatusHoldTicks;
|
||||
|
||||
if(onStatusHoldTicks == 0 || getEnergy() <= 0) {
|
||||
if(getBlockType() instanceof BlockMachineBase)
|
||||
((BlockMachineBase) getBlockType()).setActive(false, worldObj, pos);
|
||||
onStatusHoldTicks = -1;
|
||||
}
|
||||
if (onStatusHoldTicks == 0 || getEnergy() <= 0) {
|
||||
if (getBlockType() instanceof BlockMachineBase)
|
||||
((BlockMachineBase) getBlockType()).setActive(false, worldObj, pos);
|
||||
onStatusHoldTicks = -1;
|
||||
}
|
||||
|
||||
float weatherStrength = worldObj.getThunderStrength(1.0F);
|
||||
if(weatherStrength > 0.2F) {
|
||||
//lightStrikeChance = (MAX - (CHANCE * WEATHER_STRENGTH)
|
||||
float lightStrikeChance = ((100F - ConfigTechReborn.LightningRodChance) * 20F);
|
||||
float totalChance = lightStrikeChance * getLightningStrikeMultiplier() * ((1.1F - weatherStrength));
|
||||
if (worldObj.rand.nextInt((int) Math.floor(totalChance)) == 0) {
|
||||
EntityLightningBolt lightningBolt = new EntityLightningBolt(worldObj,
|
||||
pos.getX() + 0.5F,
|
||||
worldObj.provider.getAverageGroundLevel(),
|
||||
pos.getZ() + 0.5F, false);
|
||||
worldObj.addWeatherEffect(lightningBolt);
|
||||
worldObj.spawnEntityInWorld(lightningBolt);
|
||||
addEnergy(32768 * (0.3F + weatherStrength));
|
||||
((BlockMachineBase) getBlockType()).setActive(true, worldObj, pos);
|
||||
onStatusHoldTicks = 400;
|
||||
}
|
||||
}
|
||||
float weatherStrength = worldObj.getThunderStrength(1.0F);
|
||||
if (weatherStrength > 0.2F) {
|
||||
//lightStrikeChance = (MAX - (CHANCE * WEATHER_STRENGTH)
|
||||
float lightStrikeChance = ((100F - ConfigTechReborn.LightningRodChance) * 20F);
|
||||
float totalChance = lightStrikeChance * getLightningStrikeMultiplier() * ((1.1F - weatherStrength));
|
||||
if (worldObj.rand.nextInt((int) Math.floor(totalChance)) == 0) {
|
||||
EntityLightningBolt lightningBolt = new EntityLightningBolt(worldObj,
|
||||
pos.getX() + 0.5F,
|
||||
worldObj.provider.getAverageGroundLevel(),
|
||||
pos.getZ() + 0.5F, false);
|
||||
worldObj.addWeatherEffect(lightningBolt);
|
||||
worldObj.spawnEntityInWorld(lightningBolt);
|
||||
addEnergy(32768 * (0.3F + weatherStrength));
|
||||
((BlockMachineBase) getBlockType()).setActive(true, worldObj, pos);
|
||||
onStatusHoldTicks = 400;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public float getLightningStrikeMultiplier() {
|
||||
float actualHeight = worldObj.provider.getActualHeight();
|
||||
float groundLevel = worldObj.provider.getAverageGroundLevel();
|
||||
for(int i = pos.getY() + 1; i < actualHeight; i++) {
|
||||
if(!isValidIronFence(i)) {
|
||||
if(groundLevel >= i)
|
||||
return 4.3F;
|
||||
float max = actualHeight - groundLevel;
|
||||
float got = i - groundLevel;
|
||||
return 1.2F - got / max;
|
||||
}
|
||||
}
|
||||
return 4F;
|
||||
}
|
||||
public float getLightningStrikeMultiplier() {
|
||||
float actualHeight = worldObj.provider.getActualHeight();
|
||||
float groundLevel = worldObj.provider.getAverageGroundLevel();
|
||||
for (int i = pos.getY() + 1; i < actualHeight; i++) {
|
||||
if (!isValidIronFence(i)) {
|
||||
if (groundLevel >= i)
|
||||
return 4.3F;
|
||||
float max = actualHeight - groundLevel;
|
||||
float got = i - groundLevel;
|
||||
return 1.2F - got / max;
|
||||
}
|
||||
}
|
||||
return 4F;
|
||||
}
|
||||
|
||||
public boolean isValidIronFence(int y) {
|
||||
Item itemBlock = Item.getItemFromBlock(worldObj.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock());
|
||||
for(ItemStack fence : OreDictionary.getOres("fenceIron")) {
|
||||
if(fence.getItem() == itemBlock) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isValidIronFence(int y) {
|
||||
Item itemBlock = Item.getItemFromBlock(worldObj.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock());
|
||||
for (ItemStack fence : OreDictionary.getOres("fenceIron")) {
|
||||
if (fence.getItem() == itemBlock)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 327680;
|
||||
}
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 327680;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return direction == getFacingEnum();
|
||||
}
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return direction == getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 2048;
|
||||
}
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.HIGH;
|
||||
}
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.HIGH;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package techreborn.tiles.generator;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -21,8 +20,7 @@ import techreborn.init.ModBlocks;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
|
||||
{
|
||||
public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider {
|
||||
|
||||
// TODO: run this off config
|
||||
public static final int euTick = 8;
|
||||
|
@ -35,8 +33,7 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
|
|||
// amounts.
|
||||
double pendingWithdraw = 0.0;
|
||||
|
||||
public TileSemifluidGenerator()
|
||||
{
|
||||
public TileSemifluidGenerator() {
|
||||
super(ConfigTechReborn.ThermalGeneratorTier);
|
||||
// TODO: fix this to have SemiFluid generator values
|
||||
|
||||
|
@ -51,113 +48,96 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.Semifluidgenerator, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
int fill = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(resource.amount, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
if (fluid != null)
|
||||
{
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
if (fluid != null) {
|
||||
return fluids.containsKey(FluidRegistry.getFluidName(fluid));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote)
|
||||
FluidUtils.drainContainers(this, inventory, 0, 1);
|
||||
|
||||
if (tank.getFluidAmount() > 0 && getMaxPower() - getEnergy() >= euTick && tank.getFluidType() != null && fluids.containsKey(tank.getFluidType().getName()))
|
||||
{
|
||||
if (tank.getFluidAmount() > 0 && getMaxPower() - getEnergy() >= euTick && tank.getFluidType() != null && fluids.containsKey(tank.getFluidType().getName())) {
|
||||
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
|
||||
// float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8
|
||||
// eu per tick
|
||||
|
@ -166,55 +146,47 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
|
|||
pendingWithdraw += millibucketsPerTick;
|
||||
|
||||
int currentWithdraw = (int) pendingWithdraw; // float --> int
|
||||
// conversion floors
|
||||
// the float
|
||||
// conversion floors
|
||||
// the float
|
||||
pendingWithdraw -= currentWithdraw;
|
||||
|
||||
tank.drain(currentWithdraw, true);
|
||||
addEnergy(euTick);
|
||||
}
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null)
|
||||
{
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
||||
inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null)
|
||||
{
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
|
||||
setInventorySlotContents(2, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return ConfigTechReborn.ThermalGeneratorCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return euTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,49 +11,41 @@ import java.util.List;
|
|||
/**
|
||||
* Created by modmuss50 on 25/02/2016.
|
||||
*/
|
||||
public class TileSolarPanel extends TilePowerAcceptor implements ITickable
|
||||
{
|
||||
public class TileSolarPanel extends TilePowerAcceptor implements ITickable {
|
||||
|
||||
boolean shouldMakePower = false;
|
||||
boolean lastTickSate = false;
|
||||
|
||||
int powerToAdd;
|
||||
|
||||
public TileSolarPanel()
|
||||
{
|
||||
public TileSolarPanel() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if (worldObj.getTotalWorldTime() % 60 == 0)
|
||||
{
|
||||
shouldMakePower = isSunOut();
|
||||
if (!worldObj.isRemote) {
|
||||
if (worldObj.getTotalWorldTime() % 60 == 0) {
|
||||
shouldMakePower = isSunOut();
|
||||
|
||||
}
|
||||
if (shouldMakePower)
|
||||
{
|
||||
powerToAdd = 10;
|
||||
addEnergy(powerToAdd);
|
||||
} else
|
||||
{
|
||||
powerToAdd = 0;
|
||||
}
|
||||
}
|
||||
if (shouldMakePower) {
|
||||
powerToAdd = 10;
|
||||
addEnergy(powerToAdd);
|
||||
} else {
|
||||
powerToAdd = 0;
|
||||
}
|
||||
|
||||
worldObj.setBlockState(getPos(),
|
||||
worldObj.setBlockState(getPos(),
|
||||
worldObj.getBlockState(this.getPos()).withProperty(BlockSolarPanel.ACTIVE, isSunOut()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
super.addInfo(info, isRealTile);
|
||||
if (isRealTile)
|
||||
{
|
||||
if (isRealTile) {
|
||||
// FIXME: 25/02/2016
|
||||
// info.add(TextFormatting.LIGHT_PURPLE + "Power gen/tick " +
|
||||
// TextFormatting.GREEN + PowerSystem.getLocaliszedPower(
|
||||
|
@ -61,45 +53,38 @@ public class TileSolarPanel extends TilePowerAcceptor implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isSunOut()
|
||||
{
|
||||
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
|
||||
&& worldObj.isDaytime();
|
||||
public boolean isSunOut() {
|
||||
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
|
||||
&& worldObj.isDaytime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package techreborn.tiles.generator;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
|
@ -21,79 +20,66 @@ import reborncore.common.util.Tank;
|
|||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
|
||||
{
|
||||
public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider {
|
||||
|
||||
public static final int euTick = ConfigTechReborn.ThermalGeneratorOutput;
|
||||
public Tank tank = new Tank("TileThermalGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
|
||||
public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64, this);
|
||||
|
||||
public TileThermalGenerator()
|
||||
{
|
||||
public TileThermalGenerator() {
|
||||
super(ConfigTechReborn.ThermalGeneratorTier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.thermalGenerator, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
int fill = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(resource.amount, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
FluidStack drain = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
if (fluid != null)
|
||||
{
|
||||
if (fluid == FluidRegistry.LAVA)
|
||||
{
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
if (fluid != null) {
|
||||
if (fluid == FluidRegistry.LAVA) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -101,122 +87,101 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO optimise this code
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!worldObj.isRemote) {
|
||||
FluidUtils.drainContainers(this, inventory, 0, 1);
|
||||
for (EnumFacing direction : EnumFacing.values())
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.values()) {
|
||||
if (worldObj.getBlockState(new BlockPos(getPos().getX() + direction.getFrontOffsetX(),
|
||||
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()))
|
||||
.getBlock() == Blocks.LAVA)
|
||||
{
|
||||
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()))
|
||||
.getBlock() == Blocks.LAVA) {
|
||||
addEnergy(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 40 == 0)
|
||||
{
|
||||
if (worldObj.getTotalWorldTime() % 40 == 0) {
|
||||
BlockMachineBase bmb = (BlockMachineBase) worldObj.getBlockState(pos).getBlock();
|
||||
boolean didFindLava = false;
|
||||
for (EnumFacing direction : EnumFacing.values())
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.values()) {
|
||||
if (worldObj.getBlockState(new BlockPos(getPos().getX() + direction.getFrontOffsetX(),
|
||||
getPos().getY() + direction.getFrontOffsetY(),
|
||||
getPos().getZ() + direction.getFrontOffsetZ())).getBlock() == Blocks.LAVA)
|
||||
{
|
||||
getPos().getY() + direction.getFrontOffsetY(),
|
||||
getPos().getZ() + direction.getFrontOffsetZ())).getBlock() == Blocks.LAVA) {
|
||||
didFindLava = true;
|
||||
}
|
||||
}
|
||||
bmb.setActive(didFindLava, worldObj, pos);
|
||||
}
|
||||
}
|
||||
if (tank.getFluidAmount() > 0 && getMaxPower() - getEnergy() >= euTick)
|
||||
{
|
||||
if (tank.getFluidAmount() > 0 && getMaxPower() - getEnergy() >= euTick) {
|
||||
tank.drain(1, true);
|
||||
addEnergy(euTick);
|
||||
}
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null)
|
||||
{
|
||||
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
||||
// inventory.setInventorySlotContents(2, new ItemStack(tank
|
||||
// .getFluidType().getBlock()));
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null)
|
||||
{
|
||||
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
|
||||
setInventorySlotContents(2, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return ConfigTechReborn.ThermalGeneratorCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,75 +8,61 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
/**
|
||||
* Created by modmuss50 on 25/02/2016.
|
||||
*/
|
||||
public class TileWaterMill extends TilePowerAcceptor
|
||||
{
|
||||
public class TileWaterMill extends TilePowerAcceptor {
|
||||
|
||||
int waterblocks = 0;
|
||||
|
||||
public TileWaterMill()
|
||||
{
|
||||
public TileWaterMill() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (worldObj.getTotalWorldTime() % 20 == 0)
|
||||
{
|
||||
if (worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
checkForWater();
|
||||
}
|
||||
if (waterblocks > 0)
|
||||
{
|
||||
if (waterblocks > 0) {
|
||||
addEnergy(waterblocks);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForWater()
|
||||
{
|
||||
public void checkForWater() {
|
||||
waterblocks = 0;
|
||||
for (EnumFacing facing : EnumFacing.HORIZONTALS)
|
||||
{
|
||||
if (worldObj.getBlockState(getPos().offset(facing)).getBlock() == Blocks.WATER)
|
||||
{
|
||||
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
|
||||
if (worldObj.getBlockState(getPos().offset(facing)).getBlock() == Blocks.WATER) {
|
||||
waterblocks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,66 +7,55 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
/**
|
||||
* Created by modmuss50 on 25/02/2016.
|
||||
*/
|
||||
public class TileWindMill extends TilePowerAcceptor
|
||||
{
|
||||
public class TileWindMill extends TilePowerAcceptor {
|
||||
|
||||
int basePower = 16;
|
||||
|
||||
public TileWindMill()
|
||||
{
|
||||
public TileWindMill() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (pos.getY() > 64)
|
||||
{
|
||||
if (pos.getY() > 64) {
|
||||
int actualPower = basePower;
|
||||
if (worldObj.isThundering())
|
||||
{
|
||||
if (worldObj.isThundering()) {
|
||||
actualPower *= 1.25;
|
||||
}
|
||||
addEnergy(actualPower); // Value taken from
|
||||
// http://wiki.industrial-craft.net/?title=Wind_Mill
|
||||
// Not worth making more complicated
|
||||
// http://wiki.industrial-craft.net/?title=Wind_Mill
|
||||
// Not worth making more complicated
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,38 +14,29 @@ import java.lang.reflect.Type;
|
|||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
public class IDSUManager
|
||||
{
|
||||
public class IDSUManager {
|
||||
|
||||
public static final String savename = "idsu.json";
|
||||
public static IDSUManager INSTANCE;
|
||||
public HashMap<World, IDSUWorldSaveData> worldData = new HashMap<>();
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void worldSave(WorldEvent.Save event)
|
||||
{
|
||||
public void worldSave(WorldEvent.Save event) {
|
||||
if (event.getWorld() != null && event.getWorld().getSaveHandler() != null
|
||||
&& event.getWorld().getSaveHandler().getWorldDirectory() != null)
|
||||
{
|
||||
if (worldData.containsKey(event.getWorld()))
|
||||
{
|
||||
&& event.getWorld().getSaveHandler().getWorldDirectory() != null) {
|
||||
if (worldData.containsKey(event.getWorld())) {
|
||||
worldData.get(event.getWorld()).save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void worldLoad(WorldEvent.Load event)
|
||||
{
|
||||
public void worldLoad(WorldEvent.Load event) {
|
||||
if (event.getWorld() != null && event.getWorld().getSaveHandler() != null
|
||||
&& event.getWorld().getSaveHandler().getWorldDirectory() != null)
|
||||
{
|
||||
if (worldData.containsKey(event.getWorld()))
|
||||
{
|
||||
&& event.getWorld().getSaveHandler().getWorldDirectory() != null) {
|
||||
if (worldData.containsKey(event.getWorld())) {
|
||||
worldData.get(event.getWorld()).load();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(event.getWorld());
|
||||
worldData.put(event.getWorld(), worldSaveData);
|
||||
worldSaveData.load();
|
||||
|
@ -54,13 +45,10 @@ public class IDSUManager
|
|||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void worldClosed(WorldEvent.Unload event)
|
||||
{
|
||||
public void worldClosed(WorldEvent.Unload event) {
|
||||
if (event.getWorld() != null && event.getWorld().getSaveHandler() != null
|
||||
&& event.getWorld().getSaveHandler().getWorldDirectory() != null)
|
||||
{
|
||||
if (worldData.containsKey(event.getWorld()))
|
||||
{
|
||||
&& event.getWorld().getSaveHandler().getWorldDirectory() != null) {
|
||||
if (worldData.containsKey(event.getWorld())) {
|
||||
worldData.get(event.getWorld()).save();
|
||||
}
|
||||
}
|
||||
|
@ -68,13 +56,10 @@ public class IDSUManager
|
|||
worldData.clear();
|
||||
}
|
||||
|
||||
public IDSUValueSaveData getSaveDataForWorld(World world, String channel)
|
||||
{
|
||||
if (worldData.containsKey(world))
|
||||
{
|
||||
public IDSUValueSaveData getSaveDataForWorld(World world, String channel) {
|
||||
if (worldData.containsKey(world)) {
|
||||
return worldData.get(world).getSaves(channel);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
|
||||
worldData.put(world, worldSaveData);
|
||||
worldSaveData.load();
|
||||
|
@ -82,13 +67,10 @@ public class IDSUManager
|
|||
}
|
||||
}
|
||||
|
||||
public IDSUWorldSaveData getWorldDataFormWorld(World world)
|
||||
{
|
||||
if (worldData.containsKey(world))
|
||||
{
|
||||
public IDSUWorldSaveData getWorldDataFormWorld(World world) {
|
||||
if (worldData.containsKey(world)) {
|
||||
return worldData.get(world);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
|
||||
worldData.put(world, worldSaveData);
|
||||
worldSaveData.load();
|
||||
|
@ -96,31 +78,25 @@ public class IDSUManager
|
|||
}
|
||||
}
|
||||
|
||||
public void loadFromString(String json, World world)
|
||||
{
|
||||
if (json.equals("EMPTY"))
|
||||
{
|
||||
public void loadFromString(String json, World world) {
|
||||
if (json.equals("EMPTY")) {
|
||||
return;
|
||||
}
|
||||
IDSUWorldSaveData worldSaveData;
|
||||
if (worldData.containsKey(world))
|
||||
{
|
||||
if (worldData.containsKey(world)) {
|
||||
worldSaveData = worldData.get(world);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
worldSaveData = new IDSUWorldSaveData(world);
|
||||
worldData.put(world, worldSaveData);
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>()
|
||||
{
|
||||
Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>() {
|
||||
}.getType();
|
||||
worldSaveData.idsuValues.clear();
|
||||
worldSaveData.idsuValues = gson.fromJson(json, typeOfHashMap);
|
||||
}
|
||||
|
||||
public class IDSUWorldSaveData
|
||||
{
|
||||
public class IDSUWorldSaveData {
|
||||
|
||||
public TreeMap<String, IDSUValueSaveData> idsuValues = new TreeMap<>();
|
||||
|
||||
|
@ -132,114 +108,90 @@ public class IDSUManager
|
|||
|
||||
File file;
|
||||
|
||||
public IDSUWorldSaveData(World world)
|
||||
{
|
||||
public IDSUWorldSaveData(World world) {
|
||||
this.world = world;
|
||||
this.saveHandler = world.getSaveHandler();
|
||||
folder = new File(saveHandler.getWorldDirectory(), "idsuData");
|
||||
file = new File(folder, savename);
|
||||
}
|
||||
|
||||
public IDSUValueSaveData getSaves(String udid)
|
||||
{
|
||||
if (udid == null)
|
||||
{
|
||||
public IDSUValueSaveData getSaves(String udid) {
|
||||
if (udid == null) {
|
||||
return null;
|
||||
}
|
||||
if (idsuValues.containsKey(udid))
|
||||
{
|
||||
if (idsuValues.containsKey(udid)) {
|
||||
return idsuValues.get(udid);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
IDSUValueSaveData data = new IDSUValueSaveData();
|
||||
idsuValues.put(udid, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
if (!file.exists())
|
||||
{
|
||||
public void load() {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
Type typeOfHashMap = new TypeToken<TreeMap<String, IDSUValueSaveData>>()
|
||||
{
|
||||
Type typeOfHashMap = new TypeToken<TreeMap<String, IDSUValueSaveData>>() {
|
||||
}.getType();
|
||||
idsuValues.clear();
|
||||
idsuValues = gson.fromJson(reader, typeOfHashMap);
|
||||
} catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
if (idsuValues.isEmpty())
|
||||
{
|
||||
public void save() {
|
||||
if (idsuValues.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!file.exists())
|
||||
{
|
||||
if (!folder.exists())
|
||||
{
|
||||
if (!file.exists()) {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json = gson.toJson(idsuValues);
|
||||
try
|
||||
{
|
||||
try {
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
} catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class IDSUValueSaveData
|
||||
{
|
||||
public class IDSUValueSaveData {
|
||||
|
||||
public double storedPower = 0;
|
||||
|
||||
public IDSUValueSaveData(double storedPower)
|
||||
{
|
||||
public IDSUValueSaveData(double storedPower) {
|
||||
this.storedPower = storedPower;
|
||||
}
|
||||
|
||||
public IDSUValueSaveData()
|
||||
{
|
||||
public IDSUValueSaveData() {
|
||||
}
|
||||
|
||||
public double getStoredPower()
|
||||
{
|
||||
public double getStoredPower() {
|
||||
return storedPower;
|
||||
}
|
||||
|
||||
public void setStoredPower(double storedPower)
|
||||
{
|
||||
public void setStoredPower(double storedPower) {
|
||||
this.storedPower = storedPower;
|
||||
}
|
||||
|
||||
public void addEnergy(double storedPower)
|
||||
{
|
||||
public void addEnergy(double storedPower) {
|
||||
this.storedPower += storedPower;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package techreborn.tiles.idsu;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileIDSU extends TilePowerAcceptor implements IWrenchable
|
||||
{
|
||||
public class TileIDSU extends TilePowerAcceptor implements IWrenchable {
|
||||
|
||||
public String ownerUdid;
|
||||
public int tier;
|
||||
|
@ -22,124 +21,102 @@ public class TileIDSU extends TilePowerAcceptor implements IWrenchable
|
|||
private double euChange;
|
||||
private int ticks;
|
||||
|
||||
public TileIDSU(int tier1, int output1, int maxStorage1)
|
||||
{
|
||||
public TileIDSU(int tier1, int output1, int maxStorage1) {
|
||||
super(tier1);
|
||||
this.tier = tier1;
|
||||
this.output = output1;
|
||||
this.maxStorage = maxStorage1;
|
||||
}
|
||||
|
||||
public TileIDSU()
|
||||
{
|
||||
public TileIDSU() {
|
||||
this(5, 2048, 100000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergy()
|
||||
{
|
||||
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid))
|
||||
{
|
||||
public double getEnergy() {
|
||||
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) {
|
||||
return 0.0;
|
||||
}
|
||||
return IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy)
|
||||
{
|
||||
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid))
|
||||
{
|
||||
public void setEnergy(double energy) {
|
||||
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) {
|
||||
return;
|
||||
}
|
||||
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower = energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 1000000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() == direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return maxStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.EXTREME;
|
||||
}
|
||||
|
||||
public float getChargeLevel()
|
||||
{
|
||||
public float getChargeLevel() {
|
||||
float ret = (float) this.getEnergy() / (float) this.maxStorage;
|
||||
if (ret > 1.0F)
|
||||
{
|
||||
if (ret > 1.0F) {
|
||||
ret = 1.0F;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
this.ownerUdid = nbttagcompound.getString("ownerUdid");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid))
|
||||
{
|
||||
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) {
|
||||
return nbttagcompound;
|
||||
}
|
||||
nbttagcompound.setString("ownerUdid", this.ownerUdid);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime)
|
||||
{
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
|
||||
euChange = -1;
|
||||
ticks = 0;
|
||||
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ticks++;
|
||||
euChange += getEnergy() - euLastTick;
|
||||
if (euLastTick == getEnergy())
|
||||
{
|
||||
if (euLastTick == getEnergy()) {
|
||||
euChange = 0;
|
||||
}
|
||||
}
|
||||
|
@ -148,40 +125,37 @@ public class TileIDSU extends TilePowerAcceptor implements IWrenchable
|
|||
|
||||
boolean needsInvUpdate = false;
|
||||
|
||||
if (needsInvUpdate)
|
||||
{
|
||||
if (needsInvUpdate) {
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1)
|
||||
{
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public EnumFacing getFacing()
|
||||
{
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanRemove(EntityPlayer p0)
|
||||
{
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer p0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public float getWrenchDropRate()
|
||||
{
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
NBTTagCompound tileEntity = new NBTTagCompound();
|
||||
ItemStack dropStack = new ItemStack(ModBlocks.Idsu, 1);
|
||||
writeToNBT(tileEntity);
|
||||
|
@ -190,39 +164,30 @@ public class TileIDSU extends TilePowerAcceptor implements IWrenchable
|
|||
return dropStack;
|
||||
}
|
||||
|
||||
public double getEuChange()
|
||||
{
|
||||
if (euChange == -1)
|
||||
{
|
||||
public double getEuChange() {
|
||||
if (euChange == -1) {
|
||||
return -1;
|
||||
}
|
||||
return (euChange / ticks);
|
||||
}
|
||||
|
||||
public void handleGuiInputFromClient(int id)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
public void handleGuiInputFromClient(int id) {
|
||||
if (id == 0) {
|
||||
output += 256;
|
||||
}
|
||||
if (id == 1)
|
||||
{
|
||||
if (id == 1) {
|
||||
output += 64;
|
||||
}
|
||||
if (id == 2)
|
||||
{
|
||||
if (id == 2) {
|
||||
output -= 64;
|
||||
}
|
||||
if (id == 3)
|
||||
{
|
||||
if (id == 3) {
|
||||
output -= 256;
|
||||
}
|
||||
if (output > 4096)
|
||||
{
|
||||
if (output > 4096) {
|
||||
output = 4096;
|
||||
}
|
||||
if (output <= -1)
|
||||
{
|
||||
if (output <= -1) {
|
||||
output = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,61 +2,48 @@ package techreborn.tiles.lesu;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LesuNetwork
|
||||
{
|
||||
public class LesuNetwork {
|
||||
|
||||
public ArrayList<TileLesuStorage> storages = new ArrayList<>();
|
||||
|
||||
public TileLesu master;
|
||||
|
||||
public void addElement(TileLesuStorage lesuStorage)
|
||||
{
|
||||
if (!storages.contains(lesuStorage) && storages.size() < 5000)
|
||||
{
|
||||
public void addElement(TileLesuStorage lesuStorage) {
|
||||
if (!storages.contains(lesuStorage) && storages.size() < 5000) {
|
||||
storages.add(lesuStorage);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeElement(TileLesuStorage lesuStorage)
|
||||
{
|
||||
public void removeElement(TileLesuStorage lesuStorage) {
|
||||
storages.remove(lesuStorage);
|
||||
rebuild();
|
||||
}
|
||||
|
||||
private void rebuild()
|
||||
{
|
||||
private void rebuild() {
|
||||
master = null;
|
||||
for (TileLesuStorage lesuStorage : storages)
|
||||
{
|
||||
for (TileLesuStorage lesuStorage : storages) {
|
||||
lesuStorage.findAndJoinNetwork(lesuStorage.getWorld(), lesuStorage.getPos().getX(),
|
||||
lesuStorage.getPos().getY(), lesuStorage.getPos().getZ());
|
||||
lesuStorage.getPos().getY(), lesuStorage.getPos().getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public void merge(LesuNetwork network)
|
||||
{
|
||||
if (network != this)
|
||||
{
|
||||
public void merge(LesuNetwork network) {
|
||||
if (network != this) {
|
||||
ArrayList<TileLesuStorage> tileLesuStorages = new ArrayList<>();
|
||||
tileLesuStorages.addAll(network.storages);
|
||||
network.clear(false);
|
||||
for (TileLesuStorage lesuStorage : tileLesuStorages)
|
||||
{
|
||||
for (TileLesuStorage lesuStorage : tileLesuStorages) {
|
||||
lesuStorage.setNetwork(this);
|
||||
}
|
||||
if (network.master != null && this.master == null)
|
||||
{
|
||||
if (network.master != null && this.master == null) {
|
||||
this.master = network.master;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clear(boolean clearTiles)
|
||||
{
|
||||
if (clearTiles)
|
||||
{
|
||||
for (TileLesuStorage tileLesuStorage : storages)
|
||||
{
|
||||
private void clear(boolean clearTiles) {
|
||||
if (clearTiles) {
|
||||
for (TileLesuStorage tileLesuStorage : storages) {
|
||||
tileLesuStorage.resetNetwork();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ import techreborn.config.ConfigTechReborn;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileLesu extends TilePowerAcceptor
|
||||
{// TODO wrench
|
||||
public class TileLesu extends TilePowerAcceptor {// TODO wrench
|
||||
|
||||
public int connectedBlocks = 0;
|
||||
public Inventory inventory = new Inventory(2, "TileAesu", 64, this);
|
||||
|
@ -21,38 +20,30 @@ public class TileLesu extends TilePowerAcceptor
|
|||
private int output;
|
||||
private int maxStorage;
|
||||
|
||||
public TileLesu()
|
||||
{
|
||||
public TileLesu() {
|
||||
super(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
countedNetworks.clear();
|
||||
connectedBlocks = 0;
|
||||
for (EnumFacing dir : EnumFacing.values())
|
||||
{
|
||||
for (EnumFacing dir : EnumFacing.values()) {
|
||||
if (worldObj.getTileEntity(
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ())) instanceof TileLesuStorage)
|
||||
{
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ())) instanceof TileLesuStorage) {
|
||||
if (((TileLesuStorage) worldObj.getTileEntity(
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network != null)
|
||||
{
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network != null) {
|
||||
LesuNetwork network = ((TileLesuStorage) worldObj.getTileEntity(new BlockPos(
|
||||
getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network;
|
||||
if (!countedNetworks.contains(network))
|
||||
{
|
||||
if (network.master == null || network.master == this)
|
||||
{
|
||||
getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network;
|
||||
if (!countedNetworks.contains(network)) {
|
||||
if (network.master == null || network.master == this) {
|
||||
connectedBlocks += network.storages.size();
|
||||
countedNetworks.add(network);
|
||||
network.master = this;
|
||||
|
@ -65,20 +56,16 @@ public class TileLesu extends TilePowerAcceptor
|
|||
maxStorage = ((connectedBlocks + 1) * ConfigTechReborn.LesuStoragePerBlock);
|
||||
output = (connectedBlocks * ConfigTechReborn.ExtraOutputPerLesuBlock) + ConfigTechReborn.BaseLesuOutput;
|
||||
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime)
|
||||
{
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
|
||||
euChange = -1;
|
||||
ticks = 0;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ticks++;
|
||||
if (euChange == -1)
|
||||
{
|
||||
if (euChange == -1) {
|
||||
euChange = 0;
|
||||
}
|
||||
euChange += getEnergy() - euLastTick;
|
||||
if (euLastTick == getEnergy())
|
||||
{
|
||||
if (euLastTick == getEnergy()) {
|
||||
euChange = 0;
|
||||
}
|
||||
}
|
||||
|
@ -86,48 +73,40 @@ public class TileLesu extends TilePowerAcceptor
|
|||
euLastTick = getEnergy();
|
||||
}
|
||||
|
||||
public double getEuChange()
|
||||
{
|
||||
if (euChange == -1)
|
||||
{
|
||||
public double getEuChange() {
|
||||
if (euChange == -1) {
|
||||
return 0;
|
||||
}
|
||||
return (euChange / ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return maxStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return direction != getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return direction == getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 8192;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.EXTREME;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,75 +5,59 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
|
||||
public class TileLesuStorage extends TileMachineBase
|
||||
{
|
||||
public class TileLesuStorage extends TileMachineBase {
|
||||
|
||||
public LesuNetwork network;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (network == null)
|
||||
{
|
||||
if (network == null) {
|
||||
findAndJoinNetwork(worldObj, getPos().getX(), getPos().getY(), getPos().getZ());
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
if (network.master != null
|
||||
&& network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(),
|
||||
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master)
|
||||
{
|
||||
&& network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(),
|
||||
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
|
||||
network.master = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void findAndJoinNetwork(World world, int x, int y, int z)
|
||||
{
|
||||
public final void findAndJoinNetwork(World world, int x, int y, int z) {
|
||||
network = new LesuNetwork();
|
||||
network.addElement(this);
|
||||
for (EnumFacing direction : EnumFacing.values())
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.values()) {
|
||||
if (world.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(),
|
||||
z + direction.getFrontOffsetZ())) instanceof TileLesuStorage)
|
||||
{
|
||||
z + direction.getFrontOffsetZ())) instanceof TileLesuStorage) {
|
||||
TileLesuStorage lesu = (TileLesuStorage) world
|
||||
.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(),
|
||||
z + direction.getFrontOffsetZ()));
|
||||
if (lesu.network != null)
|
||||
{
|
||||
.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(),
|
||||
z + direction.getFrontOffsetZ()));
|
||||
if (lesu.network != null) {
|
||||
lesu.network.merge(network);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void setNetwork(LesuNetwork n)
|
||||
{
|
||||
if (n == null)
|
||||
{
|
||||
} else
|
||||
{
|
||||
public final void setNetwork(LesuNetwork n) {
|
||||
if (n == null) {
|
||||
} else {
|
||||
network = n;
|
||||
network.addElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final void resetNetwork()
|
||||
{
|
||||
public final void resetNetwork() {
|
||||
network = null;
|
||||
}
|
||||
|
||||
public final void removeFromNetwork()
|
||||
{
|
||||
if (network == null)
|
||||
{
|
||||
public final void removeFromNetwork() {
|
||||
if (network == null) {
|
||||
} else
|
||||
network.removeElement(this);
|
||||
}
|
||||
|
||||
public final void rebuildNetwork()
|
||||
{
|
||||
public final void rebuildNetwork() {
|
||||
this.removeFromNetwork();
|
||||
this.resetNetwork();
|
||||
this.findAndJoinNetwork(worldObj, getPos().getX(), getPos().getY(), getPos().getZ());
|
||||
|
|
|
@ -8,92 +8,92 @@ import techreborn.init.ModBlocks;
|
|||
|
||||
public class MultiblockChecker {
|
||||
|
||||
public static final BlockPos ZERO_OFFSET = BlockPos.ORIGIN;
|
||||
public static final BlockPos ZERO_OFFSET = BlockPos.ORIGIN;
|
||||
|
||||
public static final int CASING_NORMAL = 0;
|
||||
public static final int CASING_REINFORCED = 1;
|
||||
public static final int CASING_ADVANCED = 2;
|
||||
public static final int CASING_NORMAL = 0;
|
||||
public static final int CASING_REINFORCED = 1;
|
||||
public static final int CASING_ADVANCED = 2;
|
||||
|
||||
private final World world;
|
||||
private final BlockPos downCenter;
|
||||
private final World world;
|
||||
private final BlockPos downCenter;
|
||||
|
||||
public MultiblockChecker(World world, BlockPos downCenter) {
|
||||
this.world = world;
|
||||
this.downCenter = downCenter;
|
||||
}
|
||||
public MultiblockChecker(World world, BlockPos downCenter) {
|
||||
this.world = world;
|
||||
this.downCenter = downCenter;
|
||||
}
|
||||
|
||||
public boolean checkCasing(int offX, int offY, int offZ, int type) {
|
||||
IBlockState block = getBlock(offX, offY, offZ);
|
||||
if(block.getBlock() == ModBlocks.MachineCasing) {
|
||||
if(block.getValue(BlockMachineCasing.METADATA) == type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean checkCasing(int offX, int offY, int offZ, int type) {
|
||||
IBlockState block = getBlock(offX, offY, offZ);
|
||||
if (block.getBlock() == ModBlocks.MachineCasing) {
|
||||
if (block.getValue(BlockMachineCasing.METADATA) == type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkAir(int offX, int offY, int offZ) {
|
||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
||||
return world.isAirBlock(pos);
|
||||
}
|
||||
public boolean checkAir(int offX, int offY, int offZ) {
|
||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
||||
return world.isAirBlock(pos);
|
||||
}
|
||||
|
||||
public IBlockState getBlock(int offX, int offY, int offZ) {
|
||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
public IBlockState getBlock(int offX, int offY, int offZ) {
|
||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
public boolean checkRectY(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if(!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkRectY(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for (int x = -sizeX; x <= sizeX; x++) {
|
||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRectZ(int sizeX, int sizeY, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int y = -sizeY; y <= sizeY; y++) {
|
||||
if(!checkCasing(x + offset.getX(), y + offset.getY(), offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkRectZ(int sizeX, int sizeY, int casingType, BlockPos offset) {
|
||||
for (int x = -sizeX; x <= sizeX; x++) {
|
||||
for (int y = -sizeY; y <= sizeY; y++) {
|
||||
if (!checkCasing(x + offset.getX(), y + offset.getY(), offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRectX(int sizeZ, int sizeY, int casingType, BlockPos offset) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
for(int y = -sizeY; y <= sizeY; y++) {
|
||||
if(!checkCasing(offset.getX(), y + offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkRectX(int sizeZ, int sizeY, int casingType, BlockPos offset) {
|
||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
||||
for (int y = -sizeY; y <= sizeY; y++) {
|
||||
if (!checkCasing(offset.getX(), y + offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRingY(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkRingY(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for (int x = -sizeX; x <= sizeX; x++) {
|
||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if ((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRingYHollow(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
} else if (!checkAir(x + offset.getX(), offset.getY(), z + offset.getZ()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkRingYHollow(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for (int x = -sizeX; x <= sizeX; x++) {
|
||||
for (int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if ((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
} else if (!checkAir(x + offset.getX(), offset.getY(), z + offset.getZ()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles.multiblock;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -13,6 +12,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.misc.Location;
|
||||
import reborncore.common.multiblock.IMultiblockPart;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
|
@ -27,8 +27,7 @@ import techreborn.init.ModBlocks;
|
|||
import techreborn.multiblocks.MultiBlockCasing;
|
||||
import techreborn.tiles.TileMachineCasing;
|
||||
|
||||
public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider
|
||||
{
|
||||
public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider {
|
||||
|
||||
public static int euTick = 5;
|
||||
public int tickTime;
|
||||
|
@ -36,8 +35,7 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
|
|||
public RecipeCrafter crafter;
|
||||
public int capacity = 1000;
|
||||
|
||||
public TileBlastFurnace()
|
||||
{
|
||||
public TileBlastFurnace() {
|
||||
super(ConfigTechReborn.CentrifugeTier);
|
||||
// TODO configs
|
||||
int[] inputs = new int[2];
|
||||
|
@ -50,78 +48,65 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
crafter.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.BlastFurnace, 1);
|
||||
}
|
||||
|
||||
public int getHeat()
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.values())
|
||||
{
|
||||
public int getHeat() {
|
||||
for (EnumFacing direction : EnumFacing.values()) {
|
||||
TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(),
|
||||
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()));
|
||||
if (tileEntity instanceof TileMachineCasing)
|
||||
{
|
||||
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()));
|
||||
if (tileEntity instanceof TileMachineCasing) {
|
||||
if (((TileMachineCasing) tileEntity).isConnected()
|
||||
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled())
|
||||
{
|
||||
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()) {
|
||||
MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController();
|
||||
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
|
||||
location.modifyPositionFromSide(direction, 1);
|
||||
int heat = 0;
|
||||
if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ()))
|
||||
.getBlock() == tileEntity.getBlockType())
|
||||
{
|
||||
.getBlock() == tileEntity.getBlockType()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (IMultiblockPart part : casing.connectedParts)
|
||||
{
|
||||
for (IMultiblockPart part : casing.connectedParts) {
|
||||
BlockMachineCasing casing1 = (BlockMachineCasing) worldObj.getBlockState(part.getPos())
|
||||
.getBlock();
|
||||
.getBlock();
|
||||
heat += casing1
|
||||
.getHeatFromState(part.getWorld().getBlockState(part.getWorldLocation().toBlockPos()));
|
||||
.getHeatFromState(part.getWorld().getBlockState(part.getWorldLocation().toBlockPos()));
|
||||
// TODO meta fix
|
||||
}
|
||||
|
||||
if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava")
|
||||
&& worldObj
|
||||
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava"))
|
||||
{
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava")
|
||||
&& worldObj
|
||||
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava")) {
|
||||
heat += 500;
|
||||
}
|
||||
return heat;
|
||||
|
@ -132,96 +117,81 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tickTime = tagCompound.getInteger("tickTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
writeUpdateToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public void writeUpdateToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void writeUpdateToNBT(NBTTagCompound tagCompound) {
|
||||
tagCompound.setInteger("tickTime", tickTime);
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3 } : new int[] { 0, 1, 2, 3 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex >= 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.HIGH;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,138 +19,138 @@ import techreborn.init.ModBlocks;
|
|||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET;
|
||||
|
||||
public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider {
|
||||
public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this);
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public RecipeCrafter crafter;
|
||||
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this);
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileImplosionCompressor() {
|
||||
super(2);
|
||||
int[] inputs = new int[]{0, 1};
|
||||
int[] outputs = new int[]{2, 3};
|
||||
crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs);
|
||||
}
|
||||
public TileImplosionCompressor() {
|
||||
super(2);
|
||||
int[] inputs = new int[] { 0, 1 };
|
||||
int[] outputs = new int[] { 2, 3 };
|
||||
crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, getPos().down(3));
|
||||
}
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, getPos().down(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ImplosionCompressor, 1);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ImplosionCompressor, 1);
|
||||
}
|
||||
|
||||
public boolean getMutliBlock() {
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, new BlockPos(0, 2, 0));
|
||||
boolean chamber = multiblockChecker.checkRingYHollow(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
return down && chamber && up;
|
||||
}
|
||||
public boolean getMutliBlock() {
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, new BlockPos(0, 2, 0));
|
||||
boolean chamber = multiblockChecker.checkRingYHollow(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
return down && chamber && up;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if (getMutliBlock()) {
|
||||
crafter.updateEntity();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if (getMutliBlock()) {
|
||||
crafter.updateEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 1, 2, 3};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1, 2, 3 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 2 || index == 3;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 2 || index == 3;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 64000;
|
||||
}
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 64000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 64;
|
||||
}
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,18 +26,20 @@ import techreborn.config.ConfigTechReborn;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModFluids;
|
||||
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.*;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_NORMAL;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET;
|
||||
|
||||
public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider, ISidedInventory, ITileRecipeHandler<IndustrialGrinderRecipe>, IRecipeCrafterProvider {
|
||||
public class TileIndustrialGrinder extends TilePowerAcceptor
|
||||
implements IWrenchable, IFluidHandler, IInventoryProvider, ISidedInventory, ITileRecipeHandler<IndustrialGrinderRecipe>, IRecipeCrafterProvider {
|
||||
public static final int TANK_CAPACITY = 16000;
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileGrinder", 64, this);
|
||||
public Tank tank = new Tank("TileGrinder", TANK_CAPACITY, this);
|
||||
public RecipeCrafter crafter;
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public MultiblockChecker multiblockChecker;
|
||||
|
||||
public TileIndustrialGrinder()
|
||||
{
|
||||
public TileIndustrialGrinder() {
|
||||
super(ConfigTechReborn.CentrifugeTier);
|
||||
// TODO configs
|
||||
|
||||
|
@ -53,52 +55,47 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.IndustrialGrinder, 1);
|
||||
}
|
||||
|
||||
public boolean getMutliBlock() {
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0));
|
||||
boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
||||
boolean center = centerBlock.getBlock() == Blocks.WATER;
|
||||
return down && center && blade && up;
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0));
|
||||
boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
||||
boolean center = centerBlock.getBlock() == Blocks.WATER;
|
||||
return down && center && blade && up;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if(multiblockChecker == null) {
|
||||
BlockPos pos = getPos().offset(getFacing().getOpposite(), 2).down();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, pos);
|
||||
}
|
||||
if (multiblockChecker == null) {
|
||||
BlockPos pos = getPos().offset(getFacing().getOpposite(), 2).down();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, pos);
|
||||
}
|
||||
|
||||
if (getMutliBlock()) {
|
||||
crafter.updateEntity();
|
||||
|
@ -107,16 +104,14 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
|
@ -124,24 +119,20 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
if (resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury
|
||||
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate)
|
||||
{
|
||||
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate) {
|
||||
int filled = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return filled;
|
||||
|
@ -150,10 +141,8 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource == null || !resource.isFluidEqual(tank.getFluid()))
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
if (resource == null || !resource.isFluidEqual(tank.getFluid())) {
|
||||
return null;
|
||||
}
|
||||
FluidStack fluidStack = tank.drain(resource.amount, doDrain);
|
||||
|
@ -162,135 +151,120 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
FluidStack drained = tank.drain(maxDrain, doDrain);
|
||||
tank.compareAndUpdate();
|
||||
return drained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return fluid == FluidRegistry.WATER || fluid == ModFluids.fluidMercury || fluid == ModFluids.fluidSodiumpersulfate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex >= 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canCraft(TileEntity tile, IndustrialGrinderRecipe recipe) {
|
||||
FluidStack recipeFluid = recipe.fluidStack;
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if(tankFluid == null) {
|
||||
return false;
|
||||
}
|
||||
if (tankFluid.isFluidEqual(recipeFluid)) {
|
||||
if (tankFluid.amount >= recipeFluid.amount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
FluidStack recipeFluid = recipe.fluidStack;
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if (tankFluid == null) {
|
||||
return false;
|
||||
}
|
||||
if (tankFluid.isFluidEqual(recipeFluid)) {
|
||||
if (tankFluid.amount >= recipeFluid.amount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCraft(TileEntity tile, IndustrialGrinderRecipe recipe) {
|
||||
FluidStack recipeFluid = recipe.fluidStack;
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if(tankFluid == null) {
|
||||
return false;
|
||||
}
|
||||
if (tankFluid.isFluidEqual(recipeFluid)) {
|
||||
if (tankFluid.amount >= recipeFluid.amount) {
|
||||
if(tankFluid.amount == recipeFluid.amount)
|
||||
tank.setFluid(null);
|
||||
else tankFluid.amount -= recipeFluid.amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
FluidStack recipeFluid = recipe.fluidStack;
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if (tankFluid == null) {
|
||||
return false;
|
||||
}
|
||||
if (tankFluid.isFluidEqual(recipeFluid)) {
|
||||
if (tankFluid.amount >= recipeFluid.amount) {
|
||||
if (tankFluid.amount == recipeFluid.amount)
|
||||
tank.setFluid(null);
|
||||
else
|
||||
tankFluid.amount -= recipeFluid.amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,20 +19,20 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.blocks.BlockMachineFrame;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModFluids;
|
||||
import techreborn.items.ItemDusts;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.*;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_NORMAL;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET;
|
||||
|
||||
public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider, ISidedInventory, IListInfoProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(5, "Sawmill", 64, this);
|
||||
public Tank tank = new Tank("Sawmill", 16000, this);
|
||||
public Inventory inventory = new Inventory(5, "Sawmill", 64, this);
|
||||
public Tank tank = new Tank("Sawmill", 16000, this);
|
||||
|
||||
public int tickTime;
|
||||
public MultiblockChecker multiblockChecker;
|
||||
|
@ -45,53 +45,53 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha
|
|||
public void update() {
|
||||
super.update();
|
||||
if (getMutliBlock()) {
|
||||
ItemStack wood = inventory.getStackInSlot(0);
|
||||
if(tickTime == 0) {
|
||||
if (wood != null) {
|
||||
for (int id : OreDictionary.getOreIDs(wood)) {
|
||||
String name = OreDictionary.getOreName(id);
|
||||
if(name.equals("logWood") &&
|
||||
canAddOutput(2, 10) &&
|
||||
canAddOutput(3, 5) &&
|
||||
canAddOutput(4, 3) &&
|
||||
canUseEnergy(128.0F) &&
|
||||
!tank.isEmpty() &&
|
||||
tank.getFluid().amount >= 1000) {
|
||||
if(--wood.stackSize == 0)
|
||||
setInventorySlotContents(0, null);
|
||||
tank.drain(1000, true);
|
||||
useEnergy(128.0F);
|
||||
tickTime = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(++tickTime > 100) {
|
||||
Random rnd = worldObj.rand;
|
||||
addOutput(2, new ItemStack(Blocks.PLANKS, 6 + rnd.nextInt(4)));
|
||||
if(rnd.nextInt(4) != 0) {
|
||||
ItemStack pulp = ItemDusts.getDustByName("sawDust", 2 + rnd.nextInt(3));
|
||||
addOutput(3, pulp);
|
||||
}
|
||||
if(rnd.nextInt(3) == 0) {
|
||||
ItemStack paper = new ItemStack(Items.PAPER, 1 + rnd.nextInt(2));
|
||||
addOutput(4, paper);
|
||||
}
|
||||
tickTime = 0;
|
||||
}
|
||||
}
|
||||
ItemStack wood = inventory.getStackInSlot(0);
|
||||
if (tickTime == 0) {
|
||||
if (wood != null) {
|
||||
for (int id : OreDictionary.getOreIDs(wood)) {
|
||||
String name = OreDictionary.getOreName(id);
|
||||
if (name.equals("logWood") &&
|
||||
canAddOutput(2, 10) &&
|
||||
canAddOutput(3, 5) &&
|
||||
canAddOutput(4, 3) &&
|
||||
canUseEnergy(128.0F) &&
|
||||
!tank.isEmpty() &&
|
||||
tank.getFluid().amount >= 1000) {
|
||||
if (--wood.stackSize == 0)
|
||||
setInventorySlotContents(0, null);
|
||||
tank.drain(1000, true);
|
||||
useEnergy(128.0F);
|
||||
tickTime = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (++tickTime > 100) {
|
||||
Random rnd = worldObj.rand;
|
||||
addOutput(2, new ItemStack(Blocks.PLANKS, 6 + rnd.nextInt(4)));
|
||||
if (rnd.nextInt(4) != 0) {
|
||||
ItemStack pulp = ItemDusts.getDustByName("sawDust", 2 + rnd.nextInt(3));
|
||||
addOutput(3, pulp);
|
||||
}
|
||||
if (rnd.nextInt(3) == 0) {
|
||||
ItemStack paper = new ItemStack(Items.PAPER, 1 + rnd.nextInt(2));
|
||||
addOutput(4, paper);
|
||||
}
|
||||
tickTime = 0;
|
||||
}
|
||||
}
|
||||
FluidUtils.drainContainers(this, inventory, 1, 4);
|
||||
}
|
||||
|
||||
public void addOutput(int slot, ItemStack stack) {
|
||||
if(getStackInSlot(slot) == null)
|
||||
setInventorySlotContents(slot, stack);
|
||||
getStackInSlot(slot).stackSize += stack.stackSize;
|
||||
}
|
||||
public void addOutput(int slot, ItemStack stack) {
|
||||
if (getStackInSlot(slot) == null)
|
||||
setInventorySlotContents(slot, stack);
|
||||
getStackInSlot(slot).stackSize += stack.stackSize;
|
||||
}
|
||||
|
||||
public boolean canAddOutput(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
return stack == null || getInventoryStackLimit() - stack.stackSize >= amount;
|
||||
}
|
||||
public boolean canAddOutput(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
return stack == null || getInventoryStackLimit() - stack.stackSize >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
|
@ -101,11 +101,11 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha
|
|||
|
||||
public boolean getMutliBlock() {
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0));
|
||||
boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
||||
boolean center = centerBlock.getBlock() == Blocks.WATER;
|
||||
return down && center && blade && up;
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0));
|
||||
boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
||||
boolean center = centerBlock.getBlock() == Blocks.WATER;
|
||||
return down && center && blade && up;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,14 +137,14 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha
|
|||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
tickTime = tagCompound.getInteger("tickTime");
|
||||
tickTime = tagCompound.getInteger("tickTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
tagCompound.setInteger("tickTime", tickTime);
|
||||
tagCompound.setInteger("tickTime", tickTime);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha
|
|||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
if (resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury
|
||||
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate) {
|
||||
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate) {
|
||||
int filled = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return filled;
|
||||
|
@ -189,23 +189,23 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha
|
|||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return new FluidTankInfo[]{tank.getInfo()};
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 2, 3, 4, 5};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index >= 2;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index >= 2;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (tickTime != 0) {
|
||||
|
|
|
@ -18,35 +18,35 @@ import techreborn.init.ModBlocks;
|
|||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET;
|
||||
|
||||
public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, IRecipeCrafterProvider, ISidedInventory {
|
||||
public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, ISidedInventory {
|
||||
|
||||
public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileVacuumFreezer() {
|
||||
super(2);
|
||||
int[] inputs = new int[] {0};
|
||||
int[] outputs = new int[] {1};
|
||||
int[] inputs = new int[] { 0 };
|
||||
int[] outputs = new int[] { 1 };
|
||||
crafter = new RecipeCrafter(Reference.vacuumFreezerRecipe, this, 2, 1, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, getPos().down());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if(getMultiBlock())
|
||||
crafter.updateEntity();
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, getPos().down());
|
||||
}
|
||||
|
||||
public boolean getMultiBlock() {
|
||||
return multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET);
|
||||
}
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if (getMultiBlock())
|
||||
crafter.updateEntity();
|
||||
}
|
||||
|
||||
public boolean getMultiBlock() {
|
||||
return multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
|
@ -133,19 +133,19 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,
|
|||
return crafter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 1};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,15 +9,14 @@ import java.util.List;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class TileBatBox extends TileEnergyStorage implements IListInfoProvider
|
||||
{
|
||||
public class TileBatBox extends TileEnergyStorage implements IListInfoProvider {
|
||||
|
||||
public TileBatBox()
|
||||
{
|
||||
public TileBatBox() {
|
||||
super("BatBox", 2, ModBlocks.batBox, EnumPowerTier.LOW, 32, 32, 40000);
|
||||
}
|
||||
@Override public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
info.add("Batbox");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles.storage;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -9,6 +8,7 @@ import net.minecraft.util.ITickable;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.PoweredItem;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -17,8 +17,7 @@ import techreborn.blocks.storage.BlockEnergyStorage;
|
|||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, ITickable, IInventoryProvider
|
||||
{
|
||||
public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, ITickable, IInventoryProvider {
|
||||
|
||||
public Inventory inventory;
|
||||
public String name;
|
||||
|
@ -27,8 +26,8 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
public int maxInput;
|
||||
public int maxOutput;
|
||||
public int maxStorage;
|
||||
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage)
|
||||
{
|
||||
|
||||
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) {
|
||||
super(1);
|
||||
inventory = new Inventory(invSize, "Tile" + name, 64, this);
|
||||
this.wrenchDrop = wrenchDrop;
|
||||
|
@ -39,50 +38,44 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
this.maxStorage = maxStorage;
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public EnumFacing getFacing()
|
||||
{
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override public void updateEntity()
|
||||
{
|
||||
if (inventory.getStackInSlot(0) != null)
|
||||
{
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (inventory.getStackInSlot(0) != null) {
|
||||
ItemStack stack = inventory.getStackInSlot(0);
|
||||
if(!(stack.getItem() instanceof IEnergyItemInfo)){
|
||||
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
|
||||
return;
|
||||
}
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
|
||||
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack))
|
||||
{
|
||||
if (canUseEnergy(item.getMaxTransfer(stack)))
|
||||
{
|
||||
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)) {
|
||||
if (canUseEnergy(item.getMaxTransfer(stack))) {
|
||||
useEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inventory.getStackInSlot(1) != null)
|
||||
{
|
||||
if (inventory.getStackInSlot(1) != null) {
|
||||
ItemStack stack = inventory.getStackInSlot(1);
|
||||
if(!(stack.getItem() instanceof IEnergyItemInfo)){
|
||||
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
|
||||
return;
|
||||
}
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
|
||||
if (item.canProvideEnergy(stack))
|
||||
{
|
||||
if (getEnergy() != getMaxPower())
|
||||
{
|
||||
if (item.canProvideEnergy(stack)) {
|
||||
if (getEnergy() != getMaxPower()) {
|
||||
addEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
|
||||
}
|
||||
|
@ -95,54 +88,53 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing));
|
||||
}
|
||||
|
||||
@Override public float getWrenchDropRate()
|
||||
{
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(wrenchDrop);
|
||||
}
|
||||
|
||||
@Override public double getMaxPower()
|
||||
{
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return maxStorage;
|
||||
}
|
||||
|
||||
@Override public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override public EnumFacing getFacingEnum()
|
||||
{
|
||||
@Override
|
||||
public EnumFacing getFacingEnum() {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
if (block instanceof BlockEnergyStorage)
|
||||
{
|
||||
if (block instanceof BlockEnergyStorage) {
|
||||
return ((BlockEnergyStorage) block).getFacing(worldObj.getBlockState(pos));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacing() == direction;
|
||||
}
|
||||
|
||||
@Override public double getMaxOutput()
|
||||
{
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override public double getMaxInput()
|
||||
{
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
@Override public EnumPowerTier getTier()
|
||||
{
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
|
@ -151,19 +143,19 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 1};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,11 +6,9 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class TileMFE extends TileEnergyStorage
|
||||
{
|
||||
public class TileMFE extends TileEnergyStorage {
|
||||
|
||||
public TileMFE()
|
||||
{
|
||||
public TileMFE() {
|
||||
super("MFE", 2, ModBlocks.mfe, EnumPowerTier.MEDIUM, 512, 512, 4000000);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class TileMFSU extends TileEnergyStorage
|
||||
{
|
||||
public class TileMFSU extends TileEnergyStorage {
|
||||
|
||||
public TileMFSU()
|
||||
{
|
||||
public TileMFSU() {
|
||||
super("MFSU", 2, ModBlocks.mfsu, EnumPowerTier.HIGH, 2048, 2048, 40000000);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles.teir1;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -8,6 +7,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -15,25 +15,23 @@ import techreborn.api.Reference;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.utils.upgrade.UpgradeHandler;
|
||||
|
||||
public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, ISidedInventory
|
||||
{
|
||||
public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, ISidedInventory {
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileCompressor", 64, this);
|
||||
|
||||
public UpgradeHandler upgradeHandler;
|
||||
public UpgradeHandler upgradeHandler;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public int capacity = 1000;
|
||||
|
||||
public TileCompressor()
|
||||
{
|
||||
public TileCompressor() {
|
||||
super(1);
|
||||
int[] inputs = new int[1];
|
||||
inputs[0] = 0;
|
||||
int[] outputs = new int[1];
|
||||
outputs[0] = 1;
|
||||
crafter = new RecipeCrafter(Reference.compressorRecipe, this, 2, 1, inventory, inputs, outputs);
|
||||
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
|
||||
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,104 +43,86 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.Compressor, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 1;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles.teir1;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -9,16 +8,13 @@ import net.minecraft.item.crafting.FurnaceRecipes;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.utils.upgrade.UpgradeHandler;
|
||||
|
||||
public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
|
||||
{
|
||||
public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory {
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileElectricFurnace", 64, this);
|
||||
public int capacity = 1000;
|
||||
|
@ -27,17 +23,15 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
|
|||
public int cost = 8;
|
||||
int input1 = 0;
|
||||
int output = 1;
|
||||
private static final int[] SLOTS_TOP = new int[] {0};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {1};
|
||||
private static final int[] SLOTS_SIDES = new int[] {1};
|
||||
private static final int[] SLOTS_TOP = new int[] { 0 };
|
||||
private static final int[] SLOTS_BOTTOM = new int[] { 1 };
|
||||
private static final int[] SLOTS_SIDES = new int[] { 1 };
|
||||
|
||||
public TileElectricFurnace()
|
||||
{
|
||||
public TileElectricFurnace() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
public int gaugeProgressScaled(int scale)
|
||||
{
|
||||
public int gaugeProgressScaled(int scale) {
|
||||
return (progress * scale) / fuelScale;
|
||||
}
|
||||
|
||||
|
@ -46,65 +40,51 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
|
|||
super.update();
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (isBurning() && canSmelt())
|
||||
{
|
||||
if (isBurning() && canSmelt()) {
|
||||
updateState();
|
||||
|
||||
progress++;
|
||||
if(progress % 10 == 0){
|
||||
if (progress % 10 == 0) {
|
||||
useEnergy(cost);
|
||||
}
|
||||
if (progress >= fuelScale)
|
||||
{
|
||||
if (progress >= fuelScale) {
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
progress = 0;
|
||||
updateState();
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
if (burning != isBurning()) {
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
if (updateInventory) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems()
|
||||
{
|
||||
if (this.canSmelt())
|
||||
{
|
||||
public void cookItems() {
|
||||
if (this.canSmelt()) {
|
||||
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
||||
|
||||
if (getStackInSlot(output) == null)
|
||||
{
|
||||
if (getStackInSlot(output) == null) {
|
||||
setInventorySlotContents(output, itemstack.copy());
|
||||
} else if (getStackInSlot(output).isItemEqual(itemstack))
|
||||
{
|
||||
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
|
||||
getStackInSlot(output).stackSize += itemstack.stackSize;
|
||||
}
|
||||
if (getStackInSlot(input1).stackSize > 1)
|
||||
{
|
||||
if (getStackInSlot(input1).stackSize > 1) {
|
||||
this.decrStackSize(input1, 1);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
setInventorySlotContents(input1, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canSmelt()
|
||||
{
|
||||
if (getStackInSlot(input1) == null)
|
||||
{
|
||||
public boolean canSmelt() {
|
||||
if (getStackInSlot(input1) == null) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
|
@ -117,26 +97,21 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isBurning()
|
||||
{
|
||||
public boolean isBurning() {
|
||||
return getEnergy() > cost;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor(ItemStack stack)
|
||||
{
|
||||
public ItemStack getResultFor(ItemStack stack) {
|
||||
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
|
||||
if (result != null)
|
||||
{
|
||||
if (result != null) {
|
||||
return result.copy();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateState()
|
||||
{
|
||||
public void updateState() {
|
||||
IBlockState BlockStateContainer = worldObj.getBlockState(pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
|
||||
{
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0)
|
||||
blockMachineBase.setActive(progress > 0, worldObj, pos);
|
||||
|
@ -144,94 +119,79 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ElectricFurnace, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? SLOTS_BOTTOM : (side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package techreborn.tiles.teir1;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -12,34 +8,33 @@ import reborncore.api.power.EnumPowerTier;
|
|||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IContainerProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.ContainerExtractor;
|
||||
import techreborn.client.container.ContainerGrinder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.utils.upgrade.UpgradeHandler;
|
||||
|
||||
public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, IRecipeCrafterProvider, IContainerProvider
|
||||
{
|
||||
public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileExtractor", 64, this);
|
||||
|
||||
public UpgradeHandler upgradeHandler;
|
||||
public UpgradeHandler upgradeHandler;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public int capacity = 1000;
|
||||
|
||||
public TileExtractor()
|
||||
{
|
||||
public TileExtractor() {
|
||||
super(1);
|
||||
int[] inputs = new int[1];
|
||||
inputs[0] = 0;
|
||||
int[] outputs = new int[1];
|
||||
outputs[0] = 1;
|
||||
crafter = new RecipeCrafter(Reference.extractorRecipe, this, 2, 1, inventory, inputs, outputs);
|
||||
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
|
||||
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,97 +46,81 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInv
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.Extractor, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
|
@ -160,19 +139,19 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInv
|
|||
return RebornContainer.getContainerFromClass(ContainerExtractor.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 1};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package techreborn.tiles.teir1;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -12,12 +10,12 @@ import reborncore.api.power.EnumPowerTier;
|
|||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IContainerProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.ContainerCentrifuge;
|
||||
import techreborn.client.container.ContainerGrinder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.utils.upgrade.UpgradeHandler;
|
||||
|
@ -25,135 +23,116 @@ import techreborn.utils.upgrade.UpgradeHandler;
|
|||
import java.util.List;
|
||||
|
||||
public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInventoryProvider,
|
||||
IListInfoProvider, IRecipeCrafterProvider, IContainerProvider, ISidedInventory {
|
||||
|
||||
IListInfoProvider, IRecipeCrafterProvider, IContainerProvider, ISidedInventory {
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileGrinder", 64, this);
|
||||
|
||||
public UpgradeHandler upgradeHandler;
|
||||
public UpgradeHandler upgradeHandler;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public int capacity = 1000;
|
||||
|
||||
public TileGrinder()
|
||||
{
|
||||
public TileGrinder() {
|
||||
super(1);
|
||||
int[] inputs = new int[1];
|
||||
inputs[0] = 0;
|
||||
int[] outputs = new int[1];
|
||||
outputs[0] = 1;
|
||||
crafter = new RecipeCrafter(Reference.grinderRecipe, this, 2, 1, inventory, inputs, outputs);
|
||||
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
|
||||
upgradeHandler = new UpgradeHandler(crafter, inventory, 2, 3, 4, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
crafter.updateEntity();
|
||||
upgradeHandler.tick();
|
||||
upgradeHandler.tick();
|
||||
//charge(3); TODO
|
||||
charge(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.Grinder, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
inventory.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
@Override public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
info.add("Macerator");
|
||||
}
|
||||
|
||||
|
@ -172,18 +151,18 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInve
|
|||
return RebornContainer.getContainerFromClass(ContainerGrinder.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] {0, 1};
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package techreborn.tiles.teir1;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -8,14 +7,14 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.items.ItemParts;
|
||||
|
||||
public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory
|
||||
{
|
||||
public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory {
|
||||
|
||||
public Inventory inventory = new Inventory(6, "TileRecycler", 64, this);
|
||||
public int capacity = 1000;
|
||||
|
@ -27,118 +26,93 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInve
|
|||
public int input1 = 0;
|
||||
public int output = 1;
|
||||
|
||||
public TileRecycler()
|
||||
{
|
||||
public TileRecycler() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
public int gaugeProgressScaled(int scale)
|
||||
{
|
||||
public int gaugeProgressScaled(int scale) {
|
||||
return (progress * scale) / time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(worldObj.isRemote){
|
||||
public void updateEntity() {
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (getEnergy() <= cost && canRecycle())
|
||||
{
|
||||
if (getEnergy() > cost)
|
||||
{
|
||||
if (getEnergy() <= cost && canRecycle()) {
|
||||
if (getEnergy() > cost) {
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canRecycle())
|
||||
{
|
||||
if (isBurning() && canRecycle()) {
|
||||
updateState();
|
||||
|
||||
progress++;
|
||||
if (progress >= time)
|
||||
{
|
||||
if (progress >= time) {
|
||||
progress = 0;
|
||||
recycleItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
progress = 0;
|
||||
updateState();
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
if (burning != isBurning()) {
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
if (updateInventory) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void recycleItems()
|
||||
{
|
||||
if (this.canRecycle())
|
||||
{
|
||||
public void recycleItems() {
|
||||
if (this.canRecycle()) {
|
||||
ItemStack itemstack = ItemParts.getPartByName("scrap");
|
||||
int randomchance = worldObj.rand.nextInt(chance);
|
||||
|
||||
if (getStackInSlot(output) == null)
|
||||
{
|
||||
if (getStackInSlot(output) == null) {
|
||||
useEnergy(cost);
|
||||
if (randomchance == 1)
|
||||
{
|
||||
if (randomchance == 1) {
|
||||
setInventorySlotContents(output, itemstack.copy());
|
||||
}
|
||||
} else if (getStackInSlot(output).isItemEqual(itemstack))
|
||||
{
|
||||
} else if (getStackInSlot(output).isItemEqual(itemstack)) {
|
||||
useEnergy(cost);
|
||||
if (randomchance == 1)
|
||||
{
|
||||
if (randomchance == 1) {
|
||||
getStackInSlot(output).stackSize += itemstack.stackSize;
|
||||
}
|
||||
}
|
||||
if (getStackInSlot(input1).stackSize > 1)
|
||||
{
|
||||
if (getStackInSlot(input1).stackSize > 1) {
|
||||
useEnergy(cost);
|
||||
this.decrStackSize(input1, 1);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
useEnergy(cost);
|
||||
setInventorySlotContents(input1, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canRecycle()
|
||||
{
|
||||
public boolean canRecycle() {
|
||||
return getStackInSlot(input1) != null && hasSlotGotSpace(output);
|
||||
}
|
||||
|
||||
public boolean hasSlotGotSpace(int slot)
|
||||
{
|
||||
if (getStackInSlot(slot) == null)
|
||||
{
|
||||
public boolean hasSlotGotSpace(int slot) {
|
||||
if (getStackInSlot(slot) == null) {
|
||||
return true;
|
||||
} else if (getStackInSlot(slot).stackSize < getStackInSlot(slot).getMaxStackSize())
|
||||
{
|
||||
} else if (getStackInSlot(slot).stackSize < getStackInSlot(slot).getMaxStackSize()) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isBurning()
|
||||
{
|
||||
public boolean isBurning() {
|
||||
return getEnergy() > cost;
|
||||
}
|
||||
|
||||
public void updateState()
|
||||
{
|
||||
public void updateState() {
|
||||
IBlockState BlockStateContainer = worldObj.getBlockState(pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase)
|
||||
{
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0)
|
||||
blockMachineBase.setActive(progress > 0, worldObj, pos);
|
||||
|
@ -146,94 +120,79 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInve
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.recycler, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { output } : new int[] { input1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex == output)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,10 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by modmuss50 on 16/03/2016.
|
||||
*/
|
||||
public class TileHVTransformer extends TileTransformer
|
||||
{
|
||||
public class TileHVTransformer extends TileTransformer {
|
||||
|
||||
public TileHVTransformer()
|
||||
{
|
||||
super("HVTransformer", ModBlocks.hvt, EnumPowerTier.EXTREME, ConfigTechReborn.HVTransformerMaxInput, ConfigTechReborn.HVTransformerMaxOutput, ConfigTechReborn.HVTransformerMaxInput*2);
|
||||
public TileHVTransformer() {
|
||||
super("HVTransformer", ModBlocks.hvt, EnumPowerTier.EXTREME, ConfigTechReborn.HVTransformerMaxInput, ConfigTechReborn.HVTransformerMaxOutput, ConfigTechReborn.HVTransformerMaxInput * 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,12 +7,10 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by modmuss50 on 16/03/2016.
|
||||
*/
|
||||
public class TileLVTransformer extends TileTransformer
|
||||
{
|
||||
public class TileLVTransformer extends TileTransformer {
|
||||
|
||||
public TileLVTransformer()
|
||||
{
|
||||
super("LVTransformer", ModBlocks.lvt, EnumPowerTier.LOW, ConfigTechReborn.LVTransformerMaxInput, ConfigTechReborn.LVTransformerMaxOutput, ConfigTechReborn.LVTransformerMaxInput*2);
|
||||
public TileLVTransformer() {
|
||||
super("LVTransformer", ModBlocks.lvt, EnumPowerTier.LOW, ConfigTechReborn.LVTransformerMaxInput, ConfigTechReborn.LVTransformerMaxOutput, ConfigTechReborn.LVTransformerMaxInput * 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,29 +7,24 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by modmuss50 on 16/03/2016.
|
||||
*/
|
||||
public class TileMVTransformer extends TileTransformer
|
||||
{
|
||||
public class TileMVTransformer extends TileTransformer {
|
||||
|
||||
public TileMVTransformer()
|
||||
{
|
||||
super("MVTransformer", ModBlocks.mvt, EnumPowerTier.HIGH, ConfigTechReborn.MVTransformerMaxInput, ConfigTechReborn.MVTransformerMaxOutput, ConfigTechReborn.LVTransformerMaxInput*2);
|
||||
public TileMVTransformer() {
|
||||
super("MVTransformer", ModBlocks.mvt, EnumPowerTier.HIGH, ConfigTechReborn.MVTransformerMaxInput, ConfigTechReborn.MVTransformerMaxOutput, ConfigTechReborn.LVTransformerMaxInput * 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.HIGH;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package techreborn.tiles.transformers;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import techreborn.blocks.transformers.BlockTransformer;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public class TileTransformer extends TilePowerAcceptor implements IWrenchable, ITickable
|
||||
{
|
||||
public class TileTransformer extends TilePowerAcceptor implements IWrenchable, ITickable {
|
||||
|
||||
public String name;
|
||||
public Block wrenchDrop;
|
||||
|
@ -23,8 +22,7 @@ public class TileTransformer extends TilePowerAcceptor implements IWrenchable, I
|
|||
public int maxOutput;
|
||||
public int maxStorage;
|
||||
|
||||
public TileTransformer(String name, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage)
|
||||
{
|
||||
public TileTransformer(String name, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) {
|
||||
super(1);
|
||||
this.wrenchDrop = wrenchDrop;
|
||||
this.tier = tier;
|
||||
|
@ -34,70 +32,68 @@ public class TileTransformer extends TilePowerAcceptor implements IWrenchable, I
|
|||
this.maxStorage = maxStorage;
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1)
|
||||
{
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer p0, EnumFacing p1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public EnumFacing getFacing()
|
||||
{
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override public float getWrenchDropRate()
|
||||
{
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override public ItemStack getWrenchDrop(EntityPlayer p0)
|
||||
{
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer p0) {
|
||||
return new ItemStack(wrenchDrop);
|
||||
}
|
||||
|
||||
@Override public double getMaxPower()
|
||||
{
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return maxStorage;
|
||||
}
|
||||
|
||||
@Override public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override public EnumFacing getFacingEnum()
|
||||
{
|
||||
@Override
|
||||
public EnumFacing getFacingEnum() {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
if (block instanceof BlockTransformer)
|
||||
{
|
||||
if (block instanceof BlockTransformer) {
|
||||
return ((BlockTransformer) block).getFacing(worldObj.getBlockState(pos));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacing() == direction;
|
||||
}
|
||||
|
||||
|
||||
@Override public double getMaxOutput()
|
||||
{
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override public double getMaxInput()
|
||||
{
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
@Override public EnumPowerTier getTier()
|
||||
{
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return tier;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue