This commit is contained in:
CovertJaguar 2013-10-19 04:23:26 -07:00
commit 4d845eb5c5
33 changed files with 156 additions and 81 deletions

View file

@ -269,7 +269,6 @@ public class BuildCraftTransport {
pipeWaterproof = new ItemBuildCraft(pipeWaterproofId.getInt());
pipeWaterproof.setUnlocalizedName("pipeWaterproof");
pipeWaterproof.setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
LanguageRegistry.addName(pipeWaterproof, "Pipe Waterproof");
genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt());
CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class);

View file

@ -94,10 +94,12 @@ public final class PowerHandler {
* @return
*/
public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) {
// float prev = current;
current -= powerLoss * ticksPassed;
if (current < 0) {
current = 0;
}
// powerHandler.totalLostPower += prev - current;
return current;
}
@ -126,6 +128,11 @@ public final class PowerHandler {
private PerditionCalculator perdition;
private final PowerReceiver receiver;
private final Type type;
// Debug
// private double totalLostPower = 0;
// private double totalReceivedPower = 0;
// private double totalUsedPower = 0;
// private long startTime = -1;
public PowerHandler(IPowerReceptor receptor, Type type) {
this.receptor = receptor;
@ -235,6 +242,13 @@ public final class PowerHandler {
* design around this though if you are aware of the limitations.
*/
public void update() {
// if (startTime == -1)
// startTime = receptor.getWorld().getTotalWorldTime();
// else {
// long duration = receptor.getWorld().getTotalWorldTime() - startTime;
// System.out.printf("Power Stats: %s - Stored: %.2f Gained: %.2f - %.2f/t Lost: %.2f - %.2f/t Used: %.2f - %.2f/t%n", receptor.getClass().getSimpleName(), energyStored, totalReceivedPower, totalReceivedPower / duration, totalLostPower, totalLostPower / duration, totalUsedPower, totalUsedPower / duration);
// }
applyPerdition();
applyWork();
validateEnergy();
@ -303,6 +317,9 @@ public final class PowerHandler {
validateEnergy();
// if (doUse)
// totalUsedPower += result;
return result;
}
@ -396,9 +413,11 @@ public final class PowerHandler {
applyWork();
if (source == Type.ENGINE && type.eatsEngineExcess()) {
return Math.min(quantity, maxEnergyReceived);
used = Math.min(quantity, maxEnergyReceived);
}
// totalReceivedPower += used;
return used;
}
}

View file

@ -42,7 +42,7 @@ public class BlockArchitect extends BlockContainer {
public BlockArchitect(int i) {
super(i, Material.iron);
setHardness(5F);
//setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
//setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -32,7 +32,7 @@ public class BlockBlueprintLibrary extends BlockContainer {
public BlockBlueprintLibrary(int i) {
super(i, Material.wood);
//setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
//setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setHardness(5F);
}

View file

@ -38,7 +38,7 @@ public class BlockBuilder extends BlockContainer {
public BlockBuilder(int i) {
super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -39,7 +39,7 @@ public class BlockFiller extends BlockContainer {
super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -31,7 +31,7 @@ public class BlockMarker extends BlockContainer {
super(i, Material.circuits);
setLightValue(0.5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
private AxisAlignedBB getBoundingBox(int meta) {

View file

@ -27,7 +27,7 @@ public abstract class ItemBptBase extends ItemBuildCraft {
super(i);
maxStackSize = 1;
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@SuppressWarnings({ "all" })

View file

@ -14,7 +14,7 @@ public abstract class BlockBuildCraft extends BlockContainer {
protected BlockBuildCraft(int id, Material material) {
super(id, material);
this.rand = new Random();
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -45,7 +45,7 @@ public class BlockSpring extends Block {
setStepSound(soundStoneFootstep);
disableStats();
setTickRandomly(true);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -1,24 +1,59 @@
package buildcraft.core;
import buildcraft.BuildCraftCore;
import buildcraft.core.utils.Localization;
import buildcraft.transport.ItemFacade;
import java.util.Locale;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
public class CreativeTabBuildCraft extends CreativeTabs {
public enum CreativeTabBuildCraft {
public static final CreativeTabs tabBuildCraft = new CreativeTabBuildCraft("buildcraft");
public CreativeTabBuildCraft(String label) {
super(label);
MACHINES,
FACADES;
private final CreativeTabs tab;
private CreativeTabBuildCraft() {
tab = new Tab();
}
@Override
public ItemStack getIconItemStack() {
return new ItemStack(BuildCraftCore.diamondGearItem);
public CreativeTabs get() {
return tab;
}
@Override
public String getTranslatedTabLabel() {
return "BuildCraft";
private String getLabel() {
return "buildcraft." + name().toLowerCase(Locale.ENGLISH);
}
private String translate() {
return Localization.get("tab." + name().toLowerCase(Locale.ENGLISH));
}
private ItemStack getItem() {
switch (this) {
case FACADES:
return ItemFacade.getStack(Block.stoneBrick, 0);
default:
return new ItemStack(BuildCraftCore.diamondGearItem);
}
}
private class Tab extends CreativeTabs {
private Tab() {
super(getLabel());
}
@Override
public ItemStack getIconItemStack() {
return getItem();
}
@Override
public String getTranslatedTabLabel() {
return translate();
}
}
}

View file

@ -22,7 +22,7 @@ public class ItemBuildCraft extends Item {
public ItemBuildCraft(int i) {
super(i);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -164,7 +164,7 @@ public class RenderEntityBlock extends Render {
lightZ = (int) (Math.floor(entity.posZ) + kBase);
GL11.glDisable(2896 /* GL_LIGHTING */);
renderBlock(util, world, lightX, lightY, lightZ, false, true);
renderBlock(util, world, 0, 0, 0, lightX, lightY, lightZ, false, true);
GL11.glEnable(2896 /* GL_LIGHTING */);
GL11.glPopMatrix();
@ -206,7 +206,7 @@ public class RenderEntityBlock extends Render {
tessellator.setBrightness(brightness);
tessellator.setColorOpaque_F(lightBottom * light, lightBottom * light, lightBottom * light);
} else {
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
// tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
if (info.brightness >= 0)
tessellator.setBrightness(info.brightness);
}

View file

@ -49,7 +49,16 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
this.theIcon = new Icon[]{iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow")};
this.theIcon = new Icon[] { iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow") };
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) {
super.onNeighborBlockChange(world, x, y, z, blockId);
if (flammable && world.provider.dimensionId == -1) {
world.newExplosion(null, x, y, z, 4F, true, true);
world.setBlockToAir(x, y, z);
}
}
public BlockBuildcraftFluid setFlammable(boolean flammable) {
@ -82,13 +91,13 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
return flammable && flammability == 0;
}
public BlockBuildcraftFluid setParticleColor(float particleRed, float particleGreen, float particleBlue){
public BlockBuildcraftFluid setParticleColor(float particleRed, float particleGreen, float particleBlue) {
this.particleRed = particleRed;
this.particleGreen = particleGreen;
this.particleBlue = particleBlue;
return this;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
@ -98,21 +107,23 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
double px = (double) ((float) x + rand.nextFloat());
double py = (double) y - 1.05D;
double pz = (double) ((float) z + rand.nextFloat());
EntityFX fx = new EntityDropParticleFX(world, px, py, pz, particleRed, particleGreen, particleBlue);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlockMaterial(x, y, z).isLiquid()) return false;
if (world.getBlockMaterial(x, y, z).isLiquid())
return false;
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlockMaterial(x, y, z).isLiquid()) return false;
if (world.getBlockMaterial(x, y, z).isLiquid())
return false;
return super.displaceIfPossible(world, x, y, z);
}
}

View file

@ -35,7 +35,7 @@ public class BlockEngine extends BlockContainer {
super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setUnlocalizedName("engineBlock");
}

View file

@ -22,7 +22,7 @@ public class ItemBucketBuildcraft extends ItemBucket {
public ItemBucketBuildcraft(int i, int blockId) {
super(i, blockId);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setContainerItem(Item.bucketEmpty);
}

View file

@ -32,7 +32,7 @@ public class BlockFloodGate extends BlockContainer {
public BlockFloodGate(int i) {
super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -15,12 +15,12 @@ import buildcraft.core.IFramePipeConnection;
import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
@ -188,8 +188,8 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this));
public void getSubBlocks(int id, CreativeTabs tab, List list) {
list.add(new ItemStack(this));
}
@Override

View file

@ -20,7 +20,7 @@ public abstract class BlockMachineRoot extends BlockContainer {
protected BlockMachineRoot(int i, Material material) {
super(i, material);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setHardness(5F);
}

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 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
* 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;
import buildcraft.core.CoreConstants;
@ -14,10 +12,12 @@ import buildcraft.core.IFramePipeConnection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
@ -65,15 +65,13 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this));
public void getSubBlocks(int id, CreativeTabs tab, List list) {
list.add(new ItemStack(this));
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon("buildcraft:blockPlainPipe");
public void registerIcons(IconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon("buildcraft:blockPlainPipe");
}
}

View file

@ -32,7 +32,7 @@ public class BlockPump extends BlockContainer {
public BlockPump(int i) {
super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -43,7 +43,7 @@ public class BlockRefinery extends BlockContainer {
super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -37,7 +37,7 @@ public class BlockTank extends BlockContainer {
super(i, Material.glass);
setBlockBounds(0.125F, 0F, 0.125F, 0.875F, 1F, 0.875F);
setHardness(0.5F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -28,7 +28,7 @@ public class BlockLaser extends BlockContainer {
public BlockLaser(int i) {
super(i, Material.iron);
setHardness(10F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -27,7 +27,7 @@ public class BlockLaserTable extends BlockContainer {
setBlockBounds(0, 0, 0, 1, 9F / 16F, 1);
setHardness(10F);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -576,6 +576,23 @@ public class BlockGenericPipe extends BlockContainer {
return pipe.itemID;
}
@SideOnly(Side.CLIENT)
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer);
if (rayTraceResult != null && rayTraceResult.boundingBox != null) {
switch (rayTraceResult.hitPart) {
case Gate:
Pipe pipe = getPipe(world, x, y, z);
return pipe.gate.getGateItem();
case Plug:
return new ItemStack(BuildCraftTransport.plugItem);
}
}
return super.getPickBlock(target, world, x, y, z);
}
/* Wrappers ************************************************************ */
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
@ -691,7 +708,7 @@ public class BlockGenericPipe extends BlockContainer {
return true;
if (player.isSneaking()) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) {
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) {
if (stripGate(pipe))
return true;
}

View file

@ -153,7 +153,11 @@ public abstract class Gate {
// / UPDATING
public abstract void update();
public abstract void dropGate();
public abstract ItemStack getGateItem();
public void dropGate() {
pipe.dropItem(getGateItem());
}
public void resetGate() {
if (broadcastRedstone) {

View file

@ -140,7 +140,7 @@ public class GateVanilla extends Gate {
* @param k
*/
@Override
public void dropGate() {
public ItemStack getGateItem() {
int gateDamage;
switch (kind) {
@ -175,7 +175,7 @@ public class GateVanilla extends Gate {
gateItem = BuildCraftTransport.pipeGate;
}
pipe.dropItem(new ItemStack(gateItem, 1, gateDamage));
return new ItemStack(gateItem, 1, gateDamage);
}

View file

@ -17,15 +17,12 @@ import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class ItemFacade extends ItemBuildCraft {
@ -36,7 +33,7 @@ public class ItemFacade extends ItemBuildCraft {
setHasSubtypes(true);
setMaxDamage(0);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setCreativeTab(CreativeTabBuildCraft.FACADES.get());
}
@Override
@ -219,13 +216,13 @@ public class ItemFacade extends ItemBuildCraft {
Block bl = Block.blocksList[blockId];
// No Meta
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0xC) == 0)
return getStack(blockId, (blockMeta & 0x3) | 4);
return getStack(bl, (blockMeta & 0x3) | 4);
// Meta | 4 = true
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x8) == 0)
return getStack(blockId, (blockMeta & 0x3) | 8);
return getStack(bl, (blockMeta & 0x3) | 8);
// Meta | 8 = true
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x4) == 0)
return getStack(blockId, (blockMeta & 0x3));
return getStack(bl, (blockMeta & 0x3));
}
return null;
}
@ -253,6 +250,10 @@ public class ItemFacade extends ItemBuildCraft {
return 0;
}
public static ItemStack getStack(Block block, int metadata) {
return getStack(block.blockID, metadata);
}
public static ItemStack getStack(int blockID, int metadata) {
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
NBTTagCompound nbt = new NBTTagCompound("tag");

View file

@ -3,7 +3,6 @@ package buildcraft.transport;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.ITrigger;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemBuildCraft;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -45,7 +44,6 @@ public class ItemGate extends ItemBuildCraft {
setHasSubtypes(true);
setMaxDamage(0);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setPassSneakClick(true);
}

View file

@ -10,7 +10,6 @@ package buildcraft.transport;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.IItemPipe;
import buildcraft.core.ItemBuildCraft;
import cpw.mods.fml.relauncher.Side;
@ -32,7 +31,6 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
protected ItemPipe(int i) {
super(i);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
}
@Override

View file

@ -1,21 +1,16 @@
package buildcraft.transport;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemBuildCraft;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class ItemPlug extends ItemBuildCraft {
public ItemPlug(int i) {
super(i);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
}
@Override

View file

@ -278,17 +278,17 @@ public class PipeTransportItems extends PipeTransport {
result.add(o);
}
if (this.container.pipe instanceof IPipeTransportItemsHook) {
Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input);
result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item);
}
if (allowBouncing && result.isEmpty()) {
if (canReceivePipeObjects(item.input.getOpposite(), item)) {
result.add(item.input.getOpposite());
}
}
if (this.container.pipe instanceof IPipeTransportItemsHook) {
Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input);
result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item);
}
return result;
}