made progress in destroy animation, for #1571

This commit is contained in:
SpaceToad 2014-04-05 00:09:31 +02:00
parent c3c3a3d3f0
commit 49ef1c9c29
5 changed files with 31 additions and 0 deletions

View file

@ -131,6 +131,10 @@ public class Schematic {
}
public void writeCompleted(IBuilderContext context, int x, int y, int z, double completed) {
}
/**
* 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.
@ -168,4 +172,6 @@ public class Schematic {
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
}
}

View file

@ -55,4 +55,12 @@ public class SchematicMask extends Schematic {
requirements.add(new ItemStack(Blocks.brick_block));
}
@Override
public void writeCompleted(IBuilderContext context, int x, int y, int z, double completed) {
if (!isConcrete) {
context.world().destroyBlockInWorldPartially(0, x, y, z,
(int) (completed * 10.0F) - 1);
}
}
}

View file

@ -20,6 +20,7 @@ import buildcraft.core.blueprints.IBuilder;
import buildcraft.core.network.NetworkData;
public class BuildingItem implements IBuilder {
@NetworkData
public Position origin, destination;
@ -48,6 +49,8 @@ public class BuildingItem implements IBuilder {
public BuildingSlot slotToBuild;
public IBuilderContext context;
public double receivedProgress = 0;
public void initialize () {
if (!initialized) {
double dx = destination.x - origin.x;
@ -143,6 +146,11 @@ public class BuildingItem implements IBuilder {
lifetimeDisplay = lifetime;
previousUpdate = new Date ().getTime();
if (slotToBuild != null && lifetime > maxLifetime) {
slotToBuild.writeCompleted(context, (lifetime - maxLifetime)
/ stacksToBuild.size());
}
}
public void displayUpdate () {

View file

@ -22,6 +22,10 @@ public abstract class BuildingSlot {
}
public void writeCompleted (IBuilderContext context, double complete) {
}
public void postProcessing (IBuilderContext context) {
}

View file

@ -113,4 +113,9 @@ public class BuildingSlotBlock extends BuildingSlot implements Comparable<Buildi
public Position getDestination () {
return new Position (x + 0.5, y + 0.5, z + 0.5);
}
@Override
public void writeCompleted (IBuilderContext context, double complete) {
getSchematic().writeCompleted(context, x, y, z, complete);
}
}