mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Made TileEntities update less often to reduce server traffic
This commit is contained in:
parent
09bdfd98a0
commit
d0b8bda5cc
33 changed files with 50 additions and 8 deletions
|
@ -158,12 +158,7 @@ public enum ConfigIntValues{
|
|||
MAGNET_RING_ENERGY_USE("Magnet Ring: Energy Used", ConfigCategories.MACHINE_VALUES, 5, 0, 500, "The Amount of Energy the Magnet Ring uses per tick"),
|
||||
|
||||
WATER_RING_RANGE("Water Ring: Range", ConfigCategories.MACHINE_VALUES, 3, 1, 10, "The Range of the Water Ring"),
|
||||
WATER_RING_ENERGY_USE("Magnet Ring: Energy Used", ConfigCategories.MACHINE_VALUES, 30, 0, 500, "The Amount of Energy the Water Ring uses per Block"),
|
||||
|
||||
ORE_MAGNET_MAX_TIMER("Ore Magnet: Max Timer", ConfigCategories.MACHINE_VALUES, 20, 1, 2000, "The approximate Time it takes for the Ore Magnet to search for a new block to mine"),
|
||||
ORE_MAGNET_RANGE("Ore Magnet: Range", ConfigCategories.MACHINE_VALUES, 10, 1, 60, "The range of the Ore Magnet"),
|
||||
ORE_MAGNET_OIL_USE("Ore Magnet: Oil Use", ConfigCategories.MACHINE_VALUES, 30, 0, 5000, "The amount of oil the Ore Magnet uses every Block"),
|
||||
ORE_MAGNET_ENERGY_USE("Ore Magnet: Energy USe", ConfigCategories.MACHINE_VALUES, 250, 10, 10000, "The amount of Energy the Ore Magnet uses every tick"),
|
||||
WATER_RING_ENERGY_USE("Water Ring: Energy Used", ConfigCategories.MACHINE_VALUES, 30, 0, 500, "The Amount of Energy the Water Ring uses per Block"),
|
||||
|
||||
LEAF_GENERATOR_ENERGY_PRODUCED("Leaf Generator: Energy Produced", ConfigCategories.MACHINE_VALUES, 300, 1, 10000, "How much Energy the Leaf Generator produces per Leaf broken"),
|
||||
LEAF_GENERATOR_COOLDOWN_TIME("Leaf Generator: Cooldown Time", ConfigCategories.MACHINE_VALUES, 5, 0, 100, "The amount of ticks that it takes util another Leaf gets proken"),
|
||||
|
@ -181,7 +176,9 @@ public enum ConfigIntValues{
|
|||
RECONSTRUCTOR_DISTANCE("Atomic Reconstructor: Distance", ConfigCategories.MACHINE_VALUES, 10, 1, 50, "The max distance the Reconstructor goes forward to find blocks to convert"),
|
||||
RECONSTRCUTOR_RANGE("Atomic Reconstructor: Range", ConfigCategories.MACHINE_VALUES, 2, 1, 10, "The range of Converting blocks or items into other blocks or items"),
|
||||
RECONSTRUCTOR_USE_PER_BLOCK("Atomic Reconstructor: Energy Use per Block", ConfigCategories.MACHINE_VALUES, 800, 0, 100000, "The amount of Energy the Reconstructor uses per Block converted"),
|
||||
RECONSTRUCTOR_COOLDOWN_TIMER("Atomic Reconstrucor: Cooldown Timer", ConfigCategories.MACHINE_VALUES, 100, 0, 10000, "The amount of time the Reconstructor waits between shooting lasers");
|
||||
RECONSTRUCTOR_COOLDOWN_TIMER("Atomic Reconstrucor: Cooldown Timer", ConfigCategories.MACHINE_VALUES, 100, 0, 10000, "The amount of time the Reconstructor waits between shooting lasers"),
|
||||
|
||||
TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 5, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client");
|
||||
|
||||
public final String name;
|
||||
public final String category;
|
||||
|
|
|
@ -40,6 +40,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!this.worldObj.isRemote){
|
||||
int usePerBlock = ConfigIntValues.RECONSTRUCTOR_USE_PER_BLOCK.getValue();
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.storage.getEnergyStored() >= usePerBlock){
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -22,6 +23,8 @@ import net.minecraft.world.World;
|
|||
|
||||
public abstract class TileEntityBase extends TileEntity{
|
||||
|
||||
private int ticksElapsed;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Registering TileEntities...");
|
||||
|
||||
|
@ -66,6 +69,11 @@ public abstract class TileEntityBase extends TileEntity{
|
|||
GameRegistry.registerTileEntity(TileEntityAtomicReconstructor.class, ModUtil.MOD_ID_LOWER+":tileEntityAtomicReconstructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
this.ticksElapsed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readFromNBT(NBTTagCompound compound){
|
||||
super.readFromNBT(compound);
|
||||
|
@ -104,6 +112,8 @@ public abstract class TileEntityBase extends TileEntity{
|
|||
}
|
||||
|
||||
protected void sendUpdate(){
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
if(this.ticksElapsed % ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase{
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(this.currentTime > 0){
|
||||
|
|
|
@ -41,6 +41,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(this.isCanola(0) && ConfigIntValues.PRESS_MB_PRODUCED.getValue() <= this.tank.getCapacity()-this.tank.getFluidAmount()){
|
||||
if(this.storage.getEnergyStored() >= ConfigIntValues.PRESS_ENERGY_USED.getValue()){
|
||||
|
|
|
@ -37,6 +37,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
boolean flag = this.currentBurnTime > 0;
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
this.storeCoffee();
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class TileEntityCompost extends TileEntityInventoryBase{
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
|
||||
if(this.slots[0] != null && this.slots[0].stackSize > 0){
|
||||
|
|
|
@ -39,6 +39,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
int usagePerBlock = ConfigIntValues.DIRECTIONAL_BREAKER_RF_PER_BLOCK.getValue();
|
||||
|
|
|
@ -27,6 +27,7 @@ public class TileEntityDropper extends TileEntityInventoryBase{
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(this.currentTime > 0){
|
||||
|
|
|
@ -30,6 +30,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(this.slots[0] != null && this.slots[0].getItem() instanceof IEnergyContainerItem && this.slots[1] == null){
|
||||
if(this.storage.getEnergyStored() > 0){
|
||||
|
|
|
@ -31,6 +31,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(this.slots[0] != null && this.slots[0].getItem() instanceof IEnergyContainerItem && this.slots[1] == null){
|
||||
if(((IEnergyContainerItem)this.slots[0].getItem()).getEnergyStored(this.slots[0]) > 0){
|
||||
|
|
|
@ -34,6 +34,7 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
boolean theFlag = this.currentTimer > 0;
|
||||
List<EntityAnimal> animals = worldObj.getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(this.xCoord-ConfigIntValues.FEEDER_REACH.getValue(), this.yCoord-ConfigIntValues.FEEDER_REACH.getValue(), this.zCoord-ConfigIntValues.FEEDER_REACH.getValue(), this.xCoord+ConfigIntValues.FEEDER_REACH.getValue(), this.yCoord+ConfigIntValues.FEEDER_REACH.getValue(), this.zCoord+ConfigIntValues.FEEDER_REACH.getValue()));
|
||||
|
|
|
@ -37,6 +37,7 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(this.canolaTank.getFluidAmount() >= ConfigIntValues.BARREL_MB_PRODUCED.getValue() && ConfigIntValues.BARREL_MB_PRODUCED.getValue() <= this.oilTank.getCapacity()-this.oilTank.getFluidAmount()){
|
||||
this.currentProcessTime++;
|
||||
|
|
|
@ -37,6 +37,7 @@ public class TileEntityFishingNet extends TileEntityBase{
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(worldObj.getBlock(xCoord, yCoord-1, zCoord).getMaterial() == Material.water){
|
||||
|
|
|
@ -80,6 +80,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(this.currentTime > 0){
|
||||
|
|
|
@ -41,6 +41,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
boolean flag = this.firstSmeltTime > 0 || this.secondSmeltTime > 0;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){
|
||||
if(ConfigIntValues.FURNACE_SOLAR_ENERGY_PRODUCED.getValue() <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
||||
|
|
|
@ -24,6 +24,7 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){
|
||||
WorldPos blockToFert = this.blockToFertilize();
|
||||
|
|
|
@ -71,6 +71,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
boolean flag = this.firstCrushTime > 0 || this.secondCrushTime > 0;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
||||
if(ConfigIntValues.HEAT_COLLECTOR_ENERGY_PRODUCED.getValue() <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
||||
|
|
|
@ -82,6 +82,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
this.initVars();
|
||||
|
||||
|
|
|
@ -79,6 +79,11 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit(){
|
||||
return 64;
|
||||
|
|
|
@ -35,6 +35,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(this.slots[SLOT_OUTPUT] == null && canBeRepaired(this.slots[SLOT_INPUT])){
|
||||
if(this.slots[SLOT_INPUT].getItemDamage() <= 0){
|
||||
|
|
|
@ -32,6 +32,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(this.worldObj.isRemote){
|
||||
this.renderParticles();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(this.storage.getEnergyStored() >= ConfigIntValues.LAVA_FACTORY_ENERGY_USED.getValue() && this.isMultiblock() == HAS_AIR){
|
||||
this.currentWorkTime++;
|
||||
|
|
|
@ -41,6 +41,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)){
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
boolean flag = this.currentBurnTime > 0;
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
this.range = TileEntityPhantomface.upgradeRange(ConfigIntValues.PHANTOM_PLACER_RANGE.getValue(), worldObj, xCoord, yCoord, zCoord);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
this.range = upgradeRange(ConfigIntValues.PHANTOMFACE_RANGE.getValue(), worldObj, xCoord, yCoord, zCoord);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
int range = ConfigIntValues.RANGED_COLLECTOR_RANGE.getValue();
|
||||
|
|
|
@ -41,6 +41,7 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!Objects.equals(this.name, this.nameBefore)){
|
||||
this.nameBefore = this.name;
|
||||
|
|
|
@ -31,6 +31,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
|
|||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(this.amount > 0){
|
||||
if(this.slots[0] == null){
|
||||
|
|
Loading…
Reference in a new issue