Multiblock fixes (compressor, freezer, grinder), grinder recipes fixes, freezer JEI recipe show fix.
This commit is contained in:
parent
0011553cf7
commit
b42b5274b5
31 changed files with 1162 additions and 1175 deletions
|
@ -1,188 +0,0 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.misc.Location;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider
|
||||
{
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this);
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileImplosionCompressor()
|
||||
{
|
||||
// Input slots
|
||||
int[] inputs = new int[2];
|
||||
inputs[0] = 0;
|
||||
inputs[1] = 1;
|
||||
int[] outputs = new int[2];
|
||||
outputs[0] = 2;
|
||||
outputs[1] = 3;
|
||||
crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing()
|
||||
{
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
return new ItemStack(ModBlocks.ImplosionCompressor, 1);
|
||||
}
|
||||
|
||||
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 (!((TileMachineCasing) tileEntity).isConnected())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((tileEntity.getBlockType() instanceof BlockMachineCasing))
|
||||
{
|
||||
int heat;
|
||||
BlockMachineCasing machineCasing = (BlockMachineCasing) tileEntity.getBlockType();
|
||||
heat = machineCasing.getHeatFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));
|
||||
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
|
||||
location.modifyPositionFromSide(direction, 1);
|
||||
if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava"))
|
||||
{
|
||||
heat += 500;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
super.update();
|
||||
if (getMutliBlock()) {
|
||||
crafter.updateEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void addWailaInfo(List<String> info)
|
||||
// {
|
||||
// super.addWailaInfo(info);
|
||||
// info.add("Power Stored " + energy.getEnergyStored() +" EU");
|
||||
// if(crafter.currentRecipe !=null){
|
||||
// info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
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)
|
||||
{
|
||||
if (slotIndex >= 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
return slotIndex == 2 || slotIndex == 3;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale)
|
||||
{
|
||||
if (crafter.currentTickTime != 0)
|
||||
{
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 64000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
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 int tickTime;
|
||||
public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
|
||||
public RecipeCrafter crafter;
|
||||
public int multiBlockStatus = 0;
|
||||
|
||||
public TileVacuumFreezer() {
|
||||
// Input slots
|
||||
int[] inputs = new int[1];
|
||||
inputs[0] = 0;
|
||||
int[] outputs = new int[1];
|
||||
outputs[0] = 1;
|
||||
crafter = new RecipeCrafter(Reference.vacuumFreezerRecipe, this, 2, 1, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
crafter.updateEntity();
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
multiBlockStatus = checkMachine() ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 64000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.AlloySmelter, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)) {
|
||||
if (worldObj.getBlockState(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j,
|
||||
getPos().getZ() - zDir + k)).getBlock() != ModBlocks.MachineCasing) {
|
||||
return false;
|
||||
}
|
||||
IBlockState BlockStateContainer = worldObj.getBlockState(new BlockPos(
|
||||
getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k));
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!worldObj.isAirBlock(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j,
|
||||
getPos().getZ() - zDir + k))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft(TileEntity tile, VacuumFreezerRecipe recipe) {
|
||||
if (tile instanceof TileVacuumFreezer) {
|
||||
if (((TileVacuumFreezer) tile).multiBlockStatus == 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCraft(TileEntity tile, VacuumFreezerRecipe recipe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
|
||||
}
|
|
@ -82,4 +82,18 @@ public class MultiblockChecker {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRingYHollow(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
} else if (!checkAir(x + offset.getX(), offset.getY(), z + offset.getZ()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package techreborn.tiles;
|
||||
package techreborn.tiles.multiblock;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -6,7 +6,6 @@ import net.minecraft.inventory.ISidedInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -23,9 +22,9 @@ import techreborn.api.Reference;
|
|||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.multiblocks.MultiBlockCasing;
|
||||
import techreborn.tiles.TileMachineCasing;
|
||||
|
||||
public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider {
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
package techreborn.tiles.multiblock;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.misc.Location;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.tiles.TileMachineCasing;
|
||||
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_NORMAL;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET;
|
||||
|
||||
public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, ISidedInventory, IRecipeCrafterProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64, this);
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileImplosionCompressor() {
|
||||
int[] inputs = new int[]{0, 1};
|
||||
int[] outputs = new int[]{2, 3};
|
||||
crafter = new RecipeCrafter(Reference.implosionCompressorRecipe, this, 2, 2, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, getPos().down(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ImplosionCompressor, 1);
|
||||
}
|
||||
|
||||
public boolean getMutliBlock() {
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, new BlockPos(0, 2, 0));
|
||||
boolean chamber = multiblockChecker.checkRingYHollow(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
return down && chamber && up;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if (getMutliBlock()) {
|
||||
crafter.updateEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
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) {
|
||||
return slotIndex < 2 && isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 64000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
package techreborn.tiles;
|
||||
package techreborn.tiles.multiblock;
|
||||
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -12,6 +13,7 @@ import net.minecraftforge.fluids.*;
|
|||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
|
@ -20,36 +22,27 @@ import reborncore.common.util.Tank;
|
|||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
import techreborn.api.recipe.machines.IndustrialGrinderRecipe;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModFluids;
|
||||
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.*;
|
||||
|
||||
public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider, ISidedInventory, ITileRecipeHandler<IndustrialGrinderRecipe>, IRecipeCrafterProvider {
|
||||
public static final int TANK_CAPACITY = 16000;
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(6, "TileGrinder", 64, this);
|
||||
public Tank tank = new Tank("TileGrinder", TANK_CAPACITY, this);
|
||||
public RecipeCrafter crafter;
|
||||
public int connectionStatus;
|
||||
public MultiblockChecker multiblockChecker;
|
||||
|
||||
public TileIndustrialGrinder() {
|
||||
// TODO configs
|
||||
|
||||
int[] inputs = new int[2];
|
||||
inputs[0] = 0;
|
||||
inputs[1] = 1;
|
||||
int[] outputs = new int[4];
|
||||
outputs[0] = 2;
|
||||
outputs[1] = 3;
|
||||
outputs[2] = 4;
|
||||
outputs[3] = 5;
|
||||
int[] inputs = new int[] {0};
|
||||
int[] outputs = new int[] {2, 3, 4, 5};
|
||||
crafter = new RecipeCrafter(Reference.industrialGrinderRecipe, this, 1, 4, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,34 +65,27 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
return new ItemStack(ModBlocks.IndustrialGrinder, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
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 (((TileMachineCasing) tileEntity).isConnected()
|
||||
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()
|
||||
&& ((TileMachineCasing) tileEntity).getMultiblockController().height == 3) {
|
||||
connectionStatus = 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
connectionStatus = 0;
|
||||
return false;
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0));
|
||||
boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
||||
boolean center = centerBlock.getBlock() == Blocks.WATER;
|
||||
return down && center && blade && up;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if(multiblockChecker == null) {
|
||||
BlockPos pos = getPos().offset(getFacing().getOpposite(), 2).down();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, pos);
|
||||
}
|
||||
|
||||
if (getMutliBlock()) {
|
||||
crafter.updateEntity();
|
||||
}
|
||||
FluidUtils.drainContainers(this, inventory, 0, 5);
|
||||
FluidUtils.drainContainers(this, inventory, 1, 5);
|
||||
}
|
||||
|
||||
|
@ -118,21 +104,10 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
if (resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury
|
||||
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate) {
|
||||
if (resource != null && canFill(from, resource.getFluid())) {
|
||||
int filled = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return filled;
|
||||
|
@ -210,46 +185,41 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
|
|||
|
||||
@Override
|
||||
public boolean canCraft(TileEntity tile, IndustrialGrinderRecipe recipe) {
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if (tile instanceof TileIndustrialGrinder) {
|
||||
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
|
||||
if (grinder.tank.getFluid() == null) {
|
||||
return false;
|
||||
}
|
||||
if (grinder.tank.getFluid() == recipe.fluidStack) {
|
||||
if (grinder.tank.getFluidAmount() >= recipe.fluidStack.amount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
FluidStack recipeFluid = recipe.fluidStack;
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if(tankFluid == null) {
|
||||
return false;
|
||||
}
|
||||
if (tankFluid.isFluidEqual(recipeFluid)) {
|
||||
if (tankFluid.amount >= recipeFluid.amount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCraft(TileEntity tile, IndustrialGrinderRecipe recipe) {
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if (tile instanceof TileIndustrialGrinder) {
|
||||
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
|
||||
if (grinder.tank.getFluid() == null) {
|
||||
return false;
|
||||
}
|
||||
if (grinder.tank.getFluid() == recipe.fluidStack) {
|
||||
if (grinder.tank.getFluidAmount() >= recipe.fluidStack.amount) {
|
||||
if (grinder.tank.getFluidAmount() > 0) {
|
||||
grinder.tank.setFluid(new FluidStack(recipe.fluidStack.getFluid(),
|
||||
grinder.tank.getFluidAmount() - recipe.fluidStack.amount));
|
||||
} else {
|
||||
grinder.tank.setFluid(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
FluidStack recipeFluid = recipe.fluidStack;
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if(tankFluid == null) {
|
||||
return false;
|
||||
}
|
||||
if (tankFluid.isFluidEqual(recipeFluid)) {
|
||||
if (tankFluid.amount >= recipeFluid.amount) {
|
||||
if(tankFluid.amount == recipeFluid.amount)
|
||||
tank.setFluid(null);
|
||||
else tankFluid.amount -= recipeFluid.amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
114
src/main/java/techreborn/tiles/multiblock/TileVacuumFreezer.java
Normal file
114
src/main/java/techreborn/tiles/multiblock/TileVacuumFreezer.java
Normal file
|
@ -0,0 +1,114 @@
|
|||
package techreborn.tiles.multiblock;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.CASING_REINFORCED;
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.ZERO_OFFSET;
|
||||
|
||||
public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,IInventoryProvider, IRecipeCrafterProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileVacuumFreezer() {
|
||||
int[] inputs = new int[] {0};
|
||||
int[] outputs = new int[] {1};
|
||||
crafter = new RecipeCrafter(Reference.vacuumFreezerRecipe, this, 2, 1, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, getPos().down());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if(getMultiBlock())
|
||||
crafter.updateEntity();
|
||||
}
|
||||
|
||||
public boolean getMultiBlock() {
|
||||
return multiblockChecker.checkRectY(1, 1, CASING_REINFORCED, ZERO_OFFSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 64000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.AlloySmelter, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue