Added Alloysmelter
This commit is contained in:
parent
4ac26ac086
commit
4c5477d816
7 changed files with 326 additions and 2 deletions
|
@ -82,7 +82,7 @@ public class Core {
|
|||
@Mod.EventHandler
|
||||
public void postinit(FMLPostInitializationEvent event)
|
||||
{
|
||||
// Has to be done here as buildcraft registers there recipes late
|
||||
// Has to be done here as Buildcraft registers there recipes late
|
||||
RecipeManager.init();
|
||||
}
|
||||
|
||||
|
|
149
src/main/java/techreborn/blocks/BlockAlloySmelter.java
Normal file
149
src/main/java/techreborn/blocks/BlockAlloySmelter.java
Normal file
|
@ -0,0 +1,149 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
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.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
import techreborn.tiles.TileMachineCasing;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockAlloySmelter extends BlockContainer {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconFront;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTop;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconBottom;
|
||||
|
||||
public BlockAlloySmelter(Material material)
|
||||
{
|
||||
super(material);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setBlockName("techreborn.alloysmelter");
|
||||
setHardness(2F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int p_149915_2_)
|
||||
{
|
||||
return new TileAlloySmelter();
|
||||
}
|
||||
|
||||
@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.alloySmelterID, 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/industrial_blast_furnace_front_off");
|
||||
this.iconTop = icon.registerIcon("techreborn:machine/machine_side");
|
||||
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata)
|
||||
{
|
||||
|
||||
return metadata == 0 && side == 3 ? this.iconFront
|
||||
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
|
||||
: (side == metadata ? this.iconFront : this.blockIcon));
|
||||
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
this.setDefaultDirection(world, x, y, z);
|
||||
|
||||
}
|
||||
|
||||
private void setDefaultDirection(World world, int x, int y, int z)
|
||||
{
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block1 = world.getBlock(x, y, z - 1);
|
||||
Block block2 = world.getBlock(x, y, z + 1);
|
||||
Block block3 = world.getBlock(x - 1, y, z);
|
||||
Block block4 = world.getBlock(x + 1, y, z);
|
||||
|
||||
byte b = 3;
|
||||
|
||||
if (block1.func_149730_j() && !block2.func_149730_j())
|
||||
{
|
||||
b = 3;
|
||||
}
|
||||
if (block2.func_149730_j() && !block1.func_149730_j())
|
||||
{
|
||||
b = 2;
|
||||
}
|
||||
if (block3.func_149730_j() && !block4.func_149730_j())
|
||||
{
|
||||
b = 5;
|
||||
}
|
||||
if (block4.func_149730_j() && !block3.func_149730_j())
|
||||
{
|
||||
b = 4;
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, b, 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z,
|
||||
EntityLivingBase player, ItemStack itemstack)
|
||||
{
|
||||
|
||||
int l = MathHelper
|
||||
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
if (l == 1)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
}
|
||||
if (l == 2)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
if (l == 3)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -2,12 +2,14 @@ package techreborn.client;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.client.container.ContainerAlloySmelter;
|
||||
import techreborn.client.container.ContainerBlastFurnace;
|
||||
import techreborn.client.container.ContainerCentrifuge;
|
||||
import techreborn.client.container.ContainerQuantumChest;
|
||||
import techreborn.client.container.ContainerQuantumTank;
|
||||
import techreborn.client.container.ContainerRollingMachine;
|
||||
import techreborn.client.container.ContainerThermalGenerator;
|
||||
import techreborn.client.gui.GuiAlloySmelter;
|
||||
import techreborn.client.gui.GuiBlastFurnace;
|
||||
import techreborn.client.gui.GuiCentrifuge;
|
||||
import techreborn.client.gui.GuiQuantumChest;
|
||||
|
@ -15,6 +17,7 @@ import techreborn.client.gui.GuiQuantumTank;
|
|||
import techreborn.client.gui.GuiRollingMachine;
|
||||
import techreborn.client.gui.GuiThermalGenerator;
|
||||
import techreborn.pda.GuiPda;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
import techreborn.tiles.TileCentrifuge;
|
||||
import techreborn.tiles.TileQuantumChest;
|
||||
|
@ -31,7 +34,8 @@ public class GuiHandler implements IGuiHandler {
|
|||
public static final int centrifugeID = 3;
|
||||
public static final int rollingMachineID = 4;
|
||||
public static final int blastFurnaceID = 5;
|
||||
public static final int pdaID = 6;
|
||||
public static final int alloySmelterID = 6;
|
||||
public static final int pdaID = 7;
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
||||
|
@ -61,6 +65,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
{
|
||||
return new ContainerBlastFurnace(
|
||||
(TileBlastFurnace) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == alloySmelterID)
|
||||
{
|
||||
return new ContainerAlloySmelter(
|
||||
(TileAlloySmelter) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == pdaID)
|
||||
{
|
||||
return null;
|
||||
|
@ -97,6 +105,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
{
|
||||
return new GuiBlastFurnace(player,
|
||||
(TileBlastFurnace) world.getTileEntity(x, y, z));
|
||||
} else if (ID == alloySmelterID)
|
||||
{
|
||||
return new GuiAlloySmelter(player,
|
||||
(TileAlloySmelter) world.getTileEntity(x, y, z));
|
||||
} else if (ID == pdaID)
|
||||
{
|
||||
return new GuiPda(player);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
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;
|
||||
|
||||
public class ContainerAlloySmelter extends TechRebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
TileAlloySmelter tile;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int tickTime;
|
||||
|
||||
public ContainerAlloySmelter(TileAlloySmelter tileAlloysmelter,
|
||||
EntityPlayer player)
|
||||
{
|
||||
tile = tileAlloysmelter;
|
||||
this.player = player;
|
||||
|
||||
// input
|
||||
this.addSlotToContainer(new Slot(tileAlloysmelter.inventory, 0, 56, 25));
|
||||
this.addSlotToContainer(new Slot(tileAlloysmelter.inventory, 1, 56, 43));
|
||||
// outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileAlloysmelter.inventory, 2,
|
||||
116, 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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
46
src/main/java/techreborn/client/gui/GuiAlloySmelter.java
Normal file
46
src/main/java/techreborn/client/gui/GuiAlloySmelter.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
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 techreborn.client.container.ContainerAlloySmelter;
|
||||
import techreborn.client.container.ContainerBlastFurnace;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
|
||||
public class GuiAlloySmelter extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(
|
||||
"techreborn", "textures/gui/industrial_blast_furnace.png");
|
||||
|
||||
TileAlloySmelter alloysmelter;
|
||||
|
||||
public GuiAlloySmelter(EntityPlayer player,
|
||||
TileAlloySmelter tilealloysmelter)
|
||||
{
|
||||
super(new ContainerAlloySmelter(tilealloysmelter, player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
alloysmelter = tilealloysmelter;
|
||||
}
|
||||
|
||||
@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_)
|
||||
{
|
||||
this.fontRendererObj.drawString("Alloysmelter", 60, 6, 4210752);
|
||||
this.fontRendererObj.drawString(
|
||||
I18n.format("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import techreborn.blocks.BlockAlloySmelter;
|
||||
import techreborn.blocks.BlockBlastFurnace;
|
||||
import techreborn.blocks.BlockCentrifuge;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
|
@ -19,6 +20,7 @@ import techreborn.itemblocks.ItemBlockOre;
|
|||
import techreborn.itemblocks.ItemBlockQuantumChest;
|
||||
import techreborn.itemblocks.ItemBlockQuantumTank;
|
||||
import techreborn.itemblocks.ItemBlockStorage;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
import techreborn.tiles.TileCentrifuge;
|
||||
import techreborn.tiles.TileMachineCasing;
|
||||
|
@ -38,6 +40,7 @@ public class ModBlocks {
|
|||
public static Block RollingMachine;
|
||||
public static Block MachineCasing;
|
||||
public static Block BlastFurnace;
|
||||
public static Block AlloySmelter;
|
||||
|
||||
public static Block ore;
|
||||
public static Block storage;
|
||||
|
@ -87,6 +90,10 @@ public class ModBlocks {
|
|||
GameRegistry.registerBlock(BlastFurnace, "blastFurnace");
|
||||
GameRegistry.registerTileEntity(TileBlastFurnace.class,
|
||||
"TileBlastFurnace");
|
||||
|
||||
AlloySmelter = new BlockAlloySmelter(Material.piston);
|
||||
GameRegistry.registerBlock(AlloySmelter, "alloySmelter");
|
||||
GameRegistry.registerTileEntity(TileAlloySmelter.class, "TileAlloySmalter");
|
||||
|
||||
MachineCasing = new BlockMachineCasing(Material.piston);
|
||||
GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class,
|
||||
|
|
56
src/main/java/techreborn/tiles/TileAlloySmelter.java
Normal file
56
src/main/java/techreborn/tiles/TileAlloySmelter.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.util.Inventory;
|
||||
|
||||
public class TileAlloySmelter extends TileMachineBase implements IWrenchable {
|
||||
|
||||
public int tickTime;
|
||||
public BasicSink energy;
|
||||
public Inventory inventory = new Inventory(3, "TileAlloySmelter", 64);
|
||||
|
||||
@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)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
return new ItemStack(ModBlocks.AlloySmelter, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue