Added Industrial Sawmill pokes @modmuss50 to look at the nei handler crash issue bet I did it wrong

This commit is contained in:
Gig 2015-05-11 17:04:27 +01:00
parent 3fe5605de3
commit a8a46352c8
10 changed files with 417 additions and 0 deletions

View file

@ -0,0 +1,80 @@
package techreborn.blocks.machine;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.Core;
import techreborn.blocks.BlockMachineBase;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileIndustrialSawmill;
import techreborn.tiles.TileMachineCasing;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockIndustrialSawmill extends BlockMachineBase {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockIndustrialSawmill(Material material)
{
super(material);
setBlockName("techreborn.industrialsawmill");
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_)
{
return new TileIndustrialSawmill();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.sawMillID, world, x, y,
z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon)
{
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon.registerIcon("techreborn:machine/electric_industrial_sawmill");
this.iconTop = icon.registerIcon("techreborn:machine/machine_top");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop :
side == 0 ? this.iconBottom: (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
}

View file

@ -13,6 +13,7 @@ import techreborn.client.container.ContainerDieselGenerator;
import techreborn.client.container.ContainerGrinder;
import techreborn.client.container.ContainerImplosionCompressor;
import techreborn.client.container.ContainerIndustrialElectrolyzer;
import techreborn.client.container.ContainerIndustrialSawmill;
import techreborn.client.container.ContainerLathe;
import techreborn.client.container.ContainerMatterFabricator;
import techreborn.client.container.ContainerPlateCuttingMachine;
@ -31,6 +32,7 @@ import techreborn.client.gui.GuiDieselGenerator;
import techreborn.client.gui.GuiGrinder;
import techreborn.client.gui.GuiImplosionCompressor;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.client.gui.GuiIndustrialSawmill;
import techreborn.client.gui.GuiLathe;
import techreborn.client.gui.GuiMatterFabricator;
import techreborn.client.gui.GuiPlateCuttingMachine;
@ -50,6 +52,7 @@ import techreborn.tiles.TileDieselGenerator;
import techreborn.tiles.TileGrinder;
import techreborn.tiles.TileImplosionCompressor;
import techreborn.tiles.TileIndustrialElectrolyzer;
import techreborn.tiles.TileIndustrialSawmill;
import techreborn.tiles.TileLathe;
import techreborn.tiles.TileMatterFabricator;
import techreborn.tiles.TilePlateCuttingMachine;
@ -80,6 +83,7 @@ public class GuiHandler implements IGuiHandler {
public static final int industrialElectrolyzerID = 16;
public static final int aesuID =17;
public static final int alloyFurnaceID = 18;
public static final int sawMillID = 19;
@ -159,6 +163,10 @@ public class GuiHandler implements IGuiHandler {
{
return new ContainerAlloyFurnace(
(TileAlloyFurnace) world.getTileEntity(x, y, z), player);
} else if (ID == sawMillID)
{
return new ContainerIndustrialSawmill(
(TileIndustrialSawmill) world.getTileEntity(x, y, z), player);
} else if (ID == pdaID)
{
return null;
@ -243,6 +251,10 @@ public class GuiHandler implements IGuiHandler {
{
return new GuiAlloyFurnace(player,
(TileAlloyFurnace) world.getTileEntity(x, y, z));
} else if (ID == sawMillID)
{
return new GuiIndustrialSawmill(player,
(TileIndustrialSawmill) world.getTileEntity(x, y, z));
} else if (ID == pdaID)
{
return new GuiPda(player);

View file

@ -0,0 +1,57 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import techreborn.client.SlotOutput;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileIndustrialSawmill;
public class ContainerIndustrialSawmill extends TechRebornContainer {
EntityPlayer player;
TileIndustrialSawmill tile;
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
public int tickTime;
public ContainerIndustrialSawmill(TileIndustrialSawmill tileIndustrialSawmill,
EntityPlayer player)
{
tile = tileIndustrialSawmill;
this.player = player;
// input
this.addSlotToContainer(new Slot(tileIndustrialSawmill.inventory, 0, 32, 26));
this.addSlotToContainer(new Slot(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 Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
}

View file

@ -0,0 +1,61 @@
package techreborn.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import techreborn.client.container.ContainerAlloySmelter;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerIndustrialSawmill;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileIndustrialSawmill;
public class GuiIndustrialSawmill extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/industrial_sawmill.png");
TileIndustrialSawmill sawmill;
public GuiIndustrialSawmill(EntityPlayer player,
TileIndustrialSawmill tilesawmill)
{
super(new ContainerIndustrialSawmill(tilesawmill, player));
this.xSize = 176;
this.ySize = 167;
sawmill = tilesawmill;
}
@Override
public void initGui() {
this.buttonList.clear();
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.buttonList.add(new GuiButton(0, k + 4, l + 4, 20, 20, "R"));
super.initGui();
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
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);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
String name = StatCollector.translateToLocal("tile.techreborn.tilesawmill.name");
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -10,8 +10,10 @@ import techreborn.compat.nei.recipes.AlloySmelterRecipeHandler;
import techreborn.compat.nei.recipes.AssemblingMachineRecipeHandler;
import techreborn.compat.nei.recipes.GenericRecipeHander;
import techreborn.compat.nei.recipes.ImplosionCompressorRecipeHandler;
import techreborn.compat.nei.recipes.IndustrialSawmillRecipeHandler;
import techreborn.compat.nei.recipes.LatheRecipeHandler;
import techreborn.lib.ModInfo;
import techreborn.recipes.IndustrialSawmillRecipe;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
@ -53,6 +55,10 @@ public class NEIConfig implements IConfigureNEI {
LatheRecipeHandler lathe = new LatheRecipeHandler();
API.registerUsageHandler(lathe);
API.registerRecipeHandler(lathe);
IndustrialSawmillRecipeHandler sawmill = new IndustrialSawmillRecipeHandler();
API.registerUsageHandler(sawmill);
API.registerRecipeHandler(sawmill);
API.registerRecipeHandler(centrifugeRecipeHandler);
API.registerUsageHandler(centrifugeRecipeHandler);

View file

@ -0,0 +1,53 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraftforge.oredict.OreDictionary;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiAlloySmelter;
import techreborn.client.gui.GuiImplosionCompressor;
import techreborn.client.gui.GuiIndustrialSawmill;
import techreborn.util.ItemUtils;
import java.util.List;
public class IndustrialSawmillRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 32 - offset, 26 - offset);
input.add(pStack);
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 32 - offset, 44 - offset);
input.add(pStack2);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 84 - offset, 35 - offset);
outputs.add(pStack3);
PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 102 - offset, 35 - offset);
outputs.add(pStack4);
PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 120 - offset, 35 - offset);
outputs.add(pStack5);
}
@Override
public String getRecipeName() {
return "industrialSawmillRecipe";
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/industrial_sawmill.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiIndustrialSawmill.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
}

View file

@ -37,6 +37,7 @@ import techreborn.blocks.machine.BlockDistillationTower;
import techreborn.blocks.machine.BlockGrinder;
import techreborn.blocks.machine.BlockImplosionCompressor;
import techreborn.blocks.machine.BlockIndustrialElectrolyzer;
import techreborn.blocks.machine.BlockIndustrialSawmill;
import techreborn.blocks.machine.BlockLathe;
import techreborn.blocks.machine.BlockMatterFabricator;
import techreborn.blocks.machine.BlockPlateCuttingMachine;
@ -65,6 +66,7 @@ import techreborn.tiles.TileGrinder;
import techreborn.tiles.TileHeatGenerator;
import techreborn.tiles.TileImplosionCompressor;
import techreborn.tiles.TileIndustrialElectrolyzer;
import techreborn.tiles.TileIndustrialSawmill;
import techreborn.tiles.TileLathe;
import techreborn.tiles.TileMachineCasing;
import techreborn.tiles.TileMatterFabricator;
@ -117,6 +119,7 @@ public class ModBlocks {
public static Block FusionCoil;
public static Block LightningRod;
public static Block heatGenerator;
public static Block industrialSawmill;
public static Block ore;
public static Block storage;
@ -267,6 +270,10 @@ public class ModBlocks {
heatGenerator = new BlockHeatGenerator(Material.rock);
GameRegistry.registerBlock(heatGenerator, "heatgenerator");
GameRegistry.registerTileEntity(TileHeatGenerator.class, "TileHeatGenerator");
industrialSawmill = new BlockIndustrialSawmill(Material.rock);
GameRegistry.registerBlock(industrialSawmill, "industrialSawmill");
GameRegistry.registerTileEntity(TileIndustrialSawmill.class, "TileIndustrialSawmill");
registerOreDict();
}

View file

@ -13,6 +13,7 @@ import techreborn.config.ConfigTechReborn;
import techreborn.recipes.AlloySmelterRecipe;
import techreborn.recipes.AssemblingMachineRecipe;
import techreborn.recipes.ImplosionCompressorRecipe;
import techreborn.recipes.IndustrialSawmillRecipe;
import techreborn.recipes.LatheRecipe;
import techreborn.util.CraftingHelper;
import techreborn.util.LogHelper;
@ -204,6 +205,7 @@ public class ModRecipes {
RecipeHanderer.addRecipe(new AssemblingMachineRecipe(new ItemStack(Items.coal), new ItemStack(Blocks.sand), new ItemStack(Items.diamond), 120, 5));
//TODO BORKEN
// RecipeHanderer.addRecipe(new LatheRecipe(new ItemStack(Items.coal), new ItemStack(Items.diamond), 120, 5));
RecipeHanderer.addRecipe(new IndustrialSawmillRecipe(new ItemStack(Items.coal), new ItemStack(Blocks.sand), new ItemStack(Items.diamond), null, null , 120, 5));
LogHelper.info("Machine Recipes Added");
}

View file

@ -0,0 +1,22 @@
package techreborn.recipes;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
public class IndustrialSawmillRecipe extends BaseRecipe {
public IndustrialSawmillRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, ItemStack output3, int tickTime, int euPerTick)
{
super("industrialSawmillRecipe", tickTime, euPerTick);
if(input1 != null)
inputs.add(input1);
if(input2 != null)
inputs.add(input2);
if(output1 != null)
outputs.add(output1);
if(output2 != null)
outputs.add(output2);
if(output3 != null)
outputs.add(output3);
}
}

View file

@ -0,0 +1,117 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.util.Inventory;
public class TileIndustrialSawmill extends TileMachineBase implements IWrenchable, IEnergyTile {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64);
public RecipeCrafter crafter;
public TileIndustrialSawmill()
{
//TODO configs
energy = new BasicSink(this, 1000, 2);
//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("industrialSawmillRecipe", this, energy, 2, 3, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
{
return false;
}
@Override
public short getFacing()
{
return 0;
}
@Override
public void setFacing(short facing)
{
}
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
if (entityPlayer.isSneaking())
{
return true;
}
return false;
}
@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);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
}
}