initial progress for #1503
This commit is contained in:
parent
9001521647
commit
6549ead866
5 changed files with 50 additions and 26 deletions
|
@ -43,6 +43,7 @@ public class BuildingItem implements IBuilder {
|
|||
double maxLifetime = 0;
|
||||
private boolean initialized = false;
|
||||
double vx, vy, vz;
|
||||
double maxHeight;
|
||||
|
||||
public BuildingSlot slotToBuild;
|
||||
public IBuilderContext context;
|
||||
|
@ -57,6 +58,16 @@ public class BuildingItem implements IBuilder {
|
|||
|
||||
maxLifetime = size * 7.0;
|
||||
|
||||
maxHeight = (5.0 + (destination.y - origin.y) / 2.0);
|
||||
|
||||
double a = maxLifetime / 2.0;
|
||||
double b = maxHeight;
|
||||
double c = Math.sqrt(a * a + b * b);
|
||||
|
||||
// Since the item is going to travel up as well, this is an
|
||||
// approximation of the additional distance to go through.
|
||||
maxLifetime += c * 2;
|
||||
|
||||
vx = dx / maxLifetime;
|
||||
vy = dy / maxLifetime;
|
||||
vz = dz / maxLifetime;
|
||||
|
@ -81,7 +92,7 @@ public class BuildingItem implements IBuilder {
|
|||
Position result = new Position ();
|
||||
|
||||
result.x = origin.x + vx * time;
|
||||
result.y = origin.y + vy * time + Math.sin(time / maxLifetime * Math.PI) * (5.0 + (destination.y - origin.y) / 2.0);
|
||||
result.y = origin.y + vy * time + Math.sin(time / maxLifetime * Math.PI) * maxHeight;
|
||||
result.z = origin.z + vz * time;
|
||||
|
||||
return result;
|
||||
|
|
|
@ -125,27 +125,6 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
|||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/*ItemStack stackToUse = null;
|
||||
int slotNum = 0;
|
||||
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
stackToUse = stack;
|
||||
slotNum = slot.getIndex();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (stackToUse != null && stackToUse.stackSize <= 0) {
|
||||
setInventorySlotContents(slotNum, null);
|
||||
}
|
||||
|
||||
if (done) {
|
||||
sendNetworkUpdate();
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
|||
i.destination = slot.getDestination();
|
||||
i.slotToBuild = slot;
|
||||
i.context = getContext();
|
||||
i.stacksToBuild = slot.getRequirements(getContext());
|
||||
i.stacksToBuild = slot.stackConsumed;
|
||||
builder.addBuildingItem(i);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -10,11 +10,16 @@ package buildcraft.core.blueprints;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.Schematic;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.builders.TileAbstractBuilder;
|
||||
import buildcraft.core.blueprints.BuildingSlotBlock.Mode;
|
||||
import buildcraft.core.inventory.InventoryIterator;
|
||||
import buildcraft.core.inventory.InventoryIterator.IInvSlot;
|
||||
|
||||
public class BptBuilderTemplate extends BptBuilderBase {
|
||||
|
||||
|
@ -110,19 +115,38 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
|||
public BuildingSlotBlock internalGetNextBlock(World world, TileAbstractBuilder inv, LinkedList<BuildingSlotBlock> list) {
|
||||
BuildingSlotBlock result = null;
|
||||
|
||||
IInvSlot firstSlotToConsume = null;
|
||||
|
||||
for (IInvSlot invSlot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) {
|
||||
ItemStack stack = invSlot.getStackInSlot();
|
||||
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
firstSlotToConsume = invSlot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (list.size() > 0) {
|
||||
BuildingSlotBlock slot = list.removeFirst();
|
||||
BuildingSlotBlock slot = list.getFirst();
|
||||
|
||||
if (slot.mode == Mode.ClearIfInvalid
|
||||
&& !BuildCraftAPI.softBlocks.contains(context.world()
|
||||
.getBlock(slot.x, slot.y, slot.z))) {
|
||||
slot.addStackConsumed(new ItemStack(BuildCraftBuilders.stripesBlock));
|
||||
result = slot;
|
||||
list.removeFirst();
|
||||
|
||||
break;
|
||||
} else if (slot.mode == Mode.Build
|
||||
&& BuildCraftAPI.softBlocks.contains(context.world()
|
||||
.getBlock(slot.x, slot.y, slot.z))) {
|
||||
result = slot;
|
||||
break;
|
||||
|
||||
if (firstSlotToConsume != null) {
|
||||
slot.addStackConsumed(firstSlotToConsume.decreaseStackInSlot());
|
||||
result = slot;
|
||||
list.removeFirst();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ import buildcraft.api.core.Position;
|
|||
|
||||
public abstract class BuildingSlot {
|
||||
|
||||
public LinkedList <ItemStack> stackConsumed;
|
||||
|
||||
public void writeToWorld(IBuilderContext context) {
|
||||
|
||||
}
|
||||
|
@ -29,4 +31,12 @@ public abstract class BuildingSlot {
|
|||
}
|
||||
|
||||
public abstract Position getDestination ();
|
||||
|
||||
public void addStackConsumed (ItemStack stack) {
|
||||
if (stackConsumed == null) {
|
||||
stackConsumed = new LinkedList<ItemStack>();
|
||||
}
|
||||
|
||||
stackConsumed.add (stack);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue