Sawmill changes & fixes.
This commit is contained in:
parent
06fad2264f
commit
0011553cf7
16 changed files with 462 additions and 700 deletions
|
@ -23,14 +23,12 @@ import reborncore.common.multiblock.BlockMultiblockBase;
|
|||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.TileMachineCasing;
|
||||
|
||||
public class BlockMachineCasing extends BlockMultiblockBase implements ITexturedBlock
|
||||
{
|
||||
public class BlockMachineCasing extends BlockMultiblockBase implements ITexturedBlock {
|
||||
|
||||
public static final String[] types = new String[] { "standard", "reinforced", "advanced" };
|
||||
public PropertyInteger METADATA;
|
||||
public static final String[] types = new String[]{"standard", "reinforced", "advanced"};
|
||||
public static final PropertyInteger METADATA = PropertyInteger.create("type", 0, types.length);
|
||||
|
||||
public BlockMachineCasing(Material material)
|
||||
{
|
||||
public BlockMachineCasing(Material material) {
|
||||
super(material);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setUnlocalizedName("techreborn.machineCasing");
|
||||
|
@ -39,28 +37,21 @@ public class BlockMachineCasing extends BlockMultiblockBase implements ITextured
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(METADATA, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(METADATA);
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
|
||||
METADATA = PropertyInteger.create("type", 0, types.length);
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, METADATA);
|
||||
}
|
||||
|
||||
public int getHeatFromState(IBlockState state)
|
||||
{
|
||||
switch (getMetaFromState(state))
|
||||
{
|
||||
public int getHeatFromState(IBlockState state) {
|
||||
switch (getMetaFromState(state)) {
|
||||
case 0:
|
||||
return 1020 / 25;
|
||||
case 1:
|
||||
|
@ -72,55 +63,42 @@ public class BlockMachineCasing extends BlockMultiblockBase implements ITextured
|
|||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
||||
return Item.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int meta = 0; meta < types.length; meta++)
|
||||
{
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List<ItemStack> list) {
|
||||
for (int meta = 0; meta < types.length; meta++) {
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
int meta = getMetaFromState(state);
|
||||
return meta;
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
|
||||
{
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileMachineCasing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
|
||||
Block b = worldIn.getBlockState(pos).getBlock();
|
||||
return b != (Block) this && super.shouldSideBeRendered(blockState, worldIn, pos, side);
|
||||
}
|
||||
|
||||
public boolean shouldConnectToBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta)
|
||||
{
|
||||
return block == this;
|
||||
return b != this && super.shouldSideBeRendered(blockState, worldIn, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing)
|
||||
{
|
||||
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing) {
|
||||
return "techreborn:blocks/machine/machine_blocks/casing" + types[getMetaFromState(blockState)] + "_full";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates()
|
||||
{
|
||||
public int amountOfStates() {
|
||||
return types.length;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,77 +18,62 @@ import techreborn.init.ModBlocks;
|
|||
import java.security.InvalidParameterException;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockMachineFrame extends BaseBlock implements ITexturedBlock
|
||||
{
|
||||
public static final String[] types = new String[] { "machine", "advancedMachine", "highlyAdvancedMachine" };
|
||||
public PropertyInteger METADATA;
|
||||
public class BlockMachineFrame extends BaseBlock implements ITexturedBlock {
|
||||
public static final String[] types = new String[]{"machine", "advancedMachine", "highlyAdvancedMachine"};
|
||||
public static final PropertyInteger METADATA = PropertyInteger.create("type", 0, types.length - 1);
|
||||
|
||||
public BlockMachineFrame(Material material)
|
||||
{
|
||||
super(material);
|
||||
setUnlocalizedName("techreborn.machineFrame");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setHardness(1f);
|
||||
this.setDefaultState(this.getDefaultState().withProperty(METADATA, 0));
|
||||
}
|
||||
public BlockMachineFrame(Material material) {
|
||||
super(material);
|
||||
setUnlocalizedName("techreborn.machineFrame");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setHardness(1f);
|
||||
this.setDefaultState(this.getDefaultState().withProperty(METADATA, 0));
|
||||
}
|
||||
|
||||
public static ItemStack getFrameByName(String name, int count)
|
||||
{
|
||||
for (int i = 0; i < types.length; i++)
|
||||
{
|
||||
if (types[i].equalsIgnoreCase(name))
|
||||
{
|
||||
return new ItemStack(ModBlocks.machineframe, count, i);
|
||||
}
|
||||
}
|
||||
throw new InvalidParameterException("The part " + name + " could not be found.");
|
||||
}
|
||||
public static ItemStack getFrameByName(String name, int count) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i].equalsIgnoreCase(name)) {
|
||||
return new ItemStack(ModBlocks.machineframe, count, i);
|
||||
}
|
||||
}
|
||||
throw new InvalidParameterException("The part " + name + " could not be found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int meta = 0; meta < types.length; meta++)
|
||||
{
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List<ItemStack> list) {
|
||||
for (int meta = 0; meta < types.length; meta++) {
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
int meta = getMetaFromState(state);
|
||||
return meta;
|
||||
}
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing)
|
||||
{
|
||||
return "techreborn:blocks/machine/machine_blocks/" + types[getMetaFromState(blockState)] + "_machine_block";
|
||||
}
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing) {
|
||||
return "techreborn:blocks/machine/machine_blocks/" + types[getMetaFromState(blockState)] + "_machine_block";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates()
|
||||
{
|
||||
return types.length;
|
||||
}
|
||||
@Override
|
||||
public int amountOfStates() {
|
||||
return types.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(METADATA);
|
||||
}
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(METADATA);
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, METADATA);
|
||||
}
|
||||
|
||||
METADATA = PropertyInteger.create("type", 0, types.length - 1);
|
||||
return new BlockStateContainer(this, METADATA);
|
||||
}
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(METADATA, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(METADATA, meta);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import reborncore.common.blocks.IRotationTexture;
|
|||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.TileIndustrialSawmill;
|
||||
import techreborn.tiles.multiblock.TileIndustrialSawmill;
|
||||
|
||||
public class BlockIndustrialSawmill extends BlockMachineBase implements IRotationTexture
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import reborncore.api.tile.IContainerLayout;
|
||||
import reborncore.api.tile.IContainerProvider;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.client.container.*;
|
||||
import techreborn.client.gui.*;
|
||||
|
@ -15,6 +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.storage.TileBatBox;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
|
|
|
@ -3,49 +3,44 @@ package techreborn.client.container;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.client.gui.BaseSlot;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileIndustrialSawmill;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.multiblock.TileIndustrialSawmill;
|
||||
|
||||
public class ContainerIndustrialSawmill extends ContainerCrafting
|
||||
{
|
||||
public class ContainerIndustrialSawmill extends RebornContainer {
|
||||
|
||||
public int tickTime;
|
||||
EntityPlayer player;
|
||||
TileIndustrialSawmill tile;
|
||||
public int tickTime;
|
||||
EntityPlayer player;
|
||||
TileIndustrialSawmill tile;
|
||||
|
||||
public ContainerIndustrialSawmill(TileIndustrialSawmill tileIndustrialSawmill, EntityPlayer player)
|
||||
{
|
||||
super(tileIndustrialSawmill.crafter);
|
||||
tile = tileIndustrialSawmill;
|
||||
this.player = player;
|
||||
public ContainerIndustrialSawmill(TileIndustrialSawmill tileIndustrialSawmill, EntityPlayer player) {
|
||||
tile = tileIndustrialSawmill;
|
||||
this.player = player;
|
||||
|
||||
// input
|
||||
this.addSlotToContainer(new BaseSlot(tileIndustrialSawmill.inventory, 0, 32, 26));
|
||||
this.addSlotToContainer(new BaseSlot(tileIndustrialSawmill.inventory, 1, 32, 44));
|
||||
// outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 2, 84, 35));
|
||||
this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 3, 102, 35));
|
||||
this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 4, 120, 35));
|
||||
// input
|
||||
this.addSlotToContainer(new BaseSlot(tileIndustrialSawmill.inventory, 0, 32, 26));
|
||||
this.addSlotToContainer(new BaseSlot(tileIndustrialSawmill.inventory, 1, 32, 44));
|
||||
// outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 2, 84, 35));
|
||||
this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 3, 102, 35));
|
||||
this.addSlotToContainer(new SlotOutput(tileIndustrialSawmill.inventory, 4, 120, 35));
|
||||
|
||||
int i;
|
||||
|
||||
for (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 (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)
|
||||
{
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@ 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 reborncore.client.gui.GuiUtil;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import techreborn.client.container.ContainerIndustrialSawmill;
|
||||
import techreborn.tiles.TileIndustrialSawmill;
|
||||
import techreborn.tiles.multiblock.TileIndustrialSawmill;
|
||||
|
||||
public class GuiIndustrialSawmill extends GuiContainer
|
||||
{
|
||||
|
@ -22,7 +24,7 @@ public class GuiIndustrialSawmill extends GuiContainer
|
|||
super(new ContainerIndustrialSawmill(tilesawmill, player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
sawmill = tilesawmill;
|
||||
this.sawmill = tilesawmill;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,54 +42,54 @@ public class GuiIndustrialSawmill extends GuiContainer
|
|||
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;
|
||||
int progress = sawmill.getProgressScaled(24);
|
||||
this.drawTexturedModalRect(k + 56, l + 38, 176, 14, progress - 1, 11);
|
||||
|
||||
j = sawmill.getProgressScaled(24);
|
||||
if (j > 0)
|
||||
{
|
||||
this.drawTexturedModalRect(k + 56, l + 38, 176, 14, j - 1, 11);
|
||||
int energy = 13 - (int) (sawmill.getEnergy() / sawmill.getMaxPower() * 13F);
|
||||
drawTexturedModalRect(k + 36, l + 66 + energy, 179, 1 + energy, 7, 13 - energy);
|
||||
|
||||
if(!sawmill.tank.isEmpty()) {
|
||||
drawFluid(sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, sawmill.tank.getCapacity());
|
||||
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
drawTexturedModalRect(k + 14, l + 24, 179, 88, 9, 37);
|
||||
}
|
||||
|
||||
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
|
||||
// if (sawmill.tank.getFluidAmount() != 0) {
|
||||
// IIcon fluidIcon = sawmill.tank.getFluid().getFluid().getIcon();
|
||||
// if (fluidIcon != null) {
|
||||
// this.mc.renderEngine.bindTexture(texture);
|
||||
//
|
||||
//
|
||||
// this.mc.renderEngine
|
||||
// .bindTexture(TextureMap.locationBlocksTexture);
|
||||
// int liquidHeight = sawmill.tank.getFluidAmount() * 47
|
||||
// / sawmill.tank.getCapacity();
|
||||
// GuiUtil.drawRepeated(fluidIcon, k + 11, l + 19 + 47
|
||||
// - liquidHeight, 12.0D, liquidHeight, this.zLevel);
|
||||
//
|
||||
// this.mc.renderEngine.bindTexture(texture);
|
||||
// // drawTexturedModalRect(k + 7, l + 15, 176, 31, 20, 55);
|
||||
// }
|
||||
// }
|
||||
drawTexturedModalRect(k + 11, l + 19, 176, 86, 12, 47);
|
||||
if (!sawmill.getMutliBlock())
|
||||
{
|
||||
GuiUtil.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
|
||||
if (!sawmill.getMutliBlock()) {
|
||||
//GuiUtil.drawTooltipBox(k + 30, l + 50 + 12, 114, 10);
|
||||
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38,
|
||||
l + 52 + 12 - 0, -1);
|
||||
l + 52 + 12, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
String name = I18n.translateToLocal("tile.techreborn.industrialsawmill.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]), 58,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
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.industrialsawmill.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 58, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ public class RecipeCategoryUids
|
|||
public static final String INDUSTRIAL_GRINDER = "TechReborn.IndustrialGrinder";
|
||||
public static final String IMPLOSION_COMPRESSOR = "TechReborn.ImplosionCompressor";
|
||||
public static final String INDUSTRIAL_ELECTROLYZER = "TechReborn.IndustrialElectrolyzer";
|
||||
public static final String INDUSTRIAL_SAWMILL = "TechReborn.IndustrialSawmill";
|
||||
public static final String ROLLING_MACHINE = "TechReborn.RollingMachine";
|
||||
public static final String VACUUM_FREEZER = "TechReborn.VacuumFreezer";
|
||||
public static final String GRINDER = "TechReborn.Grinder";
|
||||
|
|
|
@ -40,8 +40,6 @@ import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipe
|
|||
import techreborn.compat.jei.industrialElectrolyzer.IndustrialElectrolyzerRecipeHandler;
|
||||
import techreborn.compat.jei.industrialGrinder.IndustrialGrinderRecipeCategory;
|
||||
import techreborn.compat.jei.industrialGrinder.IndustrialGrinderRecipeHandler;
|
||||
import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeCategory;
|
||||
import techreborn.compat.jei.industrialSawmill.IndustrialSawmillRecipeHandler;
|
||||
import techreborn.compat.jei.rollingMachine.RollingMachineRecipeCategory;
|
||||
import techreborn.compat.jei.rollingMachine.RollingMachineRecipeHandler;
|
||||
import techreborn.compat.jei.rollingMachine.RollingMachineRecipeMaker;
|
||||
|
@ -126,7 +124,7 @@ import java.util.List;
|
|||
new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper),
|
||||
new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper),
|
||||
new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper),
|
||||
new IndustrialSawmillRecipeCategory(guiHelper), new RollingMachineRecipeCategory(guiHelper),
|
||||
new RollingMachineRecipeCategory(guiHelper),
|
||||
new VacuumFreezerRecipeCategory(guiHelper), new GrinderRecipeCategory(guiHelper),
|
||||
new ExtractorRecipeCategory(guiHelper), new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
|
||||
|
||||
|
@ -135,7 +133,7 @@ import java.util.List;
|
|||
new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers),
|
||||
new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers),
|
||||
new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers),
|
||||
new IndustrialSawmillRecipeHandler(jeiHelpers), new RollingMachineRecipeHandler(),
|
||||
new RollingMachineRecipeHandler(),
|
||||
new VacuumFreezerRecipeHandler(jeiHelpers), new GrinderRecipeHandler(jeiHelpers),
|
||||
new ExtractorRecipeHandler(jeiHelpers), new CompressorRecipeHandler(jeiHelpers),
|
||||
new ScrapboxRecipeHandler(jeiHelpers));
|
||||
|
@ -186,7 +184,6 @@ import java.util.List;
|
|||
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
|
||||
registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14,
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
|
||||
registry.addRecipeClickArea(GuiIndustrialSawmill.class, 55, 36, 24, 16, RecipeCategoryUids.INDUSTRIAL_SAWMILL);
|
||||
registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE);
|
||||
registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER);
|
||||
registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER);
|
||||
|
@ -215,8 +212,6 @@ import java.util.List;
|
|||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IndustrialGrinder),
|
||||
RecipeCategoryUids.INDUSTRIAL_GRINDER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.industrialSawmill),
|
||||
RecipeCategoryUids.INDUSTRIAL_SAWMILL);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.RollingMachine),
|
||||
RecipeCategoryUids.ROLLING_MACHINE);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.scrapBox), RecipeCategoryUids.SCRAPBOX);
|
||||
|
@ -247,9 +242,6 @@ import java.util.List;
|
|||
0, 2, 4, 36);
|
||||
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class,
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerIndustrialSawmill.class, RecipeCategoryUids.INDUSTRIAL_SAWMILL, 0, 2,
|
||||
5, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
|
||||
36);
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
package techreborn.compat.jei.industrialSawmill;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import techreborn.client.gui.GuiIndustrialSawmill;
|
||||
import techreborn.compat.jei.RecipeCategoryUids;
|
||||
import techreborn.compat.jei.RecipeUtil;
|
||||
import techreborn.tiles.TileIndustrialSawmill;
|
||||
|
||||
public class IndustrialSawmillRecipeCategory extends BlankRecipeCategory
|
||||
{
|
||||
private static final int[] INPUT_SLOTS = { 0, 1 };
|
||||
private static final int[] OUTPUT_SLOTS = { 2, 3, 4 };
|
||||
private static final int[] INPUT_TANKS = { 0 };
|
||||
|
||||
private final IDrawable background;
|
||||
private final IDrawable blankArea; // for covering the lightning power
|
||||
// symbol
|
||||
private final IDrawable tankOverlay;
|
||||
private final String title;
|
||||
|
||||
public IndustrialSawmillRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
background = guiHelper.createDrawable(GuiIndustrialSawmill.texture, 7, 15, 141, 55);
|
||||
blankArea = guiHelper.createDrawable(GuiIndustrialSawmill.texture, 50, 45, 6, 6);
|
||||
tankOverlay = guiHelper.createDrawable(GuiIndustrialSawmill.texture, 176, 83, 12, 47);
|
||||
title = I18n.translateToLocal("tile.techreborn.industrialsawmill.name");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid()
|
||||
{
|
||||
return RecipeCategoryUids.INDUSTRIAL_SAWMILL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(@Nonnull Minecraft minecraft)
|
||||
{
|
||||
blankArea.draw(minecraft, 31, 51);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper)
|
||||
{
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
guiItemStacks.init(INPUT_SLOTS[0], true, 24, 10);
|
||||
guiItemStacks.init(INPUT_SLOTS[1], true, 24, 28);
|
||||
|
||||
guiItemStacks.init(OUTPUT_SLOTS[0], false, 76, 19);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[1], false, 94, 19);
|
||||
guiItemStacks.init(OUTPUT_SLOTS[2], false, 112, 19);
|
||||
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
guiFluidStacks.init(INPUT_TANKS[0], true, 4, 4, 12, 47, TileIndustrialSawmill.TANK_CAPACITY, true, tankOverlay);
|
||||
|
||||
if (recipeWrapper instanceof IndustrialSawmillRecipeWrapper)
|
||||
{
|
||||
IndustrialSawmillRecipeWrapper recipe = (IndustrialSawmillRecipeWrapper) recipeWrapper;
|
||||
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, INPUT_TANKS, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package techreborn.compat.jei.industrialSawmill;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
|
||||
import techreborn.compat.jei.RecipeCategoryUids;
|
||||
|
||||
public class IndustrialSawmillRecipeHandler implements IRecipeHandler<IndustrialSawmillRecipe>
|
||||
{
|
||||
@Nonnull
|
||||
private final IJeiHelpers jeiHelpers;
|
||||
|
||||
public IndustrialSawmillRecipeHandler(@Nonnull IJeiHelpers jeiHelpers)
|
||||
{
|
||||
this.jeiHelpers = jeiHelpers;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<IndustrialSawmillRecipe> getRecipeClass()
|
||||
{
|
||||
return IndustrialSawmillRecipe.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid()
|
||||
{
|
||||
return RecipeCategoryUids.INDUSTRIAL_SAWMILL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid(@Nonnull IndustrialSawmillRecipe recipe) {
|
||||
return RecipeCategoryUids.INDUSTRIAL_SAWMILL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull IndustrialSawmillRecipe recipe)
|
||||
{
|
||||
return new IndustrialSawmillRecipeWrapper(jeiHelpers, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull IndustrialSawmillRecipe recipe)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package techreborn.compat.jei.industrialSawmill;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
|
||||
import techreborn.client.gui.GuiIndustrialSawmill;
|
||||
import techreborn.compat.jei.BaseRecipeWrapper;
|
||||
|
||||
public class IndustrialSawmillRecipeWrapper extends BaseRecipeWrapper<IndustrialSawmillRecipe>
|
||||
{
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
public IndustrialSawmillRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull IndustrialSawmillRecipe baseRecipe)
|
||||
{
|
||||
super(baseRecipe);
|
||||
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiIndustrialSawmill.texture, 176, 14, 20, 12);
|
||||
|
||||
int ticksPerCycle = baseRecipe.tickTime();
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle,
|
||||
IDrawableAnimated.StartDirection.LEFT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public List<FluidStack> getFluidInputs()
|
||||
{
|
||||
if (baseRecipe.fluidStack != null)
|
||||
{
|
||||
return Collections.singletonList(baseRecipe.fluidStack);
|
||||
} else
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
|
||||
{
|
||||
super.drawAnimations(minecraft, recipeWidth, recipeHeight);
|
||||
progress.draw(minecraft, 49, 23);
|
||||
|
||||
int x = 70;
|
||||
int y = 40;
|
||||
int lineHeight = minecraft.fontRendererObj.FONT_HEIGHT;
|
||||
|
||||
minecraft.fontRendererObj.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444);
|
||||
minecraft.fontRendererObj.drawString("EU: " + baseRecipe.euPerTick + " EU/t", x, y += lineHeight, 0x444444);
|
||||
}
|
||||
}
|
|
@ -76,6 +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.storage.TileBatBox;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
|
|
|
@ -76,7 +76,6 @@ public class ModRecipes
|
|||
addChemicalReactorRecipes();
|
||||
addIndustrialElectrolyzerRecipes();
|
||||
|
||||
addIndustrialSawmillRecipes();
|
||||
addBlastFurnaceRecipes();
|
||||
addIndustrialGrinderRecipes();
|
||||
addImplosionCompressorRecipes();
|
||||
|
@ -1322,52 +1321,6 @@ public class ModRecipes
|
|||
100, 4));
|
||||
}
|
||||
|
||||
static void addIndustrialSawmillRecipes()
|
||||
{
|
||||
ItemStack pulpStack = OreDictionary.getOres("pulpWood").get(0);
|
||||
RecipeHandler.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 0), null,
|
||||
new FluidStack(FluidRegistry.WATER, 1000), new ItemStack(Blocks.PLANKS, 6, 0), pulpStack, null, 200, 30,
|
||||
false));
|
||||
RecipeHandler.addRecipe(
|
||||
new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 0), new ItemStack(Items.WATER_BUCKET), null,
|
||||
new ItemStack(Blocks.PLANKS, 6, 0), pulpStack, new ItemStack(Items.BUCKET), 200, 30, false));
|
||||
|
||||
RecipeHandler.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 1), null,
|
||||
new FluidStack(FluidRegistry.WATER, 1000), new ItemStack(Blocks.PLANKS, 6, 1), pulpStack, null, 200, 30,
|
||||
false));
|
||||
RecipeHandler.addRecipe(
|
||||
new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 1), new ItemStack(Items.WATER_BUCKET), null,
|
||||
new ItemStack(Blocks.PLANKS, 6, 1), pulpStack, new ItemStack(Items.BUCKET), 200, 30, false));
|
||||
|
||||
RecipeHandler.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 2), null,
|
||||
new FluidStack(FluidRegistry.WATER, 1000), new ItemStack(Blocks.PLANKS, 6, 2), pulpStack, null, 200, 30,
|
||||
false));
|
||||
RecipeHandler.addRecipe(
|
||||
new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 2), new ItemStack(Items.WATER_BUCKET), null,
|
||||
new ItemStack(Blocks.PLANKS, 6, 2), pulpStack, new ItemStack(Items.BUCKET), 200, 30, false));
|
||||
|
||||
RecipeHandler.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 3), null,
|
||||
new FluidStack(FluidRegistry.WATER, 1000), new ItemStack(Blocks.PLANKS, 6, 3), pulpStack, null, 200, 30,
|
||||
false));
|
||||
RecipeHandler.addRecipe(
|
||||
new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG, 1, 3), new ItemStack(Items.WATER_BUCKET), null,
|
||||
new ItemStack(Blocks.PLANKS, 6, 3), pulpStack, new ItemStack(Items.BUCKET), 200, 30, false));
|
||||
|
||||
RecipeHandler.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG2, 1, 0), null,
|
||||
new FluidStack(FluidRegistry.WATER, 1000), new ItemStack(Blocks.PLANKS, 6, 4), pulpStack, null, 200, 30,
|
||||
false));
|
||||
RecipeHandler.addRecipe(
|
||||
new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG2, 1, 0), new ItemStack(Items.WATER_BUCKET), null,
|
||||
new ItemStack(Blocks.PLANKS, 6, 4), pulpStack, new ItemStack(Items.BUCKET), 200, 30, false));
|
||||
|
||||
RecipeHandler.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG2, 1, 1), null,
|
||||
new FluidStack(FluidRegistry.WATER, 1000), new ItemStack(Blocks.PLANKS, 6, 5), pulpStack, null, 200, 30,
|
||||
false));
|
||||
RecipeHandler.addRecipe(
|
||||
new IndustrialSawmillRecipe(new ItemStack(Blocks.LOG2, 1, 1), new ItemStack(Items.WATER_BUCKET), null,
|
||||
new ItemStack(Blocks.PLANKS, 6, 5), pulpStack, new ItemStack(Items.BUCKET), 200, 30, false));
|
||||
}
|
||||
|
||||
static void addBlastFurnaceRecipes()
|
||||
{
|
||||
RecipeHandler.addRecipe(
|
||||
|
|
|
@ -1,259 +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 net.minecraftforge.fluids.*;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
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.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
|
||||
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 static final int TANK_CAPACITY = 16000;
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64, this);
|
||||
public Tank tank = new Tank("TileSawmill", TANK_CAPACITY, this);
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileIndustrialSawmill() {
|
||||
// TODO configs
|
||||
// Input slots
|
||||
int[] inputs = new int[2];
|
||||
inputs[0] = 0;
|
||||
inputs[1] = 1;
|
||||
int[] outputs = new int[3];
|
||||
outputs[0] = 2;
|
||||
outputs[1] = 3;
|
||||
outputs[2] = 4;
|
||||
crafter = new RecipeCrafter(Reference.industrialSawmillRecipe, this, 2, 3, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
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()) {
|
||||
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)) {
|
||||
int heat;
|
||||
BlockMachineCasing blockMachineCasing = (BlockMachineCasing) tileEntity.getBlockType();
|
||||
heat = blockMachineCasing
|
||||
.getHeatFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));
|
||||
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")) {
|
||||
heat += 500;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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.industrialSawmill, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
if (resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury
|
||||
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate) {
|
||||
int filled = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return filled;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
tank.compareAndUpdate();
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return fluid == FluidRegistry.WATER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
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};
|
||||
}
|
||||
|
||||
@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 || slotIndex == 4;
|
||||
}
|
||||
|
||||
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 boolean canCraft(TileEntity tile, IndustrialSawmillRecipe recipe) {
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if (tile instanceof TileIndustrialSawmill) {
|
||||
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
|
||||
if (sawmill.tank.getFluid() == null) {
|
||||
return false;
|
||||
}
|
||||
if (sawmill.tank.getFluid() == recipe.fluidStack) {
|
||||
if (sawmill.tank.getFluidAmount() >= recipe.fluidStack.amount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCraft(TileEntity tile, IndustrialSawmillRecipe recipe) {
|
||||
if (recipe.fluidStack == null) {
|
||||
return true;
|
||||
}
|
||||
if (tile instanceof TileIndustrialSawmill) {
|
||||
TileIndustrialSawmill sawmill = (TileIndustrialSawmill) tile;
|
||||
if (sawmill.tank.getFluid() == null) {
|
||||
return false;
|
||||
}
|
||||
if (sawmill.tank.getFluid() == recipe.fluidStack) {
|
||||
if (sawmill.tank.getFluidAmount() >= recipe.fluidStack.amount) {
|
||||
if (sawmill.tank.getFluidAmount() > 0) {
|
||||
sawmill.tank.setFluid(new FluidStack(recipe.fluidStack.getFluid(),
|
||||
sawmill.tank.getFluidAmount() - recipe.fluidStack.amount));
|
||||
} else {
|
||||
sawmill.tank.setFluid(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package techreborn.tiles.multiblock;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class MultiblockChecker {
|
||||
|
||||
public static final BlockPos ZERO_OFFSET = BlockPos.ORIGIN;
|
||||
|
||||
public static final int CASING_NORMAL = 0;
|
||||
public static final int CASING_REINFORCED = 1;
|
||||
public static final int CASING_ADVANCED = 2;
|
||||
|
||||
private final World world;
|
||||
private final BlockPos downCenter;
|
||||
|
||||
public MultiblockChecker(World world, BlockPos downCenter) {
|
||||
this.world = world;
|
||||
this.downCenter = downCenter;
|
||||
}
|
||||
|
||||
public boolean checkCasing(int offX, int offY, int offZ, int type) {
|
||||
IBlockState block = getBlock(offX, offY, offZ);
|
||||
if(block.getBlock() == ModBlocks.MachineCasing) {
|
||||
if(block.getValue(BlockMachineCasing.METADATA) == type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkAir(int offX, int offY, int offZ) {
|
||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
||||
return world.isAirBlock(pos);
|
||||
}
|
||||
|
||||
public IBlockState getBlock(int offX, int offY, int offZ) {
|
||||
BlockPos pos = downCenter.add(offX, offY, offZ);
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
public boolean checkRectY(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if(!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRectZ(int sizeX, int sizeY, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int y = -sizeY; y <= sizeY; y++) {
|
||||
if(!checkCasing(x + offset.getX(), y + offset.getY(), offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRectX(int sizeZ, int sizeY, int casingType, BlockPos offset) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
for(int y = -sizeY; y <= sizeY; y++) {
|
||||
if(!checkCasing(offset.getX(), y + offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkRingY(int sizeX, int sizeZ, int casingType, BlockPos offset) {
|
||||
for(int x = -sizeX; x <= sizeX; x++) {
|
||||
for(int z = -sizeZ; z <= sizeZ; z++) {
|
||||
if((x == sizeX || x == -sizeX) || (z == sizeZ || z == -sizeZ)) {
|
||||
if (!checkCasing(x + offset.getX(), offset.getY(), z + offset.getZ(), casingType))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,229 @@
|
|||
package techreborn.tiles.multiblock;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.blocks.BlockMachineFrame;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModFluids;
|
||||
import techreborn.items.ItemDusts;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static techreborn.tiles.multiblock.MultiblockChecker.*;
|
||||
|
||||
public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventoryProvider, ISidedInventory, IListInfoProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(5, "Sawmill", 64, this);
|
||||
public Tank tank = new Tank("Sawmill", 16000, this);
|
||||
|
||||
public int tickTime;
|
||||
public MultiblockChecker multiblockChecker;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if (getMutliBlock()) {
|
||||
ItemStack wood = inventory.getStackInSlot(0);
|
||||
if(tickTime == 0) {
|
||||
if (wood != null) {
|
||||
for (int id : OreDictionary.getOreIDs(wood)) {
|
||||
String name = OreDictionary.getOreName(id);
|
||||
if(name.equals("logWood") &&
|
||||
canAddOutput(2, 10) &&
|
||||
canAddOutput(3, 5) &&
|
||||
canAddOutput(4, 3) &&
|
||||
canUseEnergy(128.0F) &&
|
||||
!tank.isEmpty() &&
|
||||
tank.getFluid().amount >= 1000) {
|
||||
if(--wood.stackSize == 0)
|
||||
setInventorySlotContents(0, null);
|
||||
tank.drain(1000, true);
|
||||
useEnergy(128.0F);
|
||||
tickTime = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(++tickTime > 100) {
|
||||
Random rnd = worldObj.rand;
|
||||
addOutput(2, new ItemStack(Blocks.PLANKS, 6 + rnd.nextInt(4)));
|
||||
if(rnd.nextInt(4) != 0) {
|
||||
ItemStack pulp = ItemDusts.getDustByName("sawDust", 2 + rnd.nextInt(3));
|
||||
addOutput(3, pulp);
|
||||
}
|
||||
if(rnd.nextInt(3) == 0) {
|
||||
ItemStack paper = new ItemStack(Items.PAPER, 1 + rnd.nextInt(2));
|
||||
addOutput(4, paper);
|
||||
}
|
||||
tickTime = 0;
|
||||
}
|
||||
}
|
||||
FluidUtils.drainContainers(this, inventory, 1, 4);
|
||||
}
|
||||
|
||||
public void addOutput(int slot, ItemStack stack) {
|
||||
if(getStackInSlot(slot) == null)
|
||||
setInventorySlotContents(slot, stack);
|
||||
getStackInSlot(slot).stackSize += stack.stackSize;
|
||||
}
|
||||
|
||||
public boolean canAddOutput(int slot, int amount) {
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
return stack == null || getInventoryStackLimit() - stack.stackSize >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
multiblockChecker = new MultiblockChecker(worldObj, getPos().down(3));
|
||||
}
|
||||
|
||||
public boolean getMutliBlock() {
|
||||
boolean down = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, ZERO_OFFSET);
|
||||
boolean up = multiblockChecker.checkRectY(1, 1, CASING_NORMAL, new BlockPos(0, 2, 0));
|
||||
boolean blade = multiblockChecker.checkRingY(1, 1, CASING_REINFORCED, new BlockPos(0, 1, 0));
|
||||
IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
|
||||
boolean center = centerBlock.getBlock() == Blocks.WATER;
|
||||
return down && center && blade && up;
|
||||
}
|
||||
|
||||
@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.industrialSawmill, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
tickTime = tagCompound.getInteger("tickTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
tagCompound.setInteger("tickTime", tickTime);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
if (resource.getFluid() == FluidRegistry.WATER || resource.getFluid() == ModFluids.fluidMercury
|
||||
|| resource.getFluid() == ModFluids.fluidSodiumpersulfate) {
|
||||
int filled = tank.fill(resource, doFill);
|
||||
tank.compareAndUpdate();
|
||||
return filled;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
tank.compareAndUpdate();
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return fluid == FluidRegistry.WATER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
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};
|
||||
}
|
||||
|
||||
@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 || slotIndex == 4;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (tickTime != 0) {
|
||||
return tickTime * scale / 100;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 64000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.MEDIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue