Fix multifarm control blocks. Minor multiblock cleanup

This commit is contained in:
mezz committed 2015-07-20 21:52:07 -07:00
1 parent d24eb693e9
commit b52a46f352
7 files changed
+9 -194

No files matched your search

@@ -1,153 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.utils;
import forestry.core.config.Config;
import forestry.core.vect.Vect;
public class Schemata {
public enum EnumStructureBlock {
ANY('X'), FOREIGN('F'), AIR('O'), MASTER('M'), GLASS('G'), BLOCK_A('A'), BLOCK_B('B'), BLOCK_C('C'), BLOCK_D('D'), BLOCK_E('E');
private final char key;
EnumStructureBlock(char key) {
this.key = key;
}
public char getKey() {
return this.key;
}
}
private final String uid;
private final EnumStructureBlock[][][] structure;
private final int width;
private final int height;
private final int depth;
private int xOffset, yOffset, zOffset = -1;
public Schemata(String uid, int width, int height, int depth, String... patterns) {
this(uid, width, height, depth);
this.setStructure(patterns);
}
public Schemata(String uid, int width, int height, int depth) {
this.uid = uid;
this.structure = new EnumStructureBlock[width][height][depth];
this.width = width;
this.height = height;
this.depth = depth;
}
private void setStructure(String... patterns) {
String fullpattern = "";
for (String pattern : patterns) {
fullpattern = (new StringBuilder()).append(fullpattern).append(pattern).toString();
}
if (fullpattern.length() != getWidth() * getHeight() * getDepth()) {
throw new RuntimeException("Incorrect pattern " + fullpattern + " (" + fullpattern.length() + ") for (" + getWidth() + "/" + getHeight() + "/"
+ getDepth() + ")");
}
for (int i = 0; i < getWidth(); i++) {
for (int j = 0; j < getHeight(); j++) {
for (int k = 0; k < getDepth(); k++) {
for (EnumStructureBlock type : EnumStructureBlock.values()) {
if (type.getKey() == fullpattern.charAt(i * getHeight() * getDepth() + j * getDepth() + k)) {
structure[i][j][k] = type;
break;
}
}
}
}
}
/*
* for(int i = 0; i < getWidth(); i++) { for(int j = 0; j < getHeight(); j++) { System.out.print("["); for(int k = 0; k < getDepth(); k++) {
* System.out.print(structure[i][j][k].getKey()); } System.out.print("]"); } System.out.println(); }
*/
}
public Schemata setOffsets(int xOffset, int yOffset, int zOffset) {
this.xOffset = xOffset;
this.yOffset = yOffset;
this.zOffset = zOffset;
return this;
}
public EnumStructureBlock getAt(int x, int y, int z, boolean rotate) {
if (rotate) {
return structure[z][y][x];
}
return structure[x][y][z];
}
public Vect getDimensions(boolean rotate) {
if (rotate) {
return new Vect(getDepth(), getHeight(), getWidth());
} else {
return new Vect(getWidth(), getHeight(), getDepth());
}
}
public boolean isEnabled() {
return Config.isStructureEnabled(uid);
}
/**
* @return the width
*/
public int getWidth() {
return width;
}
/**
* @return the height
*/
public int getHeight() {
return height;
}
/**
* @return the depth
*/
public int getDepth() {
return depth;
}
/**
* @return the xOffset
*/
public int getxOffset() {
return xOffset;
}
/**
* @return the yOffset
*/
public int getyOffset() {
return yOffset;
}
/**
* @return the zOffset
*/
public int getzOffset() {
return zOffset;
}
}
@@ -245,7 +245,7 @@ public class BlockFarm extends BlockStructure {
ItemStack base = EnumFarmBlockTexture.BRICK_STONE.getBase();
if (tile instanceof TileFarm) {
base = ((TileFarm) tile).farmBlockTexture.getBase();
base = ((TileFarm) tile).getFarmBlockTexture().getBase();
}
Block block = StackUtils.getBlock(base);
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.farming.multiblock;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.farming.DefaultFarmListener;
@@ -24,7 +26,6 @@ public class TileControl extends TileFarm implements IFarmComponent.Listener {
private final IFarmListener farmListener;
public TileControl() {
this.fixedType = TYPE_CONTROL;
this.farmListener = new ControlFarmListener(this);
}
@@ -35,11 +36,9 @@ public class TileControl extends TileFarm implements IFarmComponent.Listener {
private static class ControlFarmListener extends DefaultFarmListener {
private final TileControl tile;
private final Vect position;
public ControlFarmListener(TileControl tile) {
this.tile = tile;
this.position = new Vect(tile.xCoord, tile.yCoord, tile.zCoord);
}
@Override
@@ -48,23 +47,11 @@ public class TileControl extends TileFarm implements IFarmComponent.Listener {
}
private boolean hasRedstoneSignal(ForgeDirection direction) {
Vect side = position.add(direction);
Vect side = new Vect(tile).add(direction);
int dir = direction.getOpposite().ordinal();
World world = tile.getWorldObj();
ForgeDirection opp = direction.getOpposite();
int dir;
if (opp.offsetZ < 0) {
dir = 2;
} else if (opp.offsetZ > 0) {
dir = 3;
} else if (opp.offsetX < 0) {
dir = 4;
} else if (opp.offsetX > 0) {
dir = 5;
} else {
dir = 0;
}
return tile.getWorldObj().getIndirectPowerLevelTo(side.x, side.y, side.z, dir) > 0 || tile.getWorldObj().isBlockProvidingPowerTo(side.x, side.y, side.z, dir) > 0;
return world.getIndirectPowerLevelTo(side.x, side.y, side.z, dir) > 0 || world.isBlockProvidingPowerTo(side.x, side.y, side.z, dir) > 0;
}
}
@@ -22,14 +22,11 @@ import net.minecraft.util.StatCollector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.api.core.IErrorLogicSource;
import forestry.api.farming.IFarmComponent;
import forestry.core.config.Config;
import forestry.core.interfaces.IClimatised;
import forestry.core.interfaces.IHintSource;
import forestry.core.interfaces.ISocketable;
import forestry.core.inventory.IInventoryAdapter;
@@ -52,6 +49,8 @@ public abstract class TileFarm extends RectangularMultiblockTileEntityBase imple
public static final int TYPE_VALVE = 6;
public static final int TYPE_CONTROL = 7;
private EnumFarmBlockTexture farmBlockTexture = EnumFarmBlockTexture.BRICK_STONE;
@Override
public void openGui(EntityPlayer player) {
if (this.isConnected()) {
@@ -83,8 +82,6 @@ public abstract class TileFarm extends RectangularMultiblockTileEntityBase imple
}
/* CONSTRUCTION MATERIAL */
EnumFarmBlockTexture farmBlockTexture = EnumFarmBlockTexture.BRICK_STONE;
protected int fixedType = -1;
public void setFarmBlockTexture(EnumFarmBlockTexture farmBlockTexture) {
if (this.farmBlockTexture != farmBlockTexture) {
@@ -99,15 +96,6 @@ public abstract class TileFarm extends RectangularMultiblockTileEntityBase imple
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
/*
* if(fixedType >= 0) return farmBlockTexture.getIcon(fixedType);
*
* int type = 0; if (meta == 1) type = TYPE_BAND;
*
* if (meta == 0 && side == 2) type = TYPE_REVERSE; else if (meta == 0 && (side == 0 || side == 1)) type = TYPE_TOP;
*
* return farmBlockTexture.getIcon(type);
*/
return null;
}
@@ -32,8 +32,6 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
public TileGearbox() {
energyManager = new EnergyManager(200, 50, 10000);
fixedType = TYPE_GEARS;
}
/* SAVING & LOADING */
@@ -42,7 +42,6 @@ public class TileHatch extends TileFarm implements ISidedInventory, IFarmCompone
private final AdjacentInventoryCache inventoryCache;
public TileHatch() {
this.fixedType = TYPE_HATCH;
this.tileCache = new AdjacentTileCache(this);
this.inventoryCache = new AdjacentInventoryCache(this, tileCache, new ITileFilter() {
@Override
@@ -23,10 +23,6 @@ import forestry.core.interfaces.ILiquidTankContainer;
public class TileValve extends TileFarm implements ILiquidTankContainer {
public TileValve() {
this.fixedType = TYPE_VALVE;
}
/* ILIQUIDTANKCONTAINER */
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {