cleanup, close #3021

This commit is contained in:
asiekierka 2015-09-19 12:59:05 +02:00
parent bab7c68f4c
commit 5e13fc69ed
7 changed files with 58 additions and 48 deletions

View file

@ -181,8 +181,7 @@ public class BuildCraftCore extends BuildCraftMod {
@Mod.Instance("BuildCraft|Core")
public static BuildCraftCore instance;
public static final boolean NONRELEASED_BLOCKS = true;
public static final boolean TABLET_TESTING = true;
public static final boolean DEVELOPER_MODE = false;
public enum RenderMode {
Full, NoDynamic
@ -357,7 +356,7 @@ public class BuildCraftCore extends BuildCraftMod {
paintbrushItem = (new ItemPaintbrush()).setUnlocalizedName("paintbrush");
CoreProxy.proxy.registerItem(paintbrushItem);
if (TABLET_TESTING) {
if (DEVELOPER_MODE) {
tabletItem = new ItemTablet();
tabletItem.setUnlocalizedName("tablet");
CoreProxy.proxy.registerItem(tabletItem);

View file

@ -261,7 +261,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Items.bucket));
}
if (!BuildCraftCore.NONRELEASED_BLOCKS) {
if (BuildCraftCore.DEVELOPER_MODE) {
if (blockRedPlasma != null) {
bucketRedPlasma = new ItemBucketBuildcraft(blockRedPlasma);
bucketRedPlasma.setUnlocalizedName("bucketRedPlasma").setContainerItem(Items.bucket);

View file

@ -47,11 +47,11 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
public enum Mode {
EDIT, COPY
NONE, EDIT, COPY
}
public String currentAuthorName = "";
public Mode mode = Mode.EDIT;
public Mode mode = Mode.NONE;
public Box box = new Box();
public String name = "";
@ -105,7 +105,11 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
sendNetworkUpdate();
return;
} else {
mode = Mode.EDIT;
if (BuildCraftCore.DEVELOPER_MODE) {
mode = Mode.EDIT;
} else {
mode = Mode.NONE;
}
}
} else {
mode = Mode.COPY;
@ -162,7 +166,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this;
return mode != Mode.NONE && worldObj.getTileEntity(xCoord, yCoord, zCoord) == this;
}
@Override

View file

@ -36,8 +36,9 @@ public class FacadePluggable extends PipePluggable implements IFacadePluggable {
public ItemFacade.FacadeState[] states;
private ItemFacade.FacadeState activeState;
private IPipeTile pipe;
// Client sync
// Client sync
private Block block;
private int meta;
private boolean transparent, renderAsHollow;
@ -50,6 +51,16 @@ public class FacadePluggable extends PipePluggable implements IFacadePluggable {
public FacadePluggable() {
}
@Override
public void invalidate() {
this.pipe = null;
}
@Override
public void validate(IPipeTile pipe, ForgeDirection direction) {
this.pipe = pipe;
}
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
FacadePluggable other = (FacadePluggable) o;
@ -166,14 +177,38 @@ public class FacadePluggable extends PipePluggable implements IFacadePluggable {
}
private void prepareStates() {
if (activeState == null) {
if (states.length > 1) {
if (pipe == null || pipe.getPipe() == null) {
activeState = states[0];
return;
}
IPipe p = pipe.getPipe();
int defaultStateId = -1;
int activeStateId = -1;
for (int i = 0; i < states.length; i++) {
ItemFacade.FacadeState state = states[i];
if (state.wire == null) {
defaultStateId = i;
continue;
}
if (p.isWireActive(state.wire)) {
activeStateId = i;
break;
}
}
activeState = activeStateId < 0 ? (defaultStateId < 0 ? states[0] : states[defaultStateId]) : states[activeStateId];
} else if (activeState == null) {
activeState = states != null && states.length > 0 ? states[0] : null;
}
}
protected void setActiveState(int id) {
if (id >= 0 && id < states.length) {
activeState = states[id];
}
}
@Override
public void update(IPipeTile pipe, ForgeDirection direction) {
if (states.length > 1) {
// Iterate over all states and activate first proper
}
}
}

View file

@ -12,6 +12,5 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
public interface IPipeTransportFluidsHook {
int fill(ForgeDirection from, FluidStack resource, boolean doFill);
}

View file

@ -16,11 +16,10 @@ import buildcraft.transport.utils.TextureMatrix;
import buildcraft.transport.utils.WireMatrix;
public class PipeRenderState implements ISerializable {
public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix();
public final TextureMatrix textureMatrix = new TextureMatrix();
public final WireMatrix wireMatrix = new WireMatrix();
protected boolean glassColorDirty = false;
private boolean glassColorDirty = false;
private byte glassColor = -127;
private boolean dirty = true;
@ -38,7 +37,10 @@ public class PipeRenderState implements ISerializable {
}
public void setGlassColor(byte color) {
this.glassColor = color;
if (this.glassColor != color) {
this.glassColor = color;
this.glassColorDirty = true;
}
}
public boolean isDirty() {

View file

@ -454,7 +454,6 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
public boolean setPipeColor(int color) {
if (!worldObj.isRemote && color >= -1 && color < 16 && glassColor != color) {
renderState.glassColorDirty = true;
glassColor = color;
notifyBlockChanged();
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockType);
@ -509,34 +508,6 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
}
// Facades
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
PipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
if (!(pluggable instanceof FacadePluggable)) {
continue;
}
FacadeState[] states = ((FacadePluggable) pluggable).states;
// Iterate over all states and activate first proper
int defaultState = -1;
int activeState = -1;
for (int i = 0; i < states.length; i++) {
FacadeState state = states[i];
if (state.wire == null) {
defaultState = i;
continue;
}
if (pipe != null && pipe.isWireActive(state.wire)) {
activeState = i;
break;
}
}
if (activeState < 0) {
activeState = defaultState;
}
((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);