More work on the Aludel
This commit is contained in:
parent
f48f9093ab
commit
c8b510f90f
10 changed files with 592 additions and 59 deletions
|
@ -1,12 +1,24 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.reference.GuiIds;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.Particles;
|
||||
import com.pahimar.ee3.reference.RenderIds;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAludel;
|
||||
import com.pahimar.ee3.tileentity.TileEntityGlassBell;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockAludel extends BlockEE implements ITileEntityProvider
|
||||
{
|
||||
|
@ -30,6 +42,12 @@ public class BlockAludel extends BlockEE implements ITileEntityProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return RenderIds.aludel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
|
@ -37,8 +55,125 @@ public class BlockAludel extends BlockEE implements ITileEntityProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
return RenderIds.aludel;
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityAludel)
|
||||
{
|
||||
if (((TileEntityAludel) tile).getState() == 1)
|
||||
{
|
||||
switch (((TileEntityAludel) tile).getOrientation())
|
||||
{
|
||||
case NORTH:
|
||||
world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.33F, (double) z + 0.175F, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case SOUTH:
|
||||
world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.33F, (double) z + 0.825F, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case WEST:
|
||||
world.spawnParticle(Particles.FLAME, (double) x + 0.175F, (double) y + 0.33F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case EAST:
|
||||
world.spawnParticle(Particles.FLAME, (double) x + 0.825F, (double) y + 0.33F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
}
|
||||
|
||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.7F, (double) z + 0.0F, 0.0D, 0.05D, 0.0D);
|
||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.7F, (double) z + 1.0F, 0.0D, 0.05D, 0.0D);
|
||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.0F, (double) y + 0.7F, (double) z + 0.5F, 0.0D, 0.05D, 0.0D);
|
||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 1.0F, (double) y + 0.7F, (double) z + 0.5F, 0.0D, 0.05D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
|
||||
{
|
||||
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
|
||||
tileEntityAludel.hasGlassBell = world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell;
|
||||
|
||||
super.onNeighborBlockChange(world, x, y, z, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int faceHit, float par7, float par8, float par9)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityAludel && world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell)
|
||||
{
|
||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventData)
|
||||
{
|
||||
super.onBlockEventReceived(world, x, y, z, eventId, eventData);
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
return tileentity != null ? tileentity.receiveClientEvent(eventId, eventData) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityAludel)
|
||||
{
|
||||
if (((TileEntityAludel) world.getTileEntity(x, y, z)).getState() == 1)
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
|
||||
{
|
||||
if (world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell)
|
||||
{
|
||||
world.markBlockForUpdate(x, y + 1, z);
|
||||
// NAME UPDATE - this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, this.zCoord);
|
||||
world.func_147451_t(x, y + 1, z);
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
||||
{
|
||||
super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);
|
||||
|
||||
if (world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell)
|
||||
{
|
||||
TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y + 1, z);
|
||||
|
||||
tileEntityGlassBell.setOrientation(ForgeDirection.UP);
|
||||
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityAludel)
|
||||
{
|
||||
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
|
||||
|
||||
ItemStack itemStackGlassBell = tileEntityGlassBell.getStackInSlot(TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX);
|
||||
|
||||
tileEntityGlassBell.setInventorySlotContents(TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, null);
|
||||
|
||||
tileEntityAludel.setInventorySlotContents(TileEntityAludel.INPUT_INVENTORY_INDEX, itemStackGlassBell);
|
||||
|
||||
tileEntityAludel.hasGlassBell = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,12 +37,6 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
|
@ -50,22 +44,23 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
if ((world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) && (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1))
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
|
||||
return super.getLightValue(world, x, y, z);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||
TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
|
||||
return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false;
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityCalcinator)
|
||||
{
|
||||
if (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1)
|
||||
{
|
||||
// Fire pot particles
|
||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.4F, (double) ((z + 0.5F) + (random.nextFloat() * 0.5F - 0.3F)), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.4F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,16 +85,21 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random)
|
||||
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventData)
|
||||
{
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityCalcinator)
|
||||
super.onBlockEventReceived(world, x, y, z, eventId, eventData);
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
return tileentity != null ? tileentity.receiveClientEvent(eventId, eventData) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if ((world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) && (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1))
|
||||
{
|
||||
if (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1)
|
||||
{
|
||||
// Fire pot particles
|
||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.4F, (double) ((z + 0.5F) + (random.nextFloat() * 0.5F - 0.3F)), 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.4F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return 15;
|
||||
}
|
||||
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import com.pahimar.ee3.inventory.ContainerAludel;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAludel;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAludel extends GuiContainer
|
||||
{
|
||||
private TileEntityAludel tileEntityAludel;
|
||||
|
||||
public GuiAludel(InventoryPlayer inventoryPlayer, TileEntityAludel tileEntityAludel)
|
||||
{
|
||||
super(new ContainerAludel(inventoryPlayer, tileEntityAludel));
|
||||
this.tileEntityAludel = tileEntityAludel;
|
||||
xSize = 176;
|
||||
ySize = 187;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
String containerName = StatCollector.translateToLocal(tileEntityAludel.getInventoryName());
|
||||
fontRendererObj.drawString(containerName, xSize / 2 - fontRendererObj.getStringWidth(containerName) / 2, 6, 4210752);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal(Names.Containers.VANILLA_INVENTORY), 8, ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALUDEL);
|
||||
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
||||
int scaleAdjustment;
|
||||
|
||||
if (this.tileEntityAludel.getState() == 1)
|
||||
{
|
||||
scaleAdjustment = this.tileEntityAludel.getBurnTimeRemainingScaled(12);
|
||||
this.drawTexturedModalRect(xStart + 45, yStart + 36 + 34 - scaleAdjustment, 176, 12 - scaleAdjustment, 14, scaleAdjustment + 2);
|
||||
}
|
||||
|
||||
scaleAdjustment = this.tileEntityAludel.getCookProgressScaled(24);
|
||||
this.drawTexturedModalRect(xStart + 76, yStart + 39, 176, 14, scaleAdjustment + 1, 16);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,10 @@
|
|||
package com.pahimar.ee3.handler;
|
||||
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalBag;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalChest;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiCalcinator;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiGlassBell;
|
||||
import com.pahimar.ee3.client.gui.inventory.*;
|
||||
import com.pahimar.ee3.inventory.*;
|
||||
import com.pahimar.ee3.reference.GuiIds;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAlchemicalChest;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAludel;
|
||||
import com.pahimar.ee3.tileentity.TileEntityCalcinator;
|
||||
import com.pahimar.ee3.tileentity.TileEntityGlassBell;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
@ -37,6 +35,11 @@ public class GuiHandler implements IGuiHandler
|
|||
TileEntityCalcinator tileEntityCalcinator = (TileEntityCalcinator) world.getTileEntity(x, y, z);
|
||||
return new ContainerCalcinator(player.inventory, tileEntityCalcinator);
|
||||
}
|
||||
else if (id == GuiIds.ALUDEL)
|
||||
{
|
||||
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
|
||||
return new ContainerAludel(player.inventory, tileEntityAludel);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -63,6 +66,11 @@ public class GuiHandler implements IGuiHandler
|
|||
TileEntityCalcinator tileEntityCalcinator = (TileEntityCalcinator) world.getTileEntity(x, y, z);
|
||||
return new GuiCalcinator(player.inventory, tileEntityCalcinator);
|
||||
}
|
||||
else if (id == GuiIds.ALUDEL)
|
||||
{
|
||||
TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z);
|
||||
return new GuiAludel(player.inventory, tileEntityAludel);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
187
src/main/java/com/pahimar/ee3/inventory/ContainerAludel.java
Normal file
187
src/main/java/com/pahimar/ee3/inventory/ContainerAludel.java
Normal file
|
@ -0,0 +1,187 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.item.ItemAlchemicalDust;
|
||||
import com.pahimar.ee3.tileentity.TileEntityAludel;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
|
||||
public class ContainerAludel extends Container
|
||||
{
|
||||
private final int PLAYER_INVENTORY_ROWS = 3;
|
||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
||||
private TileEntityAludel tileEntityAludel;
|
||||
private int lastDeviceCookTime;
|
||||
private int lastFuelBurnTime;
|
||||
private int lastItemCookTime;
|
||||
|
||||
public ContainerAludel(InventoryPlayer inventoryPlayer, TileEntityAludel tileEntityAludel)
|
||||
{
|
||||
this.tileEntityAludel = tileEntityAludel;
|
||||
|
||||
this.addSlotToContainer(new Slot(tileEntityAludel, TileEntityAludel.FUEL_INVENTORY_INDEX, 44, 74));
|
||||
this.addSlotToContainer(new Slot(tileEntityAludel, TileEntityAludel.INPUT_INVENTORY_INDEX, 44, 18));
|
||||
this.addSlotToContainer(new Slot(tileEntityAludel, TileEntityAludel.DUST_INVENTORY_INDEX, 44, 39));
|
||||
this.addSlotToContainer(new SlotAludelOutput(tileEntityAludel, TileEntityAludel.OUTPUT_INVENTORY_INDEX, 120, 39));
|
||||
|
||||
// Add the player's inventory slots to the container
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 106 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 164));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting iCrafting)
|
||||
{
|
||||
super.addCraftingToCrafters(iCrafting);
|
||||
iCrafting.sendProgressBarUpdate(this, 0, this.tileEntityAludel.deviceCookTime);
|
||||
iCrafting.sendProgressBarUpdate(this, 1, this.tileEntityAludel.fuelBurnTime);
|
||||
iCrafting.sendProgressBarUpdate(this, 2, this.tileEntityAludel.itemCookTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (Object crafter : this.crafters)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) crafter;
|
||||
|
||||
if (this.lastDeviceCookTime != this.tileEntityAludel.deviceCookTime)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 0, this.tileEntityAludel.deviceCookTime);
|
||||
}
|
||||
|
||||
if (this.lastFuelBurnTime != this.tileEntityAludel.fuelBurnTime)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 1, this.tileEntityAludel.fuelBurnTime);
|
||||
}
|
||||
|
||||
if (this.lastItemCookTime != this.tileEntityAludel.itemCookTime)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 2, this.tileEntityAludel.itemCookTime);
|
||||
}
|
||||
}
|
||||
|
||||
this.lastDeviceCookTime = this.tileEntityAludel.deviceCookTime;
|
||||
this.lastFuelBurnTime = this.tileEntityAludel.fuelBurnTime;
|
||||
this.lastItemCookTime = this.tileEntityAludel.itemCookTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
ItemStack itemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotItemStack = slot.getStack();
|
||||
itemStack = slotItemStack.copy();
|
||||
|
||||
/**
|
||||
* If we are shift-clicking an item out of the Aludel's container,
|
||||
* attempt to put it in the first available slot in the player's
|
||||
* inventory
|
||||
*/
|
||||
if (slotIndex < TileEntityAludel.INVENTORY_SIZE)
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileEntityAludel.INVENTORY_SIZE, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* If the stack being shift-clicked into the Aludel's container
|
||||
* is a fuel, first try to put it in the fuel slot. If it cannot
|
||||
* be merged into the fuel slot, try to put it in the input
|
||||
* slot.
|
||||
*/
|
||||
if (TileEntityFurnace.isItemFuel(slotItemStack))
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileEntityAludel.FUEL_INVENTORY_INDEX, TileEntityAludel.OUTPUT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the stack being shift-clicked into the Aludel's container
|
||||
* is a dust, first try to put it in the dust slot. If it cannot
|
||||
* be merged into the dust slot, try to put it in the input
|
||||
* slot.
|
||||
*/
|
||||
else if (slotItemStack.getItem() instanceof ItemAlchemicalDust)
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileEntityAludel.DUST_INVENTORY_INDEX, TileEntityAludel.OUTPUT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finally, attempt to put stack into the input slot
|
||||
*/
|
||||
else if (!this.mergeItemStack(slotItemStack, TileEntityAludel.INPUT_INVENTORY_INDEX, TileEntityAludel.DUST_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotItemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int valueType, int updatedValue)
|
||||
{
|
||||
if (valueType == 0)
|
||||
{
|
||||
this.tileEntityAludel.deviceCookTime = updatedValue;
|
||||
}
|
||||
|
||||
if (valueType == 1)
|
||||
{
|
||||
this.tileEntityAludel.fuelBurnTime = updatedValue;
|
||||
}
|
||||
|
||||
if (valueType == 2)
|
||||
{
|
||||
this.tileEntityAludel.itemCookTime = updatedValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotAludelOutput extends Slot
|
||||
{
|
||||
public SlotAludelOutput(IInventory inventory, int x, int y, int z)
|
||||
{
|
||||
super(inventory, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(entityPlayer, itemStack, inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.pahimar.ee3.reference;
|
||||
|
||||
public class Particles
|
||||
public final class Particles
|
||||
{
|
||||
/* Vanilla particle names (not necessarily all of them) */
|
||||
public static final String NORMAL_SMOKE = "smoke";
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.pahimar.ee3.reference;
|
|||
import com.pahimar.ee3.util.ResourceLocationHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class Textures
|
||||
public final class Textures
|
||||
{
|
||||
public static final String RESOURCE_PREFIX = Reference.MOD_ID.toLowerCase() + ":";
|
||||
|
||||
|
|
|
@ -6,11 +6,14 @@ import com.pahimar.ee3.network.PacketHandler;
|
|||
import com.pahimar.ee3.network.message.MessageTileEntityAludel;
|
||||
import com.pahimar.ee3.recipe.RecipesAludel;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -65,6 +68,30 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory
|
|||
return slotIndex == OUTPUT_INVENTORY_INDEX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
// Read in the ItemStacks in the inventory from NBT
|
||||
NBTTagList tagList = nbtTagCompound.getTagList("Items", 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
byte slotIndex = tagCompound.getByte("Slot");
|
||||
if (slotIndex >= 0 && slotIndex < inventory.length)
|
||||
{
|
||||
inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
deviceCookTime = nbtTagCompound.getInteger("deviceCookTime");
|
||||
fuelBurnTime = nbtTagCompound.getInteger("fuelBurnTime");
|
||||
itemCookTime = nbtTagCompound.getInteger("itemCookTime");
|
||||
hasGlassBell = nbtTagCompound.getBoolean("hasGlassBell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
|
@ -181,45 +208,102 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
// Write the ItemStacks in the inventory to NBT
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex)
|
||||
{
|
||||
if (inventory[currentIndex] != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTagCompound.setTag("Items", tagList);
|
||||
nbtTagCompound.setInteger("deviceCookTime", deviceCookTime);
|
||||
nbtTagCompound.setInteger("fuelBurnTime", fuelBurnTime);
|
||||
nbtTagCompound.setInteger("itemCookTime", itemCookTime);
|
||||
nbtTagCompound.setBoolean("hasGlassBell", hasGlassBell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAludel(this, null));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getCookProgressScaled(int scale)
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
return this.itemCookTime * scale / 200;
|
||||
}
|
||||
boolean isBurning = this.deviceCookTime > 0;
|
||||
boolean sendUpdate = false;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBurnTimeRemainingScaled(int scale)
|
||||
{
|
||||
if (this.fuelBurnTime > 0)
|
||||
// If the Aludel still has burn time, decrement it
|
||||
if (this.deviceCookTime > 0)
|
||||
{
|
||||
return this.deviceCookTime * scale / this.fuelBurnTime;
|
||||
this.deviceCookTime--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void infuseItem()
|
||||
{
|
||||
if (this.canInfuse())
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
RecipeAludel recipe = RecipesAludel.getInstance().getRecipe(inventory[INPUT_INVENTORY_INDEX], inventory[DUST_INVENTORY_INDEX]);
|
||||
// Start "cooking" a new item, if we can
|
||||
if (this.deviceCookTime == 0 && this.canInfuse())
|
||||
{
|
||||
this.fuelBurnTime = this.deviceCookTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]);
|
||||
|
||||
if (this.inventory[OUTPUT_INVENTORY_INDEX] == null)
|
||||
{
|
||||
this.inventory[OUTPUT_INVENTORY_INDEX] = recipe.getRecipeOutput().copy();
|
||||
}
|
||||
else if (this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual(recipe.getRecipeOutput()))
|
||||
{
|
||||
inventory[OUTPUT_INVENTORY_INDEX].stackSize += recipe.getRecipeOutput().stackSize;
|
||||
if (this.deviceCookTime > 0)
|
||||
{
|
||||
sendUpdate = true;
|
||||
|
||||
if (this.inventory[FUEL_INVENTORY_INDEX] != null)
|
||||
{
|
||||
--this.inventory[FUEL_INVENTORY_INDEX].stackSize;
|
||||
|
||||
if (this.inventory[FUEL_INVENTORY_INDEX].stackSize == 0)
|
||||
{
|
||||
this.inventory[FUEL_INVENTORY_INDEX] = this.inventory[FUEL_INVENTORY_INDEX].getItem().getContainerItem(inventory[FUEL_INVENTORY_INDEX]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decrStackSize(INPUT_INVENTORY_INDEX, recipe.getRecipeInputs()[0].getStackSize());
|
||||
decrStackSize(DUST_INVENTORY_INDEX, recipe.getRecipeInputs()[1].getStackSize());
|
||||
// Continue "cooking" the same item, if we can
|
||||
if (this.deviceCookTime > 0 && this.canInfuse())
|
||||
{
|
||||
this.itemCookTime++;
|
||||
|
||||
if (this.itemCookTime == 200)
|
||||
{
|
||||
this.itemCookTime = 0;
|
||||
this.infuseItem();
|
||||
sendUpdate = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.itemCookTime = 0;
|
||||
}
|
||||
|
||||
// If the state has changed, catch that something changed
|
||||
if (isBurning != this.deviceCookTime > 0)
|
||||
{
|
||||
sendUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (sendUpdate)
|
||||
{
|
||||
this.markDirty();
|
||||
this.state = this.deviceCookTime > 0 ? (byte) 1 : (byte) 0;
|
||||
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.state);
|
||||
PacketHandler.INSTANCE.sendToAllAround(new MessageTileEntityAludel(this, null), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, (double) this.xCoord, (double) this.yCoord, (double) this.zCoord, 128d));
|
||||
this.worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,4 +340,40 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void infuseItem()
|
||||
{
|
||||
if (this.canInfuse())
|
||||
{
|
||||
RecipeAludel recipe = RecipesAludel.getInstance().getRecipe(inventory[INPUT_INVENTORY_INDEX], inventory[DUST_INVENTORY_INDEX]);
|
||||
|
||||
if (this.inventory[OUTPUT_INVENTORY_INDEX] == null)
|
||||
{
|
||||
this.inventory[OUTPUT_INVENTORY_INDEX] = recipe.getRecipeOutput().copy();
|
||||
}
|
||||
else if (this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual(recipe.getRecipeOutput()))
|
||||
{
|
||||
inventory[OUTPUT_INVENTORY_INDEX].stackSize += recipe.getRecipeOutput().stackSize;
|
||||
}
|
||||
|
||||
decrStackSize(INPUT_INVENTORY_INDEX, recipe.getRecipeInputs()[0].getStackSize());
|
||||
decrStackSize(DUST_INVENTORY_INDEX, recipe.getRecipeInputs()[1].getStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getCookProgressScaled(int scale)
|
||||
{
|
||||
return this.itemCookTime * scale / 200;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBurnTimeRemainingScaled(int scale)
|
||||
{
|
||||
if (this.fuelBurnTime > 0)
|
||||
{
|
||||
return this.deviceCookTime * scale / this.fuelBurnTime;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,8 +371,7 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor
|
|||
if (eventId == 1)
|
||||
{
|
||||
this.state = (byte) eventData;
|
||||
// NAME UPDATE
|
||||
// this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, this.zCoord);
|
||||
// NAME UPDATE - this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.worldObj.func_147451_t(this.xCoord, this.yCoord, this.zCoord);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue