mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 20:22:12 +00:00
Unify IProgressTile usage, only implement where needed.
Tons of cleanup everywhere, implement final methods in TileEntityEio
This commit is contained in:
1 parent
adabb82f72
commit
57f665a03e
49 files changed
+176
-196
No files matched your search
@@ -253,8 +253,6 @@ public class ClientProxy extends CommonProxy {
|
||||
BlockSoulBinder.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new SoulBinderRenderer());
|
||||
|
||||
BlockAttractor.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
ObeliskRenderer defaultObeliskRenderer = new ObeliskRenderer();
|
||||
BlockObeliskAbstract.defaultObeliskRenderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(defaultObeliskRenderer);
|
||||
|
||||
@@ -60,6 +60,7 @@ public enum ModObject {
|
||||
blockSpawnGuard,
|
||||
blockExperienceObelisk,
|
||||
blockWeatherObelisk,
|
||||
blockInhibitorObelisk,
|
||||
blockTransceiver,
|
||||
blockBuffer,
|
||||
|
||||
|
||||
@@ -5,11 +5,63 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import crazypants.enderio.machine.PacketProgress;
|
||||
import crazypants.enderio.machine.gui.AbstractMachineContainer;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.IProgressTile;
|
||||
|
||||
public abstract class TileEntityEio extends TileEntity {
|
||||
|
||||
private final int checkOffset = (int) (Math.random() * 20);
|
||||
private final boolean isProgressTile;
|
||||
|
||||
protected int lastProgressScaled = -1;
|
||||
protected int ticksSinceLastProgressUpdate;
|
||||
|
||||
public TileEntityEio() {
|
||||
isProgressTile = this instanceof IProgressTile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canUpdate() {
|
||||
return shouldUpdate() || isProgressTile;
|
||||
}
|
||||
|
||||
protected boolean shouldUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void updateEntity() {
|
||||
doUpdate();
|
||||
if(isProgressTile) {
|
||||
int curScaled = AbstractMachineContainer.getProgressScaled(16, (IProgressTile) this);
|
||||
if(++ticksSinceLastProgressUpdate >= getProgressUpdateFreq() || curScaled != lastProgressScaled) {
|
||||
sendTaskProgressPacket();
|
||||
lastProgressScaled = curScaled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void doUpdate() {
|
||||
|
||||
}
|
||||
|
||||
protected void sendTaskProgressPacket() {
|
||||
if(isProgressTile) {
|
||||
PacketHandler.sendToAllAround(new PacketProgress((IProgressTile) this), this);
|
||||
}
|
||||
ticksSinceLastProgressUpdate = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls how often progress updates. Has no effect if your TE is not
|
||||
* {@link IProgressTile}.
|
||||
*/
|
||||
protected int getProgressUpdateFreq() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readFromNBT(NBTTagCompound root) {
|
||||
|
||||
@@ -222,7 +222,7 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TileEndermanSkull extends TileEntityEio {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
public boolean shouldUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,8 +197,6 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
|
||||
public abstract boolean isActive();
|
||||
|
||||
public abstract float getProgress();
|
||||
|
||||
public String getSoundName() {
|
||||
return null;
|
||||
}
|
||||
@@ -229,18 +227,12 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
int result = (int) (getProgress() * scale);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// --- Process Loop
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
public void doUpdate() {
|
||||
if(worldObj == null) { // sanity check
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public abstract class AbstractPoweredMachineEntity extends AbstractMachineEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
|
||||
super.updateEntity();
|
||||
super.doUpdate();
|
||||
|
||||
if(worldObj == null || worldObj.isRemote) { // sanity check
|
||||
return;
|
||||
|
||||
@@ -23,9 +23,6 @@ public abstract class AbstractPoweredTaskEntity extends AbstractPowerConsumerEnt
|
||||
protected int ticksSinceCheckedRecipe = 0;
|
||||
protected boolean startFailed = false;
|
||||
|
||||
protected int lastProgressScaled = -1;
|
||||
protected int ticksSinceLastProgressUpdate;
|
||||
|
||||
public AbstractPoweredTaskEntity(SlotDefinition slotDefinition) {
|
||||
super(slotDefinition);
|
||||
}
|
||||
@@ -135,11 +132,6 @@ public abstract class AbstractPoweredTaskEntity extends AbstractPowerConsumerEnt
|
||||
return requiresClientSync;
|
||||
}
|
||||
|
||||
protected void sendTaskProgressPacket() {
|
||||
PacketHandler.sendToAllAround(new PacketProgress(this), this);
|
||||
ticksSinceLastProgressUpdate = 0;
|
||||
}
|
||||
|
||||
protected boolean checkProgress(boolean redstoneChecksPassed) {
|
||||
if(currentTask == null || !hasPower()) {
|
||||
return false;
|
||||
@@ -153,12 +145,6 @@ public abstract class AbstractPoweredTaskEntity extends AbstractPowerConsumerEnt
|
||||
return false;
|
||||
}
|
||||
|
||||
int curScaled = getProgressScaled(16);
|
||||
if(++ticksSinceLastProgressUpdate >= 20 || curScaled != lastProgressScaled) {
|
||||
sendTaskProgressPacket();
|
||||
lastProgressScaled = curScaled;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class GuiAlloySmelter extends GuiPoweredMachineBase<TileAlloySmelter> {
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = getTileEntity().getProgressScaled(14) + 1;
|
||||
int scaled = getProgressScaled(14) + 1;
|
||||
drawTexturedModalRect(sx + 55, sy + 49 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
drawTexturedModalRect(sx + 103, sy + 49 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
}
|
||||
|
||||
@@ -46,11 +46,6 @@ public class TileBuffer extends AbstractPowerConsumerEntity implements IPaintabl
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0; // none
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
if(getEnergyStored() <= 0 || !redstoneCheckPassed) {
|
||||
|
||||
@@ -162,7 +162,7 @@ public class TileCapBank extends TileEntityEio implements IInternalPowerReceiver
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj.isRemote) {
|
||||
if(networkId == -1) {
|
||||
if(idRequestTimer <= 0) {
|
||||
|
||||
@@ -61,11 +61,6 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
ticksSinceLastCraft++;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class GuiCrusher extends GuiPoweredMachineBase<TileCrusher> {
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if(shouldRenderProgress()) {
|
||||
int barHeight = getTileEntity().getProgressScaled(24);
|
||||
int barHeight = getProgressScaled(24);
|
||||
drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, barHeight + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemShears;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,10 +27,9 @@ import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.machine.farm.farmers.FarmersCommune;
|
||||
import crazypants.enderio.machine.farm.farmers.IHarvestResult;
|
||||
import crazypants.enderio.machine.farm.farmers.RubberTreeFarmerIC2;
|
||||
import crazypants.enderio.machine.gui.AbstractMachineContainer;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.enderio.tool.ArrayMappingTool;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Lang;
|
||||
@@ -365,8 +363,8 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
public void doUpdate() {
|
||||
super.doUpdate();
|
||||
if(isActive() != wasActive) {
|
||||
wasActive = isActive();
|
||||
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
|
||||
@@ -392,7 +390,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
setNotification("noPower");
|
||||
return false;
|
||||
}
|
||||
int curScaled = getProgressScaled(16);
|
||||
int curScaled = AbstractMachineContainer.getProgressScaled(16, this);
|
||||
if(curScaled != lastProgressScaled) {
|
||||
sendTaskProgressPacket();
|
||||
lastProgressScaled = curScaled;
|
||||
|
||||
-5
@@ -102,11 +102,6 @@ public class TileCombustionGenerator extends AbstractGeneratorEntity implements
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
if(resource == null || resource.getFluid() == null || !canFill(from, resource.getFluid())) {
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ public class GuiStirlingGenerator extends GuiPoweredMachineBase<TileEntityStirli
|
||||
int scaled;
|
||||
|
||||
if(shouldRenderProgress()) {
|
||||
scaled = getTileEntity().getProgressScaled(12);
|
||||
scaled = getProgressScaled(12);
|
||||
drawTexturedModalRect(sx + 80, sy + 64 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
}
|
||||
|
||||
|
||||
+12
-1
@@ -15,8 +15,9 @@ import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.PowerDistributor;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.IProgressTile;
|
||||
|
||||
public class TileEntityStirlingGenerator extends AbstractGeneratorEntity implements ISidedInventory {
|
||||
public class TileEntityStirlingGenerator extends AbstractGeneratorEntity implements ISidedInventory, IProgressTile {
|
||||
|
||||
public static final int ENERGY_PER_TICK = Config.stirlingGeneratorBaseRfPerTick;
|
||||
|
||||
@@ -76,6 +77,16 @@ public class TileEntityStirlingGenerator extends AbstractGeneratorEntity impleme
|
||||
return (float) burnTime / (float) totalBurnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(float progress) {
|
||||
burnTime = (int) (totalBurnTime * progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSoundName() {
|
||||
return SOUND_NAME;
|
||||
|
||||
@@ -98,11 +98,6 @@ public class TileZombieGenerator extends AbstractGeneratorEntity implements IFlu
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(Block blockId) {
|
||||
super.onNeighborBlockChange(blockId);
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.util.IProgressTile;
|
||||
|
||||
public abstract class AbstractMachineContainer extends Container {
|
||||
|
||||
@@ -243,4 +244,14 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected int getProgressScaled(int scale) {
|
||||
if(getTileEntity() instanceof IProgressTile) {
|
||||
getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getProgressScaled(int scale, IProgressTile tile) {
|
||||
return (int) (tile.getProgress() * scale);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import crazypants.gui.GuiContainerBase;
|
||||
import crazypants.gui.GuiToolTip;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.IProgressTile;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
@@ -181,17 +182,27 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends Gu
|
||||
}
|
||||
|
||||
protected int scaleProgressForTooltip(float progress) {
|
||||
return (int)(progress * 100);
|
||||
return (int) (progress * 100);
|
||||
}
|
||||
|
||||
protected boolean shouldRenderProgress() {
|
||||
float progress = tileEntity.getProgress();
|
||||
if(progress > 0 && progress < 1) {
|
||||
updateProgressTooltips(scaleProgressForTooltip(progress), progress);
|
||||
return true;
|
||||
} else {
|
||||
updateProgressTooltips(-1, -1);
|
||||
return false;
|
||||
if(tileEntity instanceof IProgressTile) {
|
||||
float progress = ((IProgressTile) tileEntity).getProgress();
|
||||
if(progress > 0 && progress < 1) {
|
||||
updateProgressTooltips(scaleProgressForTooltip(progress), progress);
|
||||
return true;
|
||||
} else {
|
||||
updateProgressTooltips(-1, -1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getProgressScaled(int scale) {
|
||||
if(getTileEntity() instanceof IProgressTile) {
|
||||
return AbstractMachineContainer.getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ public class TileHyperCube extends TileEntityEio implements IInternalPowerHandle
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj == null) { // sanity check
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,14 +97,9 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
updateArmSwingProgress();
|
||||
hooverXP();
|
||||
if(worldObj != null && !worldObj.isRemote) {
|
||||
@@ -114,7 +109,7 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle
|
||||
hadSword = inventory[0] != null;
|
||||
}
|
||||
}
|
||||
super.updateEntity();
|
||||
super.doUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -107,7 +107,7 @@ public class TileElectricLight extends TileEntityEio implements IInternalPowerRe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TileLightNode extends TileEntityEio {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,11 +117,6 @@ public class TilePowerMonitor extends AbstractPowerConsumerEntity implements IIn
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getEnergyPerTick() {
|
||||
return energyPerTick;
|
||||
}
|
||||
|
||||
@@ -137,12 +137,7 @@ public class TileAttractor extends AbstractPowerConsumerEntity implements IRange
|
||||
public boolean isActive() {
|
||||
return hasPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
if(redstoneCheckPassed && hasPower()) {
|
||||
|
||||
@@ -115,11 +115,6 @@ public class TileAversionObelisk extends AbstractPowerConsumerEntity implements
|
||||
return hasPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
if(redstoneCheckPassed && hasPower()) {
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package crazypants.enderio.machine.obelisk.weather;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.machine.gui.AbstractMachineContainer;
|
||||
|
||||
public class ContainerWeatherObelisk extends AbstractMachineContainer {
|
||||
|
||||
public static final int MAX_SCALE = 31;
|
||||
|
||||
private int lastPowerUsed;
|
||||
|
||||
public ContainerWeatherObelisk(InventoryPlayer playerInv, TileWeatherObelisk te) {
|
||||
super(playerInv, te);
|
||||
}
|
||||
@@ -27,28 +22,4 @@ public class ContainerWeatherObelisk extends AbstractMachineContainer {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int par1, int par2) {
|
||||
TileWeatherObelisk te = (TileWeatherObelisk) getTileEntity();
|
||||
if(par1 == 0) {
|
||||
te.progress = par2;
|
||||
}
|
||||
}
|
||||
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
TileWeatherObelisk te = (TileWeatherObelisk) getTileEntity();
|
||||
|
||||
for (int i = 0; i < this.crafters.size(); ++i) {
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
|
||||
int powerUsed = te.powerUsed;
|
||||
if(powerUsed != lastPowerUsed) {
|
||||
icrafting.sendProgressBarUpdate(this, 0, te.getProgressScaled(MAX_SCALE));
|
||||
}
|
||||
}
|
||||
|
||||
this.lastPowerUsed = te.powerUsed;
|
||||
}
|
||||
}
|
||||
@@ -86,19 +86,20 @@ public class GuiWeatherObelisk extends GuiPoweredMachineBase<TileWeatherObelisk>
|
||||
this.drawTexturedModalRect(getGuiLeft(), getGuiTop(), 0, 0, getXSize(), getYSize());
|
||||
|
||||
if(shouldRenderProgress() && getTileEntity().activeTask != null) {
|
||||
int barHeight = getTileEntity().progress;
|
||||
// TODO test
|
||||
int barHeight = getProgressScaled(ContainerWeatherObelisk.MAX_SCALE);
|
||||
Color color = getTileEntity().activeTask.color;
|
||||
GL11.glColor3f((float) color.getRed() / 255f, (float) color.getGreen() / 255f, (float) color.getBlue() / 255f);
|
||||
this.drawTexturedModalRect(getGuiLeft() + 81, getGuiTop() + 58 - barHeight, getXSize(), 32 - barHeight, 12, barHeight);
|
||||
}
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPowerHeight() {
|
||||
return super.getPowerHeight() + 20;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPowerU() {
|
||||
return super.getPowerU();
|
||||
@@ -127,21 +128,4 @@ public class GuiWeatherObelisk extends GuiPoweredMachineBase<TileWeatherObelisk>
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketActivateWeather(getTileEntity(), WeatherTask.values()[b.id]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int scaleProgressForTooltip(float progress) {
|
||||
return (int) (progress / ((float) ContainerWeatherObelisk.MAX_SCALE) * 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldRenderProgress() {
|
||||
int progress = getTileEntity().progress;
|
||||
if(progress > 0) {
|
||||
updateProgressTooltips(scaleProgressForTooltip(progress), progress);
|
||||
return true;
|
||||
} else {
|
||||
updateProgressTooltips(-1, -1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,9 @@ import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.BasicCapacitor;
|
||||
import crazypants.enderio.power.Capacitors;
|
||||
import crazypants.enderio.power.ICapacitor;
|
||||
import crazypants.util.IProgressTile;
|
||||
|
||||
public class TileWeatherObelisk extends AbstractPowerConsumerEntity {
|
||||
public class TileWeatherObelisk extends AbstractPowerConsumerEntity implements IProgressTile {
|
||||
|
||||
public enum WeatherTask {
|
||||
CLEAR(Config.weatherObeliskClearPower, Color.YELLOW) {
|
||||
@@ -83,7 +84,7 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity {
|
||||
}
|
||||
|
||||
int powerUsed = 0;
|
||||
int progress = 0; // client only
|
||||
private float progress = 0; // client only
|
||||
WeatherTask activeTask = null;
|
||||
|
||||
private Color particleColor;
|
||||
@@ -101,8 +102,8 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity {
|
||||
setCapacitor(Capacitors.ACTIVATED_CAPACITOR);
|
||||
}
|
||||
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
public void doUpdate() {
|
||||
super.doUpdate();
|
||||
if(worldObj.isRemote) {
|
||||
if(activeParticleTicks > 0) {
|
||||
spawnParticle();
|
||||
@@ -143,6 +144,21 @@ public class TileWeatherObelisk extends AbstractPowerConsumerEntity {
|
||||
public float getProgress() {
|
||||
return isActive() ? worldObj.isRemote ? progress : (float) powerUsed / (float) activeTask.power : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(float progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getProgressUpdateFreq() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICapacitor getCapacitor() {
|
||||
|
||||
@@ -41,11 +41,6 @@ public class TileExperienceOblisk extends AbstractMachineEntity implements IFlui
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
if(xpCont.isDirty()) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class GuiPainter extends GuiPoweredMachineBase<TileEntityPainter> {
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = getTileEntity().getProgressScaled(24);
|
||||
int scaled = getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 88, l + 34, 176, 14, scaled + 1, 16);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,8 +59,7 @@ public class TileEntityPaintedBlock extends TileEntityEio implements IPaintableT
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
public boolean shouldUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -195,7 +195,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerHa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj == null) { // sanity check
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler {
|
||||
private ArrayList<TankNeighbour> tankNeighbours;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj == null || worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class GuiSliceAndSplice extends GuiPoweredMachineBase<TileSliceAndSplice>
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = getTileEntity().getProgressScaled(24);
|
||||
int scaled = getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 103, l + 49, 176, 14, scaled + 1, 16);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class TileEntitySolarPanel extends TileEntityEio implements IInternalPowe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(worldObj == null || worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class GuiSoulBinder extends GuiPoweredMachineBase<TileSoulBinder> {
|
||||
TileSoulBinder binder = getTileEntity();
|
||||
|
||||
if(shouldRenderProgress()) {
|
||||
i1 = binder.getProgressScaled(24);
|
||||
i1 = getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 80, l + 34, 176, 14, i1 + 1, 16);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,13 +74,13 @@ public class GuiPoweredSpawner extends GuiPoweredMachineBase<TilePoweredSpawner>
|
||||
int yOff = 34;
|
||||
drawTexturedModalRect(left + 80, top + yOff, 207, 0, 17, 15);
|
||||
if(spawner.getProgress() < 1 && spawner.getProgress() > 0) {
|
||||
int scaled = spawner.getProgressScaled(14) + 1;
|
||||
int scaled = getProgressScaled(14) + 1;
|
||||
drawTexturedModalRect(left + 81, top + yOff + 14 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
}
|
||||
} else {
|
||||
drawTexturedModalRect(left + 52, top + 40, 52, 170, 72, 21);
|
||||
if(spawner.getProgress() < 1 && spawner.getProgress() > 0) {
|
||||
int scaled = spawner.getProgressScaled(24);
|
||||
int scaled = getProgressScaled(24);
|
||||
drawTexturedModalRect(left + 76, top + 43, 176, 14, scaled + 1, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,9 +199,9 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
logic.updateSpawner();
|
||||
super.updateEntity();
|
||||
super.doUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -231,12 +231,7 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler, IT
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
boolean res = processItems(redstoneCheckPassed);
|
||||
|
||||
@@ -95,14 +95,14 @@ public class TileTransceiver extends AbstractPoweredTaskEntity implements IFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(!registered && worldObj != null && !worldObj.isRemote) {
|
||||
ServerChannelRegister.instance.register(this);
|
||||
registered = true;
|
||||
removeUnregsiteredChannels(sendChannels);
|
||||
removeUnregsiteredChannels(recieveChannels);
|
||||
}
|
||||
super.updateEntity();
|
||||
super.doUpdate();
|
||||
|
||||
if(worldObj != null && !worldObj.isRemote) {
|
||||
railController.doTick();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TileVacuumChest extends TileEntityEio implements IEntitySelector, I
|
||||
private boolean redstoneStateDirty = true;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
if(redstoneStateDirty) {
|
||||
updateRedstoneStatus();
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class GuiVat extends GuiPoweredMachineBase<TileVat> {
|
||||
TileVat vat = getTileEntity();
|
||||
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = vat.getProgressScaled(14) + 1;
|
||||
int scaled = getProgressScaled(14) + 1;
|
||||
drawTexturedModalRect(guiLeft + 81, guiTop + 77 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
|
||||
IIcon inputIcon = null;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TileWirelessCharger extends TileEntityEio implements IInternalPower
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void doUpdate() {
|
||||
|
||||
if(worldObj == null || worldObj.isRemote) {
|
||||
return;
|
||||
|
||||
@@ -157,7 +157,7 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
public boolean shouldUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.gui.TextFieldEIO;
|
||||
import crazypants.enderio.machine.gui.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.gui.GuiContainerBase;
|
||||
@@ -169,7 +170,7 @@ public class GuiTelePad extends GuiContainerBase implements IToggleableGui {
|
||||
|
||||
int powerScaled = te.getPowerScaled(powerScale);
|
||||
drawTexturedModalRect(sx + powerX, sy + powerY + powerScale - powerScaled, xSize, 0, 10, powerScaled);
|
||||
int progressScaled = te.getProgressScaled(progressScale);
|
||||
int progressScaled = AbstractMachineContainer.getProgressScaled(progressScale, te);
|
||||
drawTexturedModalRect(sx + progressX, sy + progressY, 0, ySize, progressScaled, 10);
|
||||
|
||||
FontRenderer fnt = getFontRenderer();
|
||||
|
||||
@@ -34,7 +34,6 @@ import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.MachineSound;
|
||||
import crazypants.enderio.machine.PacketPowerStorage;
|
||||
import crazypants.enderio.machine.PacketProgress;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.IInternalPowerReceiver;
|
||||
import crazypants.enderio.rail.TeleporterEIO;
|
||||
@@ -68,7 +67,6 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
private Queue<Entity> toTeleport = Queues.newArrayDeque();
|
||||
private int powerUsed;
|
||||
private int maxPower;
|
||||
private int lastSyncPowerUsed;
|
||||
|
||||
private static final ResourceLocation activeRes = AbstractMachineEntity.getSoundFor("telepad.active");
|
||||
private MachineSound activeSound = null;
|
||||
@@ -84,8 +82,8 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
public float speedMult = 2.5f;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
public void doUpdate() {
|
||||
super.doUpdate();
|
||||
// my master is gone!
|
||||
if(master != null && master.isInvalid()) {
|
||||
master.breakNetwork();
|
||||
@@ -142,11 +140,6 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
lastSyncPowerStored = getEnergyStored();
|
||||
PacketHandler.sendToAllAround(new PacketPowerStorage(this), this);
|
||||
}
|
||||
boolean progressChanged = (lastSyncPowerUsed != powerUsed);
|
||||
if(progressChanged) {
|
||||
lastSyncPowerUsed = getEnergyStored();
|
||||
PacketHandler.sendToAllAround(new PacketProgress(this), this);
|
||||
}
|
||||
if(coordsChanged && inNetwork() && master != null && isMaster()) {
|
||||
coordsChanged = false;
|
||||
PacketHandler.sendToAllAround(new PacketUpdateCoords(master, master.getX(), master.getY(), master.getZ(), master.getTargetDim()), master);
|
||||
@@ -287,7 +280,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
public boolean shouldUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -350,10 +343,6 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
return (int) ((((float) getEnergyStored()) / ((float) getMaxEnergyStored())) * scale);
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
return (int) (getProgress() * scale);
|
||||
}
|
||||
|
||||
private int calculateTeleportPower() {
|
||||
if (worldObj.provider.dimensionId == targetDim) {
|
||||
this.maxPower = new BlockCoord(this).distance(target) * 1000;
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
package crazypants.util;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface IProgressTile {
|
||||
|
||||
|
||||
float getProgress();
|
||||
|
||||
|
||||
/**
|
||||
* Client-only. Called to set clientside progress for syncing/rendering
|
||||
* purposes.
|
||||
*
|
||||
* @param progress
|
||||
* The % progress.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
void setProgress(float progress);
|
||||
|
||||
|
||||
TileEntity getTileEntity();
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user