fix for Java 6/7

This commit is contained in:
asiekierka 2015-04-06 09:37:32 +02:00
commit 0509624c89
13 changed files with 107 additions and 56 deletions

View file

@ -57,4 +57,8 @@ public abstract class PipePluggable implements INBTStoreable, ISerializable {
@SideOnly(Side.CLIENT)
public abstract IPipePluggableRenderer getRenderer();
public boolean requiresRenderUpdate(PipePluggable old) {
return true;
}
}

View file

@ -372,6 +372,8 @@ public class BuildCraftCore extends BuildCraftMod {
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
BCLog.logger.info("BuildCraft's fake player: UUID = " + gameProfile.getId().toString() + ", name = '" + gameProfile.getName() + "'!");
for (Object o : Block.blockRegistry) {
Block block = (Block) o;

View file

@ -253,6 +253,11 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
data.writeByte(getRenderState().ordinal());
}
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
return renderState != ((RobotStationPluggable) o).renderState;
}
@Override
public void readData(ByteBuf data) {
this.renderState = RobotStationState.values()[data.readUnsignedByte()];

View file

@ -77,6 +77,7 @@ public class RenderRobot extends Render implements IItemRenderer {
GL11.glPushMatrix();
GL11.glTranslatef(-0.125F, 0, -0.125F);
doRenderItem(robot.getStackInSlot(0));
GL11.glColor3f(1, 1, 1);
GL11.glPopMatrix();
}
@ -84,6 +85,7 @@ public class RenderRobot extends Render implements IItemRenderer {
GL11.glPushMatrix();
GL11.glTranslatef(+0.125F, 0, -0.125F);
doRenderItem(robot.getStackInSlot(1));
GL11.glColor3f(1, 1, 1);
GL11.glPopMatrix();
}
@ -91,6 +93,7 @@ public class RenderRobot extends Render implements IItemRenderer {
GL11.glPushMatrix();
GL11.glTranslatef(+0.125F, 0, +0.125F);
doRenderItem(robot.getStackInSlot(2));
GL11.glColor3f(1, 1, 1);
GL11.glPopMatrix();
}
@ -98,6 +101,7 @@ public class RenderRobot extends Render implements IItemRenderer {
GL11.glPushMatrix();
GL11.glTranslatef(-0.125F, 0, +0.125F);
doRenderItem(robot.getStackInSlot(3));
GL11.glColor3f(1, 1, 1);
GL11.glPopMatrix();
}

View file

@ -30,6 +30,12 @@ public class FacadePluggable extends PipePluggable implements IFacadePluggable {
public FacadePluggable() {
}
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
FacadePluggable other = (FacadePluggable) o;
return other.block != block || other.meta != meta || other.transparent != transparent || other.renderAsHollow != renderAsHollow;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
if (states != null) {

View file

@ -387,7 +387,7 @@ public final class Gate implements IGate, ISidedStatementContainer, IRedstoneSta
int oldRedstoneOutputSide = redstoneOutputSide;
redstoneOutputSide = 0;
boolean wasActive = activeActions.size() > 0;
BitSet temp = prevBroadcastSignal;

View file

@ -2,6 +2,7 @@ package buildcraft.transport;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@ -94,7 +95,7 @@ public class PipeEventBus {
}
private void updateEventHandlers(List<EventHandler> eventHandlerList) {
eventHandlerList.sort(COMPARATOR);
Collections.sort(eventHandlerList, COMPARATOR);
}
public void unregisterHandler(Object handler) {

View file

@ -36,8 +36,7 @@ public class PipeRenderState implements ISerializable {
}
public boolean needsRenderUpdate() {
return pipeConnectionMatrix.isDirty() || textureMatrix.isDirty()
|| wireMatrix.isDirty();
return pipeConnectionMatrix.isDirty() || textureMatrix.isDirty();
}
@Override

View file

@ -526,10 +526,10 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
((FacadePluggable) pluggable).setActiveState(activeState);
}
/* TODO: Rewrite the requiresRenderUpdate API to run on the
server side instead of the client side to save network bandwidth */
pluggableState.setPluggables(sideProperties.pluggables);
// TODO: Add way of signalizing render update via Pluggables
if (renderState.isDirty()) {
renderState.clean();
}
@ -979,16 +979,20 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
return;
}
if (pipe == null && coreState.pipeId != 0) {
initialize(BlockGenericPipe.createPipe((Item) Item.itemRegistry.getObjectById(coreState.pipeId)));
}
if (pipe == null) {
return;
}
switch (stateId) {
case 0:
if (pipe != null) {
break;
}
if (pipe == null && coreState.pipeId != 0) {
initialize(BlockGenericPipe.createPipe((Item) Item.itemRegistry.getObjectById(coreState.pipeId)));
}
if (pipe == null) {
break;
}
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
break;
@ -1000,9 +1004,26 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
break;
}
case 2: {
// TODO: Add some kind of isDirty flag? I don't know...
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
sideProperties.pluggables = pluggableState.getPluggables();
PipePluggable[] newPluggables = pluggableState.getPluggables();
// mark for render update if necessary
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
PipePluggable old = sideProperties.pluggables[i];
PipePluggable newer = newPluggables[i];
if (old == null && newer == null) {
continue;
} else if (old != null && newer != null && old.getClass() == newer.getClass()) {
if (newer.requiresRenderUpdate(old)) {
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
break;
}
} else {
// one of them is null but not the other, so update
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
break;
}
}
sideProperties.pluggables = newPluggables.clone();
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
final PipePluggable pluggable = getPipePluggable(ForgeDirection.getOrientation(i));

View file

@ -97,6 +97,12 @@ public class GatePluggable extends PipePluggable {
}
}
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
// rendered by TESR
return false;
}
@Override
public ItemStack[] getDropItems(IPipeTile pipe) {
ItemStack gate = ItemGate.makeGateItem(material, logic);

View file

@ -15,7 +15,6 @@ import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
@ -24,21 +23,18 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.ISerializable;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.lib.RFBattery;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportFluids;
public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergyHandler, ISerializable {
private static final int ENERGY_MULTIPLIER = 50;
public int liquidToExtract;
protected int standardIconIndex = PipeIconProvider.TYPE.PipeFluidsWood_Standard.ordinal();
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal();
private long lastMining = 0;
private boolean lastPower = false;
private RFBattery battery = new RFBattery(2500, 1000, 0);
private PipeLogicWood logic = new PipeLogicWood(this) {
@Override
protected boolean isValidConnectingTile(TileEntity tile) {
@ -54,7 +50,7 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergy
};
public PipeFluidsWood(Item item) {
super(new PipeTransportFluids(), item);
super(new PipeTransportFluids(), item);
transport.initFromPipe(getClass());
}
@ -76,42 +72,28 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergy
super.initialize();
}
private TileEntity getConnectingTile() {
int meta = container.getBlockMetadata();
return meta >= 6 ? null : container.getTile(ForgeDirection.getOrientation(meta));
}
@Override
public void updateEntity() {
super.updateEntity();
int meta = container.getBlockMetadata();
if (meta >= 6) {
battery.setEnergy(0);
liquidToExtract = 0;
if (liquidToExtract == 0) {
return;
}
if (liquidToExtract > 0 && meta < 6) {
ForgeDirection side = ForgeDirection.getOrientation(meta);
TileEntity tile = container.getTile(side);
if (tile instanceof IFluidHandler) {
liquidToExtract -= Math.min(10, extractFluid((IFluidHandler) tile, side));
} else {
liquidToExtract -= 10;
}
TileEntity tile = getConnectingTile();
if (liquidToExtract < 0) {
liquidToExtract = 0;
}
}
if (tile == null || !(tile instanceof IFluidHandler)) {
liquidToExtract = 0;
} else {
extractFluid((IFluidHandler) tile, ForgeDirection.getOrientation(container.getBlockMetadata()));
if (battery.useEnergy(10, 10, false) > 0) {
TileEntity tile = container.getTile(ForgeDirection
.getOrientation(meta));
if (tile instanceof IFluidHandler) {
if (liquidToExtract <= FluidContainerRegistry.BUCKET_VOLUME) {
liquidToExtract += FluidContainerRegistry.BUCKET_VOLUME;
}
}
// We always subtract the flowRate to ensure that the buffer goes down reasonably quickly.
liquidToExtract -= transport.flowRate;
}
}
@ -173,7 +155,17 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergy
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive,
boolean simulate) {
return battery.receiveEnergy(maxReceive, simulate);
TileEntity tile = getConnectingTile();
if (tile == null || !(tile instanceof IFluidHandler)) {
return 0;
}
int maxToReceive = (1000 - liquidToExtract) / ENERGY_MULTIPLIER;
int received = Math.max(maxReceive, maxToReceive);
if (!simulate) {
liquidToExtract += ENERGY_MULTIPLIER * received;
}
return received;
}
@Override
@ -184,21 +176,21 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergy
@Override
public int getEnergyStored(ForgeDirection from) {
return battery.getEnergyStored();
return 0;
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return battery.getMaxEnergyStored();
return 1000 / ENERGY_MULTIPLIER;
}
@Override
public void writeData(ByteBuf data) {
data.writeInt(liquidToExtract);
data.writeShort(liquidToExtract);
}
@Override
public void readData(ByteBuf data) {
liquidToExtract = data.readInt();
liquidToExtract = data.readShort();
}
}

View file

@ -145,6 +145,12 @@ public class LensPluggable extends PipePluggable {
isFilter = (flags & 0x20) > 0;
}
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
LensPluggable other = (LensPluggable) o;
return other.color != color || other.isFilter != isFilter;
}
private void color(TravelingItem item) {
if ((item.toCenter && item.input.getOpposite() == side)
|| (!item.toCenter && item.output == side)) {

View file

@ -119,4 +119,9 @@ public class PlugPluggable extends PipePluggable {
public void readData(ByteBuf data) {
}
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
return false;
}
}