rewrite redstone engines, certain pipes among others; start work on #2075
This commit is contained in:
parent
8e025fede5
commit
dcb138bba3
13 changed files with 55 additions and 61 deletions
|
@ -38,6 +38,7 @@ public class BlockPathMarker extends BlockMarker {
|
|||
super.breakBlock(world, x, y, z, block, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "all" })
|
||||
// @Override (client only)
|
||||
public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
||||
|
|
|
@ -19,9 +19,6 @@ import java.util.ArrayList;
|
|||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
|
|
@ -10,9 +10,6 @@ package buildcraft.core;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
|
|
@ -11,8 +11,6 @@ package buildcraft.core.recipes;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ActionParameterDirection implements IActionParameter {
|
|||
if (direction == ForgeDirection.UNKNOWN) {
|
||||
return null;
|
||||
} else {
|
||||
return StatementIconProvider.INSTANCE.getIcon(StatementIconProvider.INSTANCE.Action_Parameter_Direction_Down + direction.ordinal());
|
||||
return StatementIconProvider.INSTANCE.getIcon(StatementIconProvider.Action_Parameter_Direction_Down + direction.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
@NetworkData
|
||||
public ForgeDirection orientation = ForgeDirection.UP;
|
||||
|
||||
protected boolean constantPower = false;
|
||||
protected int progressPart = 0;
|
||||
protected boolean lastPower = false;
|
||||
protected PowerHandler powerHandler;
|
||||
|
@ -203,16 +202,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshPowerMode(TileEntity tile, ForgeDirection orientation) {
|
||||
if (isPoweredTile(tile, orientation)) {
|
||||
if ((tile instanceof IPipeTile) && (((IPipeTile) tile).getPipeType() != PipeType.POWER)) {
|
||||
constantPower = false;
|
||||
} else {
|
||||
constantPower = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
@ -240,8 +229,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
switchOrientation(true);
|
||||
} else {
|
||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||
|
||||
refreshPowerMode(tile, orientation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,9 +243,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
if (progress > 0.5 && progressPart == 1) {
|
||||
progressPart = 2;
|
||||
if (!constantPower) {
|
||||
sendPower();
|
||||
}
|
||||
} else if (progress >= 1) {
|
||||
progress = 0;
|
||||
progressPart = 0;
|
||||
|
@ -284,7 +268,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
if (!isRedstonePowered) {
|
||||
currentOutput = 0;
|
||||
} else if (constantPower && isRedstonePowered && isActive()) {
|
||||
} else if (isRedstonePowered && isActive()) {
|
||||
sendPower();
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +282,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
int minEnergy = 0;
|
||||
int maxEnergy = handler.receiveEnergy(
|
||||
orientation.getOpposite(),
|
||||
(int) Math.round(this.energy), true);
|
||||
Math.round(this.energy), true);
|
||||
return extractEnergy(minEnergy, maxEnergy, false);
|
||||
} else if (tile instanceof IPowerReceptor) {
|
||||
PowerReceiver receptor = ((IPowerReceptor) tile)
|
||||
|
@ -314,7 +298,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
protected void sendPower() {
|
||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||
if (isPoweredTile(tile, orientation)) {
|
||||
double extracted = getPowerToExtract();
|
||||
int extracted = getPowerToExtract();
|
||||
if (extracted > 0) {
|
||||
setPumping(true);
|
||||
} else {
|
||||
|
@ -323,7 +307,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
if (tile instanceof IEnergyHandler) {
|
||||
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||
if (Math.round(extracted) > 0) {
|
||||
if (extracted > 0) {
|
||||
int neededRF = handler.receiveEnergy(
|
||||
orientation.getOpposite(),
|
||||
(int) Math.round(extracted), false);
|
||||
|
@ -397,8 +381,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
TileEntity tile = getTileBuffer(o).getTile();
|
||||
|
||||
if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
|
||||
refreshPowerMode(tile, o);
|
||||
|
||||
orientation = o;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
|
@ -440,9 +422,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
progress = data.getFloat("progress");
|
||||
energy = data.getInteger("energy");
|
||||
heat = data.getFloat("heat");
|
||||
if (data.hasKey("constantPower")) {
|
||||
constantPower = data.getBoolean("constantPower");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -453,18 +432,17 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
data.setFloat("progress", progress);
|
||||
data.setInteger("energy", energy);
|
||||
data.setFloat("heat", heat);
|
||||
data.setBoolean("constantPower", constantPower);
|
||||
}
|
||||
|
||||
public void getGUINetworkData(int id, int value) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
int iEnergy = (int) Math.round(energy);
|
||||
int iEnergy = Math.round(energy);
|
||||
iEnergy = (iEnergy & 0xffff0000) | (value & 0xffff);
|
||||
energy = iEnergy;
|
||||
break;
|
||||
case 1:
|
||||
iEnergy = (int) Math.round(energy);
|
||||
iEnergy = Math.round(energy);
|
||||
iEnergy = (iEnergy & 0xffff) | ((value & 0xffff) << 16);
|
||||
energy = iEnergy;
|
||||
break;
|
||||
|
@ -478,9 +456,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
}
|
||||
|
||||
public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 0, (int) Math.round(energy) & 0xffff);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, (int) (Math.round(energy) & 0xffff0000) >> 16);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 2, (int) Math.round(currentOutput));
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 0, Math.round(energy) & 0xffff);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, (Math.round(energy) & 0xffff0000) >> 16);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 2, Math.round(currentOutput));
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, Math.round(heat * 100));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -16,8 +17,6 @@ import buildcraft.api.transport.IPipeTile.PipeType;
|
|||
|
||||
public class TileEngineWood extends TileEngine {
|
||||
|
||||
public static final int OUTPUT = 1;
|
||||
|
||||
@Override
|
||||
public ResourceLocation getBaseTexture() {
|
||||
return BASE_TEXTURES[0];
|
||||
|
@ -103,7 +102,7 @@ public class TileEngineWood extends TileEngine {
|
|||
|
||||
@Override
|
||||
public int calculateCurrentOutput() {
|
||||
return OUTPUT;
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,13 +116,22 @@ public class TileEngineWood extends TileEngine {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean hasSent = false;
|
||||
|
||||
@Override
|
||||
protected void sendPower() {
|
||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||
if (tile instanceof IPipeTile && ((IPipeTile) tile).getPipeType() != PipeType.POWER) {
|
||||
super.sendPower();
|
||||
} else { // pretend we're sending out our powers
|
||||
this.energy = 0;
|
||||
if (progressPart == 2 && !hasSent) {
|
||||
hasSent = true;
|
||||
|
||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||
|
||||
if (tile instanceof IPipeTile && ((IPipeTile) tile).getPipeType() != PipeType.POWER) {
|
||||
super.sendPower();
|
||||
} else {
|
||||
this.energy = 0;
|
||||
}
|
||||
} else if (progressPart != 2) {
|
||||
hasSent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
|
|||
|
||||
@Override
|
||||
public int getProgressScaled(int i) {
|
||||
return (int) ((getEnergy() * i) / REQUIRED_POWER);
|
||||
return (getEnergy() * i) / REQUIRED_POWER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -88,7 +88,7 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergy
|
|||
super.updateEntity();
|
||||
|
||||
int meta = container.getBlockMetadata();
|
||||
|
||||
|
||||
if (liquidToExtract > 0 && meta < 6) {
|
||||
ForgeDirection side = ForgeDirection.getOrientation(meta);
|
||||
TileEntity tile = container.getTile(side);
|
||||
|
@ -131,7 +131,7 @@ public class PipeFluidsWood extends Pipe<PipeTransportFluids> implements IEnergy
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIconProvider getIconProvider() {
|
||||
|
|
|
@ -47,7 +47,8 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
|
|||
|
||||
private int[] entitiesDropped;
|
||||
private int entitiesDroppedIndex = 0;
|
||||
|
||||
private int ticks = 0;
|
||||
|
||||
public PipeItemsObsidian(Item item) {
|
||||
super(new PipeTransportItems(), item);
|
||||
|
||||
|
@ -149,7 +150,9 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
|
|||
public void updateEntity () {
|
||||
super.updateEntity();
|
||||
|
||||
if (battery.getEnergyStored() > 0) {
|
||||
ticks++;
|
||||
|
||||
if ((ticks % 16) == 0 && battery.getEnergyStored() > 0) {
|
||||
for (int j = 1; j < 5; ++j) {
|
||||
if (suckItem(j)) {
|
||||
return;
|
||||
|
@ -220,13 +223,11 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
|
|||
|
||||
int energyUsed = Math.min(10 * contained.stackSize * distance, battery.getEnergyStored());
|
||||
|
||||
// TODO: Why is energyUsed never used here?
|
||||
|
||||
if (distance == 0 || energyUsed / distance == contained.stackSize) {
|
||||
if (distance == 0 || energyUsed / distance / 10 == contained.stackSize) {
|
||||
stack = contained;
|
||||
CoreProxy.proxy.removeEntity(entity);
|
||||
} else {
|
||||
stack = contained.splitStack(energyUsed / distance);
|
||||
stack = contained.splitStack(energyUsed / distance / 10);
|
||||
}
|
||||
|
||||
speed = Math.sqrt(item.motionX * item.motionX + item.motionY * item.motionY + item.motionZ * item.motionZ);
|
||||
|
|
|
@ -41,6 +41,9 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHa
|
|||
protected int standardIconIndex = PipeIconProvider.TYPE.PipeItemsWood_Standard.ordinal();
|
||||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal();
|
||||
|
||||
private static final int RF_PER_ITEM = 10;
|
||||
private int ticks = 0;
|
||||
|
||||
private PipeLogicWood logic = new PipeLogicWood(this) {
|
||||
@Override
|
||||
protected boolean isValidConnectingTile(TileEntity tile) {
|
||||
|
@ -107,7 +110,9 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHa
|
|||
return;
|
||||
}
|
||||
|
||||
if (battery.getEnergyStored() > 0) {
|
||||
ticks++;
|
||||
|
||||
if (shouldTick()) {
|
||||
if (transport.getNumberOfStacks() < PipeTransportItems.MAX_PIPE_STACKS) {
|
||||
extractItems();
|
||||
}
|
||||
|
@ -115,6 +120,14 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHa
|
|||
battery.setEnergy(0);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldTick() {
|
||||
if (battery.getEnergyStored() >= 64 * RF_PER_ITEM) {
|
||||
return true;
|
||||
} else {
|
||||
return (ticks % 16) == 0 && battery.getEnergyStored() >= RF_PER_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
private void extractItems() {
|
||||
int meta = container.getBlockMetadata();
|
||||
|
@ -142,7 +155,7 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHa
|
|||
|
||||
for (ItemStack stack : extracted) {
|
||||
if (stack == null || stack.stackSize == 0) {
|
||||
battery.useEnergy(10, 10, false);
|
||||
battery.useEnergy(RF_PER_ITEM, RF_PER_ITEM, false);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -192,7 +205,7 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHa
|
|||
|
||||
if (slot != null && slot.stackSize > 0 && inventory.canExtractItem(k, slot, from.ordinal())) {
|
||||
if (doRemove) {
|
||||
int stackSize = battery.useEnergy(10, slot.stackSize * 10, false) / 10;
|
||||
int stackSize = battery.useEnergy(RF_PER_ITEM, slot.stackSize * RF_PER_ITEM, false) / RF_PER_ITEM;
|
||||
|
||||
return inventory.decrStackSize(k, stackSize);
|
||||
} else {
|
||||
|
|
|
@ -93,7 +93,7 @@ public final class FacadeRenderHelper {
|
|||
}
|
||||
|
||||
public static void pipeFacadeRenderer(RenderBlocks renderblocks, ITextureStates blockStateMachine, PipeRenderState state, int x, int y, int z) {
|
||||
ITextureStates textureManager = (ITextureStates) blockStateMachine;
|
||||
ITextureStates textureManager = blockStateMachine;
|
||||
IIcon[] textures = textureManager.getTextureState().popArray();
|
||||
|
||||
//block_statemachine.setRenderAllSides();
|
||||
|
|
|
@ -37,6 +37,7 @@ public final class FakeBlock extends Block implements ITextureStates {
|
|||
textureState = new TextureStateManager(null); //Always Clientside
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureStateManager getTextureState() {
|
||||
return textureState;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue