Even more parameterization and cleanup

This commit is contained in:
Raul Tambre 2014-06-15 22:05:06 +03:00
parent 7bb2351b67
commit 5292bc6f19
25 changed files with 34 additions and 61 deletions

View file

@ -9,6 +9,8 @@
package buildcraft.api.blueprints;
public class MappingNotFoundException extends Exception {
private static final long serialVersionUID = 1L;
public MappingNotFoundException(String msg) {
super(msg);
}

View file

@ -14,9 +14,9 @@ import net.minecraft.nbt.NBTTagCompound;
public abstract class SchematicFactory<S extends Schematic> {
private static final HashMap<String, SchematicFactory> factories = new HashMap<String, SchematicFactory>();
private static final HashMap<String, SchematicFactory<?>> factories = new HashMap<String, SchematicFactory<?>>();
private static final HashMap<Class<? extends Schematic>, SchematicFactory> schematicToFactory = new HashMap<Class<? extends Schematic>, SchematicFactory>();
private static final HashMap<Class<? extends Schematic>, SchematicFactory<?>> schematicToFactory = new HashMap<Class<? extends Schematic>, SchematicFactory<?>>();
protected abstract S loadSchematicFromWorldNBT(NBTTagCompound nbt, MappingRegistry registry)
throws MappingNotFoundException;

View file

@ -33,5 +33,5 @@ public abstract class RedstoneBoardRegistry {
public abstract String getKindForParam(IBoardParameter param);
public abstract Collection<RedstoneBoardNBT> getAllBoardNBTs();
public abstract Collection<RedstoneBoardNBT<?>> getAllBoardNBTs();
}

View file

@ -388,6 +388,8 @@ public class BuildCraftEnergy extends BuildCraftMod {
}
// failed to find any free biome IDs
class BiomeIdLimitException extends RuntimeException {
private static final long serialVersionUID = 1L;
public BiomeIdLimitException(String biome) {
super(String.format("You have run out of free Biome ID spaces for %s", biome));
}

View file

@ -273,7 +273,6 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
}
public void handlePacketPayload(ByteBuf data) {
boolean initialized = box.isInitialized();
box.readFromStream(data);
done = data.readBoolean();
setPattern((FillerPattern) FillerManager.registry.getPattern(Utils.readUTF(data)));

View file

@ -14,7 +14,6 @@ import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import buildcraft.BuildCraftBuilders;
@ -35,7 +34,6 @@ public class GuiArchitect extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation(
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/architect_gui.png");
private IInventory playerInventory;
private TileArchitect architect;
private GuiButton optionRotate;
@ -48,7 +46,6 @@ public class GuiArchitect extends GuiBuildCraft {
public GuiArchitect(EntityPlayer player, TileArchitect architect) {
super(new ContainerArchitect(player, architect), architect, TEXTURE);
this.playerInventory = player.inventory;
this.architect = architect;
xSize = 256;
ySize = 166;

View file

@ -27,21 +27,15 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/library_rw.png");
private GuiButton nextPageButton;
private GuiButton prevPageButton;
private GuiButton lockButton;
private GuiButton deleteButton;
private EntityPlayer player;
private TileBlueprintLibrary library;
private ContainerBlueprintLibrary container;
private boolean computeInput;
public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) {
super(new ContainerBlueprintLibrary(player, library), library, TEXTURE);
this.player = player;
xSize = 234;
ySize = 225;
this.library = library;
container = (ContainerBlueprintLibrary) inventorySlots;
}
@SuppressWarnings("unchecked")

View file

@ -30,7 +30,7 @@ public final class MultiButtonController<T extends IMultiButtonState> {
}
public MultiButtonController<?> copy() {
return new MultiButtonController(currentState, validStates.clone());
return new MultiButtonController<T>(currentState, validStates.clone());
}
public T[] getValidStates() {

View file

@ -54,7 +54,7 @@ public final class RPCHandler {
class MethodMapping {
Method method;
Class[] parameters;
Class<?>[] parameters;
ClassSerializer[] mappings;
boolean hasInfo = false;
}
@ -279,7 +279,7 @@ public final class RPCHandler {
int methodIndex = methodsMap.get(method);
MethodMapping m = methods[methodIndex];
Class[] formals = m.parameters;
Class<?>[] formals = m.parameters;
int expectedParameters = m.hasInfo ? formals.length - 1
: formals.length;
@ -335,7 +335,7 @@ public final class RPCHandler {
short methodIndex = data.readShort();
MethodMapping m = methods [methodIndex];
Class[] formals = m.parameters;
Class<?>[] formals = m.parameters;
Object[] actuals = new Object [formals.length];

View file

@ -447,7 +447,7 @@ public class ClassMapping extends ClassSerializer {
break;
}
case Enum: {
Enum[] arr = (Enum[]) obj;
Enum<?>[] arr = (Enum[]) obj;
data.writeInt (arr.length);
for (Enum<?> element : arr) {
@ -583,7 +583,7 @@ public class ClassMapping extends ClassSerializer {
break;
}
case Enum: {
Enum[] arr;
Enum<?>[] arr;
if (obj == null) {
arr = new Enum[size];

View file

@ -8,8 +8,6 @@
*/
package buildcraft.core.render;
import java.util.Date;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.model.ModelBase;
@ -132,13 +130,10 @@ public class RenderLaser extends Render {
textureManager.bindTexture(texture);
float factor = (float) (1.0 / 16.0);
int indexList = 0;
initScaledBoxes();
double x0 = 0;
double x1 = laser.wavePosition;
double x2 = x1 + scaledBoxes [0].length * STEP;
double x3 = laser.renderSize;
@ -175,12 +170,6 @@ public class RenderLaser extends Render {
textureManager.bindTexture(texture);
float factor = (float) (1.0 / 16.0);
float lasti = 0;
int indexList = (int) ((new Date ().getTime() / 100) % 20);
initScaledBoxes();
doRenderLaserLine (laser.renderSize, laser.laserTexAnimation);

View file

@ -35,7 +35,7 @@ public class RobotIntegrationRecipe extends IntegrationTableRecipe {
}
@Override
public CraftingResult craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
public CraftingResult<ItemStack> craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
ItemStack inputB) {
CraftingResult<ItemStack> result = super.craft(crafter, preview, inputA, inputB);

View file

@ -112,7 +112,7 @@ public class PathFinding {
openList.remove(from.index);
closedList.put(from.index, from);
ArrayList nodes = new ArrayList<Node>();
ArrayList<Node> nodes = new ArrayList<Node>();
byte[][][] resultMoves = movements(from);
for (int dx = -1; dx <= +1; ++dx) {

View file

@ -113,13 +113,6 @@ public class GuiRefinery extends GuiAdvancedInterface {
((FluidSlot) slots[1]).fluid = filter1;
((FluidSlot) slots[1]).colorRenderCache = container.refinery.tanks[1].colorRenderCache;
if (filter0 != null) {
FluidStack liquid0 = new FluidStack(filter0, FluidContainerRegistry.BUCKET_VOLUME);
}
if (filter1 != null) {
FluidStack liquid1 = new FluidStack(filter1, FluidContainerRegistry.BUCKET_VOLUME);
}
CraftingResult<FluidStack> crafting = container.refinery.craftingResult;
if (crafting != null) {

View file

@ -108,8 +108,8 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
}
@Override
public Collection<RedstoneBoardNBT> getAllBoardNBTs() {
ArrayList<RedstoneBoardNBT> result = new ArrayList<RedstoneBoardNBT>();
public Collection<RedstoneBoardNBT<?>> getAllBoardNBTs() {
ArrayList<RedstoneBoardNBT<?>> result = new ArrayList<RedstoneBoardNBT<?>>();
for (BoardFactory f : boards.values()) {
result.add(f.boardNBT);

View file

@ -46,7 +46,7 @@ public class GateExpansionRecipe extends IntegrationTableRecipe {
}
@Override
public CraftingResult craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
public CraftingResult<ItemStack> craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
ItemStack inputB) {
if (inputA == null) {

View file

@ -36,7 +36,7 @@ public class GateLogicSwapRecipe extends IntegrationTableRecipe {
}
@Override
public CraftingResult craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
public CraftingResult<ItemStack> craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
ItemStack inputB) {
CraftingResult<ItemStack> result = super.craft(crafter, preview, inputA, inputB);

View file

@ -19,7 +19,7 @@ import buildcraft.silicon.TileIntegrationTable;
public abstract class IntegrationTableRecipe extends FlexibleRecipe<ItemStack> implements IIntegrationRecipe {
@Override
public final CraftingResult craft(IFlexibleCrafter crafter, boolean preview) {
public final CraftingResult<ItemStack> craft(IFlexibleCrafter crafter, boolean preview) {
TileIntegrationTable table = (TileIntegrationTable) crafter;
ItemStack inputA;
@ -44,7 +44,7 @@ public abstract class IntegrationTableRecipe extends FlexibleRecipe<ItemStack> i
return craft(table, preview, inputA, inputB);
}
public CraftingResult craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
public CraftingResult<ItemStack> craft(TileIntegrationTable crafter, boolean preview, ItemStack inputA,
ItemStack inputB) {
return super.craft(crafter, preview);
}

View file

@ -60,7 +60,7 @@ public class ActionRobotGoToStation extends BCAction {
@Override
public void actionActivate(IGate gate, IActionParameter[] parameters) {
Pipe pipe = (Pipe) gate.getPipe();
Pipe<?> pipe = (Pipe<?>) gate.getPipe();
TileGenericPipe tile = pipe.container;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {

View file

@ -70,7 +70,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
public static int facadeRenderColor = -1;
public static Map<Item, Class<? extends Pipe>> pipes = new HashMap<Item, Class<? extends Pipe>>();
public static Map<BlockIndex, Pipe> pipeRemoved = new HashMap<BlockIndex, Pipe>();
public static Map<BlockIndex, Pipe<?>> pipeRemoved = new HashMap<BlockIndex, Pipe<?>>();
private static long lastRemovedDate = -1;

View file

@ -154,7 +154,7 @@ public abstract class Pipe<T extends PipeTransport> implements IDropControlInven
}
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
Pipe otherPipe;
Pipe<?> otherPipe;
if (tile instanceof TileGenericPipe) {
otherPipe = ((TileGenericPipe) tile).pipe;

View file

@ -21,10 +21,10 @@ import buildcraft.core.utils.StringUtils;
@SideOnly(Side.CLIENT)
public final class PipeToolTipManager {
private static final Map<Class<? extends Pipe>, String> toolTips = new HashMap<Class<? extends Pipe>, String>();
private static final Map<Class<? extends Pipe<?>>, String> toolTips = new HashMap<Class<? extends Pipe<?>>, String>();
static {
for (Map.Entry<Class<? extends Pipe>, Integer> pipe : PipeTransportPower.powerCapacities.entrySet()) {
for (Map.Entry<Class<? extends Pipe<?>>, Integer> pipe : PipeTransportPower.powerCapacities.entrySet()) {
PipeToolTipManager.addToolTip(pipe.getKey(), String.format("%d MJ/t", pipe.getValue()));
}
}
@ -35,7 +35,7 @@ public final class PipeToolTipManager {
private PipeToolTipManager() {
}
public static void addToolTip(Class<? extends Pipe> pipe, String toolTip) {
public static void addToolTip(Class<? extends Pipe<?>> pipe, String toolTip) {
toolTips.put(pipe, toolTip);
}

View file

@ -40,7 +40,7 @@ import buildcraft.transport.pipes.PipePowerWood;
public class PipeTransportPower extends PipeTransport {
public static final Map<Class<? extends Pipe>, Integer> powerCapacities = new HashMap<Class<? extends Pipe>, Integer>();
public static final Map<Class<? extends Pipe<?>>, Integer> powerCapacities = new HashMap<Class<? extends Pipe<?>>, Integer>();
private static final short MAX_DISPLAY = 100;
private static final int DISPLAY_SMOOTHING = 10;

View file

@ -19,7 +19,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.mj.IBatteryObject;
import buildcraft.api.mj.IOMode;
import buildcraft.api.mj.MjAPI;
@ -44,7 +43,6 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
@MjBattery(mode = IOMode.ReceiveActive, maxCapacity = 1500, maxReceivedPerCycle = 500, minimumConsumption = 0)
private double mjStored = 0;
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker(1);
private boolean full;
private PowerHandler powerHandler;

View file

@ -220,8 +220,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
}
private void pipeRobotStationRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
float width = 0.075F;
//float width = 0.075F;
pipeRobotStationPartRender (renderblocks, block, state, x, y, z,
0.45F, 0.55F,