start adjusting BC blueprint API, fix #2925

This commit is contained in:
Adrian 2015-08-09 13:29:58 +02:00
parent 1d7ea6e729
commit 66002611b3
8 changed files with 22 additions and 10 deletions

View file

@ -155,6 +155,15 @@ public abstract class Schematic {
}
/**
* Can the block be placed in the world at these coordinates now?
* This function is only used to *delay* block placement until other
* prerequisites are met.
*/
public boolean canPlaceInWorld(IBuilderContext context, int x, int y, int z) {
return true;
}
/**
* Places the block in the world, at the location specified in the slot,
* using the stack in parameters

View file

@ -6,7 +6,7 @@
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "1.3", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints")
@API(apiVersion = "1.4", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints")
package buildcraft.api.blueprints;
import cpw.mods.fml.common.API;

View file

@ -184,7 +184,7 @@ public class AIRobot {
NBTTagCompound sub = nbt.getCompoundTag("delegateAI");
try {
Class<?> aiRobotClass = null;
Class<?> aiRobotClass;
if (sub.hasKey("class")) {
// Migration support for 6.4.x
aiRobotClass = RobotManager.getAIRobotByLegacyClassName(sub.getString("class"));
@ -210,7 +210,7 @@ public class AIRobot {
AIRobot ai = null;
try {
Class<?> aiRobotClass = null;
Class<?> aiRobotClass;
if (nbt.hasKey("class")) {
// Migration support for 6.4.x
aiRobotClass = RobotManager.getAIRobotByLegacyClassName(nbt.getString("class"));

View file

@ -24,7 +24,7 @@ public abstract class ResourceId {
public static ResourceId load(NBTTagCompound nbt) {
try {
Class cls = null;
Class cls;
if (nbt.hasKey("class")) {
// Migration support for 6.4.x
cls = RobotManager.getResourceIdByLegacyClassName(nbt.getString("class"));

View file

@ -11,6 +11,7 @@ package buildcraft.builders.schematics;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicBlock;
@ -51,6 +52,11 @@ public class SchematicRail extends SchematicBlock {
}
}
@Override
public boolean canPlaceInWorld(IBuilderContext context, int x, int y, int z) {
return y > 0 && World.doesBlockHaveSolidTopSurface(context.world(), x, y - 1, z);
}
@Override
public void placeInWorld(IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
context.world().setBlock(x, y, z, block, 0, 3);

View file

@ -164,7 +164,6 @@ public class BptBuilderBlueprint extends BptBuilderBase {
tmpExpanding.add(b);
b.buildStage = 3;
break;
}
} else {
postProcessing.add(b);
@ -421,7 +420,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
return slot;
} else if (checkRequirements(builder, slot.schematic)) {
if (!BuildCraftAPI.isSoftBlock(world, slot.x, slot.y,
slot.z)) {
slot.z) || !slot.schematic.canPlaceInWorld(context, slot.x, slot.y, slot.z)) {
continue; // Can't build yet, wait (#2751)
} else if (isBlockPlaceCanceled(world, slot.x, slot.y, slot.z, slot.schematic)) {
// Forge does not allow us to place a block in

View file

@ -13,7 +13,6 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
@ -48,7 +47,7 @@ public class TileEngineCreative extends TileEngineBase {
if (!(player instanceof FakePlayer)) {
if (BuildCraftCore.hidePowerNumbers) {
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode.numberless"
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode.numberless",
StringUtils.localize("chat.pipe.power.iron.level." + powerMode.maxPower)));
} else {
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode",

View file

@ -13,7 +13,6 @@ import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -59,7 +58,7 @@ public class PipePowerIron extends Pipe<PipeTransportPower> {
}
if (getWorld().isRemote && !(player instanceof FakePlayer)) {
if (BuildCraftCore.hidePowerNumbers) {
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode.numberless"
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode.numberless",
StringUtils.localize("chat.pipe.power.iron.level." + getMode().maxPower)));
} else {
player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode",