Added untested recipe code
This commit is contained in:
parent
e67b55eaff
commit
0c514596a1
2 changed files with 136 additions and 78 deletions
|
@ -4,6 +4,7 @@ import ic2.api.item.IC2Items;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import techreborn.api.BlastFurnaceRecipe;
|
||||||
import techreborn.api.CentrifugeRecipie;
|
import techreborn.api.CentrifugeRecipie;
|
||||||
import techreborn.api.TechRebornAPI;
|
import techreborn.api.TechRebornAPI;
|
||||||
import techreborn.config.ConfigTechReborn;
|
import techreborn.config.ConfigTechReborn;
|
||||||
|
@ -280,6 +281,7 @@ public class ModRecipes {
|
||||||
TechRebornAPI.addRollingMachinceRecipe(
|
TechRebornAPI.addRollingMachinceRecipe(
|
||||||
new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c',
|
new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c',
|
||||||
Blocks.cobblestone);
|
Blocks.cobblestone);
|
||||||
|
TechRebornAPI.registerBlastFurnaceRecipe(new BlastFurnaceRecipe(new ItemStack(Items.apple), new ItemStack(Items.ender_pearl), new ItemStack(Items.golden_apple), new ItemStack(Items.diamond), 120, 1000));
|
||||||
LogHelper.info("Machine Recipes Added");
|
LogHelper.info("Machine Recipes Added");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import ic2.api.energy.prefab.BasicSink;
|
||||||
import ic2.api.tile.IWrenchable;
|
import ic2.api.tile.IWrenchable;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
|
@ -12,178 +11,239 @@ import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import techreborn.api.CentrifugeRecipie;
|
import techreborn.api.BlastFurnaceRecipe;
|
||||||
import techreborn.api.TechRebornAPI;
|
import techreborn.api.TechRebornAPI;
|
||||||
import techreborn.blocks.BlockMachineCasing;
|
import techreborn.blocks.BlockMachineCasing;
|
||||||
import techreborn.client.SlotOutput;
|
|
||||||
import techreborn.client.container.TechRebornContainer;
|
|
||||||
import techreborn.config.ConfigTechReborn;
|
import techreborn.config.ConfigTechReborn;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.lib.Location;
|
import techreborn.lib.Location;
|
||||||
import techreborn.multiblocks.MultiBlockCasing;
|
|
||||||
import techreborn.util.Inventory;
|
import techreborn.util.Inventory;
|
||||||
|
import techreborn.util.ItemUtils;
|
||||||
|
|
||||||
public class TileBlastFurnace extends TileMachineBase implements IWrenchable, IInventory {
|
public class TileBlastFurnace extends TileMachineBase implements IWrenchable, IInventory {
|
||||||
|
|
||||||
public int tickTime;
|
public int tickTime;
|
||||||
public BasicSink energy;
|
public BasicSink energy;
|
||||||
public Inventory inventory = new Inventory(4, "TileBlastFurnace", 64);
|
public Inventory inventory = new Inventory(4, "TileBlastFurnace", 64);
|
||||||
|
public BlastFurnaceRecipe recipe;
|
||||||
|
public static int euTick = 5;
|
||||||
|
|
||||||
public TileBlastFurnace()
|
public TileBlastFurnace() {
|
||||||
{
|
|
||||||
//TODO configs
|
//TODO configs
|
||||||
energy = new BasicSink(this, ConfigTechReborn.CentrifugeCharge,
|
energy = new BasicSink(this, ConfigTechReborn.CentrifugeCharge,
|
||||||
ConfigTechReborn.CentrifugeTier);
|
ConfigTechReborn.CentrifugeTier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
|
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short getFacing()
|
public short getFacing() {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFacing(short facing)
|
public void setFacing(short facing) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getWrenchDropRate()
|
public float getWrenchDropRate() {
|
||||||
{
|
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||||
{
|
|
||||||
return new ItemStack(ModBlocks.BlastFurnace, 1);
|
return new ItemStack(ModBlocks.BlastFurnace, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeat(){
|
public int getHeat() {
|
||||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||||
if (tileEntity instanceof TileMachineCasing) {
|
if (tileEntity instanceof TileMachineCasing) {
|
||||||
if((tileEntity.getBlockType() instanceof BlockMachineCasing)){
|
if ((tileEntity.getBlockType() instanceof BlockMachineCasing)) {
|
||||||
int heat;
|
int heat;
|
||||||
heat = BlockMachineCasing.getHeatFromMeta(tileEntity.getBlockMetadata());
|
heat = BlockMachineCasing.getHeatFromMeta(tileEntity.getBlockMetadata());
|
||||||
Location location = new Location(xCoord, yCoord, zCoord, direction);
|
Location location = new Location(xCoord, yCoord, zCoord, direction);
|
||||||
location.modifyPositionFromSide(direction, 1);
|
location.modifyPositionFromSide(direction, 1);
|
||||||
if(worldObj.getBlock(location.getX(), location.getY(), location.getZ()).getUnlocalizedName().equals("tile.lava")){
|
if (worldObj.getBlock(location.getX(), location.getY(), location.getZ()).getUnlocalizedName().equals("tile.lava")) {
|
||||||
heat += 500;
|
heat += 500;
|
||||||
}
|
}
|
||||||
return heat;
|
return heat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void update(){
|
public void update() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(getStackInSlot(0) != null && getStackInSlot(1) != null){
|
if (getStackInSlot(0) != null && getStackInSlot(1) != null) {
|
||||||
//TODO recipe stuffs
|
if (recipe == null) {
|
||||||
|
for (BlastFurnaceRecipe furnaceRecipe : TechRebornAPI.blastFurnaceRecipes) {
|
||||||
|
if (ItemUtils.isItemEqual(getStackInSlot(0), furnaceRecipe.getInput1(), true, true) && ItemUtils.isItemEqual(getStackInSlot(0), furnaceRecipe.getInput2(), true, true)) {
|
||||||
|
recipe = furnaceRecipe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!ItemUtils.isItemEqual(getStackInSlot(0), recipe.getInput1(), true, true) || !ItemUtils.isItemEqual(getStackInSlot(0), recipe.getInput2(), true, true)) {
|
||||||
|
recipe = null;
|
||||||
|
tickTime = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tickTime >= recipe.getTickTime()) {
|
||||||
|
//When both slots are empty
|
||||||
|
if (getStackInSlot(2) == null && getStackInSlot(3) == null) {
|
||||||
|
setInventorySlotContents(2, recipe.getOutput1());
|
||||||
|
setInventorySlotContents(3, recipe.getOutput2());
|
||||||
|
tickTime = 0;
|
||||||
|
recipe = null;
|
||||||
|
}
|
||||||
|
//When both are the same as the recipe
|
||||||
|
if (ItemUtils.isItemEqual(getStackInSlot(2), recipe.getOutput1(), true, true) && ItemUtils.isItemEqual(getStackInSlot(3), recipe.getOutput2(), true, true) && !areBothOutputsFull()) {
|
||||||
|
decrStackSize(2, -recipe.getOutput1().stackSize);
|
||||||
|
decrStackSize(3, -recipe.getOutput2().stackSize);
|
||||||
|
tickTime = 0;
|
||||||
|
recipe = null;
|
||||||
|
}
|
||||||
|
//When slot one has stuff and slot 2 is empty
|
||||||
|
if (ItemUtils.isItemEqual(getStackInSlot(2), recipe.getOutput1(), true, true) && getStackInSlot(3) == null) {
|
||||||
|
//Stops if the first slot if full
|
||||||
|
if (recipe.getOutput1() != null
|
||||||
|
&& getStackInSlot(2) != null
|
||||||
|
&& getStackInSlot(2).stackSize
|
||||||
|
+ recipe.getOutput1().stackSize > recipe
|
||||||
|
.getOutput1().getMaxStackSize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
decrStackSize(2, recipe.getOutput1().stackSize);
|
||||||
|
setInventorySlotContents(3, recipe.getOutput2());
|
||||||
|
tickTime = 0;
|
||||||
|
recipe = null;
|
||||||
|
}
|
||||||
|
//When slot 2 has stuff and slot 1 is empty
|
||||||
|
if (ItemUtils.isItemEqual(getStackInSlot(3), recipe.getInput2(), true, true) && getStackInSlot(2) == null) {
|
||||||
|
if (recipe.getOutput2() != null
|
||||||
|
&& getStackInSlot(3) != null
|
||||||
|
&& getStackInSlot(3).stackSize
|
||||||
|
+ recipe.getOutput2().stackSize > recipe
|
||||||
|
.getOutput1().getMaxStackSize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
decrStackSize(3, recipe.getOutput2().stackSize);
|
||||||
|
setInventorySlotContents(2, recipe.getOutput1());
|
||||||
|
tickTime = 0;
|
||||||
|
recipe = null;
|
||||||
|
}
|
||||||
|
} else if (getHeat() >= recipe.getMinHeat()) {
|
||||||
|
if (energy.canUseEnergy(5)) {
|
||||||
|
tickTime++;
|
||||||
|
energy.useEnergy(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
recipe = null;
|
||||||
|
tickTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean areBothOutputsFull() {
|
||||||
|
if (recipe.getOutput1() != null
|
||||||
|
&& getStackInSlot(2) != null
|
||||||
|
&& getStackInSlot(2).stackSize
|
||||||
|
+ recipe.getOutput1().stackSize > recipe
|
||||||
|
.getOutput1().getMaxStackSize()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (recipe.getOutput2() != null
|
||||||
|
&& getStackInSlot(3) != null
|
||||||
|
&& getStackInSlot(3).stackSize
|
||||||
|
+ recipe.getOutput2().stackSize > recipe
|
||||||
|
.getOutput1().getMaxStackSize()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory() {
|
||||||
{
|
|
||||||
return inventory.getSizeInventory();
|
return inventory.getSizeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int p_70301_1_)
|
public ItemStack getStackInSlot(int p_70301_1_) {
|
||||||
{
|
|
||||||
return inventory.getStackInSlot(p_70301_1_);
|
return inventory.getStackInSlot(p_70301_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_)
|
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
|
||||||
{
|
|
||||||
return inventory.decrStackSize(p_70298_1_, p_70298_2_);
|
return inventory.decrStackSize(p_70298_1_, p_70298_2_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlotOnClosing(int p_70304_1_)
|
public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
|
||||||
{
|
|
||||||
return inventory.getStackInSlotOnClosing(p_70304_1_);
|
return inventory.getStackInSlotOnClosing(p_70304_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_)
|
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
|
||||||
{
|
|
||||||
inventory.setInventorySlotContents(p_70299_1_, p_70299_2_);
|
inventory.setInventorySlotContents(p_70299_1_, p_70299_2_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInventoryName()
|
public String getInventoryName() {
|
||||||
{
|
|
||||||
return inventory.getInventoryName();
|
return inventory.getInventoryName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCustomInventoryName()
|
public boolean hasCustomInventoryName() {
|
||||||
{
|
|
||||||
return inventory.hasCustomInventoryName();
|
return inventory.hasCustomInventoryName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInventoryStackLimit()
|
public int getInventoryStackLimit() {
|
||||||
{
|
|
||||||
return inventory.getInventoryStackLimit();
|
return inventory.getInventoryStackLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUseableByPlayer(EntityPlayer p_70300_1_)
|
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
|
||||||
{
|
|
||||||
return inventory.isUseableByPlayer(p_70300_1_);
|
return inventory.isUseableByPlayer(p_70300_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openInventory()
|
public void openInventory() {
|
||||||
{
|
|
||||||
inventory.openInventory();
|
inventory.openInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeInventory()
|
public void closeInventory() {
|
||||||
{
|
|
||||||
inventory.closeInventory();
|
inventory.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_)
|
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
|
||||||
{
|
|
||||||
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
|
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate()
|
public void invalidate() {
|
||||||
{
|
|
||||||
energy.invalidate();
|
energy.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkUnload()
|
public void onChunkUnload() {
|
||||||
{
|
|
||||||
energy.onChunkUnload();
|
energy.onChunkUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket() {
|
||||||
{
|
|
||||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||||
writeToNBT(nbtTag);
|
writeToNBT(nbtTag);
|
||||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord,
|
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord,
|
||||||
|
@ -192,31 +252,27 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable, II
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(NetworkManager net,
|
public void onDataPacket(NetworkManager net,
|
||||||
S35PacketUpdateTileEntity packet)
|
S35PacketUpdateTileEntity packet) {
|
||||||
{
|
|
||||||
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord,
|
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord,
|
||||||
yCoord, zCoord);
|
yCoord, zCoord);
|
||||||
readFromNBT(packet.func_148857_g());
|
readFromNBT(packet.func_148857_g());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tagCompound)
|
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
inventory.readFromNBT(tagCompound);
|
inventory.readFromNBT(tagCompound);
|
||||||
tickTime = tagCompound.getInteger("tickTime");
|
tickTime = tagCompound.getInteger("tickTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tagCompound)
|
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
|
||||||
super.writeToNBT(tagCompound);
|
super.writeToNBT(tagCompound);
|
||||||
inventory.writeToNBT(tagCompound);
|
inventory.writeToNBT(tagCompound);
|
||||||
writeUpdateToNBT(tagCompound);
|
writeUpdateToNBT(tagCompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeUpdateToNBT(NBTTagCompound tagCompound)
|
public void writeUpdateToNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
|
||||||
tagCompound.setInteger("tickTime", tickTime);
|
tagCompound.setInteger("tickTime", tickTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue