Multiblock fixes (compressor, freezer, grinder), grinder recipes fixes, freezer JEI recipe show fix.

This commit is contained in:
Dragon2488 2016-07-25 02:26:15 +07:00
parent 0011553cf7
commit b42b5274b5
31 changed files with 1162 additions and 1175 deletions

View file

@ -9,13 +9,11 @@ public class IndustrialGrinderRecipe extends BaseRecipe {
public FluidStack fluidStack;
public IndustrialGrinderRecipe(ItemStack input1, ItemStack input2, FluidStack fluidStack, ItemStack output1,
public IndustrialGrinderRecipe(ItemStack input1, FluidStack fluidStack, ItemStack output1,
ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) {
super(Reference.industrialGrinderRecipe, tickTime, euPerTick);
if (input1 != null)
inputs.add(input1);
if (input2 != null)
inputs.add(input2);
if (output1 != null)
addOutput(output1);
if (output2 != null)

View file

@ -9,7 +9,7 @@ import reborncore.common.blocks.IRotationTexture;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.multiblock.TileBlastFurnace;
public class BlockBlastFurnace extends BlockMachineBase implements IRotationTexture
{

View file

@ -9,7 +9,7 @@ import reborncore.common.blocks.IRotationTexture;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileImplosionCompressor;
import techreborn.tiles.multiblock.TileImplosionCompressor;
public class BlockImplosionCompressor extends BlockMachineBase implements IRotationTexture
{

View file

@ -10,7 +10,7 @@ import reborncore.common.blocks.IRotationTexture;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileIndustrialGrinder;
import techreborn.tiles.multiblock.TileIndustrialGrinder;
public class BlockIndustrialGrinder extends BlockMachineBase implements IRotationTexture
{

View file

@ -1,8 +1,13 @@
package techreborn.blocks.machine;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.blocks.BlockMachineBase;
@ -10,7 +15,7 @@ import reborncore.common.blocks.IAdvancedRotationTexture;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileVacuumFreezer;
import techreborn.tiles.multiblock.TileVacuumFreezer;
public class BlockVacuumFreezer extends BlockMachineBase implements IAdvancedRotationTexture
{
@ -25,21 +30,18 @@ public class BlockVacuumFreezer extends BlockMachineBase implements IAdvancedRot
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
public TileEntity createNewTileEntity(World world, int meta) {
return new TileVacuumFreezer();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ)
{
TileVacuumFreezer tileVacuumFreezer = (TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z));
tileVacuumFreezer.multiBlockStatus = tileVacuumFreezer.checkMachine() ? 1 : 0;
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.vacuumFreezerID, world, x, y, z);
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!player.isSneaking()) {
player.openGui(Core.INSTANCE, GuiHandler.vacuumFreezerID, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
return false;
}
@Override
public String getFront(boolean isActive)

View file

@ -14,7 +14,7 @@ import techreborn.tiles.fusionReactor.TileEntityFusionController;
import techreborn.tiles.generator.*;
import techreborn.tiles.idsu.TileIDSU;
import techreborn.tiles.lesu.TileLesu;
import techreborn.tiles.multiblock.TileIndustrialSawmill;
import techreborn.tiles.multiblock.*;
import techreborn.tiles.storage.TileBatBox;
import techreborn.tiles.storage.TileMFE;
import techreborn.tiles.storage.TileMFSU;

View file

@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IContainerListener;
import reborncore.client.gui.BaseSlot;
import reborncore.client.gui.SlotOutput;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.multiblock.TileBlastFurnace;
public class ContainerBlastFurnace extends ContainerCrafting
{

View file

@ -16,7 +16,6 @@ public abstract class ContainerCrafting extends RebornContainer
int currentNeededTicks = 0;
int energy;
@Deprecated
public ContainerCrafting(RecipeCrafter crafter)
{
this();

View file

@ -6,7 +6,7 @@ import reborncore.client.gui.BaseSlot;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.SlotOutput;
import techreborn.tiles.TileImplosionCompressor;
import techreborn.tiles.multiblock.TileImplosionCompressor;
public class ContainerImplosionCompressor extends ContainerCrafting
{

View file

@ -6,17 +6,14 @@ import reborncore.client.gui.BaseSlot;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.SlotOutput;
import techreborn.tiles.TileIndustrialGrinder;
import techreborn.tiles.multiblock.TileIndustrialGrinder;
public class ContainerIndustrialGrinder extends ContainerCrafting
{
public class ContainerIndustrialGrinder extends ContainerCrafting {
public int connectionStatus;
EntityPlayer player;
TileIndustrialGrinder tile;
public ContainerIndustrialGrinder(TileIndustrialGrinder tileGrinder, EntityPlayer player)
{
public ContainerIndustrialGrinder(TileIndustrialGrinder tileGrinder, EntityPlayer player) {
super(tileGrinder.crafter);
tile = tileGrinder;
this.player = player;
@ -31,57 +28,22 @@ public class ContainerIndustrialGrinder extends ContainerCrafting
this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 4, 113, 35));
this.addSlotToContainer(new SlotOutput(tileGrinder.inventory, 5, 131, 35));
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
for (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_)
{
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
for (int i = 0; i < this.listeners.size(); i++)
{
IContainerListener IContainerListener = this.listeners.get(i);
if (this.connectionStatus != tile.connectionStatus)
{
IContainerListener.sendProgressBarUpdate(this, 10, tile.connectionStatus);
}
}
}
@Override
public void addListener(IContainerListener crafting)
{
super.addListener(crafting);
crafting.sendProgressBarUpdate(this, 10, tile.connectionStatus);
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value)
{
if (id == 10)
{
this.connectionStatus = value;
}
}
}

View file

@ -6,17 +6,14 @@ import reborncore.client.gui.BaseSlot;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.client.gui.SlotOutput;
import techreborn.tiles.TileVacuumFreezer;
import techreborn.tiles.multiblock.TileVacuumFreezer;
public class ContainerVacuumFreezer extends ContainerCrafting
{
public class ContainerVacuumFreezer extends ContainerCrafting {
public int tickTime;
public int machineStatus;
EntityPlayer player;
TileVacuumFreezer tile;
public ContainerVacuumFreezer(TileVacuumFreezer tileAlloysmelter, EntityPlayer player)
{
public ContainerVacuumFreezer(TileVacuumFreezer tileAlloysmelter, EntityPlayer player) {
super(tileAlloysmelter.crafter);
tile = tileAlloysmelter;
this.player = player;
@ -26,58 +23,21 @@ public class ContainerVacuumFreezer extends ContainerCrafting
// outputs
this.addSlotToContainer(new SlotOutput(tileAlloysmelter.inventory, 1, 116, 35));
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
for (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
for (int i = 0; i < this.listeners.size(); i++)
{
IContainerListener IContainerListener = this.listeners.get(i);
if (this.machineStatus != tile.multiBlockStatus)
{
IContainerListener.sendProgressBarUpdate(this, 3, tile.multiBlockStatus);
}
}
}
@Override
public void addListener(IContainerListener crafting)
{
super.addListener(crafting);
crafting.sendProgressBarUpdate(this, 3, tile.multiBlockStatus);
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value)
{
super.updateProgressBar(id, value);
if (id == 3)
{
machineStatus = value;
}
}
}

View file

@ -15,7 +15,7 @@ import reborncore.common.multiblock.CoordTriplet;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.init.ModBlocks;
import techreborn.proxies.ClientProxy;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.multiblock.TileBlastFurnace;
import java.io.IOException;

View file

@ -6,10 +6,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import techreborn.client.container.ContainerImplosionCompressor;
import techreborn.tiles.TileImplosionCompressor;
import techreborn.tiles.multiblock.TileImplosionCompressor;
public class GuiImplosionCompressor extends GuiContainer
{
public class GuiImplosionCompressor extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/implosion_compressor.png");
@ -17,8 +16,7 @@ public class GuiImplosionCompressor extends GuiContainer
TileImplosionCompressor compresser;
ContainerImplosionCompressor containerImplosionCompressor;
public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser)
{
public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser) {
super(new ContainerImplosionCompressor(tilecompresser, player));
containerImplosionCompressor = (ContainerImplosionCompressor) this.inventorySlots;
this.xSize = 176;
@ -27,51 +25,41 @@ public class GuiImplosionCompressor extends GuiContainer
}
@Override
public void initGui()
{
public void initGui() {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
super.initGui();
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
{
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (containerImplosionCompressor.multIBlockState == 0)
{
if (containerImplosionCompressor.multIBlockState == 0) {
// GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38,
l + 52 + 12 - 0, -1);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
}
int j = 0;
this.mc.getTextureManager().bindTexture(texture);
j = compresser.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 60, l + 37, 176, 14, j + 1, 16);
int j = compresser.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 61, l + 37, 176, 14, j + 1, 16);
}
j = (int)(compresser.getEnergy() * 12f / compresser.getMaxPower());
if (j > 0)
{
j = (int) (compresser.getEnergy() * 12f / compresser.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 14, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.implosioncompressor.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}
}

View file

@ -2,14 +2,16 @@ package techreborn.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fluids.FluidStack;
import techreborn.client.container.ContainerIndustrialGrinder;
import techreborn.tiles.TileIndustrialGrinder;
import techreborn.tiles.multiblock.TileIndustrialGrinder;
public class GuiIndustrialGrinder extends GuiContainer
{
public class GuiIndustrialGrinder extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_grinder.png");
@ -17,75 +19,73 @@ public class GuiIndustrialGrinder extends GuiContainer
TileIndustrialGrinder grinder;
ContainerIndustrialGrinder containerGrinder;
public GuiIndustrialGrinder(EntityPlayer player, TileIndustrialGrinder tilegrinder)
{
public GuiIndustrialGrinder(EntityPlayer player, TileIndustrialGrinder tilegrinder) {
super(new ContainerIndustrialGrinder(tilegrinder, player));
this.xSize = 176;
this.ySize = 167;
grinder = tilegrinder;
containerGrinder = (ContainerIndustrialGrinder) this.inventorySlots;
}
@Override
public void initGui()
{
public void initGui() {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
super.initGui();
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
{
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
if (containerGrinder.connectionStatus == 0)
{
// GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - j, 114, 10);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38,
l + 52 + 12 - j, -1);
}
j = grinder.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 50, l + 36, 176, 14, j + 1, 16);
int progress = grinder.getProgressScaled(24);
if (progress > 0) {
this.drawTexturedModalRect(k + 50, l + 35, 176, 14, progress + 1, 16);
}
j = (int)(grinder.getEnergy() * 12f / grinder.getMaxPower());
if (j > 0)
{
this.drawTexturedModalRect(k + 132, l + 63 + 12 - j, 176, 12 - j, 14, j + 2);
int energy = (int) (grinder.getEnergy() * 12f / grinder.getMaxPower());
if (energy > 0) {
this.drawTexturedModalRect(k + 132, l + 63 + 12 - energy, 176, 12 - energy, 14, energy + 2);
}
if(!grinder.tank.isEmpty()) {
drawFluid(grinder.tank.getFluid(), k + 11, l + 66, 12, 47, grinder.tank.getCapacity());
// TODO 1.8 nope
// if (grinder.tank.getFluidAmount() != 0) {
// IIcon fluidIcon = grinder.tank.getFluid().getFluid().getIcon();
// if (fluidIcon != null) {
// this.mc.renderEngine.bindTexture(texture);
// drawTexturedModalRect(k + 7, l + 15, 176, 31, 20, 55);
//
// this.mc.renderEngine
// .bindTexture(TextureMap.locationBlocksTexture);
// int liquidHeight = grinder.tank.getFluidAmount() * 47
// / grinder.tank.getCapacity();
// GuiUtil.drawRepeated(fluidIcon, k + 11, l + 19 + 47
// - liquidHeight, 12.0D, liquidHeight, this.zLevel);
//
// this.mc.renderEngine.bindTexture(texture);
//
// drawTexturedModalRect(k + 11, l + 19, 176, 86, 12, 47);
// }
// }
mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
if (!grinder.getMutliBlock()) {
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
}
}
public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) {
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
ResourceLocation still = fluid.getFluid().getStill(fluid);
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(still.toString());
int drawHeight = (int) ((fluid.amount / (maxCapacity * 1F)) * height);
int iconHeight = sprite.getIconHeight();
int offsetHeight = drawHeight;
int iteration = 0;
while(offsetHeight != 0) {
int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight);
offsetHeight -= curHeight;
iteration++;
if(iteration > 50) break;
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = I18n.translateToLocal("tile.techreborn.industrialgrinder.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);

View file

@ -1,123 +1,55 @@
package techreborn.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import reborncore.client.gui.GuiUtil;
import reborncore.client.multiblock.MultiblockSet;
import reborncore.common.misc.Location;
import reborncore.common.multiblock.CoordTriplet;
import techreborn.client.ClientMultiBlocks;
import techreborn.client.container.ContainerVacuumFreezer;
import techreborn.proxies.ClientProxy;
import techreborn.tiles.TileVacuumFreezer;
import techreborn.tiles.multiblock.TileVacuumFreezer;
public class GuiVacuumFreezer extends GuiContainer
{
public class GuiVacuumFreezer extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/vacuum_freezer.png");
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/vacuum_freezer.png");
TileVacuumFreezer crafter;
ContainerVacuumFreezer containerVacuumFreezer;
public GuiVacuumFreezer(EntityPlayer player, TileVacuumFreezer tilealloysmelter)
{
super(new ContainerVacuumFreezer(tilealloysmelter, player));
public GuiVacuumFreezer(EntityPlayer player, TileVacuumFreezer freezer) {
super(new ContainerVacuumFreezer(freezer, player));
this.xSize = 176;
this.ySize = 167;
crafter = tilealloysmelter;
this.containerVacuumFreezer = (ContainerVacuumFreezer) this.inventorySlots;
crafter = freezer;
}
@Override
public void initGui()
{
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
GuiButton button = new GuiButton(212, k + this.xSize - 24, l + 4, 20, 20, "");
buttonList.add(button);
super.initGui();
CoordTriplet coordinates = new CoordTriplet(crafter.getPos().getX(), crafter.getPos().getY() - 5,
crafter.getPos().getZ());
if (coordinates.equals(ClientProxy.multiblockRenderEvent.anchor))
{
ClientProxy.multiblockRenderEvent.setMultiblock(null);
button.displayString = "B";
} else
{
button.displayString = "A";
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
{
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = crafter.getProgressScaled(24);
if (j > 0)
{
this.drawTexturedModalRect(k + 79, l + 37, 176, 14, j + 1, 16);
int j = crafter.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 80, l + 37, 176, 14, j + 1, 16);
}
j = (int)(crafter.getEnergy() * 12f / crafter.getMaxPower());
if (j > 0)
{
j = (int) (crafter.getEnergy() * 12f / crafter.getMaxPower());
if (j > 0) {
this.drawTexturedModalRect(k + 26, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
}
if (containerVacuumFreezer.machineStatus == 0)
{
GuiUtil.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38,
l + 52 + 12 - 0, -1);
}
if (!crafter.getMultiBlock()) {
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38, l + 52 + 12, -1);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
}
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String name = I18n.translateToLocal("tile.techreborn.vacuumfreezer.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
public void actionPerformed(GuiButton button) throws IOException
{
super.actionPerformed(button);
if (button.id == 212)
{
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null)
{
{// This code here makes a basic multiblock and then sets to the
// selected one.
MultiblockSet set = new MultiblockSet(ClientMultiBlocks.frezzer);
ClientProxy.multiblockRenderEvent.setMultiblock(set);
ClientProxy.multiblockRenderEvent.partent = new Location(crafter.getPos().getX(),
crafter.getPos().getY(), crafter.getPos().getZ(), crafter.getWorld());
ClientProxy.multiblockRenderEvent.anchor = new CoordTriplet(crafter.getPos().getX(),
crafter.getPos().getY() - 5, crafter.getPos().getZ());
}
button.displayString = "A";
} else
{
ClientProxy.multiblockRenderEvent.setMultiblock(null);
button.displayString = "B";
}
}
}
}

View file

@ -0,0 +1,76 @@
package techreborn.client.gui.widget;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.util.text.translation.LanguageMap;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import java.util.ArrayList;
public abstract class GuiWidget<T extends Container> extends GuiContainer {
public static final LanguageMap translate = ObfuscationReflectionHelper.getPrivateValue(LanguageMap.class, null, 2);
private final ArrayList<Widget> widgets = new ArrayList<>();
private final ResourceLocation background;
public GuiWidget(T inventorySlotsIn, ResourceLocation background, int xSize, int ySize) {
super(inventorySlotsIn);
this.xSize = xSize;
this.ySize = ySize;
this.background = background;
}
public T getContainer() {
return (T) inventorySlots;
}
@Override
public void initGui() {
super.initGui();
widgets.clear();
initWidgets();
}
public void addWidget(Widget widget) {
widgets.add(widget);
}
public void removeWidget(Widget widget) {
widgets.remove(widget);
}
public abstract void initWidgets();
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(background);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
String name = translate.translateKey("tile.techreborn.industrialgrinder.name");
fontRendererObj.drawString(name, xSize / 2 - fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
fontRendererObj.drawString(translate.translateKey("container.inventory"), 8, ySize - 94, 4210752);
for(Widget widget : widgets)
widget.drawWidget(this, x, y, mouseX, mouseY);
}
public FontRenderer getFontRenderer() {
return fontRendererObj;
}
}

View file

@ -0,0 +1,49 @@
package techreborn.client.gui.widget;
import net.minecraft.client.gui.GuiScreen;
import techreborn.client.gui.widget.tooltip.ToolTip;
public abstract class Widget {
private final int x, y;
protected final int width, height;
private ToolTip toolTip;
public Widget(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public ToolTip getToolTip() {
return toolTip;
}
public void setToolTip(ToolTip toolTip) {
this.toolTip = toolTip;
}
public final void drawWidget(GuiWidget gui, int cornerX, int cornerY, int mouseX, int mouseY) {
int drawX = cornerX + x;
int drawY = cornerY + y;
if(toolTip != null && drawX > mouseX && drawY > mouseY &&
drawX + width < mouseX && drawY + height < mouseY) {
toolTip.draw(gui.getFontRenderer(), mouseX, mouseY);
}
draw(gui, drawX, drawY);
}
protected abstract void draw(GuiScreen guiScreen, int x, int y);
protected abstract void mouseClick(GuiWidget guiWidget, int mouseX, int mouseY);
}

View file

@ -0,0 +1,61 @@
package techreborn.client.gui.widget.tooltip;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import reborncore.client.gui.GuiUtil;
import java.util.ArrayList;
import java.util.Collections;
public class ToolTip {
protected ArrayList<ToolTipLine> lines = new ArrayList<>();
public ToolTip(String... textLines) {
for(String text : textLines)
lines.add(new ToolTipLine(text));
}
public ToolTip(ToolTipLine... toolTipLines) {
Collections.addAll(lines, toolTipLines);
}
public ToolTip(int linesSize) {
for(int i = 0; i < linesSize; i++)
lines.add(new ToolTipLine());
}
public void addLine(ToolTipLine toolTipLine) {
lines.add(toolTipLine);
}
public void removeLine(int index) {
lines.remove(index);
}
public ToolTipLine getLine(int index) {
return lines.get(index);
}
public ArrayList<ToolTipLine> getLines() {
return lines;
}
protected void refresh() {}
public void draw(FontRenderer font, int mouseX, int mouseY) {
refresh();
int maxLineLength = 0;
int textX = mouseX + 3;
int textY = mouseY + 3;
for(ToolTipLine toolTipLine : lines) {
toolTipLine.draw(font, textX, textY);
textY += (font.FONT_HEIGHT + 3);
int lineWidth = toolTipLine.getWidth(font);
if(lineWidth > maxLineLength)
maxLineLength = lineWidth;
}
GuiUtil.drawTooltipBox(mouseX, mouseY, maxLineLength, textY + 3);
}
}

View file

@ -0,0 +1,84 @@
package techreborn.client.gui.widget.tooltip;
import net.minecraft.client.gui.FontRenderer;
public class ToolTipLine {
private String line;
private int color;
private boolean shadowed;
public ToolTipLine(String line, int color, boolean shadowed) {
this.line = line;
this.color = color;
this.shadowed = shadowed;
}
public ToolTipLine(String line, int color) {
this(line, color, false);
}
public ToolTipLine(String line, boolean shadowed) {
this(line, 0xFFFFFF, shadowed);
}
public ToolTipLine(String line) {
this(line, 0xFFFFFF, false);
}
public ToolTipLine() {
this("");
}
public String getLine() {
return line;
}
public void setLine(String line) {
this.line = line;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public boolean isShadowed() {
return shadowed;
}
public void setShadowed(boolean shadowed) {
this.shadowed = shadowed;
}
public int getWidth(FontRenderer fontRenderer) {
return fontRenderer.getStringWidth(getLine());
}
public void draw(FontRenderer fontRenderer, int x, int y) {
fontRenderer.drawString(getLine(), x, y, color, isShadowed());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ToolTipLine that = (ToolTipLine) o;
return color == that.color &&
shadowed == that.shadowed &&
line.equals(that.line);
}
@Override
public int hashCode() {
int result = line.hashCode();
result = 31 * result + color;
result = 31 * result + (shadowed ? 1 : 0);
return result;
}
}

View file

@ -14,7 +14,7 @@ import net.minecraft.util.text.translation.I18n;
import techreborn.client.gui.GuiIndustrialGrinder;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
import techreborn.tiles.TileIndustrialGrinder;
import techreborn.tiles.multiblock.TileIndustrialGrinder;
public class IndustrialGrinderRecipeCategory extends BlankRecipeCategory
{

View file

@ -29,13 +29,13 @@ public class VacuumFreezerRecipeHandler implements IRecipeHandler<VacuumFreezerR
@Override
public String getRecipeCategoryUid()
{
return RecipeCategoryUids.SCRAPBOX;
return RecipeCategoryUids.VACUUM_FREEZER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull VacuumFreezerRecipe recipe) {
return RecipeCategoryUids.SCRAPBOX;
return RecipeCategoryUids.VACUUM_FREEZER;
}
@Nonnull

View file

@ -31,9 +31,9 @@ public class MTIndustrialGrinder extends MTGeneric {
fluidStack = MinetweakerCompat.toFluidStack(fluid);
}
IndustrialGrinderRecipe r = new IndustrialGrinderRecipe(oInput1, oInput2, fluidStack, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output2), MinetweakerCompat.toStack(output3), MinetweakerCompat.toStack(output4), ticktime, euTick);
addRecipe(r);
//FIXME 25.07.2016
//IndustrialGrinderRecipe r = new IndustrialGrinderRecipe(oInput1, oInput2, fluidStack, MinetweakerCompat.toStack(output1), MinetweakerCompat.toStack(output3), MinetweakerCompat.toStack(output4), ticktime, euTick);
//addRecipe(r);
}
@ZenMethod

View file

@ -76,7 +76,7 @@ import techreborn.tiles.generator.*;
import techreborn.tiles.idsu.TileIDSU;
import techreborn.tiles.lesu.TileLesu;
import techreborn.tiles.lesu.TileLesuStorage;
import techreborn.tiles.multiblock.TileIndustrialSawmill;
import techreborn.tiles.multiblock.*;
import techreborn.tiles.storage.TileBatBox;
import techreborn.tiles.storage.TileMFE;
import techreborn.tiles.storage.TileMFSU;

File diff suppressed because it is too large Load diff

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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 {

View file

@ -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;
}
}

View file

@ -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
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,45 +185,40 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IWrencha
@Override
public boolean canCraft(TileEntity tile, IndustrialGrinderRecipe recipe) {
FluidStack recipeFluid = recipe.fluidStack;
FluidStack tankFluid = tank.getFluid();
if (recipe.fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialGrinder) {
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null) {
if(tankFluid == null) {
return false;
}
if (grinder.tank.getFluid() == recipe.fluidStack) {
if (grinder.tank.getFluidAmount() >= recipe.fluidStack.amount) {
if (tankFluid.isFluidEqual(recipeFluid)) {
if (tankFluid.amount >= recipeFluid.amount) {
return true;
}
}
}
return false;
}
@Override
public boolean onCraft(TileEntity tile, IndustrialGrinderRecipe recipe) {
FluidStack recipeFluid = recipe.fluidStack;
FluidStack tankFluid = tank.getFluid();
if (recipe.fluidStack == null) {
return true;
}
if (tile instanceof TileIndustrialGrinder) {
TileIndustrialGrinder grinder = (TileIndustrialGrinder) tile;
if (grinder.tank.getFluid() == null) {
if(tankFluid == 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);
}
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;
}

View 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;
}
}