Rewrite to use new RebornCore Power API. Texture fixes.

This commit is contained in:
Dragon2488 2016-07-21 22:22:56 +07:00
parent 6f54e3801f
commit b292fdd352
77 changed files with 1342 additions and 3008 deletions

View file

@ -42,15 +42,13 @@ public class GuiAlloySmelter extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = alloysmelter.getProgressScaled(24);
if (j > 0)
{
int j = alloysmelter.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16);
}
j = alloysmelter.getEnergyScaled(12);
j = (int)(alloysmelter.getEnergy() * 24f / alloysmelter.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -45,15 +45,12 @@ public class GuiAssemblingMachine extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = assemblingmachine.getProgressScaled(20);
if (j > 0)
{
int j = assemblingmachine.getProgressScaled(20);
if (j > 0) {
this.drawTexturedModalRect(k + 86, l + 34, 176, 14, j + 1, 16);
}
j = assemblingmachine.getEnergyScaled(12);
j = (int)(assemblingmachine.getEnergy() * 12f / assemblingmachine.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -42,9 +42,7 @@ public class GuiBatbox extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = generator.getEnergyScaled(24);
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);

View file

@ -78,17 +78,15 @@ public class GuiBlastFurnace extends GuiContainer
l + 52 + 12 - 0, -1);
}
int j = 0;
this.mc.getTextureManager().bindTexture(texture);
j = blastfurnace.getProgressScaled(24);
int j = blastfurnace.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 64, l + 37, 176, 14, j + 1, 16);
}
j = blastfurnace.getEnergyScaled(12);
if (j > 0)
{
j = (int)(blastfurnace.getEnergy() * 12f / blastfurnace.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 9, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}

View file

@ -43,9 +43,7 @@ public class GuiCentrifuge extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = centrifuge.getProgressScaled(11);
int j = centrifuge.getProgressScaled(11);
if (j > 0)
{
this.drawTexturedModalRect(k + 83, l + 23 + 10 - j, 177, 15 + 10 - j, 10, j);
@ -54,10 +52,8 @@ public class GuiCentrifuge extends GuiContainer
this.drawTexturedModalRect(k + 68 + 10 - j, l + 38, 177 + 10 - j, 27, j, 10);
}
j = centrifuge.getEnergyScaled(12);
if (j > 0)
{
j = (int)(centrifuge.getEnergy() * 12f / centrifuge.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
}
}

View file

@ -42,9 +42,8 @@ public class GuiChargeBench extends GuiContainer
int j = 0;
j = chargebench.getEnergyScaled(12);
if (j > 0)
{
j = (int)(chargebench.getEnergy() * 12f / chargebench.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 10, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
}
}

View file

@ -51,9 +51,8 @@ public class GuiChemicalReactor extends GuiContainer
this.drawTexturedModalRect(k + 73, l + 39, 177, 15, 30, j);
}
j = chemicalReactor.getEnergyScaled(12);
if (j > 0)
{
j = (int)(chemicalReactor.getEnergy() * 12f / chemicalReactor.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 9, l + 32 + 12 - j, 176, 12 - j, 14, j + 2);
}

View file

@ -34,19 +34,16 @@ public class GuiCompressor extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = compressor.getProgressScaled(24);
if (j > 0)
{
int j = compressor.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = compressor.getEnergyScaled(12);
if (j > 0)
{
j = (int)(compressor.getEnergy() * 12f / compressor.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)

View file

@ -34,19 +34,16 @@ public class GuiElectricFurnace extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = furnace.gaugeProgressScaled(24);
if (j > 0)
{
int j = furnace.gaugeProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 34, 176, 14, j + 1, 16);
}
j = furnace.getEnergyScaled(12);
if (j > 0)
{
j = (int)(furnace.getEnergy() * 12f / furnace.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)

View file

@ -35,17 +35,13 @@ public class GuiExtractor extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = extractor.getProgressScaled(24);
if (j > 0)
{
int j = extractor.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = extractor.getEnergyScaled(12);
if (j > 0)
{
j = (int)(extractor.getEnergy() * 12f / extractor.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}

View file

@ -42,11 +42,8 @@ public class GuiGenerator extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = generator.getEnergyScaled(24);
if (j > 0)
{
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
}

View file

@ -43,9 +43,8 @@ public class GuiGrinder extends GuiContainer
this.drawTexturedModalRect(k + 80, l + 36, 176, 14, j + 1, 16);
}
j = grinder.getEnergyScaled(12);
if (j > 0)
{
j = (int)(grinder.getEnergy() * 12f / grinder.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}

View file

@ -58,7 +58,7 @@ public class GuiImplosionCompressor extends GuiContainer
this.drawTexturedModalRect(k + 60, l + 37, 176, 14, j + 1, 16);
}
j = compresser.getEnergyScaled(12);
j = (int)(compresser.getEnergy() * 12f / compresser.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -52,7 +52,7 @@ public class GuiIndustrialElectrolyzer extends GuiContainer
this.drawTexturedModalRect(k + 72, l + 38, 176, 14, j + 1, 16);
}
j = eletrolyzer.getEnergyScaled(12);
j = (int)(eletrolyzer.getEnergy() * 12f / eletrolyzer.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 134, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -55,7 +55,7 @@ public class GuiIndustrialGrinder extends GuiContainer
this.drawTexturedModalRect(k + 50, l + 36, 176, 14, j + 1, 16);
}
j = grinder.getEnergyScaled(12);
j = (int)(grinder.getEnergy() * 12f / grinder.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 132, l + 63 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -50,9 +50,8 @@ public class GuiIndustrialSawmill extends GuiContainer
this.drawTexturedModalRect(k + 56, l + 38, 176, 14, j - 1, 11);
}
j = sawmill.getEnergyScaled(12);
if (j > 0)
{
j = (int)(sawmill.getEnergy() * 12f / sawmill.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 33, l + 65 + 12 - j, 176, 12 - j, 14, j + 2);
}
// TODO 1.8

View file

@ -45,11 +45,8 @@ public class GuiMFE extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = generator.getEnergyScaled(24);
if (j > 0)
{
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
}
//

View file

@ -45,11 +45,8 @@ public class GuiMFSU extends GuiContainer
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = generator.getEnergyScaled(24);
if (j > 0)
{
int j = (int)(generator.getEnergy() * 24f / generator.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
}
//

View file

@ -42,7 +42,7 @@ public class GuiRecycler extends GuiContainer
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = compressor.getEnergyScaled(12);
j = (int)(compressor.getEnergy() * 12f / compressor.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -38,7 +38,7 @@ public class GuiRollingMachine extends GuiContainer
int j = this.containerRollingMachine.getBurnTimeRemainingScaled(24);
this.drawTexturedModalRect(k + 91, l + 34, 176, 14, j + 1, 19);
j = this.rollingMachine.getEnergyScaled(12);
j = (int)(rollingMachine.getEnergy() * 12f / rollingMachine.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 7, l + 33 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -44,7 +44,7 @@ public class GuiScrapboxinator extends GuiContainer
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = tile.getEnergyScaled(12);
j = (int)(tile.getEnergy() * 12f / tile.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 24, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -72,7 +72,7 @@ public class GuiVacuumFreezer extends GuiContainer
this.drawTexturedModalRect(k + 79, l + 37, 176, 14, j + 1, 16);
}
j = crafter.getEnergyScaled(12);
j = (int)(crafter.getEnergy() * 12f / crafter.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);

View file

@ -55,8 +55,7 @@ public class ItemBlockAesu extends ItemBlock
}
if (stack != null && stack.hasTagCompound())
{
((TileAesu) world.getTileEntity(pos))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
//TODO ((TileAesu) world.getTileEntity(pos)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
}
return true;
}

View file

@ -34,6 +34,8 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.Properties;
import net.minecraftforge.fml.common.Loader;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.tile.IEnergyProducerTile;
import reborncore.api.power.tile.IEnergyReceiverTile;
import reborncore.common.RebornCoreConfig;
import reborncore.common.misc.Functions;
import reborncore.common.misc.vecmath.Vecs3dCube;
@ -211,8 +213,11 @@ public class CableMultipart extends Multipart
TileEntity tile = getNeighbourTile(dir);
if(tile != null) {
EnumFacing facing = dir.getOpposite();
if (tile instanceof IEnergyInterfaceTile &&
((IEnergyInterfaceTile) tile).canAcceptEnergy(facing)) {
if (tile instanceof IEnergyReceiverTile &&
((IEnergyReceiverTile) tile).canAcceptEnergy(facing)) {
return true;
} else if(tile instanceof IEnergyProducerTile &&
((IEnergyProducerTile) tile).canProvideEnergy(facing)) {
return true;
} else if (tile instanceof IEnergyReceiver &&
((IEnergyReceiver) tile).canConnectEnergy(facing) &&

View file

@ -11,6 +11,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.api.power.tile.IEnergyReceiverTile;
import reborncore.common.RebornCoreConfig;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.mcmultipart.block.TileMultipartContainer;
@ -26,25 +27,6 @@ import java.util.function.BiFunction;
public class EnergyUtils {
/**
* Dispatches energy to available neighbours
* @param world world
* @param source source position
* @param tile controller
* @param amount amount of energy
* @return amount of energy dispatched
*/
public static double dispatchEnergyToNeighbours(World world, BlockPos source, IEnergyInterfaceTile tile, double amount) {
double energyLeft = amount;
for(EnumFacing facing : EnumFacing.VALUES) {
if(tile.canProvideEnergy(facing)) {
PowerNetReceiver receiver = getReceiver(world, facing.getOpposite(), source.offset(facing));
if(receiver != null) energyLeft -= receiver.receiveEnergy(energyLeft, false);
if(energyLeft == 0) return energyLeft;
}
}
return amount - energyLeft;
}
/**
* Same as {@link #dispatchWiresEnergyPacketRecursively(World, ArrayList, BlockPos, boolean, double)}
@ -174,8 +156,8 @@ public class EnergyUtils {
}
public static PowerNetReceiver getInternalReceiver(TileEntity tileEntity, EnumFacing side) {
if(tileEntity instanceof IEnergyInterfaceTile) {
IEnergyInterfaceTile energyInterface = (IEnergyInterfaceTile) tileEntity;
if(tileEntity instanceof IEnergyReceiverTile) {
IEnergyReceiverTile energyInterface = (IEnergyReceiverTile) tileEntity;
return new PowerNetReceiver(
(energy, simulated) -> {
if(energyInterface.canAcceptEnergy(side))

View file

@ -1,5 +1,6 @@
package techreborn.tiles;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -7,12 +8,13 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileAesu extends TilePowerAcceptor implements IWrenchable
{
public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
public static final int MAX_OUTPUT = ConfigTechReborn.AesuMaxOutput;
public static final int MAX_STORAGE = ConfigTechReborn.AesuMaxStorage;
@ -22,117 +24,116 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable
private double euChange;
private int ticks;
public TileAesu()
{
super(5);
}
@Override
public void updateEntity()
{
super.updateEntity();
if (ticks == ConfigTechReborn.AverageEuOutTickTime)
{
public void update() {
super.update();
if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
euChange = -1;
ticks = 0;
} else
{
} else {
ticks++;
euChange += getEnergy() - euLastTick;
if (euLastTick == getEnergy())
{
if (euLastTick == getEnergy()) {
euChange = 0;
}
}
euLastTick = getEnergy();
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
for(EnumFacing facing : EnumFacing.VALUES) {
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
}
}
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
@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);
dropStack.setTagCompound(new NBTTagCompound());
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
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 +142,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 +151,18 @@ public class TileAesu extends TilePowerAcceptor implements IWrenchable
}
@Override
public double getMaxPower()
{
public double getMaxPower() {
return TileAesu.MAX_STORAGE;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return getFacingEnum() != direction;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return getFacingEnum() == direction;
}
@Override
public double getMaxOutput()
{
public double getMaxOutput() {
return OUTPUT;
}
@Override
public double getMaxInput()
{
return 4096 * 2;
public EnumPowerTier getTier() {
return EnumPowerTier.INSANE;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.EXTREME;
}
}

View file

@ -18,8 +18,7 @@ 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()
{
super.updateEntity();
public void update() {
super.update();
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;
}
@ -321,4 +266,5 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II
public Inventory getInventory() {
return inventory;
}
}

View file

@ -9,25 +9,21 @@ 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.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
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);
public RecipeCrafter crafter;
public int capacity = 1000;
UpgradeHandler upgrades;
public TileAlloySmelter()
{
super(1);
public TileAlloySmelter() {
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -39,60 +35,51 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
}
@Override
public void updateEntity()
{
public void update() {
super.updateEntity();
crafter.updateEntity();
upgrades.tick();
charge(3);
//charge(3); TODO
}
@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;
@ -110,67 +97,36 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable,I
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
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()
{
return capacity;
public double getMaxPower() {
return 8000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}

View file

@ -10,23 +10,20 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
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()
{
super(2);
public TileAssemblingMachine() {
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -37,66 +34,57 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha
}
@Override
public void updateEntity()
{
super.updateEntity();
charge(3);
public void update() {
super.update();
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.AssemblyMachine, 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 } : new int[] { 0, 1, 2 };
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;
}
@ -110,49 +98,21 @@ 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()
{
return 10000;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}
@Override
@ -169,4 +129,5 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha
public RebornContainer getContainer() {
return RebornContainer.getContainerFromClass(ContainerAssemblingMachine.class, this);
}
}

View file

@ -16,8 +16,8 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.misc.Location;
import reborncore.common.multiblock.IMultiblockPart;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler;
@ -27,8 +27,7 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.multiblocks.MultiBlockCasing;
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,9 +35,7 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
public RecipeCrafter crafter;
public int capacity = 1000;
public TileBlastFurnace()
{
super(ConfigTechReborn.CentrifugeTier);
public TileBlastFurnace() {
// TODO configs
int[] inputs = new int[2];
inputs[0] = 0;
@ -50,65 +47,53 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
}
@Override
public void updateEntity()
{
super.updateEntity();
public void update() {
super.update();
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)
{
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();
heat += casing1
@ -119,9 +104,8 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,I
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"))
{
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
.getBlock().getUnlocalizedName().equals("tile.lava")) {
heat += 500;
}
return heat;
@ -132,96 +116,61 @@ 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());
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)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3 } : new int[] { 0, 1, 2, 3 };
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()
{
return 10000;
public double getMaxPower() {
return 512000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.HIGH;
}

View file

@ -13,8 +13,8 @@ import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.ContainerCentrifuge;
@ -23,9 +23,7 @@ import techreborn.init.ModBlocks;
import java.util.List;
public class TileCentrifuge extends TilePowerAcceptor
implements IWrenchable,IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider
{
public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, IListInfoProvider, IRecipeCrafterProvider, IContainerProvider {
public int tickTime;
public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this);
@ -33,9 +31,7 @@ public class TileCentrifuge extends TilePowerAcceptor
public int euTick = ConfigTechReborn.CentrifugeInputTick;
public TileCentrifuge()
{
super(2);
public TileCentrifuge() {
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -50,20 +46,16 @@ public class TileCentrifuge extends TilePowerAcceptor
}
@Override
public void updateEntity()
{
super.updateEntity();
public void update() {
super.update();
crafter.updateEntity();
charge(6);
if (inventory.getStackInSlot(6) != null)
{
// charge(6); TODO
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,105 +65,68 @@ 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()
{
return 10000;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}
@Override

View file

@ -8,35 +8,23 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyInterfaceItem;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.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()
{
super(4);
}
@Override
public void updateEntity()
{
super.updateEntity();
public void update() {
super.update();
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()));
@ -49,56 +37,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)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
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,38 +89,12 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable,II
}
@Override
public double getMaxPower()
{
return capacity;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 512;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}

View file

@ -9,8 +9,8 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
@ -24,7 +24,6 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
public TileChemicalReactor()
{
super(2);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -35,11 +34,11 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
}
@Override
public void updateEntity()
public void update()
{
super.updateEntity();
super.update();
crafter.updateEntity();
charge(3);
//charge(3); TODO
}
@Override
@ -135,31 +134,7 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl
@Override
public double getMaxPower()
{
return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
return 8000;
}
@Override

View file

@ -6,12 +6,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.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,79 +19,42 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable,II
public int euTick = 32;
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()
{
return 10000;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}

View file

@ -31,8 +31,9 @@ public class TileDigitalChest extends TileMachineBase implements IInventoryProvi
public Inventory inventory = new Inventory(3, "TileDigitalChest", storage, this);
@Override
public void updateEntity()
public void update()
{
super.update();
if (!worldObj.isRemote)
{
if (storedItem != null)

View file

@ -12,8 +12,8 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.misc.Location;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.blocks.BlockMachineCasing;
@ -28,7 +28,6 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc
public TileImplosionCompressor()
{
super(1);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -101,11 +100,10 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc
}
@Override
public void updateEntity()
public void update()
{
super.updateEntity();
if (getMutliBlock())
{
super.update();
if (getMutliBlock()) {
crafter.updateEntity();
}
}
@ -169,37 +167,13 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc
@Override
public double getMaxPower()
{
return 100000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 64;
return 64000;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
return EnumPowerTier.MEDIUM;
}
@Override

View file

@ -9,8 +9,8 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
@ -24,7 +24,6 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
public TileIndustrialElectrolyzer()
{
super(2);
// Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -38,11 +37,11 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
}
@Override
public void updateEntity()
public void update()
{
super.updateEntity();
super.update();
crafter.updateEntity();
charge(6);
//charge(6); TODO
}
@Override
@ -138,37 +137,13 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr
@Override
public double getMaxPower()
{
return 1000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
return 64000;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
return EnumPowerTier.MEDIUM;
}
@Override

View file

@ -12,8 +12,8 @@ import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
@ -24,9 +24,7 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
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 int tickTime;
@ -35,9 +33,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
public RecipeCrafter crafter;
public int connectionStatus;
public TileIndustrialGrinder()
{
super(ConfigTechReborn.CentrifugeTier);
public TileIndustrialGrinder() {
// TODO configs
int[] inputs = new int[2];
@ -52,52 +48,42 @@ public class TileIndustrialGrinder 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.IndustrialGrinder, 1);
}
public boolean isComplete()
{
public boolean isComplete() {
return false;
}
public boolean getMutliBlock()
{
for (EnumFacing direction : EnumFacing.values())
{
public boolean getMutliBlock() {
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)
{
if (tileEntity instanceof TileMachineCasing) {
if (((TileMachineCasing) tileEntity).isConnected()
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()
&& ((TileMachineCasing) tileEntity).getMultiblockController().height == 3)
{
&& ((TileMachineCasing) tileEntity).getMultiblockController().height == 3) {
connectionStatus = 1;
return true;
}
@ -108,11 +94,9 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
}
@Override
public void updateEntity()
{
super.updateEntity();
if (getMutliBlock())
{
public void update() {
super.update();
if (getMutliBlock()) {
crafter.updateEntity();
}
FluidUtils.drainContainers(this, inventory, 0, 5);
@ -120,16 +104,14 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
}
@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);
@ -137,24 +119,20 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
}
@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;
@ -163,10 +141,8 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
}
@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);
@ -175,95 +151,60 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
}
@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)
{
return new FluidTankInfo[] { tank.getInfo() };
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return new FluidTankInfo[]{tank.getInfo()};
}
// ISidedInventory
@Override
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 };
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()
{
return 10000;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}
@ -320,4 +261,5 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
public RecipeCrafter getRecipeCrafter() {
return crafter;
}
}

View file

@ -14,8 +14,8 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.misc.Location;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
@ -26,9 +26,7 @@ import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
public class TileIndustrialSawmill extends TilePowerAcceptor
implements IWrenchable, IFluidHandler,IInventoryProvider, ISidedInventory, IListInfoProvider, ITileRecipeHandler<IndustrialSawmillRecipe>, IRecipeCrafterProvider
{
public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider, ISidedInventory, IListInfoProvider, ITileRecipeHandler<IndustrialSawmillRecipe>, IRecipeCrafterProvider {
public static final int TANK_CAPACITY = 16000;
public int tickTime;
@ -36,9 +34,7 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
public Tank tank = new Tank("TileSawmill", TANK_CAPACITY, this);
public RecipeCrafter crafter;
public TileIndustrialSawmill()
{
super(2);
public TileIndustrialSawmill() {
// TODO configs
// Input slots
int[] inputs = new int[2];
@ -52,27 +48,21 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
}
@Override
public void updateEntity()
{
super.updateEntity();
if (getMutliBlock())
{
public void update() {
super.update();
if (getMutliBlock()) {
crafter.updateEntity();
}
FluidUtils.drainContainers(this, inventory, 0, 4);
FluidUtils.drainContainers(this, inventory, 1, 4);
}
public boolean getMutliBlock()
{
for (EnumFacing direction : EnumFacing.values())
{
public boolean getMutliBlock() {
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)
{
if ((tileEntity.getBlockType() instanceof BlockMachineCasing))
{
if (tileEntity instanceof TileMachineCasing) {
if ((tileEntity.getBlockType() instanceof BlockMachineCasing)) {
int heat;
BlockMachineCasing blockMachineCasing = (BlockMachineCasing) tileEntity.getBlockType();
heat = blockMachineCasing
@ -80,8 +70,7 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
location.modifyPositionFromSide(direction, 1);
if (worldObj.getBlockState(location.getBlockPos()).getBlock().getUnlocalizedName()
.equals("tile.lava"))
{
.equals("tile.lava")) {
heat += 500;
}
return true;
@ -92,51 +81,43 @@ public class TileIndustrialSawmill 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.industrialSawmill, 1);
}
public boolean isComplete()
{
public boolean isComplete() {
return false;
}
@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);
@ -145,11 +126,9 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
/* 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;
@ -158,10 +137,8 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
}
@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);
@ -170,95 +147,60 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
}
@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;
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid)
{
public boolean canDrain(EnumFacing from, Fluid fluid) {
return false;
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from)
{
return new FluidTankInfo[] { tank.getInfo() };
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return new FluidTankInfo[]{tank.getInfo()};
}
// ISidedInventory
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4 } : new int[] { 0, 1, 2, 3, 4 };
public int[] getSlotsForFace(EnumFacing side) {
return side == EnumFacing.DOWN ? new int[]{0, 1, 2, 3, 4} : new int[]{0, 1, 2, 3, 4};
}
@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;
}
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()
{
return 10000;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 64;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}
@Override

View file

@ -16,8 +16,7 @@ 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 +29,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 +44,69 @@ public class TileIronFurnace extends TileMachineBase implements IInventoryProvid
}
@Override
public void updateEntity()
{
public void update() {
super.update();
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)
{
} 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 +119,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);

View file

@ -5,71 +5,51 @@ 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() {}
}
}

View file

@ -6,15 +6,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
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,44 +21,32 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
public int progresstime = 0;
private int amplifier = 0;
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;
}
@ -84,28 +71,21 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
// return slotIndex == 6;
// }
public int maxProgresstime()
{
public int maxProgresstime() {
return fabricationRate;
}
@Override
public void updateEntity()
{
super.updateEntity();
public void update() {
super.update();
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 +94,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 +114,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;
&& 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 +163,12 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
// }
@Override
public double getMaxPower()
{
return 100000000;
}
@Override public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override public boolean canProvideEnergy(EnumFacing direction)
{
return false;
public double getMaxPower() {
return 1024000;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 4096;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.EXTREME;
}
@ -234,4 +176,5 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
public Inventory getInventory() {
return inventory;
}
}

View file

@ -5,90 +5,48 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
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()
{
super(1);
@Override
public double getMaxPower() {
return 8000;
}
@Override
public double getMaxPower()
{
return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
@Override
public void updateEntity()
{
super.updateEntity();
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0)
{
public void update() {
super.update();
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,31 +55,28 @@ 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;
}
}

View file

@ -11,7 +11,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.*;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn;
@ -24,16 +24,12 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
public Tank tank = new Tank("TilePump", 10000, this);
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)){
public void update() {
super.update();
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){
if (fluidStack != null) {
tank.fill(drainBlock(worldObj, pos.down(), true), true);
useEnergy(ConfigTechReborn.pumpExtractEU);
}
@ -80,27 +76,7 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 32;
return 16000;
}
@Override
@ -109,71 +85,62 @@ public class TilePump extends TilePowerAcceptor implements IFluidHandler {
}
@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;
}
// 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 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)
{
return new FluidTankInfo[] { tank.getInfo() };
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return new FluidTankInfo[]{tank.getInfo()};
}
}

View file

@ -19,8 +19,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 +32,44 @@ 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 update() {
super.update();
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 +78,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());
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 +122,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 +156,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;
}
@ -235,4 +200,5 @@ public class TileQuantumChest extends TileMachineBase
public Inventory getInventory() {
return inventory;
}
}

View file

@ -22,60 +22,49 @@ import techreborn.init.ModBlocks;
import java.util.List;
public class TileQuantumTank extends TileMachineBase
implements IFluidHandler,IInventoryProvider, IWrenchable, IListInfoProvider
{
public class TileQuantumTank extends TileMachineBase 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());
readFromNBT(packet.getNbtCompound());
}
@Override
public void updateEntity()
{
super.updateEntity();
if (!worldObj.isRemote)
{
public void update() {
super.update();
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()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null)
{
} 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)
{
return new FluidTankInfo[] { tank.getInfo() };
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");
}
}
@ -186,4 +159,5 @@ public class TileQuantumTank extends TileMachineBase
public Inventory getInventory() {
return inventory;
}
}

View file

@ -9,15 +9,14 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
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,34 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
public int euTick = 5;
public TileRollingMachine()
{
super(1);
@Override
public double getMaxPower() {
return 64000;
}
@Override
public double getMaxPower()
{
return 100000;
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 64;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
}
@Override
public void updateEntity()
{
super.updateEntity();
charge(2);
if (!worldObj.isRemote)
{
public void update() {
super.update();
//charge(2); TODO
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 +62,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 +71,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 +128,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,14 +155,13 @@ 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;
}
}
}

View file

@ -9,7 +9,7 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.ScrapboxList;
import techreborn.init.ModBlocks;
@ -17,11 +17,9 @@ 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;
public int cost = 20;
public int progress;
public int time = 200;
@ -30,93 +28,71 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
public int input1 = 0;
public int output = 1;
public TileScrapboxinator()
{
super(1);
}
public int gaugeProgressScaled(int scale)
{
public int gaugeProgressScaled(int scale) {
return (progress * scale) / time;
}
@Override
public void updateEntity()
{
public void update() {
super.update();
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 +100,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)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
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,45 +147,18 @@ 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()
{
return capacity;
public double getMaxPower() {
return 16000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.MEDIUM;
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
@ -227,4 +166,5 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
public Inventory getInventory() {
return inventory;
}
}

View file

@ -11,8 +11,8 @@ import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.api.recipe.ITileRecipeHandler;
@ -20,17 +20,14 @@ import techreborn.api.recipe.machines.VacuumFreezerRecipe;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ITileRecipeHandler<VacuumFreezerRecipe>, IRecipeCrafterProvider
{
public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ITileRecipeHandler<VacuumFreezerRecipe>, IRecipeCrafterProvider {
public int tickTime;
public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
public RecipeCrafter crafter;
public int multiBlockStatus = 0;
public TileVacuumFreezer()
{
super(2);
public TileVacuumFreezer() {
// Input slots
int[] inputs = new int[1];
inputs[0] = 0;
@ -40,128 +37,84 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,
}
@Override
public void updateEntity()
{
super.updateEntity();
public void update() {
super.update();
crafter.updateEntity();
if (worldObj.getTotalWorldTime() % 20 == 0)
{
if (worldObj.getTotalWorldTime() % 20 == 0) {
multiBlockStatus = checkMachine() ? 1 : 0;
}
}
@Override
public double getMaxPower()
{
return 10000;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 128;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}
@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);
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;
}
public boolean checkMachine()
{
public boolean checkMachine() {
int xDir = EnumFacing.UP.getFrontOffsetX() * 2;
int yDir = EnumFacing.UP.getFrontOffsetY() * 2;
int zDir = EnumFacing.UP.getFrontOffsetZ() * 2;
for (int i = -1; i < 2; i++)
{
for (int j = -1; j < 2; j++)
{
for (int k = -1; k < 2; k++)
{
if ((i != 0) || (j != 0) || (k != 0))
{
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
for (int k = -1; k < 2; k++) {
if ((i != 0) || (j != 0) || (k != 0)) {
if (worldObj.getBlockState(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j,
getPos().getZ() - zDir + k)).getBlock() != ModBlocks.MachineCasing)
{
getPos().getZ() - zDir + k)).getBlock() != ModBlocks.MachineCasing) {
return false;
}
IBlockState BlockStateContainer = worldObj.getBlockState(new BlockPos(
@ -169,14 +122,12 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,
BlockMachineCasing blockMachineCasing = (BlockMachineCasing) BlockStateContainer.getBlock();
if (blockMachineCasing
.getMetaFromState(BlockStateContainer) != (((i == 0) && (j == 0) && (k != 0))
|| ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 2
: 1))
{
|| ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 2
: 1)) {
return false;
}
} else if (!worldObj.isAirBlock(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j,
getPos().getZ() - zDir + k)))
{
getPos().getZ() - zDir + k))) {
return false;
}
}
@ -209,4 +160,5 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,
public RecipeCrafter getRecipeCrafter() {
return crafter;
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.util.text.ITextComponent;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
import techreborn.api.reactor.FusionReactorRecipe;
@ -15,7 +16,7 @@ import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileEntityFusionController extends TilePowerAcceptor implements IInventoryProvider
public class TileEntityFusionController extends TilePowerAcceptorProducer implements IInventoryProvider
{
public Inventory inventory = new Inventory(3, "TileEntityFusionController", 64, this);
@ -31,31 +32,23 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
FusionReactorRecipe currentRecipe = null;
boolean hasStartedCrafting = false;
public TileEntityFusionController()
{
super(4);
}
@Override
public double getMaxPower() {
return 100000000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP);
public boolean canAcceptEnergy(EnumFacing direction) {
return hasStartedCrafting;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return direction == EnumFacing.DOWN || direction == EnumFacing.UP;
public boolean canProvideEnergy(EnumFacing direction) {
return !hasStartedCrafting;
}
@Override
public double getMaxOutput()
{
public double getMaxOutput() {
if (!hasStartedCrafting)
{
return 0;
@ -63,18 +56,10 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
return 1000000;
}
@Override
public double getMaxInput() {
if (hasStartedCrafting) {
return 0;
}
return 8192;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.EXTREME;
return EnumPowerTier.INSANE;
}
@Override
@ -152,9 +137,9 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
}
@Override
public void updateEntity()
public void update()
{
super.updateEntity();
super.update();
// TODO improve this code a lot
if (worldObj.getTotalWorldTime() % 20 == 0)
@ -276,11 +261,29 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
if (!worldObj.isRemote && getEnergy() > 0 && hasStartedCrafting) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
for(EnumFacing facing : EnumFacing.VALUES) {
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
}
}
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
private boolean validateRecipe()
{
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true))
@ -333,7 +336,7 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
@Override
public String getName()
{
return null;
return "Fusion Reactor";
}
@Override

View file

@ -1,5 +1,6 @@
package techreborn.tiles.generator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -12,6 +13,7 @@ import reborncore.api.fuel.FluidPowerManager;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
@ -19,16 +21,23 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider
public class TileDieselGenerator extends TilePowerProducer 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()
{
super(ConfigTechReborn.ThermalGeneratorTier);
@Override
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
@ -131,8 +140,8 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1);
FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType());
@ -147,57 +156,28 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
if (!tank.isEmpty() && tank.getFluidType() != null
&& FluidPowerManager.fluidPowerValues.containsKey(tank.getFluidType())) {
double powerIn = FluidPowerManager.fluidPowerValues.get(tank.getFluidType());
if (getFreeSpace() >= powerIn) {
if (getMaxPower() - getEnergy() >= powerIn) {
addEnergy(powerIn, false);
tank.drain(1, true);
}
}
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower()
{
return ConfigTechReborn.ThermalGeneratorCharge;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 64;
}
@Override
public double getMaxInput()
{
return 0;
public double getMaxPower() {
return 64000;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.LOW;
return EnumPowerTier.MEDIUM;
}
@Override
public Inventory getInventory() {
return inventory;
}
}

View file

@ -9,25 +9,31 @@ import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
{
public class TileDragonEggSiphoner extends TilePowerProducer implements IWrenchable,IInventoryProvider {
public static final int euTick = ConfigTechReborn.DragonEggSiphonerOutput;
public Inventory inventory = new Inventory(3, "TileAlloySmelter", 64, this);
public TileDragonEggSiphoner()
{
super(2);
@Override
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!worldObj.isRemote) {
if (worldObj.getBlockState(new BlockPos(getPos().getX(), getPos().getY() + 1, getPos().getZ()))
@ -35,81 +41,44 @@ public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrencha
addEnergy(euTick);
}
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@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()
{
return 1000;
public double getMaxPower() {
return 256000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return euTick;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.HIGH;
}

View file

@ -1,32 +1,31 @@
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.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.powerSystem.TilePowerAcceptor;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
import java.util.HashMap;
import java.util.Map;
public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
{
public class TileGasTurbine extends TilePowerProducer implements IWrenchable, IFluidHandler,IInventoryProvider {
// TODO: run this off config
public static final int euTick = 16;
public Tank tank = new Tank("TileGasTurbine", FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Tank tank = new Tank("TileGasTurbine", Fluid.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileGasTurbine", 64, this);
Map<String, Integer> fluids = new HashMap<>();
@ -35,9 +34,7 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IF
// amounts.
double pendingWithdraw = 0.0;
public TileGasTurbine()
{
super(ConfigTechReborn.ThermalGeneratorTier);
public TileGasTurbine() {
// TODO: fix this to have Gas Turbine generator values
fluids.put("fluidhydrogen", 15000);
@ -45,107 +42,103 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IF
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
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)
{
return new FluidTankInfo[] { tank.getInfo() };
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());
readFromNBT(packet.getNbtCompound());
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1);
tank.compareAndUpdate();
@ -173,45 +166,15 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, IF
setInventorySlotContents(2, null);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower()
{
return ConfigTechReborn.ThermalGeneratorCharge;
public double getMaxPower() {
return 64000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return euTick;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}

View file

@ -1,5 +1,6 @@
package techreborn.tiles.generator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.IWrenchable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -9,37 +10,42 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileGenerator extends TilePowerAcceptor implements IWrenchable,IInventoryProvider
{
public class TileGenerator extends TilePowerProducer 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()
{
super(1);
}
public static int getItemBurnTime(ItemStack stack)
{
public static int getItemBurnTime(ItemStack stack) {
return TileEntityFurnace.getItemBurnTime(stack) / 4;
}
@Override
public void updateEntity() {
super.updateEntity();
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public void update() {
super.update();
if (worldObj.isRemote) {
return;
}
@ -69,17 +75,11 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable,IInv
lastTickBurning = isBurning;
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
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);
@ -87,68 +87,37 @@ 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()
{
return 100;
public double getMaxPower() {
return 8000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 64;
}
@Override
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);
}

View file

@ -1,30 +1,35 @@
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.powerSystem.TilePowerAcceptor;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerProducer;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileHeatGenerator extends TilePowerAcceptor implements IWrenchable
{
public class TileHeatGenerator extends TilePowerProducer implements IWrenchable {
public static final int euTick = ConfigTechReborn.HeatGeneratorOutput;
public TileHeatGenerator()
{
super(1);
@Override
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!worldObj.isRemote) {
if (worldObj.getBlockState(new BlockPos(getPos().getX() + 1, getPos().getY(), getPos().getZ()))
@ -46,89 +51,45 @@ public class TileHeatGenerator extends TilePowerAcceptor implements IWrenchable
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@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()
{
return 10000;
public double getMaxPower() {
return 16000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 64;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
// @Override
// public void addWailaInfo(List<String> info)
// {
// super.addWailaInfo(info);
// info.add("Power Generarating " + euTick +" EU/t");
//
// }
}

View file

@ -8,18 +8,14 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.oredict.OreDictionary;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import techreborn.config.ConfigTechReborn;
import techreborn.power.EnergyUtils;
public class TileLightningRod extends TilePowerAcceptor {
public class TileLightningRod extends TilePowerProducer {
private int onStatusHoldTicks = -1;
public TileLightningRod() {
super(2);
}
@Override
public void update() {
super.update();
@ -51,10 +47,6 @@ public class TileLightningRod extends TilePowerAcceptor {
}
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
public float getLightningStrikeMultiplier() {
@ -72,6 +64,17 @@ public class TileLightningRod extends TilePowerAcceptor {
return 4F;
}
@Override
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
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")) {
@ -82,32 +85,17 @@ public class TileLightningRod extends TilePowerAcceptor {
@Override
public double getMaxPower() {
return 327680;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return direction == getFacingEnum();
return 1024000;
}
@Override
public double getMaxOutput() {
return 2048;
}
@Override
public double getMaxInput() {
return 0;
return 32768;
}
@Override
public EnumPowerTier getTier() {
return EnumPowerTier.HIGH;
return EnumPowerTier.INSANE;
}
}

View file

@ -1,28 +1,27 @@
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.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.powerSystem.TilePowerAcceptor;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
import java.util.HashMap;
import java.util.Map;
public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
{
public class TileSemifluidGenerator extends TilePowerProducer implements IWrenchable, IFluidHandler,IInventoryProvider {
// TODO: run this off config
public static final int euTick = 8;
@ -35,9 +34,7 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
// amounts.
double pendingWithdraw = 0.0;
public TileSemifluidGenerator()
{
super(ConfigTechReborn.ThermalGeneratorTier);
public TileSemifluidGenerator() {
// TODO: fix this to have SemiFluid generator values
fluids.put("creosote", 3000);
@ -51,107 +48,103 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
{
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
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)
{
return new FluidTankInfo[] { tank.getInfo() };
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());
readFromNBT(packet.getNbtCompound());
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1);
@ -177,45 +170,15 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
setInventorySlotContents(2, null);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower()
{
return ConfigTechReborn.ThermalGeneratorCharge;
public double getMaxPower() {
return 16000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return euTick;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
@ -223,4 +186,5 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
public Inventory getInventory() {
return inventory;
}
}

View file

@ -2,8 +2,9 @@ package techreborn.tiles.generator;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import techreborn.blocks.generator.BlockSolarPanel;
import techreborn.power.EnergyUtils;
@ -12,22 +13,15 @@ import java.util.List;
/**
* Created by modmuss50 on 25/02/2016.
*/
public class TileSolarPanel extends TilePowerAcceptor implements ITickable
{
public class TileSolarPanel extends TilePowerProducer implements ITickable {
boolean shouldMakePower = false;
boolean lastTickSate = false;
int powerToAdd;
public TileSolarPanel()
{
super(1);
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!worldObj.isRemote) {
if (worldObj.getTotalWorldTime() % 60 == 0) {
shouldMakePower = isSunOut();
@ -41,19 +35,12 @@ public class TileSolarPanel extends TilePowerAcceptor implements ITickable
}
worldObj.setBlockState(getPos(), worldObj.getBlockState(this.getPos()).withProperty(BlockSolarPanel.ACTIVE, isSunOut()));
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@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.getLocalizedPower(
@ -61,45 +48,30 @@ public class TileSolarPanel extends TilePowerAcceptor implements ITickable
}
}
public boolean isSunOut()
{
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
@Override
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
public boolean isSunOut() {
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering()
&& worldObj.isDaytime();
}
@Override
public double getMaxPower()
{
return 1000;
public double getMaxPower() {
return 8000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 32;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
}

View file

@ -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;
@ -12,8 +11,9 @@ 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.tile.TilePowerProducer;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory;
import reborncore.common.util.Tank;
@ -21,79 +21,73 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchable, IFluidHandler,IInventoryProvider
{
public class TileThermalGenerator extends TilePowerProducer 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()
{
super(ConfigTechReborn.ThermalGeneratorTier);
@Override
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@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,35 +95,30 @@ 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)
{
return new FluidTankInfo[] { tank.getInfo() };
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());
readFromNBT(packet.getNbtCompound());
@ -137,8 +126,8 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab
@Override
// TODO optimise this code
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!worldObj.isRemote) {
FluidUtils.drainContainers(this, inventory, 0, 1);
for (EnumFacing direction : EnumFacing.values()) {
@ -172,46 +161,15 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
setInventorySlotContents(2, null);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower()
{
return ConfigTechReborn.ThermalGeneratorCharge;
public double getMaxPower() {
return 16000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 128;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}

View file

@ -2,84 +2,57 @@ package techreborn.tiles.generator;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import techreborn.power.EnergyUtils;
/**
* Created by modmuss50 on 25/02/2016.
*/
public class TileWaterMill extends TilePowerAcceptor
{
public class TileWaterMill extends TilePowerProducer {
int waterblocks = 0;
public TileWaterMill()
{
super(1);
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (worldObj.getTotalWorldTime() % 20 == 0) {
checkForWater();
}
if (waterblocks > 0) {
addEnergy(waterblocks);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
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()
{
return 1000;
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
public double getMaxPower() {
return 8000;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 32;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
}

View file

@ -1,70 +1,47 @@
package techreborn.tiles.generator;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerProducer;
import techreborn.power.EnergyUtils;
/**
* Created by modmuss50 on 25/02/2016.
*/
public class TileWindMill extends TilePowerAcceptor
{
public class TileWindMill extends TilePowerProducer {
int basePower = 16;
public TileWindMill()
{
super(2);
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (pos.getY() > 64) {
double actualPower = basePower + basePower * worldObj.getThunderStrength(1.0F);
addEnergy(actualPower);
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
}
}
@Override
public double getMaxPower()
{
return 10000;
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
addEnergy(amount - receiver.receiveEnergy(amount, false));
} else addEnergy(amount);
return 0; //Temporary hack die to my bug RebornCore
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return false;
public double getMaxPower() {
return 8000;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return true;
}
@Override
public double getMaxOutput()
{
return 128;
}
@Override
public double getMaxInput()
{
return 0;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
}

View file

@ -15,37 +15,29 @@ 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 +46,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 +57,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 +68,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 +79,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 +109,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;
}
}

View file

@ -1,19 +1,19 @@
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 net.minecraft.util.math.BlockPos;
import org.apache.commons.lang3.StringUtils;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.IWrenchable;
import reborncore.common.tile.TilePowerAcceptorProducer;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.power.EnergyUtils;
public class TileIDSU extends TilePowerAcceptor implements IWrenchable
{
public class TileIDSU extends TilePowerAcceptorProducer implements IWrenchable {
public String ownerUdid;
public int tier;
@ -23,111 +23,67 @@ public class TileIDSU extends TilePowerAcceptor implements IWrenchable
private double euChange;
private int ticks;
public TileIDSU(int tier1, int output1, int maxStorage1)
{
super(tier1);
public TileIDSU(int tier1, int output1, int maxStorage1) {
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)
{
}
@Override
public double getMaxPower()
{
public double getMaxPower() {
return 1000000000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return getFacingEnum() != direction;
public EnumPowerTier getTier() {
return EnumPowerTier.INSANE;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return getFacingEnum() == direction;
}
@Override
public double getMaxOutput()
{
return output;
}
@Override
public double getMaxInput()
{
return maxStorage;
}
@Override
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.isEmpty(ownerUdid)) {
return nbttagcompound;
}
nbttagcompound.setString("ownerUdid", this.ownerUdid);
return nbttagcompound;
}
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
euChange = -1;
@ -145,38 +101,55 @@ public class TileIDSU extends TilePowerAcceptor implements IWrenchable
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
for(EnumFacing facing : EnumFacing.VALUES) {
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
}
}
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
{
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
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);
@ -185,40 +158,32 @@ 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;
}
}
}

View file

@ -3,15 +3,14 @@ package techreborn.tiles.lesu;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory;
import techreborn.config.ConfigTechReborn;
import techreborn.power.EnergyUtils;
import java.util.ArrayList;
public class TileLesu extends TilePowerAcceptor
{// TODO wrench
public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench
public int connectedBlocks = 0;
public Inventory inventory = new Inventory(2, "TileAesu", 64, this);
@ -22,14 +21,10 @@ public class TileLesu extends TilePowerAcceptor
private int output;
private int maxStorage;
public TileLesu()
{
super(5);
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (worldObj.isRemote) {
return;
}
@ -77,53 +72,44 @@ public class TileLesu extends TilePowerAcceptor
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
for(EnumFacing facing : EnumFacing.VALUES) {
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
}
}
public double getEuChange()
{
if (euChange == -1)
{
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
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)
{
return direction != getFacingEnum();
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return direction == getFacingEnum();
}
@Override
public double getMaxOutput()
{
return output;
}
@Override
public double getMaxInput()
{
return 8192;
}
@Override
public EnumPowerTier getTier()
{
return EnumPowerTier.EXTREME;
public EnumPowerTier getTier() {
return EnumPowerTier.INSANE;
}
}

View file

@ -1,11 +1,8 @@
package techreborn.tiles.storage;
import reborncore.api.IListInfoProvider;
import reborncore.api.power.EnumPowerTier;
import techreborn.init.ModBlocks;
import java.util.List;
/**
* Created by modmuss50 on 14/03/2016.
*/

View file

@ -1,17 +1,18 @@
package techreborn.tiles.storage;
import reborncore.api.IListInfoProvider;
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 net.minecraft.util.math.BlockPos;
import reborncore.api.IListInfoProvider;
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.tile.TilePowerAcceptorProducer;
import reborncore.common.util.Inventory;
import techreborn.blocks.storage.BlockEnergyStorage;
import techreborn.power.EnergyUtils;
@ -21,7 +22,7 @@ import java.util.List;
/**
* Created by Rushmead
*/
public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, ITickable, IInventoryProvider, IListInfoProvider {
public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWrenchable, ITickable, IInventoryProvider, IListInfoProvider {
public Inventory inventory;
public String name;
@ -32,7 +33,6 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
public 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;
this.tier = tier;
@ -64,7 +64,8 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
}
@Override
public void updateEntity() {
public void update() {
super.update();
if (inventory.getStackInSlot(0) != null) {
ItemStack stack = inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
@ -92,13 +93,33 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
}
}
if (!worldObj.isRemote && getEnergy() > 0) {
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
for(EnumFacing facing : EnumFacing.VALUES) {
double disposed = emitEnergy(facing, maxOutput);
if(disposed != 0) {
maxOutput -= disposed;
useEnergy(disposed);
if (maxOutput == 0) return;
}
}
}
}
//TODO move to RebornCore
public double emitEnergy(EnumFacing enumFacing, double amount) {
BlockPos pos = getPos().offset(enumFacing);
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
worldObj, enumFacing.getOpposite(), pos);
if(receiver != null) {
return receiver.receiveEnergy(amount, false);
}
return 0;
}
@Override
public void setFacing(EnumFacing enumFacing) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing));
@ -119,12 +140,6 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
return maxStorage;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return getFacingEnum() != direction;
}
@Override
public EnumFacing getFacingEnum() {
Block block = worldObj.getBlockState(pos).getBlock();
@ -134,21 +149,6 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
return null;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return getFacing() == direction;
}
@Override
public double getMaxOutput() {
return maxOutput;
}
@Override
public double getMaxInput() {
return maxInput;
}
@Override
public EnumPowerTier getTier() {
return tier;

View file

@ -8,22 +8,19 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.init.ModBlocks;
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 RecipeCrafter crafter;
public int capacity = 1000;
public TileCompressor()
{
super(1);
public TileCompressor() {
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
@ -32,111 +29,74 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II
}
@Override
public void updateEntity()
{
super.updateEntity();
public void update() {
super.update();
crafter.updateEntity();
// upgrades.tick();
charge(3);
//charge(3); TODO
}
@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)
{
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
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)
{
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)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}

View file

@ -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,99 +8,79 @@ 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.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.init.ModBlocks;
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;
public int progress;
public int fuelScale = 100;
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()
{
super(1);
}
public int gaugeProgressScaled(int scale)
{
public int gaugeProgressScaled(int scale) {
return (progress * scale) / fuelScale;
}
@Override
public void updateEntity()
{
public void update() {
super.update();
//charge(3); TODO
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;
@ -114,26 +93,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);
@ -141,94 +115,59 @@ 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 == 2;
}
@Override
public double getMaxPower()
{
return capacity;
public double getMaxPower() {
return 16000;
}
@Override
public boolean canAcceptEnergy(EnumFacing direction)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}

View file

@ -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,24 +8,22 @@ import reborncore.api.power.EnumPowerTier;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.IWrenchable;
import reborncore.common.container.RebornContainer;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.ContainerExtractor;
import techreborn.client.container.ContainerGrinder;
import techreborn.init.ModBlocks;
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 RecipeCrafter crafter;
public int capacity = 1000;
public TileExtractor()
{
super(1);
public TileExtractor() {
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
@ -38,106 +32,68 @@ public class TileExtractor extends TilePowerAcceptor implements IWrenchable,IInv
}
@Override
public void updateEntity()
{
public void updateEntity() {
super.updateEntity();
crafter.updateEntity();
// upgrades.tick();
charge(3);
//charge(3); TODO
}
@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)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}

View file

@ -2,7 +2,6 @@ package techreborn.tiles.teir1;
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,27 +11,21 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IContainerProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.container.RebornContainer;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.Reference;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerGrinder;
import techreborn.init.ModBlocks;
import java.util.List;
public class TileGrinder extends TilePowerAcceptor implements IWrenchable,IInventoryProvider,
IListInfoProvider, IRecipeCrafterProvider, IContainerProvider
{
IListInfoProvider, IRecipeCrafterProvider, IContainerProvider {
public Inventory inventory = new Inventory(6, "TileGrinder", 64, this);
public RecipeCrafter crafter;
public int capacity = 1000;
public TileGrinder()
{
super(1);
public TileGrinder() {
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
@ -41,114 +34,72 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable,IInven
}
@Override
public void updateEntity()
{
super.updateEntity();
public void update() {
super.update();
crafter.updateEntity();
charge(3);
//charge(3); TODO
}
@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)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
}
@Override public void addInfo(List<String> info, boolean isRealTile)
{
info.add("Macerator");
}
@Override
public Inventory getInventory() {
return inventory;

View file

@ -9,13 +9,12 @@ import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.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,91 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable,IInve
public int input1 = 0;
public int output = 1;
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 update() {
super.update();
//charge(3); TODO
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 +118,59 @@ 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)
{
return side == EnumFacing.DOWN ? new int[] { output } : new int[] { input1 };
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)
{
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction)
{
return false;
}
@Override
public double getMaxOutput()
{
return 0;
}
@Override
public double getMaxInput()
{
return 32;
}
@Override
public EnumPowerTier getTier()
{
public EnumPowerTier getTier() {
return EnumPowerTier.MEDIUM;
}

View file

@ -12,7 +12,11 @@ import techreborn.blocks.transformers.BlockTransformer;
/**
* Created by Rushmead
*
* @deprecated ? If wires limited to transfer rate and doesn't burn out, what's use of the transformers?
* TODO: Rewrite, find use or remove
*/
@Deprecated
public class TileTransformer extends TilePowerAcceptor implements IWrenchable, ITickable
{

View file

@ -4,16 +4,16 @@
"transform":"forge:default-block",
"model":"orientable",
"textures":{
"particle":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off",
"particle":"techreborn:blocks/machine/advanced_machines/advanced_machine_side",
"top":"techreborn:blocks/machine/advanced_machines/machine_top",
"side":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
"side":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
}
},
"variants":{
"inventory":{
"transform":"forge:default-block",
"textures":{
"front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
}
},
"facing":{
@ -33,22 +33,22 @@
"active":{
"true":{
"textures":{
"front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_on"
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
}
},
"false":{
"textures":{
"front":"techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
"front":"techreborn:blocks/machine/advanced_machines/advanced_machine_side"
}
}
},
"inventory": {
"model": "orientable",
"textures": {
"particle": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off",
"particle": "techreborn:blocks/machine/advanced_machines/advanced_machine_side",
"top": "techreborn:blocks/machine/advanced_machines/machine_top",
"side": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off",
"front": "techreborn:blocks/machine/advanced_machines/industrial_electrolyzer_front_off"
"side": "techreborn:blocks/machine/advanced_machines/advanced_machine_side",
"front": "techreborn:blocks/machine/advanced_machines/advanced_machine_side"
}
}
}

View file

@ -5,7 +5,7 @@
"model":"orientable",
"textures":{
"particle": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"top": "techreborn:blocks/machine/generators/lightning_rod_top",
"top": "techreborn:blocks/machine/generators/gas_generator_top",
"side": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"down":"techreborn:blocks/machine/generators/lightning_rod_side_off",
"front":"techreborn:blocks/machine/generators/plasma_generator_front"
@ -44,7 +44,7 @@
"model": "orientable",
"textures": {
"particle": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"top": "techreborn:blocks/machine/generators/lightning_rod_top",
"top": "techreborn:blocks/machine/generators/gas_generator_top",
"side": "techreborn:blocks/machine/generators/lightning_rod_side_off",
"down":"techreborn:blocks/machine/generators/lightning_rod_side_off",
"front":"techreborn:blocks/machine/generators/plasma_generator_front"

View file

@ -1,6 +1,6 @@
{
"parent": "techreborn:item/techrebornItem",
"textures": {
"layer0": "techreborn:items/tool/energyCrystalEmpty"
"layer0": "techreborn:items/tool/energyCrystal"
}
}

View file

@ -1,6 +1,6 @@
{
"parent": "techreborn:item/techrebornItem",
"textures": {
"layer0": "techreborn:items/tool/lapotronCrystalEmpty"
"layer0": "techreborn:items/tool/lapotronCrystal"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B