Replaced bucket slots in GUIs with right click functionality

This commit is contained in:
Ellpeck 2016-05-06 23:23:29 +02:00
parent b8e08d582b
commit 89963a23fb
38 changed files with 138 additions and 241 deletions

View file

@ -46,8 +46,10 @@ public class BlockCanolaPress extends BlockContainerBase{
if(!world.isRemote){ if(!world.isRemote){
TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos); TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos);
if(press != null){ if(press != null){
if(!this.tryUseItemOnTank(player, stack, side, press)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
}
return true; return true;
} }
return true; return true;

View file

@ -66,8 +66,10 @@ public class BlockCoffeeMachine extends BlockContainerBase{
if(!world.isRemote){ if(!world.isRemote){
TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(pos); TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(pos);
if(machine != null){ if(machine != null){
if(!this.tryUseItemOnTank(player, stack, f6, machine)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
}
return true; return true;
} }
return true; return true;

View file

@ -52,8 +52,10 @@ public class BlockFermentingBarrel extends BlockContainerBase{
if(!world.isRemote){ if(!world.isRemote){
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel)world.getTileEntity(pos); TileEntityFermentingBarrel press = (TileEntityFermentingBarrel)world.getTileEntity(pos);
if(press != null){ if(press != null){
if(!this.tryUseItemOnTank(player, heldItem, par6, press)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
}
return true; return true;
} }
return true; return true;

View file

@ -59,8 +59,10 @@ public class BlockFluidCollector extends BlockContainerBase{
if(!world.isRemote){ if(!world.isRemote){
TileEntityFluidCollector collector = (TileEntityFluidCollector)world.getTileEntity(pos); TileEntityFluidCollector collector = (TileEntityFluidCollector)world.getTileEntity(pos);
if(collector != null){ if(collector != null){
if(!this.tryUseItemOnTank(player, stack, par6, collector)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
}
return true; return true;
} }
return true; return true;

View file

@ -68,8 +68,10 @@ public class BlockOilGenerator extends BlockContainerBase{
if(!world.isRemote){ if(!world.isRemote){
TileEntityOilGenerator generator = (TileEntityOilGenerator)world.getTileEntity(pos); TileEntityOilGenerator generator = (TileEntityOilGenerator)world.getTileEntity(pos);
if(generator != null){ if(generator != null){
if(!this.tryUseItemOnTank(player, stack, par6, generator)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
}
return true; return true;
} }
return true; return true;

View file

@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.tile.*;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
@ -33,11 +32,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.IFluidHandler;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
@ -174,6 +175,10 @@ public abstract class BlockContainerBase extends BlockContainer{
} }
} }
protected boolean tryUseItemOnTank(EntityPlayer player, ItemStack heldItem, EnumFacing sideHit, IFluidHandler tank){
return heldItem != null && FluidUtil.interactWithTank(heldItem, player, tank, sideHit);
}
@Override @Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state){ public void onBlockAdded(World world, BlockPos pos, IBlockState state){
this.updateRedstoneState(world, pos); this.updateRedstoneState(world, pos);

View file

@ -34,8 +34,6 @@ public class ContainerCanolaPress extends Container{
this.press = (TileEntityCanolaPress)tile; this.press = (TileEntityCanolaPress)tile;
this.addSlotToContainer(new Slot(this.press, 0, 81, 10)); this.addSlotToContainer(new Slot(this.press, 0, 81, 10));
this.addSlotToContainer(new Slot(this.press, 1, 136, 73));
this.addSlotToContainer(new SlotOutput(this.press, 2, 136, 42));
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){ for(int j = 0; j < 9; j++){
@ -49,7 +47,7 @@ public class ContainerCanolaPress extends Container{
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){ public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 3; final int inventoryStart = 1;
final int inventoryEnd = inventoryStart+26; final int inventoryEnd = inventoryStart+26;
final int hotbarStart = inventoryEnd+1; final int hotbarStart = inventoryEnd+1;
final int hotbarEnd = hotbarStart+8; final int hotbarEnd = hotbarStart+8;
@ -68,11 +66,6 @@ public class ContainerCanolaPress extends Container{
return null; return null;
} }
} }
else if(FluidContainerRegistry.getContainerCapacity(new FluidStack(InitFluids.fluidCanolaOil, 1), newStack) > 0){
if(!this.mergeItemStack(newStack, 1, 2, false)){
return null;
}
}
// //
else if(slot >= inventoryStart && slot <= inventoryEnd){ else if(slot >= inventoryStart && slot <= inventoryEnd){

View file

@ -44,9 +44,6 @@ public class ContainerCoffeeMachine extends Container{
} }
} }
this.addSlotToContainer(new Slot(this.machine, TileEntityCoffeeMachine.SLOT_WATER_INPUT, 26, 73));
this.addSlotToContainer(new SlotOutput(this.machine, TileEntityCoffeeMachine.SLOT_WATER_OUTPUT, 45, 73));
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){ for(int j = 0; j < 9; j++){
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
@ -59,7 +56,7 @@ public class ContainerCoffeeMachine extends Container{
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){ public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 13; final int inventoryStart = 11;
final int inventoryEnd = inventoryStart+26; final int inventoryEnd = inventoryStart+26;
final int hotbarStart = inventoryEnd+1; final int hotbarStart = inventoryEnd+1;
final int hotbarEnd = hotbarStart+8; final int hotbarEnd = hotbarStart+8;
@ -85,11 +82,6 @@ public class ContainerCoffeeMachine extends Container{
return null; return null;
} }
} }
else if(FluidContainerRegistry.containsFluid(newStack, new FluidStack(FluidRegistry.WATER, 1))){
if(!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_WATER_INPUT, TileEntityCoffeeMachine.SLOT_WATER_INPUT+1, false)){
return null;
}
}
else if(ItemCoffee.getIngredientFromStack(newStack) != null){ else if(ItemCoffee.getIngredientFromStack(newStack) != null){
if(!this.mergeItemStack(newStack, 3, 11, false)){ if(!this.mergeItemStack(newStack, 3, 11, false)){
return null; return null;

View file

@ -31,11 +31,6 @@ public class ContainerFermentingBarrel extends Container{
public ContainerFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){ public ContainerFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){
this.barrel = (TileEntityFermentingBarrel)tile; this.barrel = (TileEntityFermentingBarrel)tile;
this.addSlotToContainer(new Slot(this.barrel, 0, 42, 74));
this.addSlotToContainer(new SlotOutput(this.barrel, 1, 42, 43));
this.addSlotToContainer(new Slot(this.barrel, 2, 118, 74));
this.addSlotToContainer(new SlotOutput(this.barrel, 3, 118, 43));
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){ for(int j = 0; j < 9; j++){
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
@ -48,7 +43,7 @@ public class ContainerFermentingBarrel extends Container{
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){ public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 4; final int inventoryStart = 0;
final int inventoryEnd = inventoryStart+26; final int inventoryEnd = inventoryStart+26;
final int hotbarStart = inventoryEnd+1; final int hotbarStart = inventoryEnd+1;
final int hotbarEnd = hotbarStart+8; final int hotbarEnd = hotbarStart+8;
@ -61,20 +56,7 @@ public class ContainerFermentingBarrel extends Container{
//Other Slots in Inventory excluded //Other Slots in Inventory excluded
if(slot >= inventoryStart){ if(slot >= inventoryStart){
//Shift from Inventory if(slot >= inventoryStart && slot <= inventoryEnd){
if(FluidContainerRegistry.containsFluid(newStack, new FluidStack(InitFluids.fluidCanolaOil, 1))){
if(!this.mergeItemStack(newStack, 0, 1, false)){
return null;
}
}
else if(FluidContainerRegistry.getContainerCapacity(new FluidStack(InitFluids.fluidOil, 1), newStack) > 0){
if(!this.mergeItemStack(newStack, 2, 3, false)){
return null;
}
}
//
else if(slot >= inventoryStart && slot <= inventoryEnd){
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
return null; return null;
} }
@ -106,6 +88,6 @@ public class ContainerFermentingBarrel extends Container{
@Override @Override
public boolean canInteractWith(EntityPlayer player){ public boolean canInteractWith(EntityPlayer player){
return this.barrel.isUseableByPlayer(player); return this.barrel.canPlayerUse(player);
} }
} }

View file

@ -29,9 +29,6 @@ public class ContainerFluidCollector extends Container{
public ContainerFluidCollector(InventoryPlayer inventory, TileEntityBase tile){ public ContainerFluidCollector(InventoryPlayer inventory, TileEntityBase tile){
this.collector = (TileEntityFluidCollector)tile; this.collector = (TileEntityFluidCollector)tile;
this.addSlotToContainer(new Slot(this.collector, 0, 90, 73));
this.addSlotToContainer(new SlotOutput(this.collector, 1, 90, 42));
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){ for(int j = 0; j < 9; j++){
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
@ -44,7 +41,7 @@ public class ContainerFluidCollector extends Container{
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){ public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 2; final int inventoryStart = 0;
final int inventoryEnd = inventoryStart+26; final int inventoryEnd = inventoryStart+26;
final int hotbarStart = inventoryEnd+1; final int hotbarStart = inventoryEnd+1;
final int hotbarEnd = hotbarStart+8; final int hotbarEnd = hotbarStart+8;
@ -64,15 +61,7 @@ public class ContainerFluidCollector extends Container{
} }
//Other Slots in Inventory excluded //Other Slots in Inventory excluded
else if(slot >= inventoryStart){ else if(slot >= inventoryStart){
//Shift from Inventory if(slot >= inventoryStart && slot <= inventoryEnd){
if(FluidContainerRegistry.isEmptyContainer(newStack)){
if(!this.mergeItemStack(newStack, 0, 1, false)){
return null;
}
}
//
else if(slot >= inventoryStart && slot <= inventoryEnd){
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
return null; return null;
} }
@ -104,6 +93,6 @@ public class ContainerFluidCollector extends Container{
@Override @Override
public boolean canInteractWith(EntityPlayer player){ public boolean canInteractWith(EntityPlayer player){
return this.collector.isUseableByPlayer(player); return this.collector.canPlayerUse(player);
} }
} }

View file

@ -10,8 +10,6 @@
package de.ellpeck.actuallyadditions.mod.inventory; package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
import invtweaks.api.container.InventoryContainer; import invtweaks.api.container.InventoryContainer;
@ -20,8 +18,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
@InventoryContainer @InventoryContainer
public class ContainerOilGenerator extends Container{ public class ContainerOilGenerator extends Container{
@ -31,9 +27,6 @@ public class ContainerOilGenerator extends Container{
public ContainerOilGenerator(InventoryPlayer inventory, TileEntityBase tile){ public ContainerOilGenerator(InventoryPlayer inventory, TileEntityBase tile){
this.generator = (TileEntityOilGenerator)tile; this.generator = (TileEntityOilGenerator)tile;
this.addSlotToContainer(new Slot(this.generator, 0, 98, 74));
this.addSlotToContainer(new SlotOutput(this.generator, 1, 98, 43));
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){ for(int j = 0; j < 9; j++){
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
@ -46,12 +39,12 @@ public class ContainerOilGenerator extends Container{
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){ public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 2; final int inventoryStart = 0;
final int inventoryEnd = inventoryStart+26; final int inventoryEnd = inventoryStart+26;
final int hotbarStart = inventoryEnd+1; final int hotbarStart = inventoryEnd+1;
final int hotbarEnd = hotbarStart+8; final int hotbarEnd = hotbarStart+8;
Slot theSlot = (Slot)this.inventorySlots.get(slot); Slot theSlot = this.inventorySlots.get(slot);
if(theSlot != null && theSlot.getHasStack()){ if(theSlot != null && theSlot.getHasStack()){
ItemStack newStack = theSlot.getStack(); ItemStack newStack = theSlot.getStack();
@ -59,15 +52,7 @@ public class ContainerOilGenerator extends Container{
//Other Slots in Inventory excluded //Other Slots in Inventory excluded
if(slot >= inventoryStart){ if(slot >= inventoryStart){
//Shift from Inventory if(slot >= inventoryStart && slot <= inventoryEnd){
if(FluidContainerRegistry.containsFluid(newStack, new FluidStack(InitFluids.fluidOil, 1))){
if(!this.mergeItemStack(newStack, 0, 1, false)){
return null;
}
}
//
else if(slot >= inventoryStart && slot <= inventoryEnd){
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
return null; return null;
} }
@ -99,6 +84,6 @@ public class ContainerOilGenerator extends Container{
@Override @Override
public boolean canInteractWith(EntityPlayer player){ public boolean canInteractWith(EntityPlayer player){
return this.generator.isUseableByPlayer(player); return this.generator.canPlayerUse(player);
} }
} }

View file

@ -54,7 +54,7 @@ public class GuiFermentingBarrel extends GuiContainer{
@Override @Override
public void drawGuiContainerForegroundLayer(int x, int y){ public void drawGuiContainerForegroundLayer(int x, int y){
AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.press.getName()); AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.press.name);
} }
@Override @Override

View file

@ -49,7 +49,7 @@ public class GuiFluidCollector extends GuiContainer{
@Override @Override
public void drawGuiContainerForegroundLayer(int x, int y){ public void drawGuiContainerForegroundLayer(int x, int y){
AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.collector.getName()); AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.collector.name);
} }
@Override @Override

View file

@ -52,7 +52,7 @@ public class GuiOilGenerator extends GuiContainer{
@Override @Override
public void drawGuiContainerForegroundLayer(int x, int y){ public void drawGuiContainerForegroundLayer(int x, int y){
AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.generator.getName()); AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.generator.name);
} }
@Override @Override

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketUpdateTileEntity; import de.ellpeck.actuallyadditions.mod.network.PacketUpdateTileEntity;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
@ -30,7 +31,13 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
public boolean isRedstonePowered; public boolean isRedstonePowered;
protected int ticksElapsed; protected int ticksElapsed;
public String name;
public TileEntityBase(String name){
this.name = "container."+ModUtil.MOD_ID+"."+name;
}
//TODO Change for next major update to use the name variable automatically
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Registering TileEntities..."); ModUtil.LOGGER.info("Registering TileEntities...");
@ -151,6 +158,10 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
this.markDirty(); this.markDirty();
} }
public boolean canPlayerUse(EntityPlayer player){
return player.getDistanceSq(this.getPos().getX()+0.5D, this.pos.getY()+0.5D, this.pos.getZ()+0.5D) <= 64 && !this.isInvalid() && this.worldObj.getTileEntity(this.pos) == this;
}
protected final boolean sendUpdateWithInterval(){ protected final boolean sendUpdateWithInterval(){
if(this.ticksElapsed%ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){ if(this.ticksElapsed%ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){
this.sendUpdate(); this.sendUpdate();

View file

@ -15,6 +15,7 @@ import cofh.api.energy.IEnergyReceiver;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -30,14 +31,14 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
public static final int ENERGY_USE = 35; public static final int ENERGY_USE = 35;
private static final int TIME = 30; private static final int TIME = 30;
public EnergyStorage storage = new EnergyStorage(40000); public EnergyStorage storage = new EnergyStorage(40000);
public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); public FluidTank tank = new FluidTank(2*Util.BUCKET);
public int currentProcessTime; public int currentProcessTime;
private int lastEnergyStored; private int lastEnergyStored;
private int lastTankAmount; private int lastTankAmount;
private int lastProcessTime; private int lastProcessTime;
public TileEntityCanolaPress(){ public TileEntityCanolaPress(){
super(3, "canolaPress"); super(1, "canolaPress");
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -97,8 +98,6 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
this.currentProcessTime = 0; this.currentProcessTime = 0;
} }
WorldUtil.fillBucket(this.tank, this.slots, 1, 2);
if(this.tank.getFluidAmount() > 0){ if(this.tank.getFluidAmount() > 0){
WorldUtil.pushFluid(this.worldObj, this.pos, EnumFacing.DOWN, this.tank); WorldUtil.pushFluid(this.worldObj, this.pos, EnumFacing.DOWN, this.tank);
if(!this.isRedstonePowered){ if(!this.isRedstonePowered){
@ -119,7 +118,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == 0 && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CANOLA.ordinal()) || (i == 1 && stack.getItem() == Items.BUCKET); return (i == 0 && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CANOLA.ordinal());
} }
public boolean isCanola(int slot){ public boolean isCanola(int slot){
@ -133,7 +132,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return slot == 2 && FluidContainerRegistry.containsFluid(this.slots[0], new FluidStack(InitFluids.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME)); return false;
} }
@Override @Override

View file

@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -34,15 +35,13 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public static final int SLOT_COFFEE_BEANS = 0; public static final int SLOT_COFFEE_BEANS = 0;
public static final int SLOT_INPUT = 1; public static final int SLOT_INPUT = 1;
public static final int SLOT_OUTPUT = 2; public static final int SLOT_OUTPUT = 2;
public static final int SLOT_WATER_INPUT = 11;
public static final int SLOT_WATER_OUTPUT = 12;
public static final int CACHE_USE = 15; public static final int CACHE_USE = 15;
public static final int ENERGY_USED = 150; public static final int ENERGY_USED = 150;
public static final int WATER_USE = 500; public static final int WATER_USE = 500;
public static final int COFFEE_CACHE_MAX_AMOUNT = 300; public static final int COFFEE_CACHE_MAX_AMOUNT = 300;
private static final int TIME_USED = 500; private static final int TIME_USED = 500;
public EnergyStorage storage = new EnergyStorage(300000); public EnergyStorage storage = new EnergyStorage(300000);
public FluidTank tank = new FluidTank(4*FluidContainerRegistry.BUCKET_VOLUME); public FluidTank tank = new FluidTank(4*Util.BUCKET);
public int coffeeCacheAmount; public int coffeeCacheAmount;
public int brewTime; public int brewTime;
private int lastEnergy; private int lastEnergy;
@ -51,7 +50,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
private int lastBrewTime; private int lastBrewTime;
public TileEntityCoffeeMachine(){ public TileEntityCoffeeMachine(){
super(13, "coffeeMachine"); super(11, "coffeeMachine");
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -113,7 +112,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal()) || (i == SLOT_WATER_INPUT && FluidContainerRegistry.containsFluid(stack, new FluidStack(FluidRegistry.WATER, 1))); return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal());
} }
public void storeCoffee(){ public void storeCoffee(){
@ -127,8 +126,6 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
this.coffeeCacheAmount += toAdd; this.coffeeCacheAmount += toAdd;
} }
} }
WorldUtil.emptyBucket(this.tank, this.slots, SLOT_WATER_INPUT, SLOT_WATER_OUTPUT, FluidRegistry.WATER);
} }
public void brew(){ public void brew(){
@ -180,7 +177,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.slots.length-2 && ItemCoffee.getIngredientFromStack(stack) == null) || slot == SLOT_WATER_OUTPUT; return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.slots.length-2 && ItemCoffee.getIngredientFromStack(stack) == null);
} }
@Override @Override

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -20,18 +21,18 @@ import net.minecraftforge.fluids.*;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public class TileEntityFermentingBarrel extends TileEntityInventoryBase implements IFluidHandler, IFluidSaver{ public class TileEntityFermentingBarrel extends TileEntityBase implements IFluidHandler, IFluidSaver{
private static final int PROCESS_TIME = 100; private static final int PROCESS_TIME = 100;
public FluidTank canolaTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); public FluidTank canolaTank = new FluidTank(2*Util.BUCKET);
public FluidTank oilTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); public FluidTank oilTank = new FluidTank(2*Util.BUCKET);
public int currentProcessTime; public int currentProcessTime;
private int lastCanola; private int lastCanola;
private int lastOil; private int lastOil;
private int lastProcessTime; private int lastProcessTime;
public TileEntityFermentingBarrel(){ public TileEntityFermentingBarrel(){
super(4, "fermentingBarrel"); super("fermentingBarrel");
} }
@Override @Override
@ -72,9 +73,6 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
this.currentProcessTime = 0; this.currentProcessTime = 0;
} }
WorldUtil.emptyBucket(this.canolaTank, this.slots, 0, 1, InitFluids.fluidCanolaOil);
WorldUtil.fillBucket(this.oilTank, this.slots, 2, 3);
if(this.oilTank.getFluidAmount() > 0){ if(this.oilTank.getFluidAmount() > 0){
WorldUtil.pushFluid(this.worldObj, this.pos, EnumFacing.DOWN, this.oilTank); WorldUtil.pushFluid(this.worldObj, this.pos, EnumFacing.DOWN, this.oilTank);
if(!this.isRedstonePowered){ if(!this.isRedstonePowered){
@ -93,11 +91,6 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
} }
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == 0 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitFluids.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME))) || (i == 2 && stack.getItem() == Items.BUCKET);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getProcessScaled(int i){ public int getProcessScaled(int i){
return this.currentProcessTime*i/PROCESS_TIME; return this.currentProcessTime*i/PROCESS_TIME;
@ -113,16 +106,6 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
return this.canolaTank.getFluidAmount()*i/this.canolaTank.getCapacity(); return this.canolaTank.getFluidAmount()*i/this.canolaTank.getCapacity();
} }
@Override
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack);
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return (slot == 1 && stack.getItem() == Items.BUCKET) || (slot == 3 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitFluids.fluidOil, FluidContainerRegistry.BUCKET_VOLUME)));
}
@Override @Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill){ public int fill(EnumFacing from, FluidStack resource, boolean doFill){
if(from != EnumFacing.DOWN && resource.getFluid() == InitFluids.fluidCanolaOil){ if(from != EnumFacing.DOWN && resource.getFluid() == InitFluids.fluidCanolaOil){

View file

@ -32,6 +32,10 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
private boolean activateOnceWithSignal; private boolean activateOnceWithSignal;
private int oldEnergy; private int oldEnergy;
public TileEntityFireworkBox(){
super("fireworkBox");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);

View file

@ -32,6 +32,10 @@ public class TileEntityFishingNet extends TileEntityBase{
public int timeUntilNextDrop; public int timeUntilNextDrop;
public TileEntityFishingNet(){
super("fishingNet");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);

View file

@ -12,11 +12,10 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -24,20 +23,20 @@ import net.minecraftforge.fluids.*;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public class TileEntityFluidCollector extends TileEntityInventoryBase implements IFluidHandler, IFluidSaver, IRedstoneToggle{ public class TileEntityFluidCollector extends TileEntityBase implements IFluidHandler, IFluidSaver, IRedstoneToggle{
public FluidTank tank = new FluidTank(8*FluidContainerRegistry.BUCKET_VOLUME); public FluidTank tank = new FluidTank(8*Util.BUCKET);
public boolean isPlacer; public boolean isPlacer;
private int lastTankAmount; private int lastTankAmount;
private int currentTime; private int currentTime;
private boolean activateOnceWithSignal; private boolean activateOnceWithSignal;
public TileEntityFluidCollector(int slots, String name){ public TileEntityFluidCollector(String name){
super(slots, name); super(name);
} }
public TileEntityFluidCollector(){ public TileEntityFluidCollector(){
super(2, "fluidCollector"); this("fluidCollector");
this.isPlacer = false; this.isPlacer = false;
} }
@ -62,28 +61,28 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
if(coordsBlock != null){ if(coordsBlock != null){
Block blockToBreak = PosUtil.getBlock(coordsBlock, this.worldObj); Block blockToBreak = PosUtil.getBlock(coordsBlock, this.worldObj);
if(!this.isPlacer && blockToBreak != null && PosUtil.getMetadata(coordsBlock, this.worldObj) == 0 && FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){ if(!this.isPlacer && blockToBreak != null && PosUtil.getMetadata(coordsBlock, this.worldObj) == 0 && Util.BUCKET <= this.tank.getCapacity()-this.tank.getFluidAmount()){
if(blockToBreak instanceof IFluidBlock && ((IFluidBlock)blockToBreak).getFluid() != null){ if(blockToBreak instanceof IFluidBlock && ((IFluidBlock)blockToBreak).getFluid() != null){
if(this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){ if(this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), Util.BUCKET), false) >= Util.BUCKET){
this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), true); this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), Util.BUCKET), true);
WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.pos); WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.pos);
} }
} }
else if(blockToBreak == Blocks.LAVA || blockToBreak == Blocks.FLOWING_LAVA){ else if(blockToBreak == Blocks.LAVA || blockToBreak == Blocks.FLOWING_LAVA){
if(this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){ if(this.tank.fill(new FluidStack(FluidRegistry.LAVA, Util.BUCKET), false) >= Util.BUCKET){
this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), true); this.tank.fill(new FluidStack(FluidRegistry.LAVA, Util.BUCKET), true);
WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.pos); WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.pos);
} }
} }
else if(blockToBreak == Blocks.WATER || blockToBreak == Blocks.FLOWING_WATER){ else if(blockToBreak == Blocks.WATER || blockToBreak == Blocks.FLOWING_WATER){
if(this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){ if(this.tank.fill(new FluidStack(FluidRegistry.WATER, Util.BUCKET), false) >= Util.BUCKET){
this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), true); this.tank.fill(new FluidStack(FluidRegistry.WATER, Util.BUCKET), true);
WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.pos); WorldUtil.breakBlockAtSide(sideToManipulate, this.worldObj, this.pos);
} }
} }
} }
else if(this.isPlacer && PosUtil.getBlock(coordsBlock, this.worldObj).isReplaceable(this.worldObj, coordsBlock)){ else if(this.isPlacer && PosUtil.getBlock(coordsBlock, this.worldObj).isReplaceable(this.worldObj, coordsBlock)){
if(this.tank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME){ if(this.tank.getFluidAmount() >= Util.BUCKET){
Block block = this.tank.getFluid().getFluid().getBlock(); Block block = this.tank.getFluid().getFluid().getBlock();
if(block != null){ if(block != null){
BlockPos offsetPos = this.pos.offset(sideToManipulate); BlockPos offsetPos = this.pos.offset(sideToManipulate);
@ -91,7 +90,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
boolean replaceable = blockPresent.isReplaceable(this.worldObj, offsetPos); boolean replaceable = blockPresent.isReplaceable(this.worldObj, offsetPos);
if(replaceable){ if(replaceable){
PosUtil.setBlock(offsetPos, this.worldObj, block, 0, 3); PosUtil.setBlock(offsetPos, this.worldObj, block, 0, 3);
this.tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); this.tank.drain(Util.BUCKET, true);
} }
} }
} }
@ -169,13 +168,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
} }
} }
if(!this.isPlacer){
WorldUtil.fillBucket(this.tank, this.slots, 0, 1);
}
else{
WorldUtil.emptyBucket(this.tank, this.slots, 0, 1);
}
if(!this.isPlacer && this.tank.getFluidAmount() > 0){ if(!this.isPlacer && this.tank.getFluidAmount() > 0){
WorldUtil.pushFluid(this.worldObj, this.pos, EnumFacing.DOWN, this.tank); WorldUtil.pushFluid(this.worldObj, this.pos, EnumFacing.DOWN, this.tank);
if(!this.isRedstonePowered){ if(!this.isRedstonePowered){
@ -192,34 +184,11 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
} }
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
if(i == 0){
if(this.isPlacer){
return FluidContainerRegistry.isFilledContainer(stack);
}
else{
return stack.isItemEqual(FluidContainerRegistry.EMPTY_BUCKET);
}
}
return false;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getTankScaled(int i){ public int getTankScaled(int i){
return this.tank.getFluidAmount()*i/this.tank.getCapacity(); return this.tank.getFluidAmount()*i/this.tank.getCapacity();
} }
@Override
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack);
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return slot == 1;
}
@Override @Override
public FluidStack[] getFluids(){ public FluidStack[] getFluids(){
return new FluidStack[]{this.tank.getFluid()}; return new FluidStack[]{this.tank.getFluid()};
@ -233,7 +202,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
public static class TileEntityFluidPlacer extends TileEntityFluidCollector{ public static class TileEntityFluidPlacer extends TileEntityFluidCollector{
public TileEntityFluidPlacer(){ public TileEntityFluidPlacer(){
super(2, "fluidPlacer"); super("fluidPlacer");
this.isPlacer = true; this.isPlacer = true;
} }

View file

@ -26,6 +26,10 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
public EnergyStorage storage = new EnergyStorage(30000); public EnergyStorage storage = new EnergyStorage(30000);
private int oldEnergy; private int oldEnergy;
public TileEntityFurnaceSolar(){
super("solarPanel");
}
@Override @Override
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){ public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
return this.storage.extractEnergy(maxExtract, simulate); return this.storage.extractEnergy(maxExtract, simulate);

View file

@ -24,6 +24,10 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
private int timeUntilNextFert; private int timeUntilNextFert;
public TileEntityGreenhouseGlass(){
super("greenhouseGlass");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync); super.writeSyncableNBT(compound, isForSync);

View file

@ -32,6 +32,10 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
public EnergyStorage storage = new EnergyStorage(30000); public EnergyStorage storage = new EnergyStorage(30000);
private int oldEnergy; private int oldEnergy;
public TileEntityHeatCollector(){
super("heatCollector");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync); super.writeSyncableNBT(compound, isForSync);

View file

@ -27,12 +27,12 @@ import net.minecraftforge.items.wrapper.SidedInvWrapper;
public abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{ public abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{
public ItemStack slots[]; public ItemStack slots[];
public String name;
private SidedInvWrapper[] invWrappers = new SidedInvWrapper[6]; private SidedInvWrapper[] invWrappers = new SidedInvWrapper[6];
public TileEntityInventoryBase(int slots, String name){ public TileEntityInventoryBase(int slots, String name){
super(name);
this.initializeSlots(slots); this.initializeSlots(slots);
this.name = "container."+ModUtil.MOD_ID+"."+name;
for(int i = 0; i < this.invWrappers.length; i++){ for(int i = 0; i < this.invWrappers.length; i++){
this.invWrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]); this.invWrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]);
@ -109,10 +109,9 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
@Override @Override
public boolean isUseableByPlayer(EntityPlayer player){ public boolean isUseableByPlayer(EntityPlayer player){
return player.getDistanceSq(this.getPos().getX()+0.5D, this.pos.getY()+0.5D, this.pos.getZ()+0.5D) <= 64 && !this.isInvalid() && this.worldObj.getTileEntity(this.pos) == this; return this.canPlayerUse(player);
} }
@Override @Override
public void openInventory(EntityPlayer player){ public void openInventory(EntityPlayer player){

View file

@ -31,6 +31,10 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
public static final int MAX_DISTANCE = 15; public static final int MAX_DISTANCE = 15;
private static final float[] COLOR = new float[]{1F, 0F, 0F}; private static final float[] COLOR = new float[]{1F, 0F, 0F};
public TileEntityLaserRelay(){
super("laserRelay");
}
@Override @Override
public void receiveSyncCompound(NBTTagCompound compound){ public void receiveSyncCompound(NBTTagCompound compound){
BlockPos thisPos = this.pos; BlockPos thisPos = this.pos;

View file

@ -33,6 +33,10 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
private int currentWorkTime; private int currentWorkTime;
private int oldEnergy; private int oldEnergy;
public TileEntityLavaFactoryController(){
super("lavaFactory");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);

View file

@ -37,6 +37,10 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
private int nextUseCounter; private int nextUseCounter;
private int oldEnergy; private int oldEnergy;
public TileEntityLeafGenerator(){
super("leafGenerator");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);

View file

@ -14,6 +14,7 @@ import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyProvider;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -22,19 +23,19 @@ import net.minecraftforge.fluids.*;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public class TileEntityOilGenerator extends TileEntityInventoryBase implements IEnergyProvider, IFluidHandler, IEnergySaver, IFluidSaver{ public class TileEntityOilGenerator extends TileEntityBase implements IEnergyProvider, IFluidHandler, IEnergySaver, IFluidSaver{
public static final int ENERGY_PRODUCED = 76; public static final int ENERGY_PRODUCED = 76;
private static final int BURN_TIME = 100; private static final int BURN_TIME = 100;
public EnergyStorage storage = new EnergyStorage(50000); public EnergyStorage storage = new EnergyStorage(50000);
public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); public FluidTank tank = new FluidTank(2*Util.BUCKET);
public int currentBurnTime; public int currentBurnTime;
private int lastEnergy; private int lastEnergy;
private int lastTank; private int lastTank;
private int lastBurnTime; private int lastBurnTime;
public TileEntityOilGenerator(){ public TileEntityOilGenerator(){
super(2, "oilGenerator"); super("oilGenerator");
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -88,8 +89,6 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
} }
WorldUtil.emptyBucket(this.tank, this.slots, 0, 1, InitFluids.fluidOil);
if(this.storage.getEnergyStored() > 0){ if(this.storage.getEnergyStored() > 0){
WorldUtil.pushEnergyToAllSides(this.worldObj, this.pos, this.storage); WorldUtil.pushEnergyToAllSides(this.worldObj, this.pos, this.storage);
} }
@ -115,21 +114,6 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return FluidContainerRegistry.containsFluid(stack, new FluidStack(InitFluids.fluidOil, FluidContainerRegistry.BUCKET_VOLUME)) && i == 0;
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack);
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return slot == 1;
}
@Override @Override
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){ public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
return this.storage.extractEnergy(maxExtract, simulate); return this.storage.extractEnergy(maxExtract, simulate);

View file

@ -12,4 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
public class TileEntityPhantomBooster extends TileEntityBase{ public class TileEntityPhantomBooster extends TileEntityBase{
public TileEntityPhantomBooster(){
super("phantomBooster");
}
} }

View file

@ -22,6 +22,10 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
public String name; public String name;
private String nameBefore; private String nameBefore;
public TileEntitySmileyCloud(){
super("smileyCloud");
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);

View file

@ -17,6 +17,7 @@ import net.minecraft.item.Item;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import java.util.Random; import java.util.Random;
@ -26,6 +27,7 @@ public class Util{
public static final Random RANDOM = new Random(); public static final Random RANDOM = new Random();
public static final int WILDCARD = OreDictionary.WILDCARD_VALUE; public static final int WILDCARD = OreDictionary.WILDCARD_VALUE;
public static final int BUCKET = FluidContainerRegistry.BUCKET_VOLUME;
public static final EnumRarity CRYSTAL_RED_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalRed", TextFormatting.DARK_RED, ModUtil.NAME+" Red Crystal"); public static final EnumRarity CRYSTAL_RED_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalRed", TextFormatting.DARK_RED, ModUtil.NAME+" Red Crystal");
public static final EnumRarity CRYSTAL_BLUE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalBlue", TextFormatting.DARK_BLUE, ModUtil.NAME+" Blue Crystal"); public static final EnumRarity CRYSTAL_BLUE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalBlue", TextFormatting.DARK_BLUE, ModUtil.NAME+" Blue Crystal");

View file

@ -120,9 +120,17 @@ public class WorldUtil{
boolean replaceable = block.isReplaceable(world, offsetPos); boolean replaceable = block.isReplaceable(world, offsetPos);
//Fluids //Fluids
if(replaceable && FluidContainerRegistry.isFilledContainer(stack) && !(block instanceof IFluidBlock) && !(block instanceof BlockLiquid)){ if(replaceable && !(block instanceof IFluidBlock) && !(block instanceof BlockLiquid)){
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack); FluidStack fluid = null;
if(fluid != null && fluid.getFluid().getBlock() != null && fluid.getFluid().getBlock().canPlaceBlockAt(world, offsetPos)){ //TODO Remove when FluidContainerRegistry is gone
if(FluidContainerRegistry.isFilledContainer(stack)){
fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
}
else if(stack.getItem() instanceof IFluidContainerItem){
fluid = ((IFluidContainerItem)stack.getItem()).getFluid(stack);
}
if(fluid != null && fluid.amount >= Util.BUCKET && fluid.getFluid().getBlock() != null && fluid.getFluid().getBlock().canPlaceBlockAt(world, offsetPos)){
if(PosUtil.setBlock(offsetPos, world, fluid.getFluid().getBlock(), 0, 2)){ if(PosUtil.setBlock(offsetPos, world, fluid.getFluid().getBlock(), 0, 2)){
return stack.getItem().getContainerItem(stack); return stack.getItem().getContainerItem(stack);
} }
@ -170,56 +178,6 @@ public class WorldUtil{
} }
} }
public static void fillBucket(FluidTank tank, ItemStack[] slots, int inputSlot, int outputSlot){
if(slots[inputSlot] != null && tank.getFluid() != null){
ItemStack filled = FluidContainerRegistry.fillFluidContainer(tank.getFluid(), slots[inputSlot].copy());
if(filled != null && FluidContainerRegistry.isEmptyContainer(slots[inputSlot]) && (slots[outputSlot] == null || (slots[outputSlot].isItemEqual(filled) && slots[outputSlot].stackSize < slots[outputSlot].getMaxStackSize()))){
int cap = FluidContainerRegistry.getContainerCapacity(tank.getFluid(), slots[inputSlot]);
if(cap > 0 && cap <= tank.getFluidAmount()){
if(slots[outputSlot] == null){
slots[outputSlot] = FluidContainerRegistry.fillFluidContainer(tank.getFluid(), slots[inputSlot].copy());
}
else{
slots[outputSlot].stackSize++;
}
if(slots[outputSlot] != null){
tank.drain(cap, true);
slots[inputSlot].stackSize--;
if(slots[inputSlot].stackSize <= 0){
slots[inputSlot] = null;
}
}
}
}
}
}
public static void emptyBucket(FluidTank tank, ItemStack[] slots, int inputSlot, int outputSlot){
emptyBucket(tank, slots, inputSlot, outputSlot, null);
}
public static void emptyBucket(FluidTank tank, ItemStack[] slots, int inputSlot, int outputSlot, Fluid containedFluid){
if(slots[inputSlot] != null && FluidContainerRegistry.isFilledContainer(slots[inputSlot]) && (slots[outputSlot] == null || (slots[outputSlot].isItemEqual(FluidContainerRegistry.drainFluidContainer(slots[inputSlot].copy())) && slots[outputSlot].stackSize < slots[outputSlot].getMaxStackSize()))){
if(containedFluid == null || FluidContainerRegistry.containsFluid(slots[inputSlot], new FluidStack(containedFluid, 0))){
if((tank.getFluid() == null || FluidContainerRegistry.getFluidForFilledItem(slots[inputSlot]).isFluidEqual(tank.getFluid())) && tank.getCapacity()-tank.getFluidAmount() >= FluidContainerRegistry.getContainerCapacity(slots[inputSlot])){
if(slots[outputSlot] == null){
slots[outputSlot] = FluidContainerRegistry.drainFluidContainer(slots[inputSlot].copy());
}
else{
slots[outputSlot].stackSize++;
}
tank.fill(FluidContainerRegistry.getFluidForFilledItem(slots[inputSlot]), true);
slots[inputSlot].stackSize--;
if(slots[inputSlot].stackSize <= 0){
slots[inputSlot] = null;
}
}
}
}
}
public static EnumFacing getDirectionBySidesInOrder(int side){ public static EnumFacing getDirectionBySidesInOrder(int side){
switch(side){ switch(side){
case 0: case 0:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB