Merge branch 'Prototik-advanced-phased-facades' into 6.1.x
This commit is contained in:
commit
631bdc0da9
7 changed files with 278 additions and 247 deletions
|
@ -172,6 +172,8 @@ item.PipeItemsSandstone.name=Sandstone Transport Pipe
|
||||||
item.PipeFluidsSandstone.name=Sandstone Fluid Pipe
|
item.PipeFluidsSandstone.name=Sandstone Fluid Pipe
|
||||||
item.Facade.name=Facade
|
item.Facade.name=Facade
|
||||||
item.FacadePhased.name=Phased Facade
|
item.FacadePhased.name=Phased Facade
|
||||||
|
item.FacadePhased.state=%s: %s
|
||||||
|
item.FacadePhase.state_default=Default: %s
|
||||||
item.PipePlug.name=Pipe Plug
|
item.PipePlug.name=Pipe Plug
|
||||||
|
|
||||||
itemGroup.buildcraft.blocks=Buildcraft Blocks
|
itemGroup.buildcraft.blocks=Buildcraft Blocks
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
|
import buildcraft.api.core.JavaTools;
|
||||||
import buildcraft.api.recipes.IIntegrationRecipeManager;
|
import buildcraft.api.recipes.IIntegrationRecipeManager;
|
||||||
import buildcraft.api.transport.PipeWire;
|
import buildcraft.api.transport.PipeWire;
|
||||||
import buildcraft.silicon.ItemRedstoneChipset;
|
import buildcraft.silicon.ItemRedstoneChipset;
|
||||||
|
@ -28,12 +29,12 @@ public class AdvancedFacadeRecipe implements IIntegrationRecipeManager.IIntegrat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidInputA(ItemStack inputA) {
|
public boolean isValidInputA(ItemStack inputA) {
|
||||||
return inputA != null && inputA.getItem() instanceof ItemFacade && ItemFacade.getType(inputA) == ItemFacade.TYPE_BASIC;
|
return inputA != null && inputA.getItem() instanceof ItemFacade;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidInputB(ItemStack inputB) {
|
public boolean isValidInputB(ItemStack inputB) {
|
||||||
return inputB != null && inputB.getItem() instanceof ItemFacade && ItemFacade.getType(inputB) == ItemFacade.TYPE_BASIC;
|
return inputB != null && inputB.getItem() instanceof ItemFacade && ItemFacade.getType(inputB) == ItemFacade.FacadeType.Basic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +57,21 @@ public class AdvancedFacadeRecipe implements IIntegrationRecipeManager.IIntegrat
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wire != null) {
|
if (wire != null) {
|
||||||
return ItemFacade.getAdvancedFacade(wire, ItemFacade.getBlocks(inputA)[0], ItemFacade.getMetaValues(inputA)[0], ItemFacade.getBlocks(inputB)[0], ItemFacade.getMetaValues(inputB)[0]);
|
ItemFacade.FacadeState[] statesA = ItemFacade.getFacadeStates(inputA),
|
||||||
|
statesB = ItemFacade.getFacadeStates(inputB);
|
||||||
|
|
||||||
|
ItemFacade.FacadeState additionalState = statesB[0];
|
||||||
|
additionalState = new ItemFacade.FacadeState(additionalState.block, additionalState.metadata, wire);
|
||||||
|
|
||||||
|
// if in statesA exists state with the same wire just override it
|
||||||
|
for (int i = 0; i < statesA.length; i++) {
|
||||||
|
if (statesA[i].wire == wire) {
|
||||||
|
statesA[i] = additionalState;
|
||||||
|
return ItemFacade.getFacade(statesA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// otherwise concat all states into one facade
|
||||||
|
return ItemFacade.getFacade(JavaTools.concat(statesA, new ItemFacade.FacadeState[] {additionalState}));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -934,7 +934,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
||||||
|
|
||||||
private boolean addFacade(EntityPlayer player, Pipe pipe, ForgeDirection side) {
|
private boolean addFacade(EntityPlayer player, Pipe pipe, ForgeDirection side) {
|
||||||
ItemStack stack = player.getCurrentEquippedItem();
|
ItemStack stack = player.getCurrentEquippedItem();
|
||||||
if (stack != null && stack.getItem() instanceof ItemFacade && pipe.container.addFacade(side, ItemFacade.getType(stack), ItemFacade.getWireType(stack), ItemFacade.getBlocks(stack), ItemFacade.getMetaValues(stack))) {
|
if (stack != null && stack.getItem() instanceof ItemFacade && pipe.container.addFacade(side, ItemFacade.getFacadeStates(stack))) {
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.capabilities.isCreativeMode) {
|
||||||
stack.stackSize--;
|
stack.stackSize--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,14 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
|
@ -44,13 +46,82 @@ import buildcraft.core.proxy.CoreProxy;
|
||||||
import buildcraft.core.utils.StringUtils;
|
import buildcraft.core.utils.StringUtils;
|
||||||
|
|
||||||
public class ItemFacade extends ItemBuildCraft {
|
public class ItemFacade extends ItemBuildCraft {
|
||||||
|
public static final int MAX_STATES = PipeWire.values().length;
|
||||||
|
|
||||||
|
public static class FacadeState {
|
||||||
|
public final Block block;
|
||||||
|
public final int metadata;
|
||||||
|
public final PipeWire wire;
|
||||||
|
|
||||||
|
public FacadeState(Block block, int metadata, PipeWire wire) {
|
||||||
|
this.block = block;
|
||||||
|
this.metadata = metadata;
|
||||||
|
this.wire = wire;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FacadeState(NBTTagCompound nbt) {
|
||||||
|
block = (Block) Block.blockRegistry.getObject(nbt.getString("block"));
|
||||||
|
metadata = nbt.getInteger("metadata");
|
||||||
|
if (nbt.hasKey("wire")) {
|
||||||
|
wire = PipeWire.fromOrdinal(nbt.getInteger("wire"));
|
||||||
|
} else {
|
||||||
|
wire = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FacadeState create(Block block, int metadata) {
|
||||||
|
return create(block, metadata, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FacadeState create(Block block, int metadata, PipeWire wire) {
|
||||||
|
return new FacadeState(block, metadata, wire);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
nbt.setString("block", Block.blockRegistry.getNameForObject(block));
|
||||||
|
nbt.setInteger("metadata", metadata);
|
||||||
|
if (wire != null) {
|
||||||
|
nbt.setInteger("wire", wire.ordinal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagList writeArray(FacadeState[] states) {
|
||||||
|
if (states == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
NBTTagList list = new NBTTagList();
|
||||||
|
for (FacadeState state : states) {
|
||||||
|
NBTTagCompound stateNBT = new NBTTagCompound();
|
||||||
|
state.writeToNBT(stateNBT);
|
||||||
|
list.appendTag(stateNBT);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FacadeState[] readArray(NBTTagList list) {
|
||||||
|
if (list == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final int length = list.tagCount();
|
||||||
|
FacadeState[] states = new FacadeState[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
states[i] = new FacadeState(list.getCompoundTagAt(i));
|
||||||
|
}
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum FacadeType {
|
||||||
|
Basic, Phased;
|
||||||
|
|
||||||
|
public static FacadeType fromOrdinal(int ordinal) {
|
||||||
|
return ordinal == 1 ? Phased : Basic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final LinkedList<ItemStack> allFacades = new LinkedList<ItemStack>();
|
public static final LinkedList<ItemStack> allFacades = new LinkedList<ItemStack>();
|
||||||
public static final LinkedList<String> blacklistedFacades = new LinkedList<String>();
|
public static final LinkedList<String> blacklistedFacades = new LinkedList<String>();
|
||||||
|
|
||||||
public static final int TYPE_BASIC = 0;
|
|
||||||
public static final int TYPE_PHASED = 1;
|
|
||||||
|
|
||||||
private static final Block NULL_BLOCK = null;
|
private static final Block NULL_BLOCK = null;
|
||||||
private static final ItemStack NO_MATCH = new ItemStack(NULL_BLOCK, 0, 0);
|
private static final ItemStack NO_MATCH = new ItemStack(NULL_BLOCK, 0, 0);
|
||||||
|
|
||||||
|
@ -63,43 +134,14 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||||
String name = super.getItemStackDisplayName(itemstack);
|
switch(getType(itemstack)) {
|
||||||
|
case Basic:
|
||||||
if (getType(itemstack) == TYPE_PHASED) {
|
return super.getItemStackDisplayName(itemstack) + ": " + getFacadeStateDisplayName(getFacadeStates(itemstack)[0]);
|
||||||
name = StringUtils.localize("item.FacadePhased.name");
|
case Phased:
|
||||||
|
return StringUtils.localize("item.FacadePhased.name");
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = ItemFacade.getBlocks(itemstack)[0];
|
|
||||||
int meta = ItemFacade.getMetaValues(itemstack)[0];
|
|
||||||
Block blockAlt = ItemFacade.getBlocks(itemstack)[1];
|
|
||||||
int metaAlt = ItemFacade.getMetaValues(itemstack)[1];
|
|
||||||
|
|
||||||
if (block != null && block.getRenderType() == 31) {
|
|
||||||
meta &= 0x3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockAlt != null && blockAlt.getRenderType() == 31) {
|
|
||||||
metaAlt &= 0x3;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(block, 1, meta);
|
|
||||||
ItemStack stackAlt = new ItemStack(blockAlt, 1, metaAlt);
|
|
||||||
|
|
||||||
if (getType(itemstack) == TYPE_BASIC) {
|
|
||||||
if (Item.getItemFromBlock(block) != null) {
|
|
||||||
name += ": " + CoreProxy.proxy.getItemDisplayName(stack);
|
|
||||||
}
|
|
||||||
} else if (getType(itemstack) == TYPE_PHASED) {
|
|
||||||
if (Item.getItemFromBlock(block) != null) {
|
|
||||||
name += ": " + CoreProxy.proxy.getItemDisplayName(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Item.getItemFromBlock(blockAlt) != null) {
|
|
||||||
name += " / " + CoreProxy.proxy.getItemDisplayName(stackAlt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,11 +151,30 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean debug) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean debug) {
|
||||||
if (getType(stack) == TYPE_PHASED) {
|
if (getType(stack) == FacadeType.Phased) {
|
||||||
list.add("Wire: " + PipeWire.fromOrdinal(getWireType(stack)).getColor());
|
String stateString = StringUtils.localize("item.FacadePhased.state");
|
||||||
|
FacadeState defaultState = null;
|
||||||
|
for (FacadeState state : getFacadeStates(stack)) {
|
||||||
|
if (state.wire == null) {
|
||||||
|
defaultState = state;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.add(String.format(stateString, state.wire.getColor(), getFacadeStateDisplayName(state)));
|
||||||
|
}
|
||||||
|
if (defaultState != null) {
|
||||||
|
list.add(1, String.format(StringUtils.localize("item.FacadePhase.state_default"), getFacadeStateDisplayName(defaultState)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getFacadeStateDisplayName(FacadeState state) {
|
||||||
|
int meta = state.metadata;
|
||||||
|
if (state.block != null && state.block.getRenderType() == 31) {
|
||||||
|
meta &= 0x3;
|
||||||
|
}
|
||||||
|
return CoreProxy.proxy.getItemDisplayName(new ItemStack(state.block, 1, meta));
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
@ -138,7 +199,7 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
}
|
}
|
||||||
TileGenericPipe pipeTile = (TileGenericPipe) tile;
|
TileGenericPipe pipeTile = (TileGenericPipe) tile;
|
||||||
|
|
||||||
if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getType(stack), ItemFacade.getWireType(stack), ItemFacade.getBlocks(stack), ItemFacade.getMetaValues(stack))) {
|
if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), getFacadeStates(stack))) {
|
||||||
stack.stackSize--;
|
stack.stackSize--;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -231,79 +292,85 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GETTERS FOR FACADE DATA
|
public static FacadeState[] getFacadeStates(ItemStack stack) {
|
||||||
public static int getType(ItemStack stack) {
|
if (!stack.hasTagCompound()) {
|
||||||
// Type is based on various other data included in the stack
|
return new FacadeState[0];
|
||||||
int wireType = getWireType(stack);
|
|
||||||
|
|
||||||
if (wireType == -1) {
|
|
||||||
// Automatically considered a basic facade
|
|
||||||
return TYPE_BASIC;
|
|
||||||
}
|
}
|
||||||
|
NBTTagCompound nbt = stack.getTagCompound();
|
||||||
Block[] blocks = getBlocks(stack);
|
nbt = migrate(stack, nbt);
|
||||||
|
if (!nbt.hasKey("states")) {
|
||||||
if (blocks.length == 1 || blocks[1] == null) {
|
return new FacadeState[0];
|
||||||
return TYPE_BASIC;
|
|
||||||
}
|
}
|
||||||
|
return FacadeState.readArray(nbt.getTagList("states", Constants.NBT.TAG_COMPOUND));
|
||||||
return TYPE_PHASED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getWireType(ItemStack stack) {
|
private static NBTTagCompound migrate(ItemStack stack, NBTTagCompound nbt) {
|
||||||
int type = -1;
|
Block block = null, blockAlt = null;
|
||||||
|
int metadata = 0, metadataAlt;
|
||||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("wire")) {
|
PipeWire wire = null;
|
||||||
type = stack.getTagCompound().getInteger("wire");
|
if (nbt.hasKey("id")) {
|
||||||
|
block = (Block) Block.blockRegistry.getObjectById(nbt.getInteger("id"));
|
||||||
|
} else if (nbt.hasKey("name")) {
|
||||||
|
block = (Block) Block.blockRegistry.getObject(nbt.getString("name"));
|
||||||
}
|
}
|
||||||
|
if (nbt.hasKey("name_alt")) {
|
||||||
return type;
|
blockAlt = (Block) Block.blockRegistry.getObject(nbt.getString("name_alt"));
|
||||||
|
}
|
||||||
|
if (nbt.hasKey("meta")) {
|
||||||
|
metadata = nbt.getInteger("meta");
|
||||||
|
}
|
||||||
|
if (nbt.hasKey("meta_alt")) {
|
||||||
|
metadataAlt = nbt.getInteger("meta_alt");
|
||||||
|
} else {
|
||||||
|
metadataAlt = stack.getItemDamage() & 0x0000F;
|
||||||
|
}
|
||||||
|
if (nbt.hasKey("wire")) {
|
||||||
|
wire = PipeWire.fromOrdinal(nbt.getInteger("wire"));
|
||||||
|
}
|
||||||
|
if (block != null) {
|
||||||
|
FacadeState[] states;
|
||||||
|
FacadeState mainState = FacadeState.create(block, metadata);
|
||||||
|
if (blockAlt != null && wire != null) {
|
||||||
|
FacadeState altState = FacadeState.create(blockAlt, metadataAlt, wire);
|
||||||
|
states = new FacadeState[] {mainState, altState};
|
||||||
|
} else {
|
||||||
|
states = new FacadeState[] {mainState};
|
||||||
|
}
|
||||||
|
NBTTagCompound newNbt = getFacade(states).getTagCompound();
|
||||||
|
stack.setTagCompound(newNbt);
|
||||||
|
return newNbt;
|
||||||
|
}
|
||||||
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Block[] getBlocks(ItemStack stack) {
|
public static Block[] getBlocks(ItemStack stack) {
|
||||||
if (!stack.hasTagCompound()) {
|
FacadeState[] states = getFacadeStates(stack);
|
||||||
return null;
|
Block[] blocks = new Block[states.length];
|
||||||
|
for (int i = 0; i < states.length; i++) {
|
||||||
|
blocks[i] = states[i].block;
|
||||||
}
|
}
|
||||||
|
return blocks;
|
||||||
Block facadeBlock = null;
|
|
||||||
Block facadeBlockAlt = null;
|
|
||||||
|
|
||||||
NBTTagCompound stackTagCompound = stack.getTagCompound();
|
|
||||||
|
|
||||||
// reading the 'id' tag is kept to maintain back-compat.
|
|
||||||
// The stack gets upgraded the first time this code is run.
|
|
||||||
if (stackTagCompound.hasKey("id")) {
|
|
||||||
facadeBlock = (Block) Block.blockRegistry.getObjectById(stackTagCompound.getInteger("id"));
|
|
||||||
stackTagCompound.removeTag("id");
|
|
||||||
stackTagCompound.setString("name", Block.blockRegistry.getNameForObject(facadeBlock));
|
|
||||||
} else if (stackTagCompound.hasKey("name")) {
|
|
||||||
facadeBlock = (Block) Block.blockRegistry.getObject(stackTagCompound.getString("name"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stackTagCompound.hasKey("name_alt")) {
|
|
||||||
facadeBlockAlt = (Block) Block.blockRegistry.getObject(stack.getTagCompound().getString("name_alt"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Block[] {facadeBlock, facadeBlockAlt};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] getMetaValues(ItemStack stack) {
|
public static int[] getMetaValues(ItemStack stack) {
|
||||||
int meta = 0;
|
FacadeState[] states = getFacadeStates(stack);
|
||||||
int metaAlt = 0;
|
int[] meta = new int[states.length];
|
||||||
|
for (int i = 0; i < states.length; i++) {
|
||||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("meta")) {
|
meta[i] = states[i].metadata;
|
||||||
meta = stack.getTagCompound().getInteger("meta");
|
|
||||||
} else {
|
|
||||||
meta = stack.getItemDamage() & 0x0000F;
|
|
||||||
}
|
}
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("meta_alt")) {
|
// GETTERS FOR FACADE DATA
|
||||||
metaAlt = stack.getTagCompound().getInteger("meta_alt");
|
public static FacadeType getType(ItemStack stack) {
|
||||||
} else {
|
if (!stack.hasTagCompound()) {
|
||||||
metaAlt = stack.getItemDamage() & 0x0000F;
|
return FacadeType.Basic;
|
||||||
}
|
}
|
||||||
|
NBTTagCompound nbt = stack.getTagCompound();
|
||||||
return new int[] {meta, metaAlt};
|
if (!nbt.hasKey("type")) {
|
||||||
|
return FacadeType.Basic;
|
||||||
|
}
|
||||||
|
return FacadeType.fromOrdinal(nbt.getInteger("type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -442,22 +509,25 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getFacade(Block block, int metadata) {
|
public static ItemStack getFacade(Block block, int metadata) {
|
||||||
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
|
return getFacade(FacadeState.create(block, metadata));
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
|
||||||
nbt.setInteger("meta", metadata);
|
|
||||||
nbt.setString("name", Block.blockRegistry.getNameForObject(block));
|
|
||||||
stack.setTagCompound(nbt);
|
|
||||||
return stack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getAdvancedFacade(PipeWire wire, Block block, int metadata, Block blockAlt, int metaDataAlt) {
|
public static ItemStack getAdvancedFacade(PipeWire wire, Block block, int metadata, Block blockAlt, int metaDataAlt) {
|
||||||
|
return getFacade(FacadeState.create(block, metadata), FacadeState.create(blockAlt, metaDataAlt, wire));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getFacade(FacadeState... states) {
|
||||||
|
if (states == null || states.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final boolean basic = states.length == 1 && states[0].wire == null;
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
|
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
|
||||||
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
nbt.setInteger("wire", wire.ordinal());
|
nbt.setInteger("type", (basic ? FacadeType.Basic : FacadeType.Phased).ordinal());
|
||||||
nbt.setString("name", Block.blockRegistry.getNameForObject(block));
|
nbt.setTag("states", FacadeState.writeArray(states));
|
||||||
nbt.setInteger("meta", metadata);
|
|
||||||
nbt.setString("name_alt", Block.blockRegistry.getNameForObject(blockAlt));
|
|
||||||
nbt.setInteger("meta_alt", metaDataAlt);
|
|
||||||
stack.setTagCompound(nbt);
|
stack.setTagCompound(nbt);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -29,6 +30,7 @@ import net.minecraft.world.WorldServer;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
@ -117,41 +119,19 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SideProperties {
|
public static class SideProperties {
|
||||||
int[] facadeTypes = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
ItemFacade.FacadeState[][] facadeStates = new ItemFacade.FacadeState[ForgeDirection.VALID_DIRECTIONS.length][];
|
||||||
int[] facadeWires = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
|
||||||
|
|
||||||
Block[][] facadeBlocks = new Block[ForgeDirection.VALID_DIRECTIONS.length][2];
|
|
||||||
int[][] facadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length][2];
|
|
||||||
|
|
||||||
boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
||||||
boolean[] robotStations = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
boolean[] robotStations = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
||||||
|
|
||||||
public void writeToNBT (NBTTagCompound nbt) {
|
public void writeToNBT (NBTTagCompound nbt) {
|
||||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||||
nbt.setInteger("facadeTypes[" + i + "]", facadeTypes[i]);
|
NBTTagList list = ItemFacade.FacadeState.writeArray(facadeStates[i]);
|
||||||
nbt.setInteger("facadeWires[" + i + "]", facadeWires[i]);
|
if (list != null) {
|
||||||
|
nbt.setTag("facadeState[" + i + "]", list);
|
||||||
if (facadeBlocks[i][0] != null) {
|
|
||||||
nbt.setString("facadeBlocksStr[" + i + "][0]",
|
|
||||||
Block.blockRegistry.getNameForObject(facadeBlocks[i][0]));
|
|
||||||
} else {
|
} else {
|
||||||
// remove tag is useful in case we're overwritting an NBT
|
nbt.removeTag("facadeState[" + i + "]");
|
||||||
// already set, for example in a blueprint.
|
|
||||||
nbt.removeTag("facadeBlocksStr[" + i + "][0]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (facadeBlocks[i][1] != null) {
|
|
||||||
nbt.setString("facadeBlocksStr[" + i + "][1]",
|
|
||||||
Block.blockRegistry.getNameForObject(facadeBlocks[i][1]));
|
|
||||||
} else {
|
|
||||||
// remove tag is useful in case we're overwritting an NBT
|
|
||||||
// already set, for example in a blueprint.
|
|
||||||
nbt.removeTag("facadeBlocksStr[" + i + "][1]");
|
|
||||||
}
|
|
||||||
|
|
||||||
nbt.setInteger("facadeMeta[" + i + "][0]", facadeMeta[i][0]);
|
|
||||||
nbt.setInteger("facadeMeta[" + i + "][1]", facadeMeta[i][1]);
|
|
||||||
|
|
||||||
nbt.setBoolean("plug[" + i + "]", plugs[i]);
|
nbt.setBoolean("plug[" + i + "]", plugs[i]);
|
||||||
nbt.setBoolean("robotStation[" + i + "]", robotStations[i]);
|
nbt.setBoolean("robotStation[" + i + "]", robotStations[i]);
|
||||||
}
|
}
|
||||||
|
@ -159,35 +139,32 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
|
|
||||||
public void readFromNBT (NBTTagCompound nbt) {
|
public void readFromNBT (NBTTagCompound nbt) {
|
||||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||||
facadeTypes[i] = nbt.getInteger("facadeTypes[" + i + "]");
|
if (nbt.hasKey("facadeState[" + i + "]")) {
|
||||||
facadeWires[i] = nbt.getInteger("facadeWires[" + i + "]");
|
facadeStates[i] = ItemFacade.FacadeState.readArray(nbt.getTagList("facadeState[" + i + "]", Constants.NBT.TAG_COMPOUND));
|
||||||
|
|
||||||
if (nbt.hasKey("facadeBlocks[" + i + "]")) {
|
|
||||||
// In this case, we're on legacy pre-6.0 facade loading
|
|
||||||
// mode.
|
|
||||||
facadeBlocks[i][0] = (Block) Block.blockRegistry.getObjectById
|
|
||||||
(nbt.getInteger("facadeBlocks[" + i + "]"));
|
|
||||||
facadeBlocks[i][1] = null;
|
|
||||||
|
|
||||||
facadeMeta[i][0] = nbt.getInteger("facadeMeta[" + i + "]");
|
|
||||||
facadeMeta[i][1] = 0;
|
|
||||||
} else {
|
} else {
|
||||||
if (nbt.hasKey("facadeBlocksStr[" + i + "][0]")) {
|
// Migration support for 5.0.x and 6.0.x
|
||||||
facadeBlocks[i][0] = (Block) Block.blockRegistry.getObject
|
if (nbt.hasKey("facadeBlocks[" + i + "]")) {
|
||||||
(nbt.getString("facadeBlocksStr[" + i + "][0]"));
|
// 5.0.x
|
||||||
} else {
|
Block block = (Block) Block.blockRegistry.getObjectById(nbt.getInteger("facadeBlocks[" + i + "]"));
|
||||||
facadeBlocks[i][0] = null;
|
int metadata = nbt.getInteger("facadeMeta[" + i + "]");
|
||||||
|
facadeStates[i] = new ItemFacade.FacadeState[] {ItemFacade.FacadeState.create(block, metadata)};
|
||||||
|
} else if (nbt.hasKey("facadeBlocksStr[" + i + "][0]")) {
|
||||||
|
// 6.0.x
|
||||||
|
ItemFacade.FacadeState mainState = ItemFacade.FacadeState.create(
|
||||||
|
(Block) Block.blockRegistry.getObject(nbt.getString("facadeBlocksStr[" + i + "][0]")),
|
||||||
|
nbt.getInteger("facadeMeta[" + i + "][0]")
|
||||||
|
);
|
||||||
|
if (nbt.hasKey("facadeBlocksStr[" + i + "][1]")) {
|
||||||
|
ItemFacade.FacadeState phasedState = ItemFacade.FacadeState.create(
|
||||||
|
(Block) Block.blockRegistry.getObject(nbt.getString("facadeBlocksStr[" + i + "][1]")),
|
||||||
|
nbt.getInteger("facadeMeta[" + i + "][1]"),
|
||||||
|
PipeWire.fromOrdinal(nbt.getInteger("facadeWires[" + i + "]"))
|
||||||
|
);
|
||||||
|
facadeStates[i] = new ItemFacade.FacadeState[] {mainState, phasedState};
|
||||||
|
} else {
|
||||||
|
facadeStates[i] = new ItemFacade.FacadeState[] {mainState};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbt.hasKey("facadeBlocksStr[" + i + "][1]")) {
|
|
||||||
facadeBlocks[i][1] = (Block) Block.blockRegistry.getObject
|
|
||||||
(nbt.getString("facadeBlocksStr[" + i + "][1]"));
|
|
||||||
} else {
|
|
||||||
facadeBlocks[i][1] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
facadeMeta[i][0] = nbt.getInteger("facadeMeta[" + i + "][0]");
|
|
||||||
facadeMeta[i][1] = nbt.getInteger("facadeMeta[" + i + "][1]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugs[i] = nbt.getBoolean("plug[" + i + "]");
|
plugs[i] = nbt.getBoolean("plug[" + i + "]");
|
||||||
|
@ -196,32 +173,19 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotateLeft() {
|
public void rotateLeft() {
|
||||||
int[] newFacadeTypes = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
ItemFacade.FacadeState[][] newFacadeStates = new ItemFacade.FacadeState[ForgeDirection.VALID_DIRECTIONS.length][];
|
||||||
int[] newFacadeWires = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
|
||||||
|
|
||||||
Block[][] newFacadeBlocks = new Block[ForgeDirection.VALID_DIRECTIONS.length][2];
|
|
||||||
int[][] newFacadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length][2];
|
|
||||||
|
|
||||||
boolean[] newPlugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
boolean[] newPlugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
||||||
boolean[] newRobotStations = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
boolean[] newRobotStations = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
||||||
|
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
ForgeDirection r = dir.getRotation(ForgeDirection.UP);
|
ForgeDirection r = dir.getRotation(ForgeDirection.UP);
|
||||||
|
|
||||||
newFacadeTypes[r.ordinal()] = facadeTypes[dir.ordinal()];
|
newFacadeStates[r.ordinal()] = facadeStates[dir.ordinal()];
|
||||||
newFacadeWires[r.ordinal()] = facadeWires[dir.ordinal()];
|
|
||||||
newFacadeBlocks[r.ordinal()][0] = facadeBlocks[dir.ordinal()][0];
|
|
||||||
newFacadeBlocks[r.ordinal()][1] = facadeBlocks[dir.ordinal()][1];
|
|
||||||
newFacadeMeta[r.ordinal()][0] = facadeMeta[dir.ordinal()][0];
|
|
||||||
newFacadeMeta[r.ordinal()][1] = facadeMeta[dir.ordinal()][1];
|
|
||||||
newPlugs[r.ordinal()] = plugs[dir.ordinal()];
|
newPlugs[r.ordinal()] = plugs[dir.ordinal()];
|
||||||
newRobotStations[r.ordinal()] = robotStations[dir.ordinal()];
|
newRobotStations[r.ordinal()] = robotStations[dir.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
facadeTypes = newFacadeTypes;
|
facadeStates = newFacadeStates;
|
||||||
facadeWires = newFacadeWires;
|
|
||||||
facadeBlocks = newFacadeBlocks;
|
|
||||||
facadeMeta = newFacadeMeta;
|
|
||||||
plugs = newPlugs;
|
plugs = newPlugs;
|
||||||
robotStations = newRobotStations;
|
robotStations = newRobotStations;
|
||||||
}
|
}
|
||||||
|
@ -397,23 +361,28 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
|
|
||||||
// Facades
|
// Facades
|
||||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
int type = sideProperties.facadeTypes[direction.ordinal()];
|
ItemFacade.FacadeState[] states = sideProperties.facadeStates[direction.ordinal()];
|
||||||
|
if (states == null) {
|
||||||
if (type == ItemFacade.TYPE_BASIC) {
|
renderState.facadeMatrix.setFacade(direction, null, 0);
|
||||||
Block block = sideProperties.facadeBlocks[direction.ordinal()][0];
|
continue;
|
||||||
renderState.facadeMatrix.setFacade(direction, block, sideProperties.facadeMeta[direction.ordinal()][0]);
|
}
|
||||||
} else if (type == ItemFacade.TYPE_PHASED) {
|
// Iterate over all states and activate first proper
|
||||||
PipeWire wire = PipeWire.fromOrdinal(sideProperties.facadeWires[direction.ordinal()]);
|
ItemFacade.FacadeState defaultState = null, activeState = null;
|
||||||
Block block = sideProperties.facadeBlocks[direction.ordinal()][0];
|
for (ItemFacade.FacadeState state : states) {
|
||||||
Block blockAlt = sideProperties.facadeBlocks[direction.ordinal()][1];
|
if (state.wire == null) {
|
||||||
int meta = sideProperties.facadeMeta[direction.ordinal()][0];
|
defaultState = state;
|
||||||
int metaAlt = sideProperties.facadeMeta[direction.ordinal()][1];
|
continue;
|
||||||
|
|
||||||
if (isWireActive(wire)) {
|
|
||||||
renderState.facadeMatrix.setFacade(direction, blockAlt, metaAlt);
|
|
||||||
} else {
|
|
||||||
renderState.facadeMatrix.setFacade(direction, block, meta);
|
|
||||||
}
|
}
|
||||||
|
if (isWireActive(state.wire)) {
|
||||||
|
activeState = state;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (activeState == null) {
|
||||||
|
activeState = defaultState;
|
||||||
|
}
|
||||||
|
if (activeState != null) {
|
||||||
|
renderState.facadeMatrix.setFacade(direction, activeState.block, activeState.metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,7 +720,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
refreshRenderState = true;
|
refreshRenderState = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addFacade(ForgeDirection direction, int type, int wire, Block[] blocks, int[] metaValues) {
|
public boolean addFacade(ForgeDirection direction, ItemFacade.FacadeState[] states) {
|
||||||
if (this.getWorldObj().isRemote) {
|
if (this.getWorldObj().isRemote) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -760,18 +729,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
dropFacadeItem(direction);
|
dropFacadeItem(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
sideProperties.facadeTypes[direction.ordinal()] = type;
|
sideProperties.facadeStates[direction.ordinal()] = states;
|
||||||
|
|
||||||
if (type == ItemFacade.TYPE_BASIC || wire == -1) {
|
|
||||||
sideProperties.facadeBlocks[direction.ordinal()][0] = blocks[0];
|
|
||||||
sideProperties.facadeMeta[direction.ordinal()][0] = metaValues[0];
|
|
||||||
} else {
|
|
||||||
sideProperties.facadeWires[direction.ordinal()] = wire;
|
|
||||||
sideProperties.facadeBlocks[direction.ordinal()][0] = blocks[0];
|
|
||||||
sideProperties.facadeMeta[direction.ordinal()][0] = metaValues[0];
|
|
||||||
sideProperties.facadeBlocks[direction.ordinal()][1] = blocks[1];
|
|
||||||
sideProperties.facadeMeta[direction.ordinal()][1] = metaValues[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock());
|
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock());
|
||||||
|
|
||||||
|
@ -786,7 +744,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
} else if (this.getWorldObj().isRemote) {
|
} else if (this.getWorldObj().isRemote) {
|
||||||
return renderState.facadeMatrix.getFacadeBlock(direction) != null;
|
return renderState.facadeMatrix.getFacadeBlock(direction) != null;
|
||||||
} else {
|
} else {
|
||||||
return sideProperties.facadeBlocks[direction.ordinal()][0] != null;
|
return sideProperties.facadeStates[direction.ordinal()] != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,13 +753,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getFacade(ForgeDirection direction) {
|
public ItemStack getFacade(ForgeDirection direction) {
|
||||||
int type = sideProperties.facadeTypes[direction.ordinal()];
|
return ItemFacade.getFacade(sideProperties.facadeStates[direction.ordinal()]);
|
||||||
|
|
||||||
if (type == ItemFacade.TYPE_BASIC) {
|
|
||||||
return ItemFacade.getFacade(sideProperties.facadeBlocks[direction.ordinal()][0], sideProperties.facadeMeta[direction.ordinal()][0]);
|
|
||||||
} else {
|
|
||||||
return ItemFacade.getAdvancedFacade(PipeWire.fromOrdinal(sideProperties.facadeWires[direction.ordinal()]), sideProperties.facadeBlocks[direction.ordinal()][0], sideProperties.facadeMeta[direction.ordinal()][0], sideProperties.facadeBlocks[direction.ordinal()][1], sideProperties.facadeMeta[direction.ordinal()][1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dropFacade(ForgeDirection direction) {
|
public boolean dropFacade(ForgeDirection direction) {
|
||||||
|
@ -811,12 +763,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
|
||||||
|
|
||||||
if (!worldObj.isRemote) {
|
if (!worldObj.isRemote) {
|
||||||
dropFacadeItem(direction);
|
dropFacadeItem(direction);
|
||||||
sideProperties.facadeTypes[direction.ordinal()] = 0;
|
sideProperties.facadeStates[direction.ordinal()] = null;
|
||||||
sideProperties.facadeWires[direction.ordinal()] = -1;
|
|
||||||
sideProperties.facadeBlocks[direction.ordinal()][0] = null;
|
|
||||||
sideProperties.facadeMeta[direction.ordinal()][0] = 0;
|
|
||||||
sideProperties.facadeBlocks[direction.ordinal()][1] = null;
|
|
||||||
sideProperties.facadeMeta[direction.ordinal()][1] = 0;
|
|
||||||
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock());
|
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock());
|
||||||
scheduleRenderUpdate();
|
scheduleRenderUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
||||||
if (id == 0 /* Action state update */) {
|
if (id == 0 /* Action state update */) {
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
/* Bit mask of triggers */
|
/* Bit mask of triggers */
|
||||||
actionsState[i] = ActionState.values()[((state >> (i * 2)) & 0x03)];
|
actionsState[i] = ActionState.values()[(state >> (i * 2)) & 0x03];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,31 +30,28 @@ public class FacadeItemRenderer implements IItemRenderer {
|
||||||
|
|
||||||
private long lastTime = 0L;
|
private long lastTime = 0L;
|
||||||
|
|
||||||
private boolean renderState = false;
|
private int renderState = 0;
|
||||||
|
|
||||||
private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
||||||
if (lastTime < System.currentTimeMillis()) {
|
if (lastTime < System.currentTimeMillis()) {
|
||||||
renderState = !renderState;
|
// 12 = LCM(1, 2, 3, 4)
|
||||||
|
renderState = (renderState + 1) % 12;
|
||||||
lastTime = System.currentTimeMillis() + 1000L;
|
lastTime = System.currentTimeMillis() + 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = null;
|
ItemFacade.FacadeType type = ItemFacade.getType(item);
|
||||||
int decodedMeta = 0;
|
ItemFacade.FacadeState[] states = ItemFacade.getFacadeStates(item);
|
||||||
|
ItemFacade.FacadeState activeState = null;
|
||||||
int type = ItemFacade.getType(item);
|
if (type == ItemFacade.FacadeType.Basic) {
|
||||||
|
activeState = states[0];
|
||||||
if (type == ItemFacade.TYPE_BASIC) {
|
} else if (type == ItemFacade.FacadeType.Phased) {
|
||||||
block = ItemFacade.getBlocks(item)[0];
|
activeState = states[renderState % states.length];
|
||||||
decodedMeta = ItemFacade.getMetaValues(item)[0];
|
|
||||||
} else if (type == ItemFacade.TYPE_PHASED) {
|
|
||||||
if (renderState) {
|
|
||||||
block = ItemFacade.getBlocks(item)[1];
|
|
||||||
decodedMeta = ItemFacade.getMetaValues(item)[1];
|
|
||||||
} else {
|
|
||||||
block = ItemFacade.getBlocks(item)[0];
|
|
||||||
decodedMeta = ItemFacade.getMetaValues(item)[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (activeState == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Block block = activeState.block;
|
||||||
|
int decodedMeta = activeState.metadata;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int color = item.getItem().getColorFromItemStack(new ItemStack(block, 1, decodedMeta), 0);
|
int color = item.getItem().getColorFromItemStack(new ItemStack(block, 1, decodedMeta), 0);
|
||||||
|
|
Loading…
Reference in a new issue