fix statement parameter rotation, icon registration, directional statements, blueprint NPE, remove some stuff from heuristic block detection
This commit is contained in:
parent
85e588780f
commit
ea1e384253
10 changed files with 68 additions and 57 deletions
|
@ -27,7 +27,7 @@ public final class HeuristicBlockDetection {
|
|||
|
||||
public static void start() {
|
||||
// Initialize craftableBlockList
|
||||
for (Object or : CraftingManager.getInstance().getRecipeList()) {
|
||||
/* for (Object or : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (or instanceof IRecipe) {
|
||||
IRecipe recipe = ((IRecipe) or);
|
||||
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() != null &&
|
||||
|
@ -39,7 +39,7 @@ public final class HeuristicBlockDetection {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
// Register fluids
|
||||
for (Fluid f : FluidRegistry.getRegisteredFluids().values()) {
|
||||
|
@ -64,20 +64,6 @@ public final class HeuristicBlockDetection {
|
|||
|
||||
boolean creativeOnly = false;
|
||||
|
||||
if (!canCraft(block, meta)) {
|
||||
|
||||
// Does it drop a different block type?
|
||||
try {
|
||||
if (block.getItemDropped(meta, null, 0) != Item.getItemFromBlock(block)) {
|
||||
creativeOnly = true;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
// The "null" for Random in getItemDropped stops blocks
|
||||
// depending on an RNG for deciding the dropped item
|
||||
// from being autodetected.
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (creativeOnly) {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockCreative.class);
|
||||
|
|
|
@ -211,26 +211,28 @@ public class Blueprint extends BlueprintBase {
|
|||
|
||||
if (block != null) {
|
||||
contents[x][y][z] = SchematicRegistry.INSTANCE.createSchematicBlock(block, cpt.getInteger("blockMeta"));
|
||||
contents[x][y][z].readSchematicFromNBT(cpt, mapping);
|
||||
if (contents[x][y][z] != null) {
|
||||
contents[x][y][z].readSchematicFromNBT(cpt, mapping);
|
||||
|
||||
if (!contents[x][y][z].doNotUse()) {
|
||||
contents[x][y][z].idsToWorld(mapping);
|
||||
if (!contents[x][y][z].doNotUse()) {
|
||||
contents[x][y][z].idsToWorld(mapping);
|
||||
|
||||
switch (contents[x][y][z].getBuildingPermission()) {
|
||||
case ALL:
|
||||
break;
|
||||
case CREATIVE_ONLY:
|
||||
if (buildingPermission == BuildingPermission.ALL) {
|
||||
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
switch (contents[x][y][z].getBuildingPermission()) {
|
||||
case ALL:
|
||||
break;
|
||||
case CREATIVE_ONLY:
|
||||
if (buildingPermission == BuildingPermission.ALL) {
|
||||
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
}
|
||||
break;
|
||||
case NONE:
|
||||
buildingPermission = BuildingPermission.NONE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NONE:
|
||||
buildingPermission = BuildingPermission.NONE;
|
||||
break;
|
||||
} else {
|
||||
contents[x][y][z] = null;
|
||||
isComplete = false;
|
||||
}
|
||||
} else {
|
||||
contents[x][y][z] = null;
|
||||
isComplete = false;
|
||||
}
|
||||
} else {
|
||||
contents[x][y][z] = null;
|
||||
|
|
|
@ -14,17 +14,20 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IGate;
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class StatementParameterDirection implements IStatementParameter {
|
||||
|
||||
@NetworkData
|
||||
@NetworkData
|
||||
public ForgeDirection direction = ForgeDirection.UNKNOWN;
|
||||
|
||||
private IIcon[] icons;
|
||||
private static IIcon[] icons;
|
||||
|
||||
public StatementParameterDirection() {
|
||||
|
||||
|
@ -45,11 +48,11 @@ public class StatementParameterDirection implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
if (source instanceof IPipe) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
if (source.getTile() instanceof TileGenericPipe) {
|
||||
do {
|
||||
direction = ForgeDirection.getOrientation((direction.ordinal() + (mouseButton > 0 ? -1 : 1)) % 6);
|
||||
} while (!((IPipe) source).getTile().isPipeConnected(direction));
|
||||
} while (((TileGenericPipe) source.getTile()).isPipeConnected(direction));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.IIcon;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
|
@ -14,7 +15,7 @@ public class StatementParameterRedstoneGateSideOnly implements
|
|||
@NetworkData
|
||||
public boolean isOn = false;
|
||||
|
||||
private IIcon icon;
|
||||
private static IIcon icon;
|
||||
|
||||
public StatementParameterRedstoneGateSideOnly() {
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class StatementParameterRedstoneGateSideOnly implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
isOn = !isOn;
|
||||
}
|
||||
|
||||
|
|
|
@ -397,8 +397,6 @@ public class ItemGate extends ItemBuildCraft {
|
|||
expansion.registerItemOverlay(iconRegister);
|
||||
}
|
||||
|
||||
for (IStatement statement : StatementManager.statements.values()) {
|
||||
statement.registerIcons(iconRegister);
|
||||
}
|
||||
StatementManager.registerIcons(iconRegister);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
if (param != null) {
|
||||
param.onClick(pipe.container, statement.getStatement(), mc.thePlayer.inventory.getItemStack(), k);
|
||||
param.onClick(gate, statement.getStatement(), mc.thePlayer.inventory.getItemStack(), k);
|
||||
paramSlot.setParameter(param, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import buildcraft.api.blueprints.MappingNotFoundException;
|
|||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.api.blueprints.SchematicTile;
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementManager;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.Gate;
|
||||
|
@ -100,6 +101,30 @@ public class SchematicPipe extends SchematicTile {
|
|||
a = a.rotateLeft();
|
||||
gateNBT.setString("action[" + i + "]", a.getUniqueTag());
|
||||
}
|
||||
|
||||
for (int j = 0; j < Gate.MAX_PARAMETERS; ++j) {
|
||||
if (gateNBT.hasKey("triggerParameters[" + i + "][" + j + "]")) {
|
||||
NBTTagCompound cpt = gateNBT.getCompoundTag("triggerParameters[" + i + "][" + j + "]");
|
||||
IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind"));
|
||||
parameter.readFromNBT(cpt);
|
||||
|
||||
parameter = parameter.rotateLeft();
|
||||
|
||||
parameter.writeToNBT(cpt);
|
||||
gateNBT.setTag("triggerParameters[" + i + "][" + j + "]", cpt);
|
||||
}
|
||||
|
||||
if (gateNBT.hasKey("actionParameters[" + i + "][" + j + "]")) {
|
||||
NBTTagCompound cpt = gateNBT.getCompoundTag("actionParameters[" + i + "][" + j + "]");
|
||||
IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind"));
|
||||
parameter.readFromNBT(cpt);
|
||||
|
||||
parameter = parameter.rotateLeft();
|
||||
|
||||
parameter.writeToNBT(cpt);
|
||||
gateNBT.setTag("actionParameters[" + i + "][" + j + "]", cpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gateNBT.hasKey("direction")) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.IIcon;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -24,7 +25,7 @@ public class ActionParameterSignal implements IStatementParameter {
|
|||
|
||||
@NetworkData
|
||||
public PipeWire color = null;
|
||||
private IIcon[] icons;
|
||||
private static IIcon[] icons;
|
||||
|
||||
public ActionParameterSignal() {
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class ActionParameterSignal implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
if (color == null) {
|
||||
color = mouseButton == 0 ? PipeWire.RED : PipeWire.YELLOW;
|
||||
} else if (color == (mouseButton == 0 ? PipeWire.YELLOW : PipeWire.RED)) {
|
||||
|
|
|
@ -71,13 +71,7 @@ public class ActionValve extends BCStatement implements IActionInternal {
|
|||
|
||||
@Override
|
||||
public IStatementParameter createParameter(int index) {
|
||||
IStatementParameter param = null;
|
||||
|
||||
if (index == 0) {
|
||||
param = new StatementParameterDirection();
|
||||
}
|
||||
|
||||
return param;
|
||||
return new StatementParameterDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.IIcon;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -28,7 +29,7 @@ public class TriggerParameterSignal implements IStatementParameter {
|
|||
@NetworkData
|
||||
public PipeWire color = null;
|
||||
|
||||
private IIcon[] icons;
|
||||
private static IIcon[] icons;
|
||||
|
||||
public TriggerParameterSignal() {
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class TriggerParameterSignal implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
if (mouseButton == 0) {
|
||||
if (color == null) {
|
||||
active = true;
|
||||
|
|
Loading…
Reference in a new issue