Merge branch '6.0.x' into 6.1.x

This commit is contained in:
SpaceToad 2014-05-14 17:45:05 +02:00
commit 03fd7afb7f
70 changed files with 784 additions and 550 deletions

View file

@ -17,27 +17,21 @@ import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.core.IInvSlot;
/**
* This class allow to specify specific behavior for blocks stored in
* blueprints:
* A schematic is a piece of a blueprint. It allows to stock blocks or entities
* to blueprints, and can have a state that moves from a blueprint referential
* to a world referential. Although default schematic behavior will be OK for a
* lot of objects, specific blocks and entities may be associated with a
* dedicated schematic class, which will be instantiated automatically.
*
* - what items needs to be used to create that block - how the block has to be
* built on the world - how to rotate the block - what extra data to store /
* load in the blueprint
* Schematic perform "id translation" in case the block ids between a blueprint
* and the world installation are different. Mapping is done through the builder
* context.
*
* Default implementations of this can be seen in the package
* buildcraft.api.schematics. The class SchematicUtils provide some additional
* utilities.
* Detailed documentation on the schematic behavior can be found on
* http://www.mod-buildcraft.com/wiki/doku.php?id=builder_support
*
* Blueprints perform "id translation" in case the block ids between a blueprint
* and the world installation are different. Mapping is done through the
* builder context.
*
* At blueprint load time, BuildCraft will check that each block id of the
* blueprint corresponds to the block id in the installation. If not, it will
* perform a search through the block list, and upon matching signature, it will
* translate all blocks ids of the blueprint to the installation ones. If no
* such block id is found, BuildCraft will assume that the block is not
* installed and will not load the blueprint.
* Example of schematics for minecraft blocks are available in the package
* buildcraft.core.schematics.
*/
public abstract class Schematic {
@ -66,39 +60,19 @@ public abstract class Schematic {
}
/**
* Return true if the block on the world correspond to the block stored in
* the blueprint at the location given by the slot. By default, this
* subprogram is permissive and doesn't take into account metadata.
*/
public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) {
return true;
}
/**
* Return true if the block should not be placed to the world. Requirements
* will not be asked on such a block, and building will not be called. Post
* processing will still be called on these blocks though.
*/
public boolean doNotBuild() {
return false;
}
/**
* This is called each time an item matches a reqquirement, that is: (req id
* == stack id) for damageable items (req id == stack id && req dmg == stack
* dmg) for other items by default, it will increase damage of damageable
* items by the amount of damage of the requirement, and remove the intended
* amount of non damageable item.
* This is called each time an item matches a requirement. By default, it
* will increase damage of items that can be damaged by the amount of the
* requirement, and remove the intended amount of items that can't be
* damaged.
*
* Client may override this behavior for default items. Note that this
* subprogram may be called twice with the same parameters, once with a copy
* of requirements and stack to check if the entire requirements can be
* fullfilled, and once with the real inventory. Implementer is responsible
* for updating req (with the remaining requirements if any) and stack
* (after usage)
* Client may override this behavior. Note that this subprogram may be
* called twice with the same parameters, once with a copy of requirements
* and stack to check if the entire requirements can be fulfilled, and once
* with the real inventory. Implementer is responsible for updating req
* (with the remaining requirements if any) and slot (after usage).
*
* returns: what was used (similer to req, but created from stack, so that
* any NBT based differences are drawn from the correct source)
* returns what was used (similar to req, but created from slot, so that any
* NBT based differences are drawn from the correct source)
*/
public ItemStack useItem(IBuilderContext context, ItemStack req, IInvSlot slot) {
ItemStack stack = slot.getStackInSlot();
@ -145,28 +119,43 @@ public abstract class Schematic {
/**
* Applies translations to all positions in the schematic to center in the
* blueprint referencial
* blueprint referential
*/
public void translateToSchematic(Translation transform) {
public void translateToBlueprint(Translation transform) {
}
/**
* Apply translations to all positions in the schematic to center in the
* builder referencial
* builder referential
*/
public void translateToWorld(Translation transform) {
}
public void idsToSchematic(MappingRegistry registry) {
/**
* Translates blocks and item ids to the blueprint referential
*/
public void idsToBlueprint(MappingRegistry registry) {
}
/**
* Translates blocks and item ids to the world referential
*/
public void idsToWorld(MappingRegistry registry) {
}
/**
* Initializes a schematic for blueprint according to an objet placed on {x,
* y, z} on the world. For blocks, block and meta fields will be initialized
* automatically.
*/
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
}
/**
* Places the block in the world, at the location specified in the slot,
* using the stack in parameters
@ -176,68 +165,21 @@ public abstract class Schematic {
}
/**
* Initializes a slot from the blueprint according to an objet placed on {x,
* y, z} on the world. This typically means adding entries in slot.cpt. Note
* that "id" and "meta" will be set automatically, corresponding to the
* block id and meta.
*
* By default, if the block is a BlockContainer, tile information will be to
* save / load the block.
* Write specific requirements coming from the world to the blueprint.
*/
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
}
/**
* Called on a block when the blueprint has finished to place all the
* blocks. This may be useful to adjust variable depending on surrounding
* blocks that may not be there already at initial building.
*/
public void postProcessing(IBuilderContext context, int x, int y, int z) {
}
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}
/**
* Returns the requirements needed to build this block. When the
* requirements are met, they will be removed all at once from the builder,
* before calling buildBlock.
* before calling writeToWorld.
*/
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
}
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
}
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
}
public LinkedList<ItemStack> getStacksToDisplay(
LinkedList<ItemStack> stackConsumed) {
return stackConsumed;
}
/**
* Return the stage where this schematic has to be built.
*/
public BuildingStage getBuildStage () {
return BuildingStage.STANDALONE;
}
/**
* Return the building permission for blueprint containing this schematic.
*/
public BuildingPermission getBuildingPermission () {
return BuildingPermission.ALL;
}
/**
* Returns the amount of energy required to build this slot, depends on the
* stacks selected for the build.
@ -251,4 +193,84 @@ public abstract class Schematic {
return result;
}
/**
* Returns the flying stacks to display in the builder animation.
*/
public LinkedList<ItemStack> getStacksToDisplay(
LinkedList<ItemStack> stackConsumed) {
return stackConsumed;
}
/**
* Return the stage where this schematic has to be built.
*/
public BuildingStage getBuildStage () {
return BuildingStage.STANDALONE;
}
/**
* Return true if the block on the world correspond to the block stored in
* the blueprint at the location given by the slot. By default, this
* subprogram is permissive and doesn't take into account metadata.
*
* Post processing will be called on these blocks.
*/
public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) {
return true;
}
/**
* Return true if the block should not be placed to the world. Requirements
* will not be asked on such a block, and building will not be called.
*
* Post processing will be called on these blocks.
*/
public boolean doNotBuild() {
return false;
}
/**
* Return true if the schematic should not be used at all. This is computed
* straight after readFromNBT can be used to deactivate schematics in which
* an inconsistency is detected. It will be considered as a block of air
* instead.
*
* Post processing will *not* be called on these blocks.
*/
public boolean doNotUse() {
return false;
}
/**
* Return the maximium building permission for blueprint containing this
* schematic.
*/
public BuildingPermission getBuildingPermission () {
return BuildingPermission.ALL;
}
/**
* Called on a block when the blueprint has finished to place all the
* blocks. This may be useful to adjust variable depending on surrounding
* blocks that may not be there already at initial building.
*/
public void postProcessing(IBuilderContext context, int x, int y, int z) {
}
/**
* Saves this schematic to the blueprint NBT.
*/
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
}
/**
* Loads this schematic from the blueprint NBT.
*/
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
}
}

View file

@ -35,7 +35,7 @@ public class SchematicBlock extends SchematicBlockBase {
public ItemStack [] storedRequirements = new ItemStack [0];
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
if (block != null) {
if (storedRequirements.length != 0) {
for (ItemStack s : storedRequirements) {
@ -54,24 +54,16 @@ public class SchematicBlock extends SchematicBlockBase {
@Override
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
super.writeToWorld(context, x, y, z, stacks);
// Meta needs to be specified twice, depending on the block behavior
context.world().setBlock(x, y, z, block, meta, 3);
context.world().setBlockMetadataWithNotify(x, y, z, meta, 3);
}
@Override
public boolean doNotBuild() {
return false;
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
super.writeRequirementsToSchematic(context, x, y, z);
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeRequirementsToBlueprint(context, x, y, z);
if (block != null) {
ArrayList<ItemStack> req = block.getDrops(context.world(), x,

View file

@ -28,7 +28,13 @@ public class SchematicEntity extends Schematic {
public Class<? extends Entity> entity;
public NBTTagCompound cpt = new NBTTagCompound();
/**
* This tree contains additional data to be stored in the blueprint. By
* default, it will be initialized from Schematic.readFromWord with the
* standard readNBT function of the corresponding tile (if any) and will be
* loaded from BptBlock.writeToWorld using the standard writeNBT function.
*/
public NBTTagCompound entityNBT = new NBTTagCompound();
/**
* This field contains requirements for a given block when stored in the
@ -38,70 +44,70 @@ public class SchematicEntity extends Schematic {
public ItemStack[] storedRequirements = new ItemStack[0];
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
for (ItemStack s : storedRequirements) {
requirements.add(s);
}
}
public void writeToWorld(IBuilderContext context) {
Entity e = EntityList.createEntityFromNBT(cpt, context.world());
Entity e = EntityList.createEntityFromNBT(entityNBT, context.world());
context.world().spawnEntityInWorld(e);
}
public void readFromWorld(IBuilderContext context, Entity entity) {
entity.writeToNBTOptional(cpt);
entity.writeToNBTOptional(entityNBT);
}
@Override
public void translateToSchematic(Translation transform) {
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
public void translateToBlueprint(Translation transform) {
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
Position pos = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));
pos = transform.translate(pos);
cpt.setTag("Pos",
entityNBT.setTag("Pos",
this.newDoubleNBTList(pos.x, pos.y, pos.z));
}
@Override
public void translateToWorld(Translation transform) {
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
Position pos = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));
pos = transform.translate(pos);
cpt.setTag("Pos",
entityNBT.setTag("Pos",
this.newDoubleNBTList(pos.x, pos.y, pos.z));
}
@Override
public void idsToSchematic(MappingRegistry registry) {
registry.scanAndTranslateStacksToRegistry(cpt);
public void idsToBlueprint(MappingRegistry registry) {
registry.scanAndTranslateStacksToRegistry(entityNBT);
}
@Override
public void idsToWorld(MappingRegistry registry) {
try {
registry.scanAndTranslateStacksToWorld(cpt);
registry.scanAndTranslateStacksToWorld(entityNBT);
} catch (MappingNotFoundException e) {
cpt = new NBTTagCompound();
entityNBT = new NBTTagCompound();
}
}
@Override
public void rotateLeft(IBuilderContext context) {
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
Position pos = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));
pos = context.rotatePositionLeft(pos);
cpt.setTag("Pos",
entityNBT.setTag("Pos",
this.newDoubleNBTList(pos.x, pos.y, pos.z));
nbttaglist = cpt.getTagList("Rotation", 5);
nbttaglist = entityNBT.getTagList("Rotation", 5);
float yaw = nbttaglist.func_150308_e(0);
yaw += 90;
cpt.setTag(
entityNBT.setTag(
"Rotation",
this.newFloatNBTList(yaw,
nbttaglist.func_150308_e(1)));
@ -111,10 +117,10 @@ public class SchematicEntity extends Schematic {
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
super.writeToNBT(nbt, registry);
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
nbt.setInteger("entityId", registry.getIdForEntity(entity));
nbt.setTag("entity", cpt);
nbt.setTag("entity", entityNBT);
NBTTagList rq = new NBTTagList();
@ -132,7 +138,7 @@ public class SchematicEntity extends Schematic {
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
super.readFromNBT(nbt, registry);
cpt = nbt.getCompoundTag("entity");
entityNBT = nbt.getCompoundTag("entity");
NBTTagList rq = nbt.getTagList("rq",
Constants.NBT.TAG_COMPOUND);
@ -191,7 +197,7 @@ public class SchematicEntity extends Schematic {
}
public boolean isAlreadyBuilt(IBuilderContext context) {
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
Position newPosition = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));

View file

@ -13,6 +13,7 @@ import java.util.LinkedList;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.WorldServer;
import buildcraft.api.core.BuildCraftAPI;
@ -41,7 +42,7 @@ public class SchematicMask extends SchematicBlockBase {
context.world().setBlock(x, y, z, Blocks.air, 0, 3);
stack.tryPlaceItemIntoWorld(
BuildCraftAPI.proxy.getBuildCraftPlayer(context.world()),
BuildCraftAPI.proxy.getBuildCraftPlayer((WorldServer) context.world()).get(),
context.world(), x, y, z, 1, 0.0f, 0.0f, 0.0f);
}
} else {

View file

@ -55,6 +55,11 @@ public final class SchematicRegistry {
}
private static void internalRegisterSchematicBlock (Block block, Class clas, Object ... params) {
if (schematicBlocks.containsKey(block)) {
throw new RuntimeException("Block " + Block.blockRegistry.getNameForObject(block)
+ " is already associated with a schematic.");
}
SchematicConstructor c = new SchematicConstructor ();
c.clas = clas;
c.params = params;

View file

@ -22,23 +22,23 @@ public class SchematicTile extends SchematicBlock {
/**
* This tree contains additional data to be stored in the blueprint. By
* default, it will be initialized from Schematic.readFromWord with
* the standard readNBT function of the corresponding tile (if any) and will
* be loaded from BptBlock.buildBlock using the standard writeNBT function.
* default, it will be initialized from Schematic.readFromWord with the
* standard readNBT function of the corresponding tile (if any) and will be
* loaded from BptBlock.writeToWorld using the standard writeNBT function.
*/
public NBTTagCompound cpt = new NBTTagCompound();
public NBTTagCompound tileNBT = new NBTTagCompound();
@Override
public void idsToSchematic(MappingRegistry registry) {
registry.scanAndTranslateStacksToRegistry(cpt);
public void idsToBlueprint(MappingRegistry registry) {
registry.scanAndTranslateStacksToRegistry(tileNBT);
}
@Override
public void idsToWorld(MappingRegistry registry) {
try {
registry.scanAndTranslateStacksToWorld(cpt);
registry.scanAndTranslateStacksToWorld(tileNBT);
} catch (MappingNotFoundException e) {
cpt = new NBTTagCompound();
tileNBT = new NBTTagCompound();
}
}
@ -52,32 +52,32 @@ public class SchematicTile extends SchematicBlock {
if (block.hasTileEntity(meta)) {
TileEntity tile = context.world().getTileEntity(x, y, z);
cpt.setInteger("x", x);
cpt.setInteger("y", y);
cpt.setInteger("z", z);
tileNBT.setInteger("x", x);
tileNBT.setInteger("y", y);
tileNBT.setInteger("z", z);
if (tile != null) {
tile.readFromNBT(cpt);
tile.readFromNBT(tileNBT);
}
}
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
super.writeToSchematic(context, x, y, z);
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeToBlueprint(context, x, y, z);
if (block.hasTileEntity(meta)) {
TileEntity tile = context.world().getTileEntity(x, y, z);
if (tile != null) {
tile.writeToNBT(cpt);
tile.writeToNBT(tileNBT);
}
}
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
super.writeRequirementsToSchematic(context, x, y, z);
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeRequirementsToBlueprint(context, x, y, z);
if (block.hasTileEntity(meta)) {
TileEntity tile = context.world().getTileEntity(x, y, z);
@ -103,13 +103,13 @@ public class SchematicTile extends SchematicBlock {
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
super.writeToNBT(nbt, registry);
nbt.setTag("blockCpt", cpt);
nbt.setTag("blockCpt", tileNBT);
}
@Override
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
super.readFromNBT(nbt, registry);
cpt = nbt.getCompoundTag("blockCpt");
tileNBT = nbt.getCompoundTag("blockCpt");
}
}

View file

@ -8,9 +8,11 @@
*/
package buildcraft.api.core;
import java.lang.ref.WeakReference;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
public interface ICoreProxy {
EntityPlayer getBuildCraftPlayer(World world);
WeakReference<EntityPlayer> getBuildCraftPlayer(WorldServer world);
}

View file

@ -22,7 +22,7 @@ import buildcraft.api.core.JavaTools;
* battery field is of type double, and is the only piece of data specific to
* this object. Others are class-wide.
*/
public class BatteryObject implements IBatteryObject {
public class BatteryObject implements IBatteryIOObject {
protected Field energyStored;
protected Object obj;
protected MjBattery batteryData;
@ -32,6 +32,9 @@ public class BatteryObject implements IBatteryObject {
*/
@Override
public double getEnergyRequested() {
if (!batteryData.mode().canReceive) {
return 0;
}
try {
return JavaTools.bounds(batteryData.maxCapacity() - energyStored.getDouble(obj),
batteryData.minimumConsumption(), batteryData.maxReceivedPerCycle());
@ -54,6 +57,9 @@ public class BatteryObject implements IBatteryObject {
*/
@Override
public double addEnergy(double mj, boolean ignoreCycleLimit) {
if (!batteryData.mode().canReceive) {
return 0;
}
try {
double contained = energyStored.getDouble(obj);
double maxAccepted = batteryData.maxCapacity() - contained + batteryData.minimumConsumption();
@ -126,8 +132,14 @@ public class BatteryObject implements IBatteryObject {
* {@inheritDoc}
*/
@Override
public BatteryObject reconfigure(final double maxCapacity, final double maxReceivedPerCycle, final double minimumConsumption) {
final ForgeDirection[] sides = batteryData != null ? batteryData.sides() : new ForgeDirection[] { ForgeDirection.UNKNOWN };
public BatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption) {
overrideBattery(maxCapacity, maxReceivedPerCycle, minimumConsumption,
batteryData.kind(), batteryData.sides(), batteryData.mode());
return this;
}
public void overrideBattery(final double maxCapacity, final double maxReceivedPerCycle, final double minimumConsumption,
final String kind, final ForgeDirection[] sides, final IOMode mode) {
batteryData = new MjBattery() {
@Override
public double maxCapacity() {
@ -151,20 +163,38 @@ public class BatteryObject implements IBatteryObject {
@Override
public String kind() {
return MjAPI.DEFAULT_POWER_FRAMEWORK;
return kind;
}
@Override
public ForgeDirection[] sides() {
return sides;
}
};
return this;
@Override
public IOMode mode() {
return mode;
}
};
}
@Override
public String kind() {
return batteryData.kind();
}
@Override
public IOMode mode() {
return batteryData.mode();
}
@Override
public boolean canSend() {
return batteryData.mode().canSend;
}
@Override
public boolean canReceive() {
return batteryData.mode().canReceive;
}
}

View file

@ -0,0 +1,17 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
public interface IBatteryIOObject extends IBatteryObject {
IOMode mode();
boolean canSend();
boolean canReceive();
}

View file

@ -0,0 +1,20 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
public enum IOMode {
Both(true, true), Receive(true, false), Send(false, true), None(false, false);
public final boolean canReceive, canSend;
IOMode(boolean canReceive, boolean canSend) {
this.canReceive = canReceive;
this.canSend = canSend;
}
}

View file

@ -1,15 +1,15 @@
/**
* Copyright (c) 2014, Prototik and the BuildFactory Team
* http://buildfactory.org/
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildFactory is distributed under the terms of the Minecraft Mod Public
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://buildfactory.org/license
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.mj;
import net.minecraftforge.common.util.ForgeDirection;
public interface ISidedBatteryProvider extends IBatteryProvider {
public interface ISidedBatteryProvider {
IBatteryObject getMjBattery(String kind, ForgeDirection direction);
}

View file

@ -65,21 +65,21 @@ public final class MjAPI {
return null;
}
IBatteryObject battery = null;
if (o instanceof ISidedBatteryProvider) {
battery = ((ISidedBatteryProvider) o).getMjBattery(kind, side);
if (battery == null && side != ForgeDirection.UNKNOWN) {
battery = ((ISidedBatteryProvider) o).getMjBattery(kind, ForgeDirection.UNKNOWN);
}
}
if (o instanceof IBatteryProvider) {
IBatteryObject battery;
battery = ((IBatteryProvider) o).getMjBattery(kind);
}
if (o instanceof ISidedBatteryProvider) {
battery = ((ISidedBatteryProvider) o).getMjBattery(kind, side);
if (battery == null && side != ForgeDirection.UNKNOWN) {
battery = ((ISidedBatteryProvider) o).getMjBattery(kind, ForgeDirection.UNKNOWN);
}
} else {
battery = ((IBatteryProvider) o).getMjBattery(kind);
}
if (battery != null) {
return battery;
}
if (battery != null) {
return battery;
}
BatteryField f = getMjBatteryField(o.getClass(), kind, side);

View file

@ -65,4 +65,9 @@ public @interface MjBattery {
* @return Sides on which this battery should works.
*/
ForgeDirection[] sides() default { ForgeDirection.UNKNOWN };
/**
* @return Current battery input/output mode
*/
IOMode mode() default IOMode.Receive;
}

View file

@ -22,12 +22,12 @@ apply plugin: 'forge' // adds the forge dependency
apply plugin: 'maven' // for uploading to a maven repo
apply plugin: 'checkstyle'
version = "6.0.11"
version = "6.0.13"
group= "com.mod-buildcraft"
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
minecraft {
version = "1.7.2-10.12.1.1060" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
version = "1.7.2-10.12.1.1079" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
assetDir = "run/assets" // the place for ForgeGradle to download the assets. The assets that the launcher gets and stuff

View file

@ -0,0 +1,8 @@
#1785 improve consistency of schematic API naming [SpaceToad]
#1784 fix crashes when using reflection with pipes [undergroundminer3]
#1783 fix NPE in Box.extendToEncompass [SpaceToad]
#1782 fix tile marker crashes [SpaceToad]
#1781 support for IO modes in MjAPI enhancement [Prototik]
#1780 fix possible crash while scrolling through facades [SpaceToad]
#1779 improve blueprint behavior when blocks are missing [SpaceToad]
#1778 enhance default behavior of id translation [SpaceToad]

View file

@ -0,0 +1,7 @@
#1799 fix drain method causing dupe glitches [M3gaFr3ak]
#1794 glass should be considered standalone block [SpaceToad]
#1792 remove unnecessary extends for ISidedBatteryProvider [Prototik]
#1791 refinery doesn't get emptied in blueprints [SpaceToad]
#1790 blueprints don't remove liquid from pumps [SpaceToad]
#1789 quarries should not remove bedrock [SpaceToad]
#1786 migrate to Forge's fake player management [SpaceToad]

View file

@ -1,2 +1,2 @@
1.6.4:BuildCraft:4.2.2
1.7.2:BuildCraft:6.0.11
1.7.2:BuildCraft:6.0.13

View file

@ -93,10 +93,10 @@ import buildcraft.builders.schematics.SchematicFactoryMask;
import buildcraft.builders.schematics.SchematicFarmland;
import buildcraft.builders.schematics.SchematicFire;
import buildcraft.builders.schematics.SchematicFluid;
import buildcraft.builders.schematics.SchematicGlassPane;
import buildcraft.builders.schematics.SchematicGravel;
import buildcraft.builders.schematics.SchematicHanging;
import buildcraft.builders.schematics.SchematicIgnore;
import buildcraft.builders.schematics.SchematicIgnoreMeta;
import buildcraft.builders.schematics.SchematicLever;
import buildcraft.builders.schematics.SchematicMinecart;
import buildcraft.builders.schematics.SchematicPiston;
@ -111,6 +111,7 @@ import buildcraft.builders.schematics.SchematicSeeds;
import buildcraft.builders.schematics.SchematicSign;
import buildcraft.builders.schematics.SchematicSkull;
import buildcraft.builders.schematics.SchematicStairs;
import buildcraft.builders.schematics.SchematicStandalone;
import buildcraft.builders.schematics.SchematicStone;
import buildcraft.builders.schematics.SchematicTileCreative;
import buildcraft.builders.schematics.SchematicTripWireHook;
@ -309,8 +310,6 @@ public class BuildCraftBuilders extends BuildCraftMod {
SchematicRegistry.registerSchematicBlock(Blocks.redstone_wire, SchematicRedstoneWire.class, new ItemStack(Items.redstone));
SchematicRegistry.registerSchematicBlock(Blocks.cake, SchematicCustomStack.class, new ItemStack(Items.cake));
SchematicRegistry.registerSchematicBlock(Blocks.pumpkin_stem, SchematicCustomStack.class, new ItemStack(Items.pumpkin_seeds));
SchematicRegistry.registerSchematicBlock(Blocks.melon_stem, SchematicCustomStack.class, new ItemStack(Items.melon_seeds));
SchematicRegistry.registerSchematicBlock(Blocks.glowstone, SchematicCustomStack.class, new ItemStack(Blocks.glowstone));
SchematicRegistry.registerSchematicBlock(Blocks.powered_repeater, SchematicRedstoneDiode.class, Items.repeater);
@ -326,7 +325,8 @@ public class BuildCraftBuilders extends BuildCraftMod {
SchematicRegistry.registerSchematicBlock(Blocks.lava, SchematicFluid.class, new ItemStack(Items.lava_bucket));
SchematicRegistry.registerSchematicBlock(Blocks.flowing_lava, SchematicFluid.class, new ItemStack(Items.lava_bucket));
SchematicRegistry.registerSchematicBlock(Blocks.glass_pane, SchematicIgnoreMeta.class);
SchematicRegistry.registerSchematicBlock(Blocks.glass_pane, SchematicGlassPane.class);
SchematicRegistry.registerSchematicBlock(Blocks.stained_glass_pane, SchematicGlassPane.class);
SchematicRegistry.registerSchematicBlock(Blocks.piston, SchematicPiston.class);
SchematicRegistry.registerSchematicBlock(Blocks.piston_extension, SchematicPiston.class);
@ -368,6 +368,16 @@ public class BuildCraftBuilders extends BuildCraftMod {
SchematicRegistry.registerSchematicBlock(Blocks.mob_spawner, SchematicTileCreative.class);
SchematicRegistry.registerSchematicBlock(Blocks.glass, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.stone_slab, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.double_stone_slab, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.wooden_slab, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.double_wooden_slab, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.stained_glass, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.fence, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.daylight_detector, SchematicStandalone.class);
SchematicRegistry.registerSchematicBlock(Blocks.iron_bars, SchematicStandalone.class);
// Standard entities
SchematicRegistry.registerSchematicEntity(EntityMinecartEmpty.class, SchematicMinecart.class, Items.minecart);

View file

@ -15,6 +15,8 @@ import java.nio.IntBuffer;
import java.util.HashSet;
import java.util.TreeMap;
import com.mojang.authlib.GameProfile;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
@ -102,7 +104,7 @@ import buildcraft.core.triggers.TriggerMachine;
import buildcraft.core.triggers.TriggerRedstoneInput;
import buildcraft.core.utils.CraftingHandler;
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.2,1.8)", dependencies = "required-after:Forge@[10.12.0.1024,)")
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.2,1.8)", dependencies = "required-after:Forge@[10.12.1.1079,)")
public class BuildCraftCore extends BuildCraftMod {
public static final boolean NONRELEASED_BLOCKS = true;
@ -170,7 +172,6 @@ public class BuildCraftCore extends BuildCraftMod {
public static BCAction actionOff = new ActionMachineControl(Mode.Off);
public static BCAction actionLoop = new ActionMachineControl(Mode.Loop);
public static boolean loadDefaultRecipes = true;
public static boolean forcePneumaticPower = true;
public static boolean consumeWaterSources = false;
//public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length];
@Mod.Instance("BuildCraft|Core")
@ -205,6 +206,8 @@ public class BuildCraftCore extends BuildCraftMod {
public static float diffX, diffY, diffZ;
public static GameProfile gameProfile = new GameProfile("buildcraft.core", "[BuildCraft]");
private static FloatBuffer modelviewF;
private static FloatBuffer projectionF;
private static IntBuffer viewport;

View file

@ -57,8 +57,6 @@ import buildcraft.factory.FactoryProxy;
import buildcraft.factory.FactoryProxyClient;
import buildcraft.factory.GuiHandler;
import buildcraft.factory.PumpDimensionList;
import buildcraft.factory.SchematicRefinery;
import buildcraft.factory.SchematicTank;
import buildcraft.factory.TileAutoWorkbench;
import buildcraft.factory.TileFloodGate;
import buildcraft.factory.TileHopper;
@ -68,6 +66,9 @@ import buildcraft.factory.TileQuarry;
import buildcraft.factory.TileRefinery;
import buildcraft.factory.TileTank;
import buildcraft.factory.network.PacketHandlerFactory;
import buildcraft.factory.schematics.SchematicPump;
import buildcraft.factory.schematics.SchematicRefinery;
import buildcraft.factory.schematics.SchematicTank;
@Mod(name = "BuildCraft Factory", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE)
public class BuildCraftFactory extends BuildCraftMod {
@ -150,6 +151,7 @@ public class BuildCraftFactory extends BuildCraftMod {
SchematicRegistry.registerSchematicBlock(refineryBlock, SchematicRefinery.class);
SchematicRegistry.registerSchematicBlock(tankBlock, SchematicTank.class);
SchematicRegistry.registerSchematicBlock(frameBlock, SchematicIgnoreMeta.class);
SchematicRegistry.registerSchematicBlock(pumpBlock, SchematicPump.class);
if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes();

View file

@ -9,6 +9,7 @@
package buildcraft;
import java.util.EnumMap;
import java.util.logging.Level;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.Packet;
@ -19,29 +20,55 @@ import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget;
import cpw.mods.fml.relauncher.Side;
import buildcraft.api.core.BCLog;
import buildcraft.core.network.BuildCraftPacket;
public class BuildCraftMod {
public EnumMap<Side, FMLEmbeddedChannel> channels;
public void sendToPlayers(Packet packet, World world, int x, int y, int z, int maxDistance) {
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
channels.get(Side.SERVER).writeOutbound(packet);
try {
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.ALL);
channels.get(Side.SERVER).writeOutbound(packet);
} catch (Throwable t) {
BCLog.logger.log(Level.WARNING, "sentToPlayers crash", t);
}
}
public void sendToPlayers(BuildCraftPacket packet, World world, int x, int y, int z, int maxDistance) {
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
channels.get(Side.SERVER).writeOutbound(packet);
try {
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.ALL);
channels.get(Side.SERVER).writeOutbound(packet);
} catch (Throwable t) {
BCLog.logger.log(Level.WARNING, "sentToPlayers crash", t);
}
}
public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityplayer);
channels.get(Side.SERVER).writeOutbound(packet);
try {
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(FMLOutboundHandler.OutboundTarget.PLAYER);
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityplayer);
channels.get(Side.SERVER).writeOutbound(packet);
} catch (Throwable t) {
String name = entityplayer.getDisplayName();
if (name == null) {
name = "<no name>";
}
BCLog.logger.log(Level.WARNING, "sentToPlayer \"" + name + "\" crash", t);
}
}
public void sendToServer(BuildCraftPacket packet) {
channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER);
channels.get(Side.CLIENT).writeOutbound(packet);
try {
channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER);
channels.get(Side.CLIENT).writeOutbound(packet);
} catch (Throwable t) {
BCLog.logger.log(Level.WARNING, "sentToServer crash", t);
}
}
}

View file

@ -19,14 +19,14 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicBed extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
if ((meta & 8) == 0) {
requirements.add(new ItemStack(Items.bed));
}
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -19,12 +19,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicCactus extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.cactus));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -24,12 +24,12 @@ public class SchematicCustomStack extends SchematicBlock {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(customStack.copy());
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}
}

View file

@ -20,12 +20,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicDirt extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.dirt));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -28,14 +28,14 @@ public class SchematicDoor extends SchematicBlock {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
if ((meta & 8) == 0) {
requirements.add(stack.copy());
}
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}
@ -83,8 +83,8 @@ public class SchematicDoor extends SchematicBlock {
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
super.writeToSchematic(context, x, y, z);
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeToBlueprint(context, x, y, z);
if ((meta & 8) == 0) {
upperMeta = context.world().getBlockMetadata(x, y + 1, z);

View file

@ -23,13 +23,13 @@ public class SchematicEnderChest extends SchematicRotateMeta {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.obsidian, 8));
requirements.add(new ItemStack(Items.ender_eye, 1));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -20,12 +20,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicFarmland extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.dirt));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -19,12 +19,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicFire extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack (Items.flint_and_steel));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}
}

View file

@ -26,14 +26,14 @@ public class SchematicFluid extends SchematicBlock {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
if (meta == 0) {
requirements.add(bucketStack.copy());
}
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -0,0 +1,39 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.schematics;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicBlock;
public class SchematicGlassPane extends SchematicBlock {
@Override
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
}
@Override
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}
@Override
public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) {
return block == context.world().getBlock(x, y, z);
}
@Override
public BuildingStage getBuildStage() {
return BuildingStage.STANDALONE;
}
}

View file

@ -20,12 +20,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicGravel extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.gravel));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -29,40 +29,40 @@ public class SchematicHanging extends SchematicEntity {
}
@Override
public void translateToSchematic(Translation transform) {
super.translateToSchematic(transform);
public void translateToBlueprint(Translation transform) {
super.translateToBlueprint(transform);
Position pos = new Position (cpt.getInteger("TileX"), cpt.getInteger("TileY"), cpt.getInteger("TileZ"));
Position pos = new Position (entityNBT.getInteger("TileX"), entityNBT.getInteger("TileY"), entityNBT.getInteger("TileZ"));
pos = transform.translate(pos);
cpt.setInteger("TileX", (int) pos.x);
cpt.setInteger("TileY", (int) pos.y);
cpt.setInteger("TileZ", (int) pos.z);
entityNBT.setInteger("TileX", (int) pos.x);
entityNBT.setInteger("TileY", (int) pos.y);
entityNBT.setInteger("TileZ", (int) pos.z);
}
@Override
public void translateToWorld(Translation transform) {
super.translateToWorld(transform);
Position pos = new Position (cpt.getInteger("TileX"), cpt.getInteger("TileY"), cpt.getInteger("TileZ"));
Position pos = new Position (entityNBT.getInteger("TileX"), entityNBT.getInteger("TileY"), entityNBT.getInteger("TileZ"));
pos = transform.translate(pos);
cpt.setInteger("TileX", (int) pos.x);
cpt.setInteger("TileY", (int) pos.y);
cpt.setInteger("TileZ", (int) pos.z);
entityNBT.setInteger("TileX", (int) pos.x);
entityNBT.setInteger("TileY", (int) pos.y);
entityNBT.setInteger("TileZ", (int) pos.z);
}
@Override
public void rotateLeft(IBuilderContext context) {
super.rotateLeft(context);
Position pos = new Position (cpt.getInteger("TileX"), cpt.getInteger("TileY"), cpt.getInteger("TileZ"));
Position pos = new Position (entityNBT.getInteger("TileX"), entityNBT.getInteger("TileY"), entityNBT.getInteger("TileZ"));
pos = context.rotatePositionLeft(pos);
cpt.setInteger("TileX", (int) pos.x);
cpt.setInteger("TileY", (int) pos.y);
cpt.setInteger("TileZ", (int) pos.z);
entityNBT.setInteger("TileX", (int) pos.x);
entityNBT.setInteger("TileY", (int) pos.y);
entityNBT.setInteger("TileZ", (int) pos.z);
int direction = cpt.getByte("Direction");
int direction = entityNBT.getByte("Direction");
direction = direction < 3 ? direction + 1 : 0;
cpt.setInteger("Direction", direction);
entityNBT.setInteger("Direction", direction);
}
@Override
@ -70,7 +70,7 @@ public class SchematicHanging extends SchematicEntity {
super.readFromWorld(context, entity);
if (baseItem == Items.item_frame) {
NBTTagCompound tag = cpt.getCompoundTag("Item");
NBTTagCompound tag = entityNBT.getCompoundTag("Item");
ItemStack stack = ItemStack.loadItemStackFromNBT(tag);
if (stack != null) {
@ -89,9 +89,9 @@ public class SchematicHanging extends SchematicEntity {
@Override
public boolean isAlreadyBuilt(IBuilderContext context) {
Position newPosition = new Position (cpt.getInteger("TileX"), cpt.getInteger("TileY"), cpt.getInteger("TileZ"));
Position newPosition = new Position (entityNBT.getInteger("TileX"), entityNBT.getInteger("TileY"), entityNBT.getInteger("TileZ"));
int dir = cpt.getInteger("Direction");
int dir = entityNBT.getInteger("Direction");
for (Object o : context.world().loadedEntityList) {
Entity e = (Entity) o;

View file

@ -18,7 +18,7 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicIgnore extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
}
@ -28,7 +28,7 @@ public class SchematicIgnore extends SchematicBlock {
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
}
@ -38,7 +38,7 @@ public class SchematicIgnore extends SchematicBlock {
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -18,12 +18,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicIgnoreMeta extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -28,15 +28,15 @@ public class SchematicMinecart extends SchematicEntity {
}
@Override
public void translateToSchematic(Translation transform) {
super.translateToSchematic(transform);
public void translateToBlueprint(Translation transform) {
super.translateToBlueprint(transform);
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
Position pos = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));
pos.x -= 0.5;
pos.z -= 0.5;
cpt.setTag("Pos", this.newDoubleNBTList(new double[] {pos.x, pos.y, pos.z}));
entityNBT.setTag("Pos", this.newDoubleNBTList(new double[] {pos.x, pos.y, pos.z}));
}
@ -44,12 +44,12 @@ public class SchematicMinecart extends SchematicEntity {
public void translateToWorld(Translation transform) {
super.translateToWorld(transform);
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
Position pos = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));
pos.x += 0.5;
pos.z += 0.5;
cpt.setTag("Pos", this.newDoubleNBTList(new double[] {pos.x, pos.y, pos.z}));
entityNBT.setTag("Pos", this.newDoubleNBTList(new double[] {pos.x, pos.y, pos.z}));
}
@Override
@ -62,7 +62,7 @@ public class SchematicMinecart extends SchematicEntity {
@Override
public boolean isAlreadyBuilt(IBuilderContext context) {
NBTTagList nbttaglist = cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
Position newPosition = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));

View file

@ -19,12 +19,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicPortal extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -18,12 +18,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicPumpkin extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -24,12 +24,12 @@ public class SchematicRedstoneDiode extends SchematicBlock {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(baseItem));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -20,12 +20,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicRedstoneLamp extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.redstone_lamp, 1, 0));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -24,12 +24,12 @@ public class SchematicRedstoneWire extends SchematicBlock {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(customStack.copy());
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -25,12 +25,12 @@ public class SchematicSeeds extends SchematicBlock {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(seeds));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -27,12 +27,12 @@ public class SchematicSign extends SchematicTile {
}
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Items.sign));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
// cancel requirements reading
}

View file

@ -15,11 +15,11 @@ public class SchematicSkull extends SchematicTile {
@Override
public void rotateLeft(IBuilderContext context) {
int rot = cpt.getByte("Rot");
int rot = tileNBT.getByte("Rot");
rot = (rot + 4) % 16;
cpt.setByte("Rot", (byte) rot);
tileNBT.setByte("Rot", (byte) rot);
}
}

View file

@ -18,12 +18,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicStairs extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -0,0 +1,20 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.schematics;
import buildcraft.api.blueprints.SchematicBlock;
public class SchematicStandalone extends SchematicBlock {
@Override
public BuildingStage getBuildStage() {
return BuildingStage.STANDALONE;
}
}

View file

@ -20,12 +20,12 @@ import buildcraft.api.blueprints.SchematicBlock;
public class SchematicStone extends SchematicBlock {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.stone));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -60,7 +60,7 @@ public class Blueprint extends BlueprintBase {
super.translateToBlueprint(transform);
for (SchematicEntity e : entities) {
e.translateToSchematic(transform);
e.translateToBlueprint(transform);
}
}
@ -107,8 +107,8 @@ public class Blueprint extends BlueprintBase {
}
try {
slot.writeToSchematic(context, x, y, z);
slot.writeRequirementsToSchematic(context, x, y, z);
slot.writeToBlueprint(context, x, y, z);
slot.writeRequirementsToBlueprint(context, x, y, z);
contents[posX][posY][posZ] = slot;
} catch (Throwable t) {
// Defensive code against errors in implementers
@ -163,7 +163,7 @@ public class Blueprint extends BlueprintBase {
NBTTagCompound cpt = new NBTTagCompound();
if (contents [x][y][z] != null) {
contents[x][y][z].idsToSchematic(mapping);
contents[x][y][z].idsToBlueprint(mapping);
contents[x][y][z].writeToNBT(cpt, mapping);
}
@ -178,7 +178,7 @@ public class Blueprint extends BlueprintBase {
for (SchematicEntity s : entities) {
NBTTagCompound subNBT = new NBTTagCompound();
s.idsToSchematic(mapping);
s.idsToBlueprint(mapping);
s.writeToNBT(subNBT, mapping);
entitiesNBT.appendTag(subNBT);
}
@ -218,19 +218,25 @@ public class Blueprint extends BlueprintBase {
if (block != null) {
contents[x][y][z] = SchematicRegistry.newSchematicBlock(block);
contents[x][y][z].readFromNBT(cpt, mapping);
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;
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;
}
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;

View file

@ -64,7 +64,7 @@ public abstract class BlueprintBase {
for (int y = 0; y < sizeY; ++y) {
for (int z = 0; z < sizeZ; ++z) {
if (contents [x][y][z] != null) {
contents[x][y][z].translateToSchematic(transform);
contents[x][y][z].translateToBlueprint(transform);
}
}
}

View file

@ -298,13 +298,24 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}
try {
if (!slot.isAlreadyBuilt(context)) {
if (BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
// if the block can't be broken, just forget this iterator
iterator.remove();
if (slot.mode == Mode.ClearIfInvalid) {
clearedLocations.add(new BlockIndex(slot.x,
slot.y, slot.z));
} else {
builtLocations.add(new BlockIndex(slot.x,
slot.y, slot.z));
}
} else if (!slot.isAlreadyBuilt(context)) {
if (slot.mode == Mode.ClearIfInvalid) {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y,
slot.z)
|| BlockUtil.isUnbreakableBlock(world, slot.x,
slot.y, slot.z)) {
slot.z)) {
iterator.remove();
clearedLocations.add(new BlockIndex(slot.x,
slot.y, slot.z));
} else {
if (setupForDestroy(builder, context, slot)) {
iterator.remove();
@ -387,7 +398,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
try {
LinkedList<ItemStack> req = new LinkedList<ItemStack>();
slot.writeRequirementsToBuilder(context, req);
slot.writeRequirementsToWorld(context, req);
for (ItemStack stk : req) {
if (stk != null) {

View file

@ -12,7 +12,9 @@ import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.blueprints.SchematicBlockBase;
import buildcraft.api.blueprints.SchematicRegistry;
import buildcraft.api.core.BuildCraftAPI;
@ -152,9 +154,15 @@ public class BptBuilderTemplate extends BptBuilderBase {
return null;
}
if (slot.mode == Mode.ClearIfInvalid) {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)
|| BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
if (BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
iterator.remove();
if (slot.mode == Mode.ClearIfInvalid) {
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
} else {
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
}
} else if (slot.mode == Mode.ClearIfInvalid) {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
iterator.remove();
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
} else {

View file

@ -88,7 +88,7 @@ public class BuildingSlotBlock extends BuildingSlot {
} else {
LinkedList<ItemStack> req = new LinkedList<ItemStack>();
getSchematic().writeRequirementsToBuilder(context, req);
getSchematic().writeRequirementsToWorld(context, req);
return req;
}

View file

@ -39,7 +39,7 @@ public class BuildingSlotEntity extends BuildingSlot {
@Override
public Position getDestination () {
NBTTagList nbttaglist = schematic.cpt.getTagList("Pos", 6);
NBTTagList nbttaglist = schematic.entityNBT.getTagList("Pos", 6);
Position pos = new Position(nbttaglist.func_150309_d(0),
nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));

View file

@ -8,11 +8,10 @@
*/
package buildcraft.core.proxy;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Random;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
@ -25,14 +24,14 @@ import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
@ -48,7 +47,7 @@ public class CoreProxy implements ICoreProxy {
public static CoreProxy proxy;
/* BUILDCRAFT PLAYER */
protected static EntityPlayer buildCraftPlayer;
protected static WeakReference<EntityPlayer> buildCraftPlayer = new WeakReference<EntityPlayer>(null);
public String getMinecraftVersion() {
return Loader.instance().getMinecraftModContainer().getVersion();
@ -142,66 +141,38 @@ public class CoreProxy implements ICoreProxy {
return "";
}
private EntityPlayer createNewPlayer(World world) {
EntityPlayer player = new EntityPlayer(world, new GameProfile (null, "[BuildCraft]")) {
@Override
public void addChatMessage(IChatComponent var1) {
}
private WeakReference<EntityPlayer> createNewPlayer(WorldServer world) {
EntityPlayer player = FakePlayerFactory.get(world, BuildCraftCore.gameProfile);
@Override
public boolean canCommandSenderUseCommand(int var1, String var2) {
return false;
}
@Override
public ChunkCoordinates getPlayerCoordinates() {
return null;
}
};
return player;
return new WeakReference<EntityPlayer>(player);
}
private EntityPlayer createNewPlayer(World world, int x, int y, int z) {
EntityPlayer player = new EntityPlayer(world, new GameProfile (null, "[BuildCraft]")) {
@Override
public void addChatMessage(IChatComponent var1) {
}
@Override
public boolean canCommandSenderUseCommand(int var1, String var2) {
return false;
}
@Override
public ChunkCoordinates getPlayerCoordinates() {
return null;
}
};
player.posX = x;
private WeakReference<EntityPlayer> createNewPlayer(WorldServer world, int x, int y, int z) {
EntityPlayer player = FakePlayerFactory.get(world, BuildCraftCore.gameProfile);
player.posY = y;
player.posZ = z;
return player;
return new WeakReference<EntityPlayer>(player);
}
@Override
public EntityPlayer getBuildCraftPlayer(World world) {
if (CoreProxy.buildCraftPlayer == null) {
public final WeakReference<EntityPlayer> getBuildCraftPlayer(WorldServer world) {
if (CoreProxy.buildCraftPlayer.get() == null) {
CoreProxy.buildCraftPlayer = createNewPlayer(world);
} else {
CoreProxy.buildCraftPlayer.worldObj = world;
CoreProxy.buildCraftPlayer.get().worldObj = world;
}
return CoreProxy.buildCraftPlayer;
}
public EntityPlayer getBuildCraftPlayer(World world, int x, int y, int z) {
if (CoreProxy.buildCraftPlayer == null) {
public final WeakReference<EntityPlayer> getBuildCraftPlayer(WorldServer world, int x, int y, int z) {
if (CoreProxy.buildCraftPlayer.get() == null) {
CoreProxy.buildCraftPlayer = createNewPlayer(world, x, y, z);
} else {
CoreProxy.buildCraftPlayer.worldObj = world;
CoreProxy.buildCraftPlayer.posX = x;
CoreProxy.buildCraftPlayer.posY = y;
CoreProxy.buildCraftPlayer.posZ = z;
CoreProxy.buildCraftPlayer.get().worldObj = world;
CoreProxy.buildCraftPlayer.get().posX = x;
CoreProxy.buildCraftPlayer.get().posY = y;
CoreProxy.buildCraftPlayer.get().posZ = z;
}
return CoreProxy.buildCraftPlayer;

View file

@ -10,8 +10,6 @@ package buildcraft.core.proxy;
import java.util.List;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
@ -24,8 +22,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import cpw.mods.fml.client.FMLClientHandler;
@ -121,35 +117,6 @@ public class CoreProxyClient extends CoreProxy {
return FMLClientHandler.instance().getClient().thePlayer.getDisplayName();
}
private EntityPlayer createNewPlayer(World world) {
EntityPlayer player = new EntityPlayer(world, new GameProfile(null, "[BuildCraft]")) {
@Override
public void addChatMessage(IChatComponent var1) {
}
@Override
public boolean canCommandSenderUseCommand(int var1, String var2) {
return false;
}
@Override
public ChunkCoordinates getPlayerCoordinates() {
return null;
}
};
return player;
}
@Override
public EntityPlayer getBuildCraftPlayer(World world) {
if (CoreProxy.buildCraftPlayer == null) {
CoreProxy.buildCraftPlayer = createNewPlayer(world);
}
return CoreProxy.buildCraftPlayer;
}
@Override
public EntityBlock newEntityBlock(World world, double i, double j, double k, double iSize, double jSize, double kSize, LaserKind laserKind) {
EntityBlock eb = super.newEntityBlock(world, i, j, k, iSize, jSize, kSize, laserKind);

View file

@ -15,6 +15,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
@ -85,7 +86,7 @@ public class EntityRobotBuilder extends EntityRobot implements
if (buildEnergy >= 25) {
buildingStack.getItem().onItemUse(buildingStack,
CoreProxy.proxy.getBuildCraftPlayer(worldObj),
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) worldObj).get(),
worldObj, x, y - 1, z, 1, 0.0f, 0.0f, 0.0f);
buildingStack = null;

View file

@ -21,6 +21,7 @@ import net.minecraft.network.play.server.S27PacketExplosion;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import cpw.mods.fml.common.FMLCommonHandler;
@ -44,7 +45,7 @@ public final class BlockUtil {
private BlockUtil() {
}
public static List<ItemStack> getItemStackFromBlock(World world, int i, int j, int k) {
public static List<ItemStack> getItemStackFromBlock(WorldServer world, int i, int j, int k) {
Block block = world.getBlock(i, j, k);
if (block == null) {
@ -58,7 +59,8 @@ public final class BlockUtil {
int meta = world.getBlockMetadata(i, j, k);
ArrayList<ItemStack> dropsList = block.getDrops(world, i, j, k, meta, 0);
float dropChance = ForgeEventFactory.fireBlockHarvesting(dropsList, world, block, i, j, k, meta, 0, 1.0F, false, CoreProxy.proxy.getBuildCraftPlayer(world));
float dropChance = ForgeEventFactory.fireBlockHarvesting(dropsList, world, block, i, j, k, meta, 0, 1.0F,
false, CoreProxy.proxy.getBuildCraftPlayer(world).get());
ArrayList<ItemStack> returnList = new ArrayList<ItemStack>();
for (ItemStack s : dropsList) {
@ -70,11 +72,11 @@ public final class BlockUtil {
return returnList;
}
public static void breakBlock(World world, int x, int y, int z) {
public static void breakBlock(WorldServer world, int x, int y, int z) {
breakBlock(world, x, y, z, BuildCraftCore.itemLifespan);
}
public static void breakBlock(World world, int x, int y, int z, int forcedLifespan) {
public static void breakBlock(WorldServer world, int x, int y, int z, int forcedLifespan) {
if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
List<ItemStack> items = getItemStackFromBlock(world, x, y, z);

View file

@ -21,25 +21,25 @@ public class SchematicEngine extends SchematicTile {
@Override
public void rotateLeft(IBuilderContext context) {
int o = cpt.getInteger("orientation");
int o = tileNBT.getInteger("orientation");
o = ForgeDirection.values()[o].getRotation(ForgeDirection.UP).ordinal();
cpt.setInteger("orientation", o);
tileNBT.setInteger("orientation", o);
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
super.writeToSchematic(context, x, y, z);
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeToBlueprint(context, x, y, z);
TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z);
cpt.setInteger("orientation", engine.orientation.ordinal());
cpt.removeTag("progress");
cpt.removeTag("energy");
cpt.removeTag("heat");
cpt.removeTag("tankFuel");
cpt.removeTag("tankCoolant");
tileNBT.setInteger("orientation", engine.orientation.ordinal());
tileNBT.removeTag("progress");
tileNBT.removeTag("energy");
tileNBT.removeTag("heat");
tileNBT.removeTag("tankFuel");
tileNBT.removeTag("tankCoolant");
}
@Override
@ -48,7 +48,7 @@ public class SchematicEngine extends SchematicTile {
TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z);
engine.orientation = ForgeDirection.getOrientation(cpt.getInteger("orientation"));
engine.orientation = ForgeDirection.getOrientation(tileNBT.getInteger("orientation"));
engine.sendNetworkUpdate();
}
@ -57,7 +57,7 @@ public class SchematicEngine extends SchematicTile {
TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z);
if (engine != null) {
engine.orientation = ForgeDirection.getOrientation(cpt.getInteger("orientation"));
engine.orientation = ForgeDirection.getOrientation(tileNBT.getInteger("orientation"));
engine.sendNetworkUpdate();
context.world().markBlockForUpdate(x, y, z);
context.world().notifyBlocksOfNeighborChange(x, y, z, block);

View file

@ -8,7 +8,7 @@
*/
package buildcraft.factory;
import com.mojang.authlib.GameProfile;
import java.lang.ref.WeakReference;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@ -20,8 +20,7 @@ import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
@ -32,6 +31,7 @@ import buildcraft.core.inventory.InventoryConcatenator;
import buildcraft.core.inventory.InventoryIterator;
import buildcraft.core.inventory.SimpleInventory;
import buildcraft.core.inventory.StackHelper;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.CraftingHelper;
import buildcraft.core.utils.Utils;
@ -50,7 +50,6 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
private IInventory inv = InventoryConcatenator.make().add(resultInv).add(craftMatrix);
private EntityPlayer internalPlayer;
private SlotCrafting craftSlot;
private InventoryCraftResult craftResult = new InventoryCraftResult();
@ -68,30 +67,8 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
}
}
private final class InternalPlayer extends EntityPlayer {
public InternalPlayer() {
super(TileAutoWorkbench.this.worldObj, new GameProfile(null, "[BuildCraft]"));
posX = TileAutoWorkbench.this.xCoord;
posY = TileAutoWorkbench.this.yCoord + 1;
posZ = TileAutoWorkbench.this.zCoord;
}
@Override
public void addChatMessage(IChatComponent var1) {
}
@Override
public boolean canCommandSenderUseCommand(int var1, String var2) {
return false;
}
@Override
public ChunkCoordinates getPlayerCoordinates() {
return null;
}
public WeakReference<EntityPlayer> getInternalPlayer() {
return CoreProxy.proxy.getBuildCraftPlayer((WorldServer) worldObj, xCoord, yCoord + 1, zCoord);
}
@Override
@ -194,6 +171,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
@Override
public void updateEntity() {
super.updateEntity();
if (worldObj.isRemote) {
return;
}
@ -201,8 +179,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
balanceSlots();
if (craftSlot == null) {
internalPlayer = new InternalPlayer();
craftSlot = new SlotCrafting(internalPlayer, craftMatrix, craftResult, 0, 0, 0);
craftSlot = new SlotCrafting(getInternalPlayer().get(), craftMatrix, craftResult, 0, 0, 0);
}
if (resultInv.getStackInSlot(SLOT_RESULT) != null) {
return;
@ -269,11 +246,11 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
return;
}
result = result.copy();
craftSlot.onPickupFromSlot(internalPlayer, result);
craftSlot.onPickupFromSlot(getInternalPlayer().get(), result);
resultInv.setInventorySlotContents(SLOT_RESULT, result);
// clean fake player inventory (crafting handler support)
for (IInvSlot slot : InventoryIterator.getIterable(internalPlayer.inventory, ForgeDirection.UP)) {
for (IInvSlot slot : InventoryIterator.getIterable(getInternalPlayer().get().inventory, ForgeDirection.UP)) {
ItemStack stack = slot.getStackInSlot();
if (stack != null) {
slot.setStackInSlot(null);

View file

@ -13,7 +13,10 @@ import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftFactory;
import buildcraft.api.gates.IAction;
@ -36,6 +39,10 @@ public class TileMiningWell extends TileBuildCraft implements IMachine {
*/
@Override
public void updateEntity () {
if (worldObj.isRemote) {
return;
}
float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier;
if (mjStored < mj) {
@ -59,7 +66,7 @@ public class TileMiningWell extends TileBuildCraft implements IMachine {
boolean wasAir = world.isAirBlock(xCoord, depth, zCoord);
List<ItemStack> stacks = BlockUtil.getItemStackFromBlock(worldObj, xCoord, depth, zCoord);
List<ItemStack> stacks = BlockUtil.getItemStackFromBlock((WorldServer) worldObj, xCoord, depth, zCoord);
world.setBlock(xCoord, depth, zCoord, BuildCraftFactory.plainPipeBlock);

View file

@ -23,6 +23,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
@ -415,7 +416,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
// Share this with mining well!
List<ItemStack> stacks = BlockUtil.getItemStackFromBlock(worldObj, i, j, k);
List<ItemStack> stacks = BlockUtil.getItemStackFromBlock((WorldServer) worldObj, i, j, k);
if (stacks != null) {
for (ItemStack s : stacks) {

View file

@ -204,7 +204,8 @@ public class TileTank extends TileBuildCraft implements IFluidHandler {
if (resource == null) {
return null;
}
if (!resource.isFluidEqual(tank.getFluid())) {
TileTank bottom = getBottomTank();
if (!resource.isFluidEqual(bottom.tank.getFluid())) {
return null;
}
return drain(from, resource.amount, doDrain);

View file

@ -0,0 +1,48 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.factory.schematics;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import buildcraft.BuildCraftFactory;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicTile;
public class SchematicPump extends SchematicTile {
@Override
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(BuildCraftFactory.pumpBlock));
}
@Override
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}
@Override
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeToBlueprint(context, x, y, z);
tileNBT.removeTag("tank");
tileNBT.removeTag("mjStored");
}
@Override
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
context.world().setBlock(x, y, z, block, 0, 3);
}
@Override
public BuildingStage getBuildStage() {
return BuildingStage.STANDALONE;
}
}

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.factory;
package buildcraft.factory.schematics;
import java.util.LinkedList;
@ -14,44 +14,46 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftFactory;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicTile;
public class SchematicRefinery extends SchematicTile {
@Override
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(BuildCraftFactory.refineryBlock));
}
@Override
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}
@Override
public void rotateLeft(IBuilderContext context) {
meta = ForgeDirection.values()[meta].getRotation(ForgeDirection.UP).ordinal();
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z);
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeToBlueprint(context, x, y, z);
// slot.cpt.setInteger("filter0", refinery.getFilter(0));
// slot.cpt.setInteger("filter1", refinery.getFilter(1));
tileNBT.removeTag("tank1");
tileNBT.removeTag("tank2");
tileNBT.removeTag("result");
tileNBT.removeTag("mjStored");
}
@Override
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
// to support refineries coming from older blueprints
tileNBT.removeTag("tank1");
tileNBT.removeTag("tank2");
tileNBT.removeTag("result");
tileNBT.removeTag("mjStored");
super.writeToWorld(context, x, y, z, stacks);
TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z);
int filter0 = cpt.getInteger("filter0");
int filter1 = cpt.getInteger("filter1");
int filterMeta0 = 0;
int filterMeta1 = 0;
if (cpt.hasKey("filterMeta0")) {
filterMeta0 = cpt.getInteger("filterMeta0");
}
if (cpt.hasKey("filterMeta1")) {
filterMeta1 = cpt.getInteger("filterMeta1");
}
// refinery.setFilter(0, filter0, filterMeta0);
// refinery.setFilter(1, filter1, filterMeta1);
}
}

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.factory;
package buildcraft.factory.schematics;
import java.util.LinkedList;
@ -18,17 +18,17 @@ import buildcraft.api.blueprints.SchematicTile;
public class SchematicTank extends SchematicTile {
@Override
public void writeRequirementsToBuilder(IBuilderContext context, LinkedList<ItemStack> requirements) {
public void writeRequirementsToWorld(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block));
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
}

View file

@ -8,12 +8,12 @@
*/
package buildcraft.silicon;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@ -26,8 +26,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
@ -47,6 +46,7 @@ import buildcraft.core.inventory.filters.CraftingFilter;
import buildcraft.core.inventory.filters.IStackFilter;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketSlotChange;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.ActionMachineControl;
import buildcraft.core.utils.CraftingHelper;
import buildcraft.core.utils.StringUtils;
@ -64,7 +64,6 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
private SlotCrafting craftSlot;
private boolean craftable;
private boolean justCrafted;
private InternalPlayer internalPlayer;
private IRecipe currentRecipe;
private TileBuffer[] cache;
private InventoryCraftResult craftResult;
@ -90,6 +89,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
@Override
public void setInventorySlotContents(int slotId, ItemStack itemstack) {
super.setInventorySlotContents(slotId, itemstack);
if (TileAdvancedCraftingTable.this.getWorldObj() == null || !TileAdvancedCraftingTable.this.getWorldObj().isRemote) {
oreIDs[slotId] = itemstack == null ? -1 : OreDictionary.getOreID(itemstack);
}
@ -139,9 +139,11 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
return result;
} else {
ItemStack result = tempStacks[bindings[slot]].splitStack(amount);
if (tempStacks[bindings[slot]].stackSize <= 0) {
tempStacks[bindings[slot]] = null;
}
return result;
}
} else {
@ -154,30 +156,6 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
}
}
private final class InternalPlayer extends EntityPlayer {
public InternalPlayer() {
super(TileAdvancedCraftingTable.this.getWorldObj(), new GameProfile(null, "[BuildCraft]"));
posX = TileAdvancedCraftingTable.this.xCoord;
posY = TileAdvancedCraftingTable.this.yCoord + 1;
posZ = TileAdvancedCraftingTable.this.zCoord;
}
@Override
public void addChatMessage(IChatComponent var1) {
}
@Override
public boolean canCommandSenderUseCommand(int var1, String var2) {
return false;
}
@Override
public ChunkCoordinates getPlayerCoordinates() {
return null;
}
}
public TileAdvancedCraftingTable() {
craftingSlots = new CraftingGrid();
inv.addListener(this);
@ -186,6 +164,10 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
craftResult = new InventoryCraftResult();
}
public WeakReference<EntityPlayer> getInternalPlayer() {
return CoreProxy.proxy.getBuildCraftPlayer((WorldServer) worldObj, xCoord, yCoord + 1, zCoord);
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
@ -241,10 +223,14 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
@Override
public void updateEntity() {
super.updateEntity();
if (internalPlayer == null) {
if (worldObj.isRemote) {
return;
}
if (internalInventoryCrafting == null) {
internalInventoryCrafting = new InternalInventoryCrafting();
internalPlayer = new InternalPlayer();
craftSlot = new SlotCrafting(internalPlayer, internalInventoryCrafting, craftResult, 0, 0, 0);
craftSlot = new SlotCrafting(getInternalPlayer().get(), internalInventoryCrafting, craftResult, 0, 0, 0);
updateRecipe();
}
if (worldObj.isRemote) {
@ -286,16 +272,21 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
internalInventoryCrafting.tempStacks = new InventoryCopy(inv).getItemStacks();
internalInventoryCrafting.hitCount = new int[internalInventoryCrafting.tempStacks.length];
ItemStack[] inputSlots = internalInventoryCrafting.tempStacks;
for (int gridSlot = 0; gridSlot < craftingSlots.getSizeInventory(); gridSlot++) {
internalInventoryCrafting.bindings[gridSlot] = -1;
if (craftingSlots.getStackInSlot(gridSlot) == null) {
continue;
}
boolean foundMatch = false;
for (int inputSlot = 0; inputSlot < inputSlots.length; inputSlot++) {
if (!isMatchingIngredient(gridSlot, inputSlot)) {
continue;
}
if (internalInventoryCrafting.hitCount[inputSlot] < inputSlots[inputSlot].stackSize
&& internalInventoryCrafting.hitCount[inputSlot] < inputSlots[inputSlot].getMaxStackSize()) {
internalInventoryCrafting.bindings[gridSlot] = inputSlot;
@ -304,6 +295,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
break;
}
}
if (!foundMatch) {
return;
}
@ -312,16 +304,14 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
private boolean isMatchingIngredient(int gridSlot, int inputSlot) {
ItemStack inputStack = internalInventoryCrafting.tempStacks[inputSlot];
if (inputStack == null) {
return false;
}
if (StackHelper.isMatchingItem(craftingSlots.getStackInSlot(gridSlot), inputStack, true, false)) {
} else if (StackHelper.isMatchingItem(craftingSlots.getStackInSlot(gridSlot), inputStack, true, false)) {
return true;
} else {
return StackHelper.isCraftingEquivalent(craftingSlots.oreIDs[gridSlot], inputStack);
}
if (StackHelper.isCraftingEquivalent(craftingSlots.oreIDs[gridSlot], inputStack)) {
return true;
}
return false;
}
private boolean hasIngredients() {
@ -329,28 +319,36 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
}
private void craftItem() {
EntityPlayer internalPlayer = getInternalPlayer().get();
ItemStack recipeOutput = getRecipeOutput();
craftSlot.onPickupFromSlot(internalPlayer, recipeOutput);
ItemStack[] tempStorage = internalInventoryCrafting.tempStacks;
for (int i = 0; i < tempStorage.length; i++) {
if (tempStorage[i] != null && tempStorage[i].stackSize <= 0) {
tempStorage[i] = null;
}
inv.getItemStacks()[i] = tempStorage[i];
}
subtractEnergy(getRequiredEnergy());
List<ItemStack> outputs = Lists.newArrayList(recipeOutput.copy());
for (int i = 0; i < internalPlayer.inventory.mainInventory.length; i++) {
if (internalPlayer.inventory.mainInventory[i] != null) {
outputs.add(internalPlayer.inventory.mainInventory[i]);
internalPlayer.inventory.mainInventory[i] = null;
}
}
for (ItemStack output : outputs) {
output.stackSize -= Transactor.getTransactorFor(invOutput).add(output, ForgeDirection.UP, true).stackSize;
if (output.stackSize > 0) {
output.stackSize -= Utils.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, output);
}
if (output.stackSize > 0) {
InvUtils.dropItems(worldObj, output, xCoord, yCoord + 1, zCoord);
}
@ -361,18 +359,24 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
if (cache == null) {
cache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false);
}
for (IInvSlot slot : InventoryIterator.getIterable(craftingSlots, ForgeDirection.UP)) {
ItemStack ingred = slot.getStackInSlot();
if (ingred == null) {
continue;
}
IStackFilter filter = new CraftingFilter(ingred);
if (InvUtils.countItems(invInput, ForgeDirection.UP, filter) < InvUtils.countItems(craftingSlots, ForgeDirection.UP, filter)) {
for (ForgeDirection side : SEARCH_SIDES) {
TileEntity tile = cache[side.ordinal()].getTile();
if (tile instanceof IInventory) {
IInventory inv = InvUtils.getInventory((IInventory) tile);
ItemStack result = InvUtils.moveOneItem(inv, side.getOpposite(), invInput, side, filter);
if (result != null) {
return;
}
@ -385,6 +389,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
public void updateCraftingMatrix(int slot, ItemStack stack) {
craftingSlots.setInventorySlotContents(slot, stack);
updateRecipe();
if (worldObj.isRemote) {
PacketSlotChange packet = new PacketSlotChange(PacketIds.ADVANCED_WORKBENCH_SETSLOT, xCoord, yCoord, zCoord, slot, stack);
BuildCraftSilicon.instance.sendToServer(packet);
@ -395,10 +400,13 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
if (internalInventoryCrafting == null) {
return;
}
internalInventoryCrafting.recipeUpdate(true);
if (this.currentRecipe == null || !this.currentRecipe.matches(internalInventoryCrafting, worldObj)) {
currentRecipe = CraftingHelper.findMatchingRecipe(internalInventoryCrafting, worldObj);
}
internalInventoryCrafting.recipeUpdate(false);
markDirty();
}
@ -408,12 +416,15 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
craftResult.setInventorySlotContents(0, null);
return;
}
ItemStack resultStack = getRecipeOutput();
if (resultStack == null) {
internalInventoryCrafting.recipeUpdate(true);
resultStack = getRecipeOutput();
internalInventoryCrafting.recipeUpdate(false);
}
craftResult.setInventorySlotContents(0, resultStack);
markDirty();
}
@ -421,8 +432,9 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
private ItemStack getRecipeOutput() {
if (internalInventoryCrafting == null || currentRecipe == null) {
return null;
} else {
return currentRecipe.getCraftingResult(internalInventoryCrafting);
}
return currentRecipe.getCraftingResult(internalInventoryCrafting);
}
public IInventory getCraftingSlots() {

View file

@ -14,9 +14,9 @@ import buildcraft.api.blueprints.SchematicTile;
public class SchematicLaserTableBase extends SchematicTile {
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
super.writeToSchematic(context, x, y, z);
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
super.writeToBlueprint(context, x, y, z);
cpt.removeTag("energy");
tileNBT.removeTag("energy");
}
}

View file

@ -22,7 +22,10 @@ import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position;
@ -102,13 +105,13 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> {
if (convertPipe(transport, event.item)) {
BuildCraftTransport.pipeItemsStripes.onItemUse(new ItemStack(
BuildCraftTransport.pipeItemsStripes), CoreProxy
.proxy.getBuildCraftPlayer(getWorld()), getWorld(), (int) p.x,
.proxy.getBuildCraftPlayer((WorldServer) getWorld()).get(), getWorld(), (int) p.x,
(int) p.y, (int) p.z, 1, 0, 0, 0
);
} else if (stack.getItem() instanceof ItemBlock) {
if (getWorld().getBlock((int) p.x, (int) p.y, (int) p.z) == Blocks.air) {
stack.tryPlaceItemIntoWorld(
CoreProxy.proxy.getBuildCraftPlayer(getWorld()),
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld()).get(),
getWorld(), (int) p.x, (int) p.y, (int) p.z, 1, 0.0f, 0.0f,
0.0f);
}
@ -118,13 +121,14 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> {
if (block instanceof BlockLeavesBase) {
getWorld().playSoundEffect((int) p.x, (int) p.y, (int) p.z, Block.soundTypeGrass.getBreakSound(), 1, 1);
getWorld().setBlockToAir((int) p.x, (int) p.y, (int) p.z);
stack.damageItem(1, CoreProxy.proxy.getBuildCraftPlayer(getWorld()));
stack.damageItem(1, CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld()).get());
}
} else if (stack.getItem() == Items.arrow) {
stack.stackSize--;
ForgeDirection direction = event.direction;
EntityArrow entityArrow = new EntityArrow(getWorld(), CoreProxy.proxy.getBuildCraftPlayer(getWorld()), 0);
EntityArrow entityArrow = new EntityArrow(getWorld(),
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld()).get(), 0);
entityArrow.setPosition(p.x + 0.5d, p.y + 0.5d, p.z + 0.5d);
entityArrow.setDamage(3);
entityArrow.setKnockbackStrength(1);
@ -135,8 +139,8 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> {
} else if ((stack.getItem() == Items.potionitem && ItemPotion.isSplash(stack.getItemDamage()))
|| stack.getItem() == Items.egg
|| stack.getItem() == Items.snowball) {
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer(getWorld(),
(int) p.x, (int) p.y, (int) p.z);
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(),
(int) p.x, (int) p.y, (int) p.z).get();
switch (event.direction) {
case DOWN:
@ -170,8 +174,8 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> {
stack.getItem().onItemRightClick(
stack,
getWorld(),
CoreProxy.proxy.getBuildCraftPlayer(getWorld(),
(int) p.x, (int) p.y, (int) p.z));
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(),
(int) p.x, (int) p.y, (int) p.z).get());
} else if (getWorld().getBlock((int) p.x, (int) p.y, (int) p.z) == Blocks.air) {
if (stack.getItem() instanceof ItemBucket) {
Block underblock = getWorld().getBlock((int) p.x, (int) p.y - 1, (int) p.z);
@ -201,12 +205,12 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> {
}
} else {
stack.tryPlaceItemIntoWorld(
CoreProxy.proxy.getBuildCraftPlayer(getWorld()),
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld()).get(),
getWorld(), (int) p.x, (int) p.y - 1, (int) p.z, 1, 0.0f, 0.0f, 0.0f);
}
} else {
stack.tryPlaceItemIntoWorld(
CoreProxy.proxy.getBuildCraftPlayer(getWorld()),
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld()).get(),
getWorld(), (int) p.x, (int) p.y, (int) p.z, 1, 0.0f, 0.0f,
0.0f);
}

View file

@ -26,7 +26,7 @@ public class BptItemPipeFilters extends BptPipeExtension {
public void rotateLeft(SchematicTile slot, IBuilderContext context) {
SimpleInventory inv = new SimpleInventory(54, "Filters", 1);
SimpleInventory newInv = new SimpleInventory(54, "Filters", 1);
inv.readFromNBT(slot.cpt);
inv.readFromNBT(slot.tileNBT);
for (int dir = 0; dir <= 5; ++dir) {
ForgeDirection r = ForgeDirection.values()[dir].getRotation(ForgeDirection.UP);
@ -36,6 +36,6 @@ public class BptItemPipeFilters extends BptPipeExtension {
}
}
newInv.writeToNBT(slot.cpt);
newInv.writeToNBT(slot.tileNBT);
}
}

View file

@ -39,7 +39,7 @@ public class SchematicPipe extends SchematicTile {
Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
if (BlockGenericPipe.isValid(pipe)) {
return pipe.item == Item.getItemById(cpt.getInteger("pipeId"));
return pipe.item == Item.getItemById(tileNBT.getInteger("pipeId"));
} else {
return false;
}
@ -49,17 +49,17 @@ public class SchematicPipe extends SchematicTile {
public void rotateLeft(IBuilderContext context) {
SideProperties props = new SideProperties ();
props.readFromNBT(cpt);
props.readFromNBT(tileNBT);
props.rotateLeft();
props.writeToNBT(cpt);
props.writeToNBT(tileNBT);
Item pipeItem = Item.getItemById(cpt.getInteger("pipeId"));
Item pipeItem = Item.getItemById(tileNBT.getInteger("pipeId"));
if (BptPipeExtension.contains(pipeItem)) {
BptPipeExtension.get(pipeItem).rotateLeft(this, context);
}
NBTTagCompound gateNBT = cpt.getCompoundTag("Gate");
NBTTagCompound gateNBT = tileNBT.getCompoundTag("Gate");
for (int i = 0; i < 8; ++i) {
if (gateNBT.hasKey("trigger[" + i + "]")) {
@ -78,44 +78,44 @@ public class SchematicPipe extends SchematicTile {
@Override
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
cpt.setInteger("x", x);
cpt.setInteger("y", y);
cpt.setInteger("z", z);
tileNBT.setInteger("x", x);
tileNBT.setInteger("y", y);
tileNBT.setInteger("z", z);
context.world().setBlock(x, y, z, block, meta, 3);
TileEntity tile = context.world().getTileEntity(x, y, z);
tile.readFromNBT(cpt);
tile.readFromNBT(tileNBT);
}
@Override
public void writeToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeToBlueprint(IBuilderContext context, int x, int y, int z) {
TileEntity tile = context.world().getTileEntity(x, y, z);
Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
if (BlockGenericPipe.isValid(pipe)) {
tile.writeToNBT(cpt);
tile.writeToNBT(tileNBT);
// remove all pipe contents
cpt.removeTag("travelingEntities");
tileNBT.removeTag("travelingEntities");
for (ForgeDirection direction : ForgeDirection.values()) {
cpt.removeTag("tank[" + direction.ordinal() + "]");
cpt.removeTag("transferState[" + direction.ordinal() + "]");
tileNBT.removeTag("tank[" + direction.ordinal() + "]");
tileNBT.removeTag("transferState[" + direction.ordinal() + "]");
}
for (int i = 0; i < 6; ++i) {
cpt.removeTag("powerQuery[" + i + "]");
cpt.removeTag("nextPowerQuery[" + i + "]");
cpt.removeTag("internalPower[" + i + "]");
cpt.removeTag("internalNextPower[" + i + "]");
tileNBT.removeTag("powerQuery[" + i + "]");
tileNBT.removeTag("nextPowerQuery[" + i + "]");
tileNBT.removeTag("internalPower[" + i + "]");
tileNBT.removeTag("internalNextPower[" + i + "]");
}
}
}
@Override
public void writeRequirementsToSchematic(IBuilderContext context, int x, int y, int z) {
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z) {
TileEntity tile = context.world().getTileEntity(x, y, z);
Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
@ -130,7 +130,7 @@ public class SchematicPipe extends SchematicTile {
@Override
public void postProcessing(IBuilderContext context, int x, int y, int z) {
Item pipeItem = Item.getItemById(cpt.getInteger("pipeId"));
Item pipeItem = Item.getItemById(tileNBT.getInteger("pipeId"));
if (BptPipeExtension.contains(pipeItem)) {
BptPipeExtension.get(pipeItem).postProcessing(this, context);
@ -143,13 +143,13 @@ public class SchematicPipe extends SchematicTile {
}
@Override
public void idsToSchematic(MappingRegistry registry) {
super.idsToSchematic(registry);
public void idsToBlueprint(MappingRegistry registry) {
super.idsToBlueprint(registry);
if (cpt.hasKey("pipeId")) {
Item item = Item.getItemById(cpt.getInteger("pipeId"));
if (tileNBT.hasKey("pipeId")) {
Item item = Item.getItemById(tileNBT.getInteger("pipeId"));
cpt.setInteger("pipeId", registry.getIdForItem(item));
tileNBT.setInteger("pipeId", registry.getIdForItem(item));
}
}
@ -157,13 +157,13 @@ public class SchematicPipe extends SchematicTile {
public void idsToWorld(MappingRegistry registry) {
super.idsToWorld(registry);
if (cpt.hasKey("pipeId")) {
if (tileNBT.hasKey("pipeId")) {
try {
Item item = registry.getItemForId(cpt.getInteger("pipeId"));
Item item = registry.getItemForId(tileNBT.getInteger("pipeId"));
cpt.setInteger("pipeId", Item.getIdFromItem(item));
tileNBT.setInteger("pipeId", Item.getIdFromItem(item));
} catch (MappingNotFoundException e) {
cpt.removeTag("pipeId");
tileNBT.removeTag("pipeId");
}
}
}
@ -183,10 +183,10 @@ public class SchematicPipe extends SchematicTile {
// translation badly broken. We need to flush out information that
// would be otherwise corrupted - that is the inventory (with the
// old formalism "items") and gate parameters.
cpt.removeTag("items");
tileNBT.removeTag("items");
if (cpt.hasKey("Gate")) {
NBTTagCompound gateNBT = cpt.getCompoundTag("Gate");
if (tileNBT.hasKey("Gate")) {
NBTTagCompound gateNBT = tileNBT.getCompoundTag("Gate");
for (int i = 0; i < 8; ++i) {
if (gateNBT.hasKey("triggerParameters[" + i + "]")) {