All Client and Server Syncing is now done with Events instead of the Vanilla Container Features

This commit is contained in:
Ellpeck 2015-07-02 04:21:21 +02:00
parent 8867c358b4
commit f5801188d6
34 changed files with 495 additions and 690 deletions

View file

@ -1,8 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
@ -13,20 +10,14 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@InventoryContainer
public class ContainerCanolaPress extends Container{
private TileEntityCanolaPress press;
private int lastEnergyStored;
private int lastTankAmount;
private int lastProcessTime;
public ContainerCanolaPress(InventoryPlayer inventory, TileEntityBase tile){
this.press = (TileEntityCanolaPress)tile;
@ -49,38 +40,6 @@ public class ContainerCanolaPress extends Container{
return this.press.isUseableByPlayer(player);
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.press.storage.getEnergyStored());
iCraft.sendProgressBarUpdate(this, 1, this.press.tank.getFluidAmount());
iCraft.sendProgressBarUpdate(this, 2, this.press.currentProcessTime);
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastEnergyStored != this.press.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.press.storage.getEnergyStored());
if(this.lastTankAmount != this.press.tank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 1, this.press.tank.getFluidAmount());
if(this.lastProcessTime != this.press.currentProcessTime) iCraft.sendProgressBarUpdate(this, 2, this.press.currentProcessTime);
}
this.lastEnergyStored = this.press.storage.getEnergyStored();
this.lastTankAmount = this.press.tank.getFluidAmount();
this.lastProcessTime = this.press.currentProcessTime;
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.press.storage.setEnergyStored(par2);
if(par1 == 1) this.press.tank.setFluid(new FluidStack(InitBlocks.fluidCanolaOil, par2));
if(par1 == 2) this.press.currentProcessTime = par2;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 3;

View file

@ -1,14 +1,11 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityCoalGenerator;
import invtweaks.api.container.InventoryContainer;
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;
@ -18,10 +15,6 @@ public class ContainerCoalGenerator extends Container{
private TileEntityCoalGenerator generator;
private int lastEnergyStored;
private int lastBurnTime;
private int lastMaxBurnTime;
public ContainerCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){
this.generator = (TileEntityCoalGenerator)tile;
@ -42,38 +35,6 @@ public class ContainerCoalGenerator extends Container{
return this.generator.isUseableByPlayer(player);
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.generator.storage.getEnergyStored());
iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime);
iCraft.sendProgressBarUpdate(this, 2, this.generator.maxBurnTime);
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastEnergyStored != this.generator.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.generator.storage.getEnergyStored());
if(this.lastBurnTime != this.generator.currentBurnTime) iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime);
if(this.lastMaxBurnTime != this.generator.maxBurnTime) iCraft.sendProgressBarUpdate(this, 2, this.generator.maxBurnTime);
}
this.lastEnergyStored = this.generator.storage.getEnergyStored();
this.lastBurnTime = this.generator.currentBurnTime;
this.lastMaxBurnTime = this.generator.maxBurnTime;
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.generator.storage.setEnergyStored(par2);
if(par1 == 1) this.generator.currentBurnTime = par2;
if(par1 == 2) this.generator.maxBurnTime = par2;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 1;

View file

@ -1,7 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.ItemCoffee;
@ -12,7 +10,6 @@ import invtweaks.api.container.InventoryContainer;
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.minecraftforge.fluids.FluidContainerRegistry;
@ -24,11 +21,6 @@ public class ContainerCoffeeMachine extends Container{
private TileEntityCoffeeMachine machine;
private int lastCoffeeAmount;
private int lastEnergyAmount;
private int lastBrewTime;
private int lastWaterAmount;
public ContainerCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){
this.machine = (TileEntityCoffeeMachine)tile;
@ -55,43 +47,6 @@ public class ContainerCoffeeMachine extends Container{
}
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.machine.storage.getEnergyStored());
iCraft.sendProgressBarUpdate(this, 1, this.machine.coffeeCacheAmount);
iCraft.sendProgressBarUpdate(this, 2, this.machine.brewTime);
iCraft.sendProgressBarUpdate(this, 3, this.machine.tank.getFluidAmount());
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastEnergyAmount != this.machine.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.machine.storage.getEnergyStored());
if(this.lastCoffeeAmount != this.machine.coffeeCacheAmount) iCraft.sendProgressBarUpdate(this, 1, this.machine.coffeeCacheAmount);
if(this.lastBrewTime != this.machine.brewTime) iCraft.sendProgressBarUpdate(this, 2, this.machine.brewTime);
if(this.lastWaterAmount != this.machine.tank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 3, this.machine.tank.getFluidAmount());
}
this.lastEnergyAmount = this.machine.storage.getEnergyStored();
this.lastCoffeeAmount = this.machine.coffeeCacheAmount;
this.lastBrewTime = this.machine.brewTime;
this.lastWaterAmount = this.machine.tank.getFluidAmount();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.machine.storage.setEnergyStored(par2);
if(par1 == 1) this.machine.coffeeCacheAmount = par2;
if(par1 == 2) this.machine.brewTime = par2;
if(par1 == 3) this.machine.tank.setFluid(new FluidStack(FluidRegistry.WATER, par2));
}
@Override
public boolean canInteractWith(EntityPlayer player){
return this.machine.isUseableByPlayer(player);

View file

@ -1,8 +1,6 @@
package ellpeck.actuallyadditions.inventory;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityEnergizer;
@ -10,7 +8,6 @@ import invtweaks.api.container.InventoryContainer;
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;
@ -19,8 +16,6 @@ public class ContainerEnergizer extends Container{
private TileEntityEnergizer energizer;
private int lastEnergyStored;
public ContainerEnergizer(InventoryPlayer inventory, TileEntityBase tile){
this.energizer = (TileEntityEnergizer)tile;
@ -42,30 +37,6 @@ public class ContainerEnergizer extends Container{
return this.energizer.isUseableByPlayer(player);
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.energizer.storage.getEnergyStored());
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastEnergyStored != this.energizer.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.energizer.storage.getEnergyStored());
}
this.lastEnergyStored = this.energizer.storage.getEnergyStored();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.energizer.storage.setEnergyStored(par2);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 2;

View file

@ -1,8 +1,6 @@
package ellpeck.actuallyadditions.inventory;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityEnervator;
@ -10,7 +8,6 @@ import invtweaks.api.container.InventoryContainer;
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;
@ -19,8 +16,6 @@ public class ContainerEnervator extends Container{
private TileEntityEnervator enervator;
private int lastEnergyStored;
public ContainerEnervator(InventoryPlayer inventory, TileEntityBase tile){
this.enervator = (TileEntityEnervator)tile;
@ -42,30 +37,6 @@ public class ContainerEnervator extends Container{
return this.enervator.isUseableByPlayer(player);
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.enervator.storage.getEnergyStored());
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastEnergyStored != this.enervator.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.enervator.storage.getEnergyStored());
}
this.lastEnergyStored = this.enervator.storage.getEnergyStored();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.enervator.storage.setEnergyStored(par2);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 2;

View file

@ -1,14 +1,11 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityFeeder;
import invtweaks.api.container.InventoryContainer;
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;
@ -17,9 +14,6 @@ public class ContainerFeeder extends Container{
private TileEntityFeeder tileFeeder;
private int lastCurrentTimer;
private int lastCurrentAnimalAmount;
public ContainerFeeder(InventoryPlayer inventory, TileEntityBase tile){
this.tileFeeder = (TileEntityFeeder)tile;
this.addSlotToContainer(new Slot(this.tileFeeder, 0, 80, 45));
@ -34,34 +28,6 @@ public class ContainerFeeder extends Container{
}
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.tileFeeder.currentTimer);
iCraft.sendProgressBarUpdate(this, 1, this.tileFeeder.currentAnimalAmount);
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastCurrentTimer != this.tileFeeder.currentTimer) iCraft.sendProgressBarUpdate(this, 0, this.tileFeeder.currentTimer);
if(this.lastCurrentAnimalAmount != this.tileFeeder.currentAnimalAmount) iCraft.sendProgressBarUpdate(this, 1, this.tileFeeder.currentAnimalAmount);
}
this.lastCurrentTimer = this.tileFeeder.currentTimer;
this.lastCurrentAnimalAmount = this.tileFeeder.currentAnimalAmount;
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.tileFeeder.currentTimer = par2;
if(par1 == 1) this.tileFeeder.currentAnimalAmount = par2;
}
@Override
public boolean canInteractWith(EntityPlayer player){
return this.tileFeeder.isUseableByPlayer(player);

View file

@ -1,7 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.tile.TileEntityBase;
@ -11,7 +9,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
@ -22,10 +19,6 @@ public class ContainerFermentingBarrel extends Container{
private TileEntityFermentingBarrel barrel;
private int lastProcessTime;
private int lastCanolaTank;
private int lastOilTank;
public ContainerFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){
this.barrel = (TileEntityFermentingBarrel)tile;
@ -49,38 +42,6 @@ public class ContainerFermentingBarrel extends Container{
return this.barrel.isUseableByPlayer(player);
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.barrel.oilTank.getFluidAmount());
iCraft.sendProgressBarUpdate(this, 1, this.barrel.canolaTank.getFluidAmount());
iCraft.sendProgressBarUpdate(this, 2, this.barrel.currentProcessTime);
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastOilTank != this.barrel.oilTank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 0, this.barrel.oilTank.getFluidAmount());
if(this.lastCanolaTank != this.barrel.canolaTank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 1, this.barrel.canolaTank.getFluidAmount());
if(this.lastProcessTime != this.barrel.currentProcessTime) iCraft.sendProgressBarUpdate(this, 2, this.barrel.currentProcessTime);
}
this.lastOilTank = this.barrel.oilTank.getFluidAmount();
this.lastCanolaTank = this.barrel.canolaTank.getFluidAmount();
this.lastProcessTime = this.barrel.currentProcessTime;
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.barrel.oilTank.setFluid(new FluidStack(InitBlocks.fluidOil, par2));
if(par1 == 1) this.barrel.canolaTank.setFluid(new FluidStack(InitBlocks.fluidCanolaOil, par2));
if(par1 == 2) this.barrel.currentProcessTime = par2;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 4;

View file

@ -1,7 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityFurnaceDouble;
@ -9,7 +7,6 @@ import invtweaks.api.container.InventoryContainer;
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.item.crafting.FurnaceRecipes;
@ -19,11 +16,6 @@ public class ContainerFurnaceDouble extends Container{
private TileEntityFurnaceDouble tileFurnace;
private int lastEnergy;
private int lastFirstCrushTime;
private int lastSecondCrushTime;
private int lastBurnTime;
public ContainerFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){
this.tileFurnace = (TileEntityFurnaceDouble)tile;
@ -42,42 +34,6 @@ public class ContainerFurnaceDouble extends Container{
}
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.tileFurnace.firstSmeltTime);
iCraft.sendProgressBarUpdate(this, 1, this.tileFurnace.secondSmeltTime);
iCraft.sendProgressBarUpdate(this, 2, this.tileFurnace.maxBurnTime);
iCraft.sendProgressBarUpdate(this, 3, this.tileFurnace.storage.getEnergyStored());
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastFirstCrushTime != this.tileFurnace.firstSmeltTime) iCraft.sendProgressBarUpdate(this, 0, this.tileFurnace.firstSmeltTime);
if(this.lastSecondCrushTime != this.tileFurnace.secondSmeltTime) iCraft.sendProgressBarUpdate(this, 1, this.tileFurnace.secondSmeltTime);
if(this.lastBurnTime != this.tileFurnace.maxBurnTime) iCraft.sendProgressBarUpdate(this, 2, this.tileFurnace.maxBurnTime);
if(this.lastEnergy != this.tileFurnace.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 3, this.tileFurnace.storage.getEnergyStored());
}
this.lastFirstCrushTime = this.tileFurnace.firstSmeltTime;
this.lastSecondCrushTime = this.tileFurnace.secondSmeltTime;
this.lastBurnTime = this.tileFurnace.maxBurnTime;
this.lastEnergy = this.tileFurnace.storage.getEnergyStored();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.tileFurnace.firstSmeltTime = par2;
if(par1 == 1) this.tileFurnace.secondSmeltTime = par2;
if(par1 == 2) this.tileFurnace.maxBurnTime = par2;
if(par1 == 3) this.tileFurnace.storage.setEnergyStored(par2);
}
@Override
public boolean canInteractWith(EntityPlayer player){
return this.tileFurnace.isUseableByPlayer(player);

View file

@ -1,7 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry;
import ellpeck.actuallyadditions.tile.TileEntityBase;
@ -10,7 +8,6 @@ import invtweaks.api.container.InventoryContainer;
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;
@ -20,11 +17,6 @@ public class ContainerGrinder extends Container{
public TileEntityGrinder tileGrinder;
private boolean isDouble;
private int lastFirstCrushTime;
private int lastSecondCrushTime;
private int lastMaxCrushTime;
private int lastEnergyStored;
public ContainerGrinder(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble){
this.tileGrinder = (TileEntityGrinder)tile;
this.isDouble = isDouble;
@ -48,42 +40,6 @@ public class ContainerGrinder extends Container{
}
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.tileGrinder.firstCrushTime);
iCraft.sendProgressBarUpdate(this, 1, this.tileGrinder.maxCrushTime);
iCraft.sendProgressBarUpdate(this, 2, this.tileGrinder.storage.getEnergyStored());
if(this.isDouble) iCraft.sendProgressBarUpdate(this, 3, this.tileGrinder.secondCrushTime);
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastFirstCrushTime != this.tileGrinder.firstCrushTime) iCraft.sendProgressBarUpdate(this, 0, this.tileGrinder.firstCrushTime);
if(this.lastMaxCrushTime != this.tileGrinder.maxCrushTime) iCraft.sendProgressBarUpdate(this, 1, this.tileGrinder.maxCrushTime);
if(this.lastEnergyStored != this.tileGrinder.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 2, this.tileGrinder.storage.getEnergyStored());
if(this.isDouble) if(this.lastSecondCrushTime != this.tileGrinder.secondCrushTime) iCraft.sendProgressBarUpdate(this, 3, this.tileGrinder.secondCrushTime);
}
this.lastFirstCrushTime = this.tileGrinder.firstCrushTime;
this.lastMaxCrushTime = this.tileGrinder.maxCrushTime;
this.lastEnergyStored = this.tileGrinder.storage.getEnergyStored();
if(this.isDouble) this.lastSecondCrushTime = this.tileGrinder.secondCrushTime;
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.tileGrinder.firstCrushTime = par2;
if(par1 == 1) this.tileGrinder.maxCrushTime = par2;
if(par1 == 2) this.tileGrinder.storage.setEnergyStored(par2);
if(this.isDouble && par1 == 3) this.tileGrinder.secondCrushTime = par2;
}
@Override
public boolean canInteractWith(EntityPlayer player){
return this.tileGrinder.isUseableByPlayer(player);

View file

@ -1,7 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.gui.GuiInputter;
import ellpeck.actuallyadditions.inventory.slot.SlotFilter;
import ellpeck.actuallyadditions.tile.TileEntityBase;
@ -10,7 +8,6 @@ import invtweaks.api.container.InventoryContainer;
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;
@ -19,16 +16,6 @@ public class ContainerInputter extends Container{
private TileEntityInputter tileInputter;
private int lastSideToPut;
private int lastSideToPull;
private int lastIsPullWhitelist;
private int lastIsPutWhitelist;
private int lastSlotPutStart;
private int lastSlotPutEnd;
private int lastSlotPullStart;
private int lastSlotPullEnd;
private boolean isAdvanced;
public ContainerInputter(InventoryPlayer inventory, TileEntityBase tile, boolean isAdvanced){
@ -57,61 +44,6 @@ public class ContainerInputter extends Container{
}
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.tileInputter.sideToPut);
iCraft.sendProgressBarUpdate(this, 1, this.tileInputter.sideToPull);
iCraft.sendProgressBarUpdate(this, 2, this.tileInputter.isPullWhitelist ? 1 : 0);
iCraft.sendProgressBarUpdate(this, 3, this.tileInputter.isPutWhitelist ? 1 : 0);
iCraft.sendProgressBarUpdate(this, 4, this.tileInputter.slotToPutStart);
iCraft.sendProgressBarUpdate(this, 5, this.tileInputter.slotToPutEnd);
iCraft.sendProgressBarUpdate(this, 6, this.tileInputter.slotToPullStart);
iCraft.sendProgressBarUpdate(this, 7, this.tileInputter.slotToPullEnd);
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastSideToPut != this.tileInputter.sideToPut) iCraft.sendProgressBarUpdate(this, 0, this.tileInputter.sideToPut);
if(this.lastSideToPull != this.tileInputter.sideToPull) iCraft.sendProgressBarUpdate(this, 1, this.tileInputter.sideToPull);
if(this.lastIsPullWhitelist != (this.tileInputter.isPullWhitelist ? 1 : 0)) iCraft.sendProgressBarUpdate(this, 2, this.tileInputter.isPullWhitelist ? 1 : 0);
if(this.lastIsPutWhitelist != (this.tileInputter.isPutWhitelist ? 1 : 0)) iCraft.sendProgressBarUpdate(this, 3, this.tileInputter.isPutWhitelist ? 1 : 0);
if(this.lastSlotPutStart != this.tileInputter.slotToPutStart) iCraft.sendProgressBarUpdate(this, 4, this.tileInputter.slotToPutStart);
if(this.lastSlotPutEnd != this.tileInputter.slotToPutEnd) iCraft.sendProgressBarUpdate(this, 5, this.tileInputter.slotToPutEnd);
if(this.lastSlotPullStart != this.tileInputter.slotToPullStart) iCraft.sendProgressBarUpdate(this, 6, this.tileInputter.slotToPullStart);
if(this.lastSlotPullEnd != this.tileInputter.slotToPullEnd) iCraft.sendProgressBarUpdate(this, 7, this.tileInputter.slotToPullEnd);
}
this.lastSideToPut = this.tileInputter.sideToPut;
this.lastSideToPull = this.tileInputter.sideToPull;
this.lastIsPutWhitelist = this.tileInputter.isPutWhitelist ? 1 : 0;
this.lastIsPullWhitelist = this.tileInputter.isPullWhitelist ? 1 : 0;
this.lastSlotPutStart = this.tileInputter.slotToPutStart;
this.lastSlotPutEnd = this.tileInputter.slotToPutEnd;
this.lastSlotPullStart = this.tileInputter.slotToPullStart;
this.lastSlotPullEnd = this.tileInputter.slotToPullEnd;
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.tileInputter.sideToPut = par2;
if(par1 == 1) this.tileInputter.sideToPull = par2;
if(par1 == 2) this.tileInputter.isPullWhitelist = par2 == 1;
if(par1 == 3) this.tileInputter.isPutWhitelist = par2 == 1;
if(par1 == 4) this.tileInputter.slotToPutStart = par2;
if(par1 == 5) this.tileInputter.slotToPutEnd = par2;
if(par1 == 6) this.tileInputter.slotToPullStart = par2;
if(par1 == 7) this.tileInputter.slotToPullEnd = par2;
}
@Override
public boolean canInteractWith(EntityPlayer player){
return this.tileInputter.isUseableByPlayer(player);

View file

@ -1,7 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.tile.TileEntityBase;
@ -10,7 +8,6 @@ import invtweaks.api.container.InventoryContainer;
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.minecraftforge.fluids.FluidContainerRegistry;
@ -21,10 +18,6 @@ public class ContainerOilGenerator extends Container{
private TileEntityOilGenerator generator;
private int lastEnergyStored;
private int lastBurnTime;
private int lastTankAmount;
public ContainerOilGenerator(InventoryPlayer inventory, TileEntityBase tile){
this.generator = (TileEntityOilGenerator)tile;
@ -46,38 +39,6 @@ public class ContainerOilGenerator extends Container{
return this.generator.isUseableByPlayer(player);
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.generator.storage.getEnergyStored());
iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime);
iCraft.sendProgressBarUpdate(this, 2, this.generator.tank.getFluidAmount());
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastEnergyStored != this.generator.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.generator.storage.getEnergyStored());
if(this.lastBurnTime != this.generator.currentBurnTime) iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime);
if(this.lastTankAmount != this.generator.tank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 2, this.generator.tank.getFluidAmount());
}
this.lastEnergyStored = this.generator.storage.getEnergyStored();
this.lastBurnTime = this.generator.currentBurnTime;
this.lastTankAmount = this.generator.tank.getFluidAmount();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.generator.storage.setEnergyStored(par2);
if(par1 == 1) this.generator.currentBurnTime = par2;
if(par1 == 2) this.generator.tank.setFluid(new FluidStack(InitBlocks.fluidOil, par2));
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
final int inventoryStart = 2;

View file

@ -1,7 +1,5 @@
package ellpeck.actuallyadditions.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityItemRepairer;
@ -9,7 +7,6 @@ import invtweaks.api.container.InventoryContainer;
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;
@ -18,8 +15,6 @@ public class ContainerRepairer extends Container{
private TileEntityItemRepairer tileRepairer;
private int lastEnergy;
public ContainerRepairer(InventoryPlayer inventory, TileEntityBase tile){
this.tileRepairer = (TileEntityItemRepairer)tile;
@ -36,30 +31,6 @@ public class ContainerRepairer extends Container{
}
}
@Override
public void addCraftingToCrafters(ICrafting iCraft){
super.addCraftingToCrafters(iCraft);
iCraft.sendProgressBarUpdate(this, 0, this.tileRepairer.storage.getEnergyStored());
}
@Override
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(Object crafter : this.crafters){
ICrafting iCraft = (ICrafting)crafter;
if(this.lastEnergy != this.tileRepairer.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.tileRepairer.storage.getEnergyStored());
}
this.lastEnergy = this.tileRepairer.storage.getEnergyStored();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0) this.tileRepairer.storage.setEnergyStored(par2);
}
@Override
public boolean canInteractWith(EntityPlayer player){
return this.tileRepairer.isUseableByPlayer(player);

View file

@ -104,7 +104,7 @@ public class GuiCoffeeMachine extends GuiContainer{
if(x >= guiLeft+16 && y >= guiTop+5 && x <= guiLeft+23 && y <= guiTop+89){
this.func_146283_a(Collections.singletonList(text1), x, y);
}
String text3 = this.machine.tank.getFluidAmount() + "/" + this.machine.tank.getCapacity() + " mB "+StatCollector.translateToLocal(FluidRegistry.WATER.getUnlocalizedName());
String text3 = this.machine.tank.getFluidAmount() + "/" + this.machine.tank.getCapacity() + " mB "+FluidRegistry.WATER.getLocalizedName(this.machine.tank.getFluid());
if(x >= guiLeft+27 && y >= guiTop+5 && x <= guiLeft+33 && y <= guiTop+70){
this.func_146283_a(Collections.singletonList(text3), x, y);
}

View file

@ -21,8 +21,6 @@ public class GuiFeeder extends GuiContainer{
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiFeeder");
public TileEntityFeeder tileFeeder;
public int loveCounter;
public GuiFeeder(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerFeeder(inventory, tile));
this.tileFeeder = (TileEntityFeeder)tile;
@ -51,14 +49,6 @@ public class GuiFeeder extends GuiContainer{
if(this.tileFeeder.currentAnimalAmount >= 2 && this.tileFeeder.currentAnimalAmount < this.tileFeeder.animalThreshold) this.drawTexturedModalRect(guiLeft + 70, guiTop + 31, 192, 16, 8, 8);
if(this.tileFeeder.currentAnimalAmount >= this.tileFeeder.animalThreshold) this.drawTexturedModalRect(guiLeft + 70, guiTop + 31, 192, 24, 8, 8);
if(this.loveCounter > 0){
this.loveCounter++;
if(this.loveCounter >= 15){
this.loveCounter = 0;
}
this.drawTexturedModalRect(guiLeft + 76, guiTop + 4, 176, 0, 25, 16);
}
}
@Override

View file

@ -1,81 +0,0 @@
package ellpeck.actuallyadditions.network;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.tile.TileEntityFluidCollector;
import io.netty.buffer.ByteBuf;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class PacketFluidCollectorToClient implements IMessage{
private boolean hasFluid;
private int fluidID;
private int fluidAmount;
private int x;
private int y;
private int z;
@SuppressWarnings("unused")
public PacketFluidCollectorToClient(){
}
public PacketFluidCollectorToClient(FluidStack fluid, TileEntity tile){
if(fluid != null){
this.hasFluid = true;
this.fluidID = fluid.getFluidID();
this.fluidAmount = fluid.amount;
}
else this.hasFluid = false;
this.x = tile.xCoord;
this.y = tile.yCoord;
this.z = tile.zCoord;
}
@Override
public void fromBytes(ByteBuf buf){
this.hasFluid = buf.readBoolean();
this.fluidID = buf.readInt();
this.fluidAmount = buf.readInt();
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf){
buf.writeBoolean(this.hasFluid);
buf.writeInt(this.fluidID);
buf.writeInt(this.fluidAmount);
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
}
public static class Handler implements IMessageHandler<PacketFluidCollectorToClient, IMessage>{
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketFluidCollectorToClient message, MessageContext ctx){
World world = FMLClientHandler.instance().getClient().theWorld;
TileEntity tile = world.getTileEntity(message.x, message.y, message.z);
if(tile instanceof TileEntityFluidCollector){
TileEntityFluidCollector collector = (TileEntityFluidCollector)tile;
if(message.hasFluid){
collector.tank.setFluid(new FluidStack(FluidRegistry.getFluid(message.fluidID), message.fluidAmount));
}
else collector.tank.setFluid(null);
}
return null;
}
}
}

View file

@ -5,6 +5,7 @@ import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import ellpeck.actuallyadditions.network.gui.PacketGuiButton;
import ellpeck.actuallyadditions.network.gui.PacketGuiNumber;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.ModUtil;
public class PacketHandler{
@ -14,9 +15,8 @@ public class PacketHandler{
public static void init(){
theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID_LOWER);
theNetwork.registerMessage(PacketTileEntityFeeder.Handler.class, PacketTileEntityFeeder.class, 0, Side.CLIENT);
theNetwork.registerMessage(PacketGuiButton.Handler.class, PacketGuiButton.class, 1, Side.SERVER);
theNetwork.registerMessage(PacketFluidCollectorToClient.Handler.class, PacketFluidCollectorToClient.class, 2, Side.CLIENT);
theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 3, Side.SERVER);
theNetwork.registerMessage(PacketGuiButton.Handler.class, PacketGuiButton.class, 0, Side.SERVER);
theNetwork.registerMessage(PacketSyncerToClient.Handler.class, PacketSyncerToClient.class, 1, Side.CLIENT);
theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 2, Side.SERVER);
}
}

View file

@ -1,74 +0,0 @@
package ellpeck.actuallyadditions.network;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.gui.GuiFeeder;
import ellpeck.actuallyadditions.tile.TileEntityFeeder;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class PacketTileEntityFeeder implements IMessage{
private int tileX;
private int tileY;
private int tileZ;
private int animalID;
@SuppressWarnings("unused")
public PacketTileEntityFeeder(){
}
public PacketTileEntityFeeder(TileEntityFeeder tile, int animalID){
this.tileX = tile.xCoord;
this.tileY = tile.yCoord;
this.tileZ = tile.zCoord;
this.animalID = animalID;
}
@Override
public void fromBytes(ByteBuf buf){
this.tileX = buf.readInt();
this.tileY = buf.readInt();
this.tileZ = buf.readInt();
this.animalID = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf){
buf.writeInt(this.tileX);
buf.writeInt(this.tileY);
buf.writeInt(this.tileZ);
buf.writeInt(this.animalID);
}
public static class Handler implements IMessageHandler<PacketTileEntityFeeder, IMessage>{
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketTileEntityFeeder message, MessageContext ctx){
World world = FMLClientHandler.instance().getClient().theWorld;
TileEntity tile = world.getTileEntity(message.tileX, message.tileY, message.tileZ);
if(tile instanceof TileEntityFeeder){
TileEntityFeeder tileFeeder = (TileEntityFeeder)tile;
tileFeeder.feedAnimal((EntityAnimal)world.getEntityByID(message.animalID));
if(Minecraft.getMinecraft().currentScreen instanceof GuiFeeder){
if(((GuiFeeder)Minecraft.getMinecraft().currentScreen).tileFeeder == tileFeeder){
((GuiFeeder)Minecraft.getMinecraft().currentScreen).loveCounter++;
}
}
}
return null;
}
}
}

View file

@ -0,0 +1,10 @@
package ellpeck.actuallyadditions.network.sync;
public interface IPacketSyncerToClient{
int[] getValues();
void setValues(int[] values);
void sendUpdate();
}

View file

@ -0,0 +1,74 @@
package ellpeck.actuallyadditions.network.sync;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.network.PacketHandler;
import io.netty.buffer.ByteBuf;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class PacketSyncerToClient implements IMessage{
private int x;
private int y;
private int z;
private int[] values;
@SuppressWarnings("unused")
public PacketSyncerToClient(){
}
public PacketSyncerToClient(TileEntity tile, int[] values){
this.x = tile.xCoord;
this.y = tile.yCoord;
this.z = tile.zCoord;
this.values = values;
}
@Override
public void fromBytes(ByteBuf buf){
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
int length = buf.readInt();
if(this.values == null) this.values = new int[length];
for(int i = 0; i < length; i++){
this.values[i] = buf.readInt();
}
}
@Override
public void toBytes(ByteBuf buf){
buf.writeInt(this.x);
buf.writeInt(this.y);
buf.writeInt(this.z);
buf.writeInt(this.values.length);
for(int value : this.values){
buf.writeInt(value);
}
}
public static class Handler implements IMessageHandler<PacketSyncerToClient, IMessage>{
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketSyncerToClient message, MessageContext ctx){
World world = FMLClientHandler.instance().getClient().theWorld;
TileEntity tile = world.getTileEntity(message.x, message.y, message.z);
if(tile != null && tile instanceof IPacketSyncerToClient){
((IPacketSyncerToClient)tile).setValues(message.values);
}
return null;
}
}
public static void sendPacket(TileEntity tile){
PacketHandler.theNetwork.sendToAllAround(new PacketSyncerToClient(tile, ((IPacketSyncerToClient)tile).getValues()), new NetworkRegistry.TargetPoint(tile.getWorldObj().provider.dimensionId, tile.xCoord, tile.yCoord, tile.zCoord, 64));
}
}

View file

@ -8,6 +8,8 @@ import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -15,17 +17,20 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler{
public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler, IPacketSyncerToClient{
public EnergyStorage storage = new EnergyStorage(40000);
private int lastEnergyStored;
public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME);
private int lastTankAmount;
public static int energyUsedPerTick = ConfigIntValues.PRESS_ENERGY_USED.getValue();
public int mbProducedPerCanola = ConfigIntValues.PRESS_MB_PRODUCED.getValue();
public int maxTimeProcessing = ConfigIntValues.PRESS_PROCESSING_TIME.getValue();
public int currentProcessTime;
private int lastProcessTime;
public TileEntityCanolaPress(){
super(3, "canolaPress");
@ -63,6 +68,13 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, this.tank);
}
}
if(this.storage.getEnergyStored() != this.lastEnergyStored || this.tank.getFluidAmount() != this.lastTankAmount | this.currentProcessTime != this.lastProcessTime){
this.lastEnergyStored = this.storage.getEnergyStored();
this.lastProcessTime = this.currentProcessTime;
this.lastTankAmount = this.tank.getFluidAmount();
this.sendUpdate();
}
}
}
@ -166,4 +178,24 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
public FluidTankInfo[] getTankInfo(ForgeDirection from){
return new FluidTankInfo[]{this.tank.getInfo()};
}
@Override
public int[] getValues(){
return new int[]{this.currentProcessTime, this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID(), this.storage.getEnergyStored()};
}
@Override
public void setValues(int[] values){
this.currentProcessTime = values[0];
if(values[2] != -1){
this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[2]), values[1]));
}
else this.tank.setFluid(null);
this.storage.setEnergyStored(values[3]);
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -5,20 +5,25 @@ import cofh.api.energy.IEnergyProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider{
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider, IPacketSyncerToClient{
public EnergyStorage storage = new EnergyStorage(60000);
private int lastEnergy;
public static int energyProducedPerTick = ConfigIntValues.COAL_GEN_ENERGY_PRODUCED.getValue();
public int maxBurnTime;
private int lastBurnTime;
public int currentBurnTime;
private int lastCurrentBurnTime;
public TileEntityCoalGenerator(){
super(1, "coalGenerator");
@ -63,6 +68,13 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
}
else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2);
}
if(this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime){
this.lastEnergy = this.storage.getEnergyStored();
this.lastCurrentBurnTime = this.currentBurnTime;
this.lastBurnTime = this.currentBurnTime;
this.sendUpdate();
}
}
}
@ -126,4 +138,21 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
public boolean canConnectEnergy(ForgeDirection from){
return true;
}
@Override
public int[] getValues(){
return new int[]{this.storage.getEnergyStored(), this.currentBurnTime, this.maxBurnTime};
}
@Override
public void setValues(int[] values){
this.storage.setEnergyStored(values[0]);
this.currentBurnTime = values[1];
this.maxBurnTime = values[2];
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -9,6 +9,8 @@ import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.ItemCoffee;
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
import ellpeck.actuallyadditions.network.gui.IButtonReactor;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -16,7 +18,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, IEnergyReceiver, IFluidHandler{
public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, IEnergyReceiver, IFluidHandler, IPacketSyncerToClient{
public static final int SLOT_COFFEE_BEANS = 0;
public static final int SLOT_INPUT = 1;
@ -25,7 +27,9 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public static final int SLOT_WATER_OUTPUT = 12;
public EnergyStorage storage = new EnergyStorage(300000);
private int lastEnergy;
public FluidTank tank = new FluidTank(4*FluidContainerRegistry.BUCKET_VOLUME);
private int lastTank;
public static int energyUsePerTick = ConfigIntValues.COFFEE_MACHINE_ENERGY_USED.getValue();
public final int waterUsedPerCoffee = 500;
@ -34,9 +38,11 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public final int coffeeCacheAddPerItem = ConfigIntValues.COFFEE_CACHE_ADDED_PER_ITEM.getValue();
public final int coffeeCacheUsePerItem = ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue();
public int coffeeCacheAmount;
private int lastCoffeeAmount;
public final int maxBrewTime = ConfigIntValues.COFFEE_MACHINE_TIME_USED.getValue();
public int brewTime;
private int lastBrewTime;
public TileEntityCoffeeMachine(){
super(13, "coffeeMachine");
@ -50,6 +56,14 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
if(this.brewTime > 0 || this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
this.brew();
}
if(this.coffeeCacheAmount != this.lastCoffeeAmount || this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.brewTime != this.lastBrewTime){
this.lastCoffeeAmount = coffeeCacheAmount;
this.lastEnergy = this.storage.getEnergyStored();
this.lastTank = this.tank.getFluidAmount();
this.lastBrewTime = this.brewTime;
this.sendUpdate();
}
}
}
@ -206,4 +220,25 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public FluidTankInfo[] getTankInfo(ForgeDirection from){
return new FluidTankInfo[]{this.tank.getInfo()};
}
@Override
public int[] getValues(){
return new int[]{this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID(), this.storage.getEnergyStored(), this.brewTime, this.coffeeCacheAmount};
}
@Override
public void setValues(int[] values){
if(values[1] != -1){
this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[1]), values[0]));
}
else this.tank.setFluid(null);
this.storage.setEnergyStored(values[2]);
this.brewTime = values[3];
this.coffeeCacheAmount = values[4];
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -5,13 +5,16 @@ import cofh.api.energy.IEnergyContainerItem;
import cofh.api.energy.IEnergyReceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver{
public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{
public EnergyStorage storage = new EnergyStorage(500000);
private int lastEnergy;
public TileEntityEnergizer(){
super(2, "energizer");
@ -32,6 +35,11 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
if(this.slots[0].stackSize <= 0) this.slots[0] = null;
}
}
if(lastEnergy != this.storage.getEnergyStored()){
this.lastEnergy = this.storage.getEnergyStored();
this.sendUpdate();
}
}
}
@ -81,4 +89,19 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
public boolean canConnectEnergy(ForgeDirection from){
return true;
}
@Override
public int[] getValues(){
return new int[]{this.storage.getEnergyStored()};
}
@Override
public void setValues(int[] values){
this.storage.setEnergyStored(values[0]);
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -5,14 +5,17 @@ import cofh.api.energy.IEnergyContainerItem;
import cofh.api.energy.IEnergyProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider{
public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider, IPacketSyncerToClient{
public EnergyStorage storage = new EnergyStorage(500000);
private int lastEnergy;
public TileEntityEnervator(){
super(2, "enervator");
@ -42,6 +45,11 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage);
}
if(lastEnergy != this.storage.getEnergyStored()){
this.lastEnergy = this.storage.getEnergyStored();
this.sendUpdate();
}
}
}
@ -91,4 +99,19 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == 1;
}
@Override
public int[] getValues(){
return new int[]{this.storage.getEnergyStored()};
}
@Override
public void setValues(int[] values){
this.storage.setEnergyStored(values[0]);
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -1,11 +1,10 @@
package ellpeck.actuallyadditions.tile;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.PacketHandler;
import ellpeck.actuallyadditions.network.PacketTileEntityFeeder;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -14,7 +13,7 @@ import net.minecraft.util.AxisAlignedBB;
import java.util.List;
import java.util.Random;
public class TileEntityFeeder extends TileEntityInventoryBase{
public class TileEntityFeeder extends TileEntityInventoryBase implements IPacketSyncerToClient{
public int reach = ConfigIntValues.FEEDER_REACH.getValue();
public int timerGoal = ConfigIntValues.FEEDER_TIME.getValue();
@ -22,6 +21,8 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
public int currentTimer;
public int currentAnimalAmount;
private int lastAnimalAmount;
private int lastTimer;
public TileEntityFeeder(){
super(1, "feeder");
@ -43,7 +44,6 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
EntityAnimal randomAnimal = animals.get(new Random().nextInt(this.currentAnimalAmount));
if(!randomAnimal.isInLove() && randomAnimal.getGrowingAge() == 0 && randomAnimal.isBreedingItem(this.slots[0])){
PacketHandler.theNetwork.sendToAllAround(new PacketTileEntityFeeder(this, randomAnimal.getEntityId()), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord, 80));
this.feedAnimal(randomAnimal);
this.slots[0].stackSize--;
@ -62,6 +62,12 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
if(theFlag != this.currentTimer > 0){
this.markDirty();
}
if(this.lastAnimalAmount != this.currentAnimalAmount || this.lastTimer != this.currentTimer){
this.lastAnimalAmount = this.currentAnimalAmount;
this.lastTimer = this.currentTimer;
this.sendUpdate();
}
}
}
@ -107,4 +113,20 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
public boolean canExtractItem(int slot, ItemStack stack, int side){
return false;
}
@Override
public int[] getValues(){
return new int[]{this.currentAnimalAmount, this.currentTimer};
}
@Override
public void setValues(int[] values){
this.currentAnimalAmount = values[0];
this.currentTimer = values[1];
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -4,6 +4,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -11,13 +13,16 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
public class TileEntityFermentingBarrel extends TileEntityInventoryBase implements IFluidHandler{
public class TileEntityFermentingBarrel extends TileEntityInventoryBase implements IFluidHandler, IPacketSyncerToClient{
public FluidTank canolaTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME);
private int lastCanola;
public FluidTank oilTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME);
private int lastOil;
public int currentProcessTime;
public int maxTimeProcessing = ConfigIntValues.BARREL_PROCESSING_TIME.getValue();
private int lastProcessTime;
public int mBProducedPerCycle = ConfigIntValues.BARREL_MB_PRODUCED.getValue();
@ -53,6 +58,13 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, this.oilTank);
}
}
if(this.canolaTank.getFluidAmount() != this.lastCanola || this.oilTank.getFluidAmount() != this.lastOil || this.currentProcessTime != this.lastProcessTime){
this.lastProcessTime = this.currentProcessTime;
this.lastCanola = this.canolaTank.getFluidAmount();
this.lastOil = this.oilTank.getFluidAmount();
this.sendUpdate();
}
}
}
@ -135,4 +147,27 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
public FluidTankInfo[] getTankInfo(ForgeDirection from){
return new FluidTankInfo[]{this.canolaTank.getInfo(), this.oilTank.getInfo()};
}
@Override
public int[] getValues(){
return new int[]{this.oilTank.getFluidAmount(), this.oilTank.getFluid() == null ? -1 : this.oilTank.getFluid().getFluidID(), this.canolaTank.getFluidAmount(), this.canolaTank.getFluid() == null ? -1 : this.canolaTank.getFluid().getFluidID(), this.currentProcessTime};
}
@Override
public void setValues(int[] values){
if(values[1] != -1){
this.oilTank.setFluid(new FluidStack(FluidRegistry.getFluid(values[1]), values[0]));
}
else this.oilTank.setFluid(null);
if(values[3] != -1){
this.canolaTank.setFluid(new FluidStack(FluidRegistry.getFluid(values[3]), values[2]));
}
else this.canolaTank.setFluid(null);
this.currentProcessTime = values[4];
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -1,11 +1,10 @@
package ellpeck.actuallyadditions.tile;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.PacketFluidCollectorToClient;
import ellpeck.actuallyadditions.network.PacketHandler;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
@ -15,14 +14,14 @@ import net.minecraft.util.ChunkCoordinates;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
public class TileEntityFluidCollector extends TileEntityInventoryBase implements IFluidHandler{
public class TileEntityFluidCollector extends TileEntityInventoryBase implements IFluidHandler, IPacketSyncerToClient{
public FluidTank tank = new FluidTank(8*FluidContainerRegistry.BUCKET_VOLUME);
private int lastTankAmount;
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
if(this.isPlacer){
this.sendPacket();
return this.tank.fill(resource, doFill);
}
return 0;
@ -31,7 +30,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
if(!this.isPlacer){
this.sendPacket();
return this.tank.drain(resource.amount, doDrain);
}
return null;
@ -40,7 +38,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
if(!this.isPlacer){
this.sendPacket();
return this.tank.drain(maxDrain, doDrain);
}
return null;
@ -61,6 +58,25 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
return new FluidTankInfo[]{this.tank.getInfo()};
}
@Override
public int[] getValues(){
return new int[]{this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID()};
}
@Override
public void setValues(int[] values){
if(values[1] != -1){
Fluid fluid = FluidRegistry.getFluid(values[1]);
this.tank.setFluid(new FluidStack(fluid, values[0]));
}
else this.tank.setFluid(null);
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
public static class TileEntityFluidPlacer extends TileEntityFluidCollector{
public TileEntityFluidPlacer(){
@ -88,8 +104,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
@SuppressWarnings("unchecked")
public void updateEntity(){
if(!worldObj.isRemote){
int amountBefore = this.tank.getFluidAmount();
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
if(this.currentTime > 0){
this.currentTime--;
@ -149,17 +163,13 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
}
}
if(amountBefore != this.tank.getFluidAmount()){
this.sendPacket();
this.markDirty();
if(lastTankAmount != this.tank.getFluidAmount()){
lastTankAmount = this.tank.getFluidAmount();
this.sendUpdate();
}
}
}
public void sendPacket(){
PacketHandler.theNetwork.sendToAllAround(new PacketFluidCollectorToClient(this.tank.getFluid(), this), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord, 120));
}
@SideOnly(Side.CLIENT)
public int getTankScaled(int i){
return this.tank.getFluidAmount() * i / this.tank.getCapacity();

View file

@ -5,12 +5,14 @@ import cofh.api.energy.IEnergyReceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver{
public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{
public static final int SLOT_INPUT_1 = 0;
public static final int SLOT_OUTPUT_1 = 1;
@ -18,13 +20,17 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
public static final int SLOT_OUTPUT_2 = 3;
public EnergyStorage storage = new EnergyStorage(30000);
private int lastEnergy;
public int energyUsePerTick = ConfigIntValues.FURNACE_ENERGY_USED.getValue();
public int maxBurnTime = ConfigIntValues.FURNACE_DOUBLE_SMELT_TIME.getValue();
public int firstSmeltTime;
private int lastFirstSmelt;
public int secondSmeltTime;
private int lastSecondSmelt;
public TileEntityFurnaceDouble(){
super(4, "furnaceDouble");
@ -72,8 +78,14 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
}
else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta+4, 2);
}
}
if(lastEnergy != this.storage.getEnergyStored() || this.lastFirstSmelt != this.firstSmeltTime || this.lastSecondSmelt != this.secondSmeltTime){
this.lastEnergy = this.storage.getEnergyStored();
this.lastFirstSmelt = this.firstSmeltTime;
this.lastSecondSmelt = this.secondSmeltTime;
this.sendUpdate();
}
}
}
public boolean canSmeltOn(int theInput, int theOutput){
@ -164,4 +176,21 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
public boolean canConnectEnergy(ForgeDirection from){
return true;
}
@Override
public int[] getValues(){
return new int[]{this.storage.getEnergyStored(), this.firstSmeltTime, this.secondSmeltTime};
}
@Override
public void setValues(int[] values){
this.storage.setEnergyStored(values[0]);
this.firstSmeltTime = values[1];
this.secondSmeltTime = values[2];
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -5,6 +5,8 @@ import cofh.api.energy.IEnergyReceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -12,9 +14,10 @@ import net.minecraftforge.common.util.ForgeDirection;
import java.util.Random;
public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver{
public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{
public EnergyStorage storage = new EnergyStorage(60000);
private int lastEnergy;
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
@ -36,6 +39,23 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
return true;
}
@Override
public int[] getValues(){
return new int[]{this.storage.getEnergyStored(), this.firstCrushTime, this.secondCrushTime};
}
@Override
public void setValues(int[] values){
this.storage.setEnergyStored(values[0]);
this.firstCrushTime = values[1];
this.secondCrushTime = values[2];
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
public static class TileEntityGrinderDouble extends TileEntityGrinder{
public TileEntityGrinderDouble(){
@ -59,7 +79,9 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
public int maxCrushTime;
public int firstCrushTime;
private int lastFirstCrush;
public int secondCrushTime;
private int lastSecondCrush;
public boolean isDouble;
@ -118,6 +140,13 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
}
else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2);
}
if(lastEnergy != this.storage.getEnergyStored() || this.lastFirstCrush != this.firstCrushTime || this.lastSecondCrush != this.secondCrushTime){
this.lastEnergy = this.storage.getEnergyStored();
this.lastFirstCrush = this.firstCrushTime;
this.lastSecondCrush = this.secondCrushTime;
this.sendUpdate();
}
}
}

View file

@ -2,6 +2,8 @@ package ellpeck.actuallyadditions.tile;
import ellpeck.actuallyadditions.network.gui.IButtonReactor;
import ellpeck.actuallyadditions.network.gui.INumberReactor;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@ -10,7 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor{
public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor, IPacketSyncerToClient{
@Override
public void onNumberReceived(int text, int textID, EntityPlayer player){
@ -23,6 +25,28 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
this.markDirty();
}
@Override
public int[] getValues(){
return new int[]{sideToPut, sideToPull, slotToPutStart, slotToPutEnd, slotToPullStart, slotToPullEnd, this.isPutWhitelist ? 1 : 0, this.isPullWhitelist ? 1 : 0};
}
@Override
public void setValues(int[] values){
this.sideToPut = values[0];
this.sideToPull = values[1];
this.slotToPutStart = values[2];
this.slotToPutEnd = values[3];
this.slotToPullStart = values[4];
this.slotToPullEnd = values[5];
this.isPutWhitelist = values[6] == 1;
this.isPullWhitelist = values[7] == 1;
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
public static class TileEntityInputterAdvanced extends TileEntityInputter{
public TileEntityInputterAdvanced(){
@ -40,23 +64,31 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
public static final int OKAY_BUTTON_ID = 133;
public int sideToPut = -1;
private int lastPutSide;
public int slotToPutStart;
private int lastPutStart;
public int slotToPutEnd;
private int lastPutEnd;
public TileEntity placeToPut;
public int sideToPull = -1;
private int lastPullSide;
public int slotToPullStart;
private int lastPullStart;
public int slotToPullEnd;
private int lastPullEnd;
public TileEntity placeToPull;
public boolean isAdvanced;
public boolean isPullWhitelist = true;
private boolean lastPullWhite;
public boolean isPutWhitelist = true;
private boolean lastPutWhite;
public TileEntityInputter(int slots, String name){
super(slots, name);
@ -78,6 +110,18 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
if(sideToPut != -1 && this.placeToPut instanceof IInventory) this.put();
}
}
if(this.sideToPut != this.lastPutSide || this.sideToPull != this.lastPullSide || this.slotToPullStart != this.lastPullStart || this.slotToPullEnd != this.lastPullEnd || this.slotToPutStart != this.lastPutStart || this.slotToPutEnd != this.lastPutEnd || this.isPullWhitelist != lastPullWhite || this.isPutWhitelist != this.lastPutWhite){
this.lastPutSide = this.sideToPut;
this.lastPullSide = this.sideToPull;
this.lastPullStart = this.slotToPullStart;
this.lastPullEnd = this.slotToPullEnd;
this.lastPutStart = this.slotToPutStart;
this.lastPutEnd = this.slotToPutEnd;
this.lastPullWhite = this.isPullWhitelist;
this.lastPutWhite = this.isPutWhitelist;
this.sendUpdate();
}
}
}

View file

@ -5,16 +5,19 @@ import cofh.api.energy.IEnergyReceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver{
public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{
public static final int SLOT_INPUT = 0;
public static final int SLOT_OUTPUT = 1;
public EnergyStorage storage = new EnergyStorage(300000);
private int lastEnergy;
private final int speedSlowdown = ConfigIntValues.REPAIRER_SPEED_SLOWDOWN.getValue();
@ -48,6 +51,11 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
}
}
else this.nextRepairTick = 0;
if(this.lastEnergy != this.storage.getEnergyStored()){
this.lastEnergy = this.storage.getEnergyStored();
this.sendUpdate();
}
}
}
@ -116,4 +124,19 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
public boolean canConnectEnergy(ForgeDirection from){
return true;
}
@Override
public int[] getValues(){
return new int[]{this.storage.getEnergyStored()};
}
@Override
public void setValues(int[] values){
this.storage.setEnergyStored(values[0]);
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -6,17 +6,21 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
public class TileEntityOilGenerator extends TileEntityInventoryBase implements IEnergyProvider, IFluidHandler{
public class TileEntityOilGenerator extends TileEntityInventoryBase implements IEnergyProvider, IFluidHandler, IPacketSyncerToClient{
public EnergyStorage storage = new EnergyStorage(50000);
private int lastEnergy;
public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME);
private int lastTank;
public static int energyProducedPerTick = ConfigIntValues.OIL_GEN_ENERGY_PRODUCED.getValue();
@ -24,6 +28,7 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
public int maxBurnTime = ConfigIntValues.OIL_GEN_BURN_TIME.getValue();
public int currentBurnTime;
private int lastBurnTime;
public TileEntityOilGenerator(){
super(2, "oilGenerator");
@ -67,6 +72,13 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
}
else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2);
}
if(this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime){
this.lastEnergy = this.storage.getEnergyStored();
this.lastTank = this.tank.getFluidAmount();
this.lastBurnTime = this.currentBurnTime;
this.sendUpdate();
}
}
}
@ -168,4 +180,24 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
public FluidTankInfo[] getTankInfo(ForgeDirection from){
return new FluidTankInfo[]{this.tank.getInfo()};
}
@Override
public int[] getValues(){
return new int[]{this.storage.getEnergyStored(), this.currentBurnTime, this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID()};
}
@Override
public void setValues(int[] values){
this.storage.setEnergyStored(values[0]);
this.currentBurnTime = values[1];
if(values[3] != -1){
this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[3]), values[2]));
}
else this.tank.setFluid(null);
}
@Override
public void sendUpdate(){
PacketSyncerToClient.sendPacket(this);
}
}

View file

@ -33,17 +33,17 @@ public class UpdateChecker{
if(doneChecking && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null && !notified){
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(checkFailed){
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".update.failed.desc")));
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".sendUpdate.failed.desc")));
}
else if(onlineVersion.length() > 0){
int update = Integer.parseInt(onlineVersion.replace("-", "").replace(".", ""));
int client = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", ""));
if(update > client){
String notice1 = "info." + ModUtil.MOD_ID_LOWER + ".update.generic.desc";
String notice2 = "info." + ModUtil.MOD_ID_LOWER + ".update.versionComp.desc";
String notice3 = "info." + ModUtil.MOD_ID_LOWER + ".update.changelog.desc";
String notice4 = "info." + ModUtil.MOD_ID_LOWER + ".update.download.desc";
String notice1 = "info." + ModUtil.MOD_ID_LOWER + ".sendUpdate.generic.desc";
String notice2 = "info." + ModUtil.MOD_ID_LOWER + ".sendUpdate.versionComp.desc";
String notice3 = "info." + ModUtil.MOD_ID_LOWER + ".sendUpdate.changelog.desc";
String notice4 = "info." + ModUtil.MOD_ID_LOWER + ".sendUpdate.download.desc";
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal(notice1)));
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice2, ModUtil.VERSION, this.onlineVersion)));
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(notice3, changelog)));
@ -67,12 +67,12 @@ public class UpdateChecker{
public void run(){
ModUtil.LOGGER.info("Starting Update Check...");
try{
URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/newestVersion.txt");
URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/sendUpdate/newestVersion.txt");
BufferedReader newestReader = new BufferedReader(new InputStreamReader(newestURL.openStream()));
onlineVersion = newestReader.readLine();
newestReader.close();
URL changeURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/changelog.txt");
URL changeURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/sendUpdate/changelog.txt");
BufferedReader changeReader = new BufferedReader(new InputStreamReader(changeURL.openStream()));
changelog = changeReader.readLine();
changeReader.close();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB