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;
|
double maxLifetime = 0;
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
double vx, vy, vz;
|
double vx, vy, vz;
|
||||||
|
double maxHeight;
|
||||||
|
|
||||||
public BuildingSlot slotToBuild;
|
public BuildingSlot slotToBuild;
|
||||||
public IBuilderContext context;
|
public IBuilderContext context;
|
||||||
|
@ -57,6 +58,16 @@ public class BuildingItem implements IBuilder {
|
||||||
|
|
||||||
maxLifetime = size * 7.0;
|
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;
|
vx = dx / maxLifetime;
|
||||||
vy = dy / maxLifetime;
|
vy = dy / maxLifetime;
|
||||||
vz = dz / maxLifetime;
|
vz = dz / maxLifetime;
|
||||||
|
@ -81,7 +92,7 @@ public class BuildingItem implements IBuilder {
|
||||||
Position result = new Position ();
|
Position result = new Position ();
|
||||||
|
|
||||||
result.x = origin.x + vx * time;
|
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;
|
result.z = origin.z + vz * time;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -125,27 +125,6 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
||||||
sendNetworkUpdate();
|
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
|
@Override
|
||||||
|
|
|
@ -49,7 +49,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
||||||
i.destination = slot.getDestination();
|
i.destination = slot.getDestination();
|
||||||
i.slotToBuild = slot;
|
i.slotToBuild = slot;
|
||||||
i.context = getContext();
|
i.context = getContext();
|
||||||
i.stacksToBuild = slot.getRequirements(getContext());
|
i.stacksToBuild = slot.stackConsumed;
|
||||||
builder.addBuildingItem(i);
|
builder.addBuildingItem(i);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -10,11 +10,16 @@ package buildcraft.core.blueprints;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import buildcraft.BuildCraftBuilders;
|
||||||
import buildcraft.api.blueprints.Schematic;
|
import buildcraft.api.blueprints.Schematic;
|
||||||
import buildcraft.api.core.BuildCraftAPI;
|
import buildcraft.api.core.BuildCraftAPI;
|
||||||
import buildcraft.builders.TileAbstractBuilder;
|
import buildcraft.builders.TileAbstractBuilder;
|
||||||
import buildcraft.core.blueprints.BuildingSlotBlock.Mode;
|
import buildcraft.core.blueprints.BuildingSlotBlock.Mode;
|
||||||
|
import buildcraft.core.inventory.InventoryIterator;
|
||||||
|
import buildcraft.core.inventory.InventoryIterator.IInvSlot;
|
||||||
|
|
||||||
public class BptBuilderTemplate extends BptBuilderBase {
|
public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
|
|
||||||
|
@ -110,19 +115,38 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
public BuildingSlotBlock internalGetNextBlock(World world, TileAbstractBuilder inv, LinkedList<BuildingSlotBlock> list) {
|
public BuildingSlotBlock internalGetNextBlock(World world, TileAbstractBuilder inv, LinkedList<BuildingSlotBlock> list) {
|
||||||
BuildingSlotBlock result = null;
|
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) {
|
while (list.size() > 0) {
|
||||||
BuildingSlotBlock slot = list.removeFirst();
|
BuildingSlotBlock slot = list.getFirst();
|
||||||
|
|
||||||
if (slot.mode == Mode.ClearIfInvalid
|
if (slot.mode == Mode.ClearIfInvalid
|
||||||
&& !BuildCraftAPI.softBlocks.contains(context.world()
|
&& !BuildCraftAPI.softBlocks.contains(context.world()
|
||||||
.getBlock(slot.x, slot.y, slot.z))) {
|
.getBlock(slot.x, slot.y, slot.z))) {
|
||||||
|
slot.addStackConsumed(new ItemStack(BuildCraftBuilders.stripesBlock));
|
||||||
result = slot;
|
result = slot;
|
||||||
|
list.removeFirst();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else if (slot.mode == Mode.Build
|
} else if (slot.mode == Mode.Build
|
||||||
&& BuildCraftAPI.softBlocks.contains(context.world()
|
&& BuildCraftAPI.softBlocks.contains(context.world()
|
||||||
.getBlock(slot.x, slot.y, slot.z))) {
|
.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 abstract class BuildingSlot {
|
||||||
|
|
||||||
|
public LinkedList <ItemStack> stackConsumed;
|
||||||
|
|
||||||
public void writeToWorld(IBuilderContext context) {
|
public void writeToWorld(IBuilderContext context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,4 +31,12 @@ public abstract class BuildingSlot {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Position getDestination ();
|
public abstract Position getDestination ();
|
||||||
|
|
||||||
|
public void addStackConsumed (ItemStack stack) {
|
||||||
|
if (stackConsumed == null) {
|
||||||
|
stackConsumed = new LinkedList<ItemStack>();
|
||||||
|
}
|
||||||
|
|
||||||
|
stackConsumed.add (stack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue