Firebox now works

This commit is contained in:
Calclavia 2014-01-17 19:49:40 +08:00
parent 61dbe025b2
commit 3a04133f96
6 changed files with 69 additions and 96 deletions

View file

@ -8,4 +8,4 @@ version.cclib=1.0.0.50
version.fmp=1.0.0.235
version.mod.major=0
version.mod.minor=3
version.mod.revis=0
version.mod.revis=1

View file

@ -4,16 +4,15 @@ import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockRI;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.utility.inventory.InventoryUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -24,7 +23,7 @@ public class BlockFirebox extends BlockRI
public BlockFirebox()
{
super("firebox", Material.piston);
super("firebox", Material.wood);
this.setTickRandomly(true);
}
@ -46,14 +45,20 @@ public class BlockFirebox extends BlockRI
{
TileFirebox tile = (TileFirebox) tileEntity;
if (tile.getStackInSlot(0) == null && entityPlayer.inventory.getCurrentItem() != null)
if (tile.getStackInSlot(0) == null)
{
tile.setInventorySlotContents(0, entityPlayer.inventory.getCurrentItem());
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
if (tile.canBurn(entityPlayer.inventory.getCurrentItem()))
{
tile.setInventorySlotContents(0, entityPlayer.inventory.getCurrentItem());
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
return true;
}
}
else
{
InventoryUtility.dropItemStack(world, new Vector3(entityPlayer), tile.getStackInSlot(0));
tile.setInventorySlotContents(0, null);
return true;
}
}
@ -83,6 +88,18 @@ public class BlockFirebox extends BlockRI
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta)
{
if (side == 1)
{
return topOff;
}
return blockIcon;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random par5Random)
{
@ -97,76 +114,20 @@ public class BlockFirebox extends BlockRI
float f3 = 0.52F;
float f4 = par5Random.nextFloat() * 0.6F - 0.3F;
if (l == 4)
{
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
}
else if (l == 5)
{
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
}
else if (l == 2)
{
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
}
else if (l == 3)
{
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
}
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
}
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta)
{
if (side == meta)
{
return topOff;
}
return this.blockIcon;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack stack)
{
int angle = MathHelper.floor_double((entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int change = 3;
switch (angle)
{
case 0:
change = 2;
break;
case 1:
change = 5;
break;
case 2:
change = 3;
break;
case 3:
change = 4;
break;
}
world.setBlockMetadataWithNotify(x, y, z, change, 3);
world.scheduleBlockUpdate(x, y, z, blockID, 20);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int side)
{
world.scheduleBlockUpdate(x, y, z, blockID, 20);
}
@Override
public TileEntity createNewTileEntity(World world)
{

View file

@ -2,6 +2,7 @@ package resonantinduction.archaic.blocks;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
@ -15,7 +16,7 @@ import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender;
import calclavia.lib.prefab.tile.TileAdvancedInventory;
import calclavia.lib.prefab.tile.TileExternalInventory;
import com.google.common.io.ByteArrayDataInput;
@ -25,13 +26,13 @@ import com.google.common.io.ByteArrayDataInput;
* @author Calclavia
*
*/
public class TileFirebox extends TileAdvancedInventory implements IPacketSender, IPacketReceiver
public class TileFirebox extends TileExternalInventory implements IPacketSender, IPacketReceiver
{
/**
* The power of the firebox in terms of thermal energy. The thermal energy can be transfered
* into fluids to increase their internal energy.
*/
private final int POWER = 1000;
private final int POWER = 50000;
private int burnTime;
@Override
@ -39,31 +40,47 @@ public class TileFirebox extends TileAdvancedInventory implements IPacketSender,
{
if (!worldObj.isRemote)
{
int blockID = worldObj.getBlockId(xCoord, yCoord + 1, zCoord);
if (burnTime > 0)
{
if (blockID == 0 && blockID != Block.fire.blockID)
{
worldObj.setBlock(xCoord, yCoord + 1, zCoord, Block.fire.blockID);
}
if (burnTime-- == 0)
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
else if (blockID == Block.fire.blockID)
{
worldObj.setBlock(xCoord, yCoord + 1, zCoord, 0);
}
if (canBurn(this.getStackInSlot(0)))
{
if (burnTime == 0)
{
burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0));
decrStackSize(1, 1);
decrStackSize(0, 1);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
}
private boolean canBurn(ItemStack stack)
public boolean canBurn(ItemStack stack)
{
return TileEntityFurnace.getItemBurnTime(stack) > 0;
}
public boolean isBurning()
{
return burnTime > 0;
}
@Override
public Packet getDescriptionPacket()
{
@ -96,9 +113,4 @@ public class TileFirebox extends TileAdvancedInventory implements IPacketSender,
e.printStackTrace();
}
}
public boolean isBurning()
{
return burnTime > 0;
}
}

View file

@ -53,17 +53,17 @@ public class InventoryCrate extends ExternalInventory
}
@Override
public NBTTagCompound saveInv(NBTTagCompound nbt)
public NBTTagCompound save(NBTTagCompound nbt)
{
return nbt;
}
@Override
public void loadInv(NBTTagCompound nbt)
public void load(NBTTagCompound nbt)
{
if (nbt.hasKey("Items"))
{
super.loadInv(nbt);
super.load(nbt);
}
}

View file

@ -8,7 +8,7 @@ import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.ResonantInduction;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileAdvancedInventory;
import calclavia.lib.prefab.tile.TileExternalInventory;
import calclavia.lib.utility.inventory.IExtendedStorage;
import com.google.common.io.ByteArrayDataInput;
@ -21,7 +21,7 @@ import cpw.mods.fml.relauncher.Side;
*
* @author DarkGuardsman
*/
public class TileCrate extends TileAdvancedInventory implements IPacketReceiver, IExtendedStorage
public class TileCrate extends TileExternalInventory implements IPacketReceiver, IExtendedStorage
{
/*
* TODO

View file

@ -13,16 +13,16 @@ import resonantinduction.core.ResonantInduction;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.content.IExtraInfo.IExtraTileEntityInfo;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileAdvancedInventory;
import calclavia.lib.utility.inventory.IExternalInv;
import calclavia.lib.utility.inventory.IInvBox;
import calclavia.lib.prefab.tile.TileExternalInventory;
import calclavia.lib.utility.inventory.IExternalInventory;
import calclavia.lib.utility.inventory.IExternalInventoryBox;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public abstract class TileMachine extends TileAdvancedInventory implements ISidedInventory, IExternalInv, IExtraTileEntityInfo
public abstract class TileMachine extends TileExternalInventory implements ISidedInventory, IExternalInventory, IExtraTileEntityInfo
{
/** Number of players with the machine's gui container open */
protected int playersUsingMachine = 0;
@ -42,7 +42,7 @@ public abstract class TileMachine extends TileAdvancedInventory implements ISide
protected boolean locked = false;
/** Inventory manager used by this machine */
protected IInvBox inventory;
protected IExternalInventoryBox inventory;
/** Default generic packet types used by all machines */
public static enum SimplePacketTypes