various experiments for BC NextGen

This commit is contained in:
SpaceToad 2014-02-01 17:19:07 +01:00
parent fef5ccbac1
commit 12cb51373e
59 changed files with 1545 additions and 206 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

View file

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 10
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1,45 @@
{
"animation": {
"frametime": 10,
"frames": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
18,
17,
16,
15,
14,
13,
12,
11,
10,
9,
8,
7,
6,
5,
4,
3,
2,
1
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

View file

@ -1,9 +1,10 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft;
@ -112,6 +113,7 @@ public class BuildCraftCore {
public static Item goldGearItem;
public static Item diamondGearItem;
public static Item wrenchItem;
public static Item redstoneCrystal;
@SideOnly(Side.CLIENT)
public static Icon redLaserTexture;
@SideOnly(Side.CLIENT)
@ -208,6 +210,7 @@ public class BuildCraftCore {
Property ironGearId = BuildCraftCore.mainConfiguration.getItem("ironGearItem.id", DefaultProps.IRON_GEAR_ID);
Property goldenGearId = BuildCraftCore.mainConfiguration.getItem("goldenGearItem.id", DefaultProps.GOLDEN_GEAR_ID);
Property diamondGearId = BuildCraftCore.mainConfiguration.getItem("diamondGearItem.id", DefaultProps.DIAMOND_GEAR_ID);
Property redstoneCrystalId = BuildCraftCore.mainConfiguration.getItem("redstoneCrystalItem.id", DefaultProps.REDSTONE_CRYSTAL_ID);
Property modifyWorldProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true);
modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)";
modifyWorld = modifyWorldProp.getBoolean(true);
@ -247,6 +250,11 @@ public class BuildCraftCore {
CoreProxy.proxy.registerItem(diamondGearItem);
OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem));
redstoneCrystal = (new ItemBuildCraft(redstoneCrystalId.getInt())).setUnlocalizedName("redstoneCrystal");
LanguageRegistry.addName(redstoneCrystal, "Redstone Crystal");
CoreProxy.proxy.registerItem(redstoneCrystal);
OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal));
Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false);
colorBlindProp.comment = "Set to true to enable alternate textures";
colorBlindMode = colorBlindProp.getBoolean(false);

View file

@ -1,16 +1,16 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft;
import buildcraft.api.fuels.IronEngineCoolant;
import buildcraft.api.fuels.IronEngineFuel;
import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.core.recipes.RefineryRecipeManager;
import buildcraft.core.BlockIndex;
import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps;
@ -20,6 +20,8 @@ import buildcraft.core.fluids.BCFluid;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.energy.BlockBuildcraftFluid;
import buildcraft.energy.BlockEnergyEmitter;
import buildcraft.energy.BlockEnergyReceiver;
import buildcraft.energy.BlockEngine;
import buildcraft.energy.BptBlockEngine;
import buildcraft.energy.EnergyProxy;
@ -27,6 +29,8 @@ import buildcraft.energy.GuiHandler;
import buildcraft.energy.ItemBucketBuildcraft;
import buildcraft.energy.ItemEngine;
import buildcraft.energy.BucketHandler;
import buildcraft.energy.TileEnergyEmitter;
import buildcraft.energy.TileEnergyReceiver;
import buildcraft.energy.TileEngine.EnergyStage;
import buildcraft.energy.triggers.TriggerEngineHeat;
import buildcraft.energy.worldgen.BiomeGenOilDesert;
@ -45,7 +49,9 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
@ -71,14 +77,20 @@ public class BuildCraftEnergy {
public static BiomeGenOilDesert biomeOilDesert;
public static BiomeGenOilOcean biomeOilOcean;
public static BlockEngine engineBlock;
public static BlockEnergyEmitter emitterBlock;
public static BlockEnergyReceiver receiverBlock;
private static Fluid buildcraftFluidOil;
private static Fluid buildcraftFluidFuel;
private static Fluid buildcraftFluidRedPlasma;
public static Fluid fluidOil;
public static Fluid fluidFuel;
public static Fluid fluidRedPlasma;
public static Block blockOil;
public static Block blockFuel;
public static Block blockRedPlasma;
public static Item bucketOil;
public static Item bucketFuel;
public static Item bucketRedPlasma;
public static Item fuel;
public static boolean canOilBurn;
public static double oilWellScalar = 1.0;
@ -103,8 +115,10 @@ public class BuildCraftEnergy {
int blockOilId = BuildCraftCore.mainConfiguration.getBlock("oil.id", defaultOilId).getInt(defaultOilId);
int blockFuelId = BuildCraftCore.mainConfiguration.getBlock("fuel.id", DefaultProps.FUEL_ID).getInt(DefaultProps.FUEL_ID);
int blockRedplasmaId = BuildCraftCore.mainConfiguration.getBlock("redPlasma.id", DefaultProps.REDPLASMA_ID).getInt(DefaultProps.REDPLASMA_ID);
int bucketOilId = BuildCraftCore.mainConfiguration.getItem("bucketOil.id", DefaultProps.BUCKET_OIL_ID).getInt(DefaultProps.BUCKET_OIL_ID);
int bucketFuelId = BuildCraftCore.mainConfiguration.getItem("bucketFuel.id", DefaultProps.BUCKET_FUEL_ID).getInt(DefaultProps.BUCKET_FUEL_ID);
int bucketRedPlasmaId = BuildCraftCore.mainConfiguration.getItem("bucketRedPlasma.id", DefaultProps.BUCKET_REDPLASMA_ID).getInt(DefaultProps.BUCKET_REDPLASMA_ID);
int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT);
int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN);
canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true);
@ -146,7 +160,6 @@ public class BuildCraftEnergy {
// Oil and fuel
buildcraftFluidOil = new BCFluid("oil").setDensity(800).setViscosity(1500);
FluidRegistry.registerFluid(buildcraftFluidOil);
fluidOil = FluidRegistry.getFluid("oil");
@ -154,6 +167,12 @@ public class BuildCraftEnergy {
FluidRegistry.registerFluid(buildcraftFluidFuel);
fluidFuel = FluidRegistry.getFluid("fuel");
buildcraftFluidRedPlasma = new BCFluid("redplasma").setDensity(10000).setViscosity(10000).setLuminosity(30);
FluidRegistry.registerFluid(buildcraftFluidRedPlasma);
fluidRedPlasma = FluidRegistry.getFluid("redplasma");
//buildcraftFluidRedPlasma = new BCFluid("fuel");
if (fluidOil.getBlockID() == -1) {
if (blockOilId > 0) {
blockOil = new BlockBuildcraftFluid(blockOilId, fluidOil, Material.water).setFlammable(canOilBurn).setFlammability(0);
@ -184,6 +203,18 @@ public class BuildCraftEnergy {
blockFuel = Block.blocksList[fluidFuel.getBlockID()];
}
if (fluidRedPlasma.getBlockID() == -1) {
if (blockRedplasmaId > 0) {
blockRedPlasma = new BlockBuildcraftFluid(blockRedplasmaId, fluidRedPlasma, Material.water).setFlammable(false).setParticleColor(0.9F, 0, 0);
blockRedPlasma.setUnlocalizedName("blockRedPlasma");
CoreProxy.proxy.addName(blockRedPlasma, "Red Plasma");
CoreProxy.proxy.registerBlock(blockRedPlasma);
fluidRedPlasma.setBlockID(blockRedPlasma);
}
} else {
blockRedPlasma = Block.blocksList[fluidRedPlasma.getBlockID()];
}
// Buckets
if (blockOil != null && bucketOilId > 0) {
@ -202,8 +233,17 @@ public class BuildCraftEnergy {
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty));
}
if (blockRedPlasma != null && bucketRedPlasmaId > 0) {
bucketRedPlasma = new ItemBucketBuildcraft(bucketRedPlasmaId, blockRedPlasma.blockID);
bucketRedPlasma.setUnlocalizedName("bucketRedPlasma").setContainerItem(Item.bucketEmpty);
LanguageRegistry.addName(bucketRedPlasma, "Red Plasma Bucket");
CoreProxy.proxy.registerItem(bucketRedPlasma);
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("redplasma", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketRedPlasma), new ItemStack(Item.bucketEmpty));
}
BucketHandler.INSTANCE.buckets.put(blockOil, bucketOil);
BucketHandler.INSTANCE.buckets.put(blockFuel, bucketFuel);
BucketHandler.INSTANCE.buckets.put(blockRedPlasma, bucketRedPlasma);
MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
BuildcraftRecipes.refinery.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1);
@ -217,6 +257,20 @@ public class BuildCraftEnergy {
IronEngineCoolant.addCoolant(FluidRegistry.getFluid("water"), 0.0023F);
IronEngineCoolant.addCoolant(Block.ice.blockID, 0, FluidRegistry.getFluidStack("water", FluidContainerRegistry.BUCKET_VOLUME * 2));
// Receiver / emitter
Property emitterId = BuildCraftCore.mainConfiguration.getBlock("energyEmitter.id", DefaultProps.EMITTER_ID);
emitterBlock = new BlockEnergyEmitter (emitterId.getInt());
CoreProxy.proxy.registerBlock(emitterBlock.setUnlocalizedName("energyEmitterBlock"));
CoreProxy.proxy.addName(emitterBlock, "Energy Emitter");
CoreProxy.proxy.registerTileEntity(TileEnergyEmitter.class, "net.minecraft.src.builders.TileEnergyEmitter");
Property receiverId = BuildCraftCore.mainConfiguration.getBlock("energyReceiver.id", DefaultProps.RECEIVER_ID);
receiverBlock = new BlockEnergyReceiver (receiverId.getInt());
CoreProxy.proxy.registerBlock(receiverBlock.setUnlocalizedName("energyReceiverBlock"));
CoreProxy.proxy.addName(receiverBlock, "Energy Receiver");
CoreProxy.proxy.registerTileEntity(TileEnergyReceiver.class, "net.minecraft.src.builders.TileEnergyReceiver");
MinecraftForge.EVENT_BUS.register(this);
}
@ -247,6 +301,7 @@ public class BuildCraftEnergy {
if (event.map.textureType == 0) {
buildcraftFluidOil.setIcons(blockOil.getBlockTextureFromSide(1), blockOil.getBlockTextureFromSide(2));
buildcraftFluidFuel.setIcons(blockFuel.getBlockTextureFromSide(1), blockFuel.getBlockTextureFromSide(2));
buildcraftFluidRedPlasma.setIcons(blockRedPlasma.getBlockTextureFromSide(1), blockRedPlasma.getBlockTextureFromSide(2));
}
}

View file

@ -1,9 +1,10 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft;

View file

@ -1,9 +1,10 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft;

View file

@ -1,9 +1,10 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft;
@ -70,6 +71,7 @@ import buildcraft.transport.pipes.PipeItemsWood;
import buildcraft.transport.pipes.PipePowerCobblestone;
import buildcraft.transport.pipes.PipePowerDiamond;
import buildcraft.transport.pipes.PipePowerGold;
import buildcraft.transport.pipes.PipePowerHeat;
import buildcraft.transport.pipes.PipePowerIron;
import buildcraft.transport.pipes.PipePowerIron.PowerMode;
import buildcraft.transport.pipes.PipePowerQuartz;
@ -101,7 +103,9 @@ import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
@ -149,6 +153,7 @@ public class BuildCraftTransport {
public static Item pipePowerIron;
public static Item pipePowerGold;
public static Item pipePowerDiamond;
public static Item pipePowerHeat;
public static ItemFacade facadeItem;
public static Item plugItem;
public static BlockFilteredBuffer filteredBufferBlock;
@ -305,6 +310,7 @@ public class BuildCraftTransport {
pipePowerIron = buildPipe(DefaultProps.PIPE_POWER_IRON_ID, PipePowerIron.class, "Iron Kinesis Pipe", Item.redstone, pipeItemsIron);
pipePowerGold = buildPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Kinesis Pipe", Item.redstone, pipeItemsGold);
pipePowerDiamond = buildPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Kinesis Pipe", Item.redstone, pipeItemsDiamond);
pipePowerHeat = buildPipe(DefaultProps.PIPE_POWER_HEAT_ID, PipePowerHeat.class, "Heat Kinesis Pipe", Block.furnaceIdle, pipeItemsDiamond);
pipeStructureCobblestone = buildPipe(DefaultProps.PIPE_STRUCTURE_COBBLESTONE_ID, PipeStructureCobblestone.class, "Cobblestone Structure Pipe", Block.gravel, pipeItemsCobblestone);

View file

@ -157,7 +157,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
}
}
RPCHandler.rpcBroadcastPlayers(this, "setName", DefaultProps.NETWORK_UPDATE_RANGE, name);
RPCHandler.rpcBroadcastPlayersAtDistance(this, "setName", DefaultProps.NETWORK_UPDATE_RANGE, name);
}
@RPC

View file

@ -0,0 +1,84 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import java.util.Iterator;
import net.minecraft.block.Block;
import net.minecraft.world.World;
public class BlockScanner implements Iterable<BlockWrapper> {
Box box;
World world;
int x, y, z;
int iterations;
class BlockIt implements Iterator<BlockWrapper> {
int it = 0;
@Override
public boolean hasNext() {
return it <= iterations;
}
@Override
public BlockWrapper next() {
if (x <= box.xMax) {
x++;
} else {
x = box.xMin;
if (y <= box.yMax) {
y++;
} else {
y = box.yMin;
if (z <= box.zMax) {
z++;
} else {
z = box.zMin;
}
}
}
it++;
BlockWrapper w = new BlockWrapper();
w.index = new BlockIndex(x, y, z);
w.block = Block.blocksList [world.getBlockId(x, y, z)];
w.tile = world.getBlockTileEntity(x, y, z);
return w;
}
@Override
public void remove() {
}
}
public BlockScanner (Box box, World world, int iterations) {
this.box = box;
this.world = world;
this.iterations = iterations;
x = box.xMin;
y = box.yMin;
z = box.zMin;
}
@Override
public Iterator<BlockWrapper> iterator() {
return new BlockIt();
}
}

View file

@ -0,0 +1,18 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
public class BlockWrapper {
public BlockIndex index;
public TileEntity tile;
public Block block;
}

View file

@ -37,9 +37,11 @@ public class DefaultProps {
public static int TEMPLATE_ITEM_ID = 19105;
public static int WRENCH_ID = 19106;
public static int BUCKET_OIL_ID = 19107;
public static int REDSTONE_CRYSTAL_ID = 19108;
public static int PIPE_WATERPROOF_ID = 19109;
public static int BUCKET_FUEL_ID = 19110;
public static int GATE_ID = 19111;
public static int BUCKET_REDPLASMA_ID = 19112;
public static int PIPE_WIRE = 19113;
public static int REDSTONE_CHIPSET = 19117;
public static int BLUEPRINT_ITEM_ID = 19118;
@ -85,6 +87,7 @@ public class DefaultProps {
public static int PIPE_POWER_QUARTZ_ID = 19208;
public static int PIPE_POWER_LAPIS_ID = 19209;
public static int PIPE_POWER_DIAZULI_ID = 19210;
public static int PIPE_POWER_HEAT_ID = 19211;
public static int PIPE_ITEMS_VOID_ID = 19220;
public static int PIPE_LIQUIDS_VOID_ID = 19221;
@ -115,10 +118,14 @@ public class DefaultProps {
public static int FILTERED_BUFFER_ID = 1523;
public static int FLOOD_GATE_ID = 1524;
public static int RECEIVER_ID = 1525;
public static int EMITTER_ID = 1526;
public static int OIL_ID = 1530;
public static int FUEL_ID = 1531;
public static int REDPLASMA_ID = 1532;
public static int URBANIST_ID = 1532;
public static int URBANIST_ID = 1533;
public static boolean CURRENT_CONTINUOUS = false;
public static double PIPES_DURABILITY = 0.25D;

View file

@ -1,14 +1,17 @@
/**
* Copyright (c) SpaceToad, 2011
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
/**
* This interface is used to provide special renders of tiles in the player
* inventory.
*/
public interface IInventoryRenderer {
public void inventoryRender(double x, double y, double z, float f, float f1);

View file

@ -7,7 +7,13 @@ public class LaserData {
public double renderSize = 0;
public double angleY = 0;
public double angleZ = 0;
public boolean isVisible = false;
public boolean isVisible = true;
public double wavePosition = 0;
public int laserTexAnimation = 0;
// Size of the wave, from 0 to 1
public float waveSize = 1F;
public void update () {
double dx = head.x - tail.x;
@ -17,6 +23,10 @@ public class LaserData {
renderSize = Math.sqrt(dx * dx + dy * dy + dz * dz);
angleZ = 360 - (Math.atan2(dz, dx) * 180.0 / Math.PI + 180.0);
dx = Math.sqrt(renderSize * renderSize - dy * dy);
angleY = -Math.atan2(dy, dx) * 180 / Math.PI;
angleY = -Math.atan2(dy, dx) * 180.0 / Math.PI;
}
public void iterateTexture () {
laserTexAnimation = (laserTexAnimation + 1) % 40;
}
}

View file

@ -0,0 +1,26 @@
package buildcraft.core;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
public class ReflectAPI {
public static String KEY_MJ_STORED = "_MJ_STORED";
static Map <Class, Field> MAP_MJ_STORED = new HashMap <Class, Field> ();
public static Field get_MJ_STORED (Class c) {
if (!MAP_MJ_STORED.containsKey(c)) {
for (Field f : c.getFields()) {
if (f.getName().equals(KEY_MJ_STORED)) {
return MAP_MJ_STORED.put(c, f);
}
}
return MAP_MJ_STORED.put(c, null);
} else {
return MAP_MJ_STORED.get(c);
}
}
}

View file

@ -1,8 +1,9 @@
/**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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.core;
@ -17,7 +18,7 @@ public final class TileBuffer {
private int blockID = 0;
private TileEntity tile;
private final SafeTimeTracker tracker = new SafeTimeTracker();
private final SafeTimeTracker tracker = new SafeTimeTracker(20, 5);
private final World world;
final int x, y, z;
private final boolean loadUnloaded;
@ -35,12 +36,15 @@ public final class TileBuffer {
public final void refresh() {
tile = null;
blockID = 0;
if (!loadUnloaded && !world.blockExists(x, y, z)) {
return;
}
blockID = world.getBlockId(this.x, this.y, this.z);
Block block = Block.blocksList[blockID];
if (block != null && block.hasTileEntity(world.getBlockMetadata(this.x, this.y, this.z))) {
tile = world.getBlockTileEntity(this.x, this.y, this.z);
}
@ -53,10 +57,11 @@ public final class TileBuffer {
}
public int getBlockID() {
if (tile != null && !tile.isInvalid())
if (tile != null && !tile.isInvalid()) {
return blockID;
}
if (tracker.markTimeIfDelay(world, 20)) {
if (tracker.markTimeIfDelay(world)) {
refresh();
if (tile != null && !tile.isInvalid())
@ -67,31 +72,37 @@ public final class TileBuffer {
}
public TileEntity getTile() {
if (tile != null && !tile.isInvalid())
if (tile != null && !tile.isInvalid()) {
return tile;
}
if (tracker.markTimeIfDelay(world, 20)) {
if (tracker.markTimeIfDelay(world)) {
refresh();
if (tile != null && !tile.isInvalid())
if (tile != null && !tile.isInvalid()) {
return tile;
}
}
return null;
}
public boolean exists() {
if(tile != null && !tile.isInvalid())
if(tile != null && !tile.isInvalid()) {
return true;
}
return world.blockExists(x, y, z);
}
public static TileBuffer[] makeBuffer(World world, int x, int y, int z, boolean loadUnloaded) {
TileBuffer[] buffer = new TileBuffer[6];
for (int i = 0; i < 6; i++) {
ForgeDirection d = ForgeDirection.getOrientation(i);
buffer[i] = new TileBuffer(world, x + d.offsetX, y + d.offsetY, z + d.offsetZ, loadUnloaded);
}
return buffer;
}
}

View file

@ -3,8 +3,8 @@ package buildcraft.core.network;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import buildcraft.transport.TileGenericPipe;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
@ -13,7 +13,6 @@ import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.repackage.com.nothome.delta.DebugDiffWriter;
public class PacketHandler implements IPacketHandler {
@ -69,8 +68,8 @@ public class PacketHandler implements IPacketHandler {
break;
}
case PacketIds.RPC: {
PacketRPC rpc = new PacketRPC();
case PacketIds.RPC_TILE: {
PacketRPCTile rpc = new PacketRPCTile();
rpc.sender = (EntityPlayer) player;
int dimId = data.readShort();
@ -99,6 +98,39 @@ public class PacketHandler implements IPacketHandler {
break;
}
case PacketIds.RPC_PIPE: {
PacketRPCPipe rpc = new PacketRPCPipe();
rpc.sender = (EntityPlayer) player;
int dimId = data.readShort();
World world = null;
if (!rpc.sender.worldObj.isRemote) {
// if this is a server, then get the world
world = DimensionManager.getProvider(dimId).worldObj;
} else if (rpc.sender.worldObj.provider.dimensionId == dimId) {
// if the player is on this world, then synchronize things
world = rpc.sender.worldObj;
}
if (world != null) {
int x = data.readInt();
int y = data.readInt();
int z = data.readInt();
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileGenericPipe) {
rpc.setPipe (((TileGenericPipe) tile).pipe);
rpc.readData(data);
}
}
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();

View file

@ -42,5 +42,6 @@ public class PacketIds {
public static final int STATE_UPDATE = 100;
public static final int RPC = 110;
public static final int RPC_TILE = 110;
public static final int RPC_PIPE = 111;
}

View file

@ -0,0 +1,49 @@
package buildcraft.core.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import buildcraft.transport.Pipe;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
public class PacketRPCPipe extends BuildCraftPacket {
public Pipe pipe;
byte [] contents;
public EntityPlayer sender;
public PacketRPCPipe () {
}
public PacketRPCPipe (byte [] bytes) {
contents = bytes;
}
public void setPipe (Pipe aPipe) {
pipe = aPipe;
}
@Override
public int getID() {
return PacketIds.RPC_PIPE;
}
@Override
public void readData(DataInputStream data) throws IOException {
RPCMessageInfo info = new RPCMessageInfo();
info.sender = sender;
RPCHandler.receiveRPC(pipe, info, data);
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.write(contents);
}
}

View file

@ -7,11 +7,7 @@ import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import org.bouncycastle.crypto.util.Pack;
import cpw.mods.fml.common.network.Player;
public class PacketRPC extends BuildCraftPacket {
public class PacketRPCTile extends BuildCraftPacket {
public TileEntity tile;
@ -19,11 +15,11 @@ public class PacketRPC extends BuildCraftPacket {
public EntityPlayer sender;
public PacketRPC () {
public PacketRPCTile () {
}
public PacketRPC (byte [] bytes) {
public PacketRPCTile (byte [] bytes) {
contents = bytes;
}
@ -33,7 +29,7 @@ public class PacketRPC extends BuildCraftPacket {
@Override
public int getID() {
return PacketIds.RPC;
return PacketIds.RPC_TILE;
}
@Override

View file

@ -12,7 +12,9 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.TreeMap;
import buildcraft.core.DefaultProps;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.Pipe;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
@ -67,6 +69,8 @@ public class RPCHandler {
// accepted
} else if (mapping.parameters [j].equals(char.class)) {
// accepted
} else if (mapping.parameters [j].equals(float.class)) {
// accepted
} else if (mapping.parameters [j].equals(String.class)) {
// accepted
} else if (mapping.parameters [j].equals(RPCMessageInfo.class)) {
@ -88,7 +92,7 @@ public class RPCHandler {
handlers.put (tile.getClass().getName(), new RPCHandler (tile.getClass()));
}
PacketRPC packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
if (packet != null) {
CoreProxy.proxy.sendToServer(packet.getPacket());
@ -100,19 +104,27 @@ public class RPCHandler {
handlers.put (tile.getClass().getName(), new RPCHandler (tile.getClass()));
}
PacketRPC packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
if (packet != null) {
CoreProxy.proxy.sendToPlayer(player, packet);
}
}
public static void rpcBroadcastPlayers (TileEntity tile, String method, int maxDistance, Object ... actuals) {
public static void rpcBroadcastDefaultPlayers (Pipe pipe, String method, Object ... actuals) {
RPCHandler.rpcBroadcastPlayers(pipe, method, DefaultProps.NETWORK_UPDATE_RANGE, actuals);
}
public static void rpcBroadcastPlayers (TileEntity tile, String method, Object ... actuals) {
RPCHandler.rpcBroadcastPlayersAtDistance(tile, method, DefaultProps.NETWORK_UPDATE_RANGE, actuals);
}
public static void rpcBroadcastPlayersAtDistance (TileEntity tile, String method, int maxDistance, Object ... actuals) {
if (!handlers.containsKey(tile.getClass().getName())) {
handlers.put (tile.getClass().getName(), new RPCHandler (tile.getClass()));
}
PacketRPC packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
if (packet != null) {
for (Object o : tile.worldObj.playerEntities) {
@ -127,15 +139,109 @@ public class RPCHandler {
}
}
public static void rpcBroadcastPlayers (Pipe pipe, String method, int maxDistance, Object ... actuals) {
if (!handlers.containsKey(pipe.getClass().getName())) {
handlers.put (pipe.getClass().getName(), new RPCHandler (pipe.getClass()));
}
PacketRPCPipe packet = handlers.get (pipe.getClass().getName()).createRCPPacket(pipe, method, actuals);
if (packet != null) {
for (Object o : pipe.container.worldObj.playerEntities) {
EntityPlayerMP player = (EntityPlayerMP) o;
if (Math.abs(player.posX - pipe.container.xCoord) <= maxDistance
&& Math.abs(player.posY - pipe.container.yCoord) <= maxDistance
&& Math.abs(player.posZ - pipe.container.zCoord) <= maxDistance) {
CoreProxy.proxy.sendToPlayer(player, packet);
}
}
}
}
public static void receiveRPC (TileEntity tile, RPCMessageInfo info, DataInputStream data) {
if (tile != null) {
if (!handlers.containsKey(tile.getClass().getName())) {
handlers.put (tile.getClass().getName(), new RPCHandler (tile.getClass()));
handlers.put(tile.getClass().getName(),
new RPCHandler(tile.getClass()));
}
handlers.get (tile.getClass().getName()).internalRpcReceive(tile, info, data);
handlers.get(tile.getClass().getName()).internalRpcReceive(tile,
info, data);
}
}
private PacketRPC createRCPPacket (TileEntity tile, String method, Object ... actuals) {
public static void receiveRPC (Pipe pipe, RPCMessageInfo info, DataInputStream data) {
if (pipe != null) {
if (!handlers.containsKey(pipe.getClass().getName())) {
handlers.put(pipe.getClass().getName(),
new RPCHandler(pipe.getClass()));
}
handlers.get(pipe.getClass().getName()).internalRpcReceive(pipe,
info, data);
}
}
private PacketRPCPipe createRCPPacket (Pipe pipe, String method, Object ... actuals) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(bytes);
try {
TileEntity tile = pipe.container;
// In order to save space on message, we assuming dimensions ids
// small. Maybe worth using a varint instead
data.writeShort(tile.worldObj.provider.dimensionId);
data.writeInt(tile.xCoord);
data.writeInt(tile.yCoord);
data.writeInt(tile.zCoord);
writeParameters(method, data, actuals);
data.flush();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new PacketRPCPipe(bytes.toByteArray());
}
private PacketRPCTile createRCPPacket (TileEntity tile, String method, Object ... actuals) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(bytes);
try {
// In order to save space on message, we assuming dimensions ids
// small. Maybe worth using a varint instead
data.writeShort(tile.worldObj.provider.dimensionId);
data.writeInt(tile.xCoord);
data.writeInt(tile.yCoord);
data.writeInt(tile.zCoord);
writeParameters(method, data, actuals);
data.flush();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new PacketRPCTile(bytes.toByteArray());
}
private void writeParameters (String method, DataOutputStream data, Object ... actuals) throws IOException, IllegalArgumentException, IllegalAccessException {
if (!methodsMap.containsKey(method)) {
throw new RuntimeException(method + " is not a callable method of " + getClass().getName());
}
@ -154,22 +260,13 @@ public class RPCHandler {
+ " expects " + m.parameters.length + "parameters, not " + actuals.length);
}
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(bytes);
try {
// In order to save space on message, we assuming dimensions ids
// small. Maybe worth using a varint instead
data.writeShort(tile.worldObj.provider.dimensionId);
data.writeInt(tile.xCoord);
data.writeInt(tile.yCoord);
data.writeInt(tile.zCoord);
data.writeShort(methodIndex);
for (int i = 0; i < actuals.length; ++i) {
if (formals [i].equals(int.class)) {
data.writeInt((Integer) actuals [i]);
} else if (formals [i].equals(float.class)) {
data.writeFloat((Float) actuals [i]);
} else if (formals [i].equals(char.class)) {
data.writeChar((Character) actuals [i]);
} else if (formals [i].equals(String.class)) {
@ -178,22 +275,9 @@ public class RPCHandler {
m.mappings [i].setData(actuals [i], data);
}
}
data.flush();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new PacketRPC(bytes.toByteArray());
}
private void internalRpcReceive (TileEntity tile, RPCMessageInfo info, DataInputStream data) {
private void internalRpcReceive (Object o, RPCMessageInfo info, DataInputStream data) {
try {
short methodIndex = data.readShort();
@ -207,6 +291,8 @@ public class RPCHandler {
for (int i = 0; i < expectedParameters; ++i) {
if (formals [i].equals(int.class)) {
actuals [i] = data.readInt();
} else if (formals [i].equals(float.class)) {
actuals [i] = data.readFloat();
} else if (formals [i].equals(char.class)) {
actuals [i] = data.readChar();
} else if (formals [i].equals(String.class)) {
@ -220,7 +306,7 @@ public class RPCHandler {
actuals [actuals.length - 1] = info;
}
m.method.invoke(tile, actuals);
m.method.invoke(o, actuals);
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {

View file

@ -9,8 +9,6 @@
package buildcraft.core.render;
import buildcraft.core.EntityEnergyLaser;
import buildcraft.core.EntityLaser;
import net.minecraft.client.model.ModelRenderer;
public class RenderEnergyLaser extends RenderLaser {
@ -26,21 +24,4 @@ public class RenderEnergyLaser extends RenderLaser {
box[i].rotationPointZ = 0;
}
}
@Override
protected ModelRenderer getBox(EntityLaser laser) {
EntityEnergyLaser eLaser = (EntityEnergyLaser) laser;
return box[eLaser.displayStage / 10];
}
@Override
protected void iterate(EntityLaser laser) {
EntityEnergyLaser eLaser = (EntityEnergyLaser) laser;
eLaser.displayStage = eLaser.displayStage + 1;
if (eLaser.displayStage >= box.length * 10) {
eLaser.displayStage = 0;
}
}
}

View file

@ -2,8 +2,6 @@ package buildcraft.core.render;
import buildcraft.core.EntityFrame;
import buildcraft.core.LaserData;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
@ -12,16 +10,8 @@ import org.lwjgl.opengl.GL11;
public class RenderFrame extends Render {
protected ModelBase model = new ModelBase() {
};
private ModelRenderer laserBox;
public RenderFrame() {
laserBox = new ModelRenderer(model, 0, 0);
laserBox.addBox(0, -0.5F, -0.5F, 16, 1, 1);
laserBox.rotationPointX = 0;
laserBox.rotationPointY = 0;
laserBox.rotationPointZ = 0;
}
@Override
@ -37,7 +27,7 @@ public class RenderFrame extends Render {
for (LaserData l : frame.lasers) {
GL11.glPushMatrix();
GL11.glTranslated(l.head.x - frame.posX, l.head.y - frame.posY, l.head.z - frame.posZ);
RenderLaser.doRenderLaser(renderManager, laserBox, l, frame.getTexture());
RenderLaser.doRenderLaser(renderManager.renderEngine, l, frame.getTexture());
GL11.glPopMatrix();
}

View file

@ -1,12 +1,16 @@
package buildcraft.core.render;
import java.util.Date;
import buildcraft.api.core.Position;
import buildcraft.core.EntityLaser;
import buildcraft.core.LaserData;
import buildcraft.core.render.RenderEntityBlock.RenderInfo;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
@ -14,16 +18,69 @@ import org.lwjgl.opengl.GL11;
public class RenderLaser extends Render {
protected ModelBase model = new ModelBase() {
public static final float STEP = 0.04F;
protected static ModelBase model = new ModelBase() {
};
private ModelRenderer box;
private static ModelRenderer [] box;
private static int [][] scaledBoxes;
public RenderLaser() {
box = new ModelRenderer(model, 0, 0);
box.addBox(0, -0.5F, -0.5F, 16, 1, 1);
box.rotationPointX = 0;
box.rotationPointY = 0;
box.rotationPointZ = 0;
}
private static ModelRenderer getBox(int index) {
if (box == null) {
box = new ModelRenderer[40];
for (int j = 0; j < box.length; ++j) {
box[j] = new ModelRenderer(model, box.length - j, 0);
box[j].addBox(0, -0.5F, -0.5F, 16, 1, 1);
box[j].rotationPointX = 0;
box[j].rotationPointY = 0;
box[j].rotationPointZ = 0;
}
}
return box [index];
}
private static void initScaledBoxes () {
if (scaledBoxes == null) {
scaledBoxes = new int [100][20];
for (int size = 0; size < 100; ++size) {
for (int i = 0; i < 20; ++i) {
scaledBoxes[size][i] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(scaledBoxes[size][i], GL11.GL_COMPILE);
RenderInfo block = new RenderInfo();
float minSize = 0.2F * (float) size / 100F;
float maxSize = 0.4F * (float) size / 100F;
//float minSize = 0.1F;
//float maxSize = 0.2F;
float range = maxSize - minSize;
float diff = (float) (Math.cos(i / 20F * 2 * Math.PI)
* range / 2F);
block.minX = 0.0;
block.minY = -maxSize / 2F + diff;
block.minZ = -maxSize / 2F + diff;
block.maxX = STEP;
block.maxY = maxSize / 2F - diff;
block.maxZ = maxSize / 2F - diff;
RenderEntityBlock.INSTANCE.renderBlock(block, null, 0, 0,
0, false, true);
GL11.glEndList();
}
}
}
}
@Override
@ -44,47 +101,101 @@ public class RenderLaser extends Render {
Position offset = laser.renderOffset();
GL11.glTranslated(x + offset.x, y + offset.y, z + offset.z);
doRenderLaser(renderManager, getBox(laser), laser.data, laser.getTexture());
iterate(laser);
// FIXME: WARNING! not using getBox (laser) will kill laser movement.
// we can use some other method for the animation though.
doRenderLaser(renderManager.renderEngine, laser.data, laser.getTexture());
GL11.glPopAttrib();
GL11.glPopMatrix();
}
public static void doRenderLaser(RenderManager renderManager, ModelRenderer box, LaserData laser, ResourceLocation texture) {
if (!laser.isVisible || texture == null)
public static void doRenderLaserWave(TextureManager textureManager, LaserData laser, ResourceLocation texture) {
if (!laser.isVisible || texture == null) {
return;
}
GL11.glPushMatrix();
laser.update();
GL11.glRotatef((float) laser.angleZ, 0, 1, 0);
GL11.glRotatef((float) laser.angleY, 0, 0, 1);
renderManager.renderEngine.bindTexture(texture);
textureManager.bindTexture(texture);
float factor = (float) (1.0 / 16.0);
int indexList = 0;
initScaledBoxes();
double x0 = 0;
double x1 = laser.wavePosition;
double x2 = x1 + scaledBoxes [0].length * STEP;
double x3 = laser.renderSize;
doRenderLaserLine(x1, laser.laserTexAnimation);
for (double i = x1; i <= x2 && i <= laser.renderSize; i += STEP) {
GL11.glCallList(scaledBoxes [(int) (laser.waveSize * 99F)][indexList]);
indexList = (indexList + 1) % scaledBoxes [0].length;
GL11.glTranslated(STEP, 0, 0);
}
if (x2 < x3) {
doRenderLaserLine(x3 - x2, laser.laserTexAnimation);
}
GL11.glPopMatrix();
}
public static void doRenderLaser(TextureManager textureManager, LaserData laser, ResourceLocation texture) {
if (!laser.isVisible || texture == null) {
return;
}
GL11.glPushMatrix();
laser.update();
GL11.glRotatef((float) laser.angleZ, 0, 1, 0);
GL11.glRotatef((float) laser.angleY, 0, 0, 1);
textureManager.bindTexture(texture);
float factor = (float) (1.0 / 16.0);
float lasti = 0;
for (float i = 0; i <= laser.renderSize - 1; ++i) {
box.render(factor);
int indexList = (int) ((new Date ().getTime() / 100) % 20);
initScaledBoxes();
doRenderLaserLine (laser.renderSize, laser.laserTexAnimation);
GL11.glPopMatrix();
}
private static void doRenderLaserLine (double len, int texId) {
float lasti = 0;
if (len - 1 > 0) {
for (float i = 0; i <= len - 1; i += 1) {
getBox(texId).render(1F / 16F);
GL11.glTranslated(1, 0, 0);
lasti = i;
}
lasti++;
GL11.glScalef(((float) laser.renderSize - lasti), 1, 1);
box.render(factor);
}
protected void iterate(EntityLaser laser) {
}
GL11.glPushMatrix();
GL11.glScalef(((float) len - lasti), 1, 1);
getBox(texId).render(1F / 16F);
GL11.glPopMatrix();
protected ModelRenderer getBox(EntityLaser laser) {
return box;
GL11.glTranslated((float) (len - lasti), 0, 0);
}
@Override

View file

@ -17,7 +17,6 @@ public class RenderRobot extends Render {
protected ModelBase model = new ModelBase() {
};
private ModelRenderer box;
private ModelRenderer laserBox;
public RenderRobot() {
box = new ModelRenderer(model, 0, 0);
@ -25,12 +24,6 @@ public class RenderRobot extends Render {
box.rotationPointX = 0;
box.rotationPointY = 0;
box.rotationPointZ = 0;
laserBox = new ModelRenderer(model, 0, 0);
laserBox.addBox(0, -0.5F, -0.5F, 16, 1, 1);
laserBox.rotationPointX = 0;
laserBox.rotationPointY = 0;
laserBox.rotationPointZ = 0;
}
@Override
@ -54,7 +47,7 @@ public class RenderRobot extends Render {
robot.laser.head.y = robot.posY;
robot.laser.head.z = robot.posZ;
RenderLaser.doRenderLaser(renderManager, laserBox, robot.laser, EntityLaser.LASER_TEXTURES [1]);
RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES [1]);
}
GL11.glEnable(2896 /* GL_LIGHTING */);

View file

@ -0,0 +1,62 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.CreativeTabBuildCraft;
public class BlockEnergyEmitter extends BlockBuildCraft {
public BlockEnergyEmitter(int id) {
super(id, Material.glass);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEnergyEmitter();
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return 1;
}
//@Override
//public boolean isOpaqueCube() {
// return false;
//}
@Override
public boolean renderAsNormalBlock() {
return false;
}
public boolean isACube() {
return false;
}
//@Override
//public int getRenderType() {
// return BuildCraftCore.blockByEntityModel;
//}
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
return false;
}
}

View file

@ -0,0 +1,48 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.CreativeTabBuildCraft;
public class BlockEnergyReceiver extends BlockBuildCraft {
public BlockEnergyReceiver(int id) {
super(id, Material.iron);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEnergyReceiver();
}
/*@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return BuildCraftCore.blockByEntityModel;
}*/
}

View file

@ -127,8 +127,9 @@ public class BlockEngine extends BlockBuildCraft {
public void randomDisplayTick(World world, int i, int j, int k, Random random) {
TileEngine tile = (TileEngine) world.getBlockTileEntity(i, j, k);
if (!tile.isBurning())
if (!tile.isBurning()) {
return;
}
float f = (float) i + 0.5F;
float f1 = (float) j + 0.0F + (random.nextFloat() * 6F) / 16F;

View file

@ -3,6 +3,7 @@ package buildcraft.energy;
import buildcraft.BuildCraftEnergy;
import buildcraft.core.render.RenderingEntityBlocks;
import buildcraft.core.render.RenderingEntityBlocks.EntityRenderIndex;
import buildcraft.energy.render.RenderEnergyEmitter;
import buildcraft.energy.render.RenderEngine;
import cpw.mods.fml.client.registry.ClientRegistry;
@ -12,10 +13,12 @@ public class EnergyProxyClient extends EnergyProxy {
public void registerTileEntities() {
super.registerTileEntities();
ClientRegistry.bindTileEntitySpecialRenderer(TileEngine.class, new RenderEngine());
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyEmitter.class, new RenderEnergyEmitter());
}
@Override
public void registerBlockRenderers() {
//RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.emitterBlock, 0), new RenderEnergyEmitter());
RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 0), new RenderEngine(TileEngine.WOOD_TEXTURE));
RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 1), new RenderEngine(TileEngine.STONE_TEXTURE));
RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 2), new RenderEngine(TileEngine.IRON_TEXTURE));

View file

@ -0,0 +1,251 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import java.util.Map;
import java.util.TreeMap;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.core.BlockIndex;
import buildcraft.core.LaserData;
import buildcraft.core.TileBuildCraft;
import buildcraft.core.network.RPC;
import buildcraft.core.network.RPCHandler;
import buildcraft.core.network.RPCMessageInfo;
import buildcraft.core.network.RPCSide;
import buildcraft.core.proxy.CoreProxy;
public class TileEnergyEmitter extends TileBuildCraft {
/**
* TODO: Try to use these instead of IPowerReceptor
*/
public float _MJ_STORED = 0;
/*
public static final float __MJ_POWER_MAX = 1024;
public static final boolean __MJ_RECEIVE_PNEUMATIC = true;
public static final boolean __MJ_RECEIVE_LASER = false;
*/
public float mjAcc = 0;
public int accumulated = 0;
private SafeTimeTracker syncMJ = new SafeTimeTracker(20, 5);
private SafeTimeTracker scanTracker = new SafeTimeTracker(100, 10);
public static class Target {
public LaserData data = new LaserData();
TileEnergyReceiver receiver;
}
public Map <BlockIndex, Target> targets = new TreeMap <BlockIndex, Target> ();
public TileEnergyEmitter () {
}
@Override
public void initialize () {
super.initialize();
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
RPCHandler.rpcServer(this, "requestLasers");
}
}
@Override
public void updateEntity() {
super.updateEntity();
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
for (Target t : targets.values()) {
if (t.data.isVisible) {
t.data.update();
t.data.wavePosition += 0.2F;
if (t.data.wavePosition > t.data.renderSize) {
t.data.wavePosition = 0;
t.data.waveSize = (_MJ_STORED / targets.size() / 10F);
if (t.data.waveSize > 1) {
t.data.waveSize = 1F;
}
}
t.data.iterateTexture();
}
}
return;
}
if (scanTracker.markTimeIfDelay(worldObj)) {
for (TileEnergyReceiver receiver : TileEnergyReceiver.knownReceivers) {
float dx = xCoord - receiver.xCoord;
float dy = yCoord - receiver.yCoord;
float dz = zCoord - receiver.zCoord;
if (dx * dx + dy * dy + dz * dz < 100 * 100) {
BlockIndex index = new BlockIndex(receiver.xCoord, receiver.yCoord, receiver.zCoord);
if (!targets.containsKey(index)) {
addLaser(receiver.xCoord, receiver.yCoord,
receiver.zCoord);
RPCHandler.rpcBroadcastPlayers(this, "addLaser",
receiver.xCoord, receiver.yCoord,
receiver.zCoord);
targets.get(index).receiver = receiver;
}
}
}
}
// synchronize regularly with the client an average of the energy in
// the emitter
mjAcc += _MJ_STORED;
accumulated++;
if (syncMJ.markTimeIfDelay(worldObj)) {
RPCHandler.rpcBroadcastPlayers(this, "synchronizeMJ", mjAcc
/ (float) accumulated);
mjAcc = 0;
accumulated = 0;
}
if (_MJ_STORED == 0) {
for (Target t : targets.values()) {
if (t.data.isVisible) {
t.data.isVisible = false;
RPCHandler.rpcBroadcastPlayers(this, "disableLaser",
t.receiver.xCoord, t.receiver.yCoord,
t.receiver.zCoord);
}
}
} else {
float perTargetEnergy = 10;
if (_MJ_STORED > targets.size() * 10) {
_MJ_STORED -= targets.size() * 10;
} else {
perTargetEnergy = _MJ_STORED / targets.size();
_MJ_STORED = 0;
}
for (Target t : targets.values()) {
if (!t.data.isVisible) {
t.data.isVisible = true;
RPCHandler.rpcBroadcastPlayers(this, "enableLaser",
t.receiver.xCoord, t.receiver.yCoord,
t.receiver.zCoord);
}
}
for (Target t : targets.values()) {
t.receiver.energyStored += perTargetEnergy;
}
}
}
@RPC (RPCSide.CLIENT)
public void synchronizeMJ (float val) {
_MJ_STORED = val;
}
@RPC (RPCSide.CLIENT)
public void addLaser (int x, int y, int z) {
BlockIndex index = new BlockIndex(x, y, z);
if (!targets.containsKey(index)) {
Target t = new Target();
t.data.head.x = xCoord + 0.5F;
t.data.head.y = yCoord + 0.5F;
t.data.head.z = zCoord + 0.5F;
t.data.tail.x = x + 0.5F;
t.data.tail.y = y + 0.5F;
t.data.tail.z = z + 0.5F;
targets.put(index, t);
}
}
@RPC (RPCSide.CLIENT)
public void enableLaser (int x, int y, int z) {
BlockIndex index = new BlockIndex(x, y, z);
if (targets.containsKey(index)) {
targets.get(index).data.isVisible = true;
}
}
@RPC (RPCSide.CLIENT)
public void disableLaser (int x, int y, int z) {
BlockIndex index = new BlockIndex(x, y, z);
if (targets.containsKey(index)) {
targets.get(index).data.isVisible = false;
}
}
@RPC (RPCSide.SERVER)
public void requestLasers (RPCMessageInfo info) {
for (BlockIndex b : targets.keySet()) {
RPCHandler.rpcPlayer(this, "addLaser", info.sender, b.x, b.y, b.z);
}
}
@Override
public World getWorld() {
return worldObj;
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
double xMin = xCoord;
double yMin = yCoord;
double zMin = zCoord;
double xMax = xCoord + 1.0;
double yMax = yCoord + 1.0;
double zMax = zCoord + 1.0;
for (Target t : targets.values()) {
if (t.data.tail.x < xMin) {
xMin = t.data.tail.x;
}
if (t.data.tail.y < yMin) {
yMin = t.data.tail.y;
}
if (t.data.tail.z < zMin) {
zMin = t.data.tail.z;
}
if (t.data.tail.x > xMax) {
xMax = t.data.tail.x;
}
if (t.data.tail.y > yMax) {
yMax = t.data.tail.y;
}
if (t.data.tail.z > zMax) {
zMax = t.data.tail.z;
}
}
return AxisAlignedBB.getBoundingBox(xMin, yMin, zMin, xMax, yMax, zMax);
}
}

View file

@ -0,0 +1,85 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import java.util.LinkedList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.transport.IPipeConnection;
import buildcraft.api.transport.IPipeTile.PipeType;
import buildcraft.core.TileBuffer;
import buildcraft.core.TileBuildCraft;
public class TileEnergyReceiver extends TileBuildCraft implements IPipeConnection {
public float energyStored = 0;;
private TileBuffer[] tileCache;
public static LinkedList<TileEnergyReceiver> knownReceivers = new LinkedList<TileEnergyReceiver>();
public TileEnergyReceiver () {
knownReceivers.add(this);
}
@Override
public void invalidate() {
knownReceivers.remove(this);
}
public TileBuffer getTileBuffer(ForgeDirection side) {
if (tileCache == null) {
tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false);
}
return tileCache[side.ordinal()];
}
public boolean isPoweredTile(TileEntity tile, ForgeDirection side) {
if (tile instanceof IPowerReceptor) {
return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null;
}
return false;
}
private void sendPower() {
for (ForgeDirection s : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = getTileBuffer(s).getTile();
if (tile instanceof IPowerReceptor) {
PowerReceiver receptor = ((IPowerReceptor) tile)
.getPowerReceiver(s.getOpposite());
if (receptor != null) {
receptor.receiveEnergy(PowerHandler.Type.ENGINE, energyStored,
s.getOpposite());
energyStored = 0;
}
}
}
}
@Override
public ConnectOverride overridePipeConnection(PipeType type,
ForgeDirection with) {
return type == PipeType.POWER ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT;
}
@Override
public void updateEntity () {
sendPower ();
}
}

View file

@ -0,0 +1,102 @@
/**
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy.render;
import org.lwjgl.opengl.GL11;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftCore.RenderMode;
import buildcraft.core.DefaultProps;
import buildcraft.core.EntityLaser;
import buildcraft.core.render.RenderLaser;
import buildcraft.energy.TileEnergyEmitter;
import buildcraft.energy.TileEnergyEmitter.Target;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class RenderEnergyEmitter extends TileEntitySpecialRenderer {
private ModelBase model = new ModelBase() {
};
private ModelRenderer box;
private static final ResourceLocation CHAMBER_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/chamber2.png");
public RenderEnergyEmitter() {
box = new ModelRenderer(model, 0, 1);
box.addBox(-8F, -8F, -8F, 16, 4, 16);
box.rotationPointX = 8;
box.rotationPointY = 8;
box.rotationPointZ = 8;
}
public void renderTileEntityAt2(TileEntity tileentity, double x, double y, double z, float f) {
if (BuildCraftCore.render == RenderMode.NoDynamic) {
return;
}
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glColor3f(1, 1, 1);
GL11.glTranslatef((float) x, (float) y, (float) z);
float step;
float[] angle = { 0, 0, 0 };
box.rotateAngleX = angle[0];
box.rotateAngleY = angle[1];
box.rotateAngleZ = angle[2];
float factor = (float) (1.0 / 16.0);
//bindTexture(EntityLaser.LASER_TEXTURES[3]);
bindTexture(CHAMBER_TEXTURE);
box.render(factor);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
TileEnergyEmitter emitter = ((TileEnergyEmitter) tileentity);
if (emitter != null) {
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslated(x, y, z);
for (Target t : emitter.targets.values()) {
GL11.glPushMatrix();
GL11.glTranslated(0.5F, 0.5F, 0.5F);
RenderLaser.doRenderLaserWave(tileEntityRenderer.renderEngine,
t.data, EntityLaser.LASER_TEXTURES[3]);
GL11.glPopMatrix();
}
//GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
}

View file

@ -103,6 +103,16 @@ public class PipeIconProvider implements IIconProvider {
PipePowerIronM64("pipePowerIronM64"),
PipePowerIronM128("pipePowerIronM128"),
//
PipePowerHeat0("pipePowerHeat0"),
PipePowerHeat1("pipePowerHeat1"),
PipePowerHeat2("pipePowerHeat2"),
PipePowerHeat3("pipePowerHeat3"),
PipePowerHeat4("pipePowerHeat4"),
PipePowerHeat5("pipePowerHeat5"),
PipePowerHeat6("pipePowerHeat6"),
PipePowerHeat7("pipePowerHeat7"),
PipePowerHeat8("pipePowerHeat8"),
//
Power_Normal("texture_cyan"),
Power_Overload("texture_red_lit"),
Stripes("pipeStripes"),

View file

@ -7,6 +7,7 @@
*/
package buildcraft.transport;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@ -23,11 +24,13 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import buildcraft.api.transport.IPipeTile.PipeType;
import buildcraft.core.DefaultProps;
import buildcraft.core.ReflectAPI;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.network.PacketPowerUpdate;
import buildcraft.transport.pipes.PipePowerCobblestone;
import buildcraft.transport.pipes.PipePowerDiamond;
import buildcraft.transport.pipes.PipePowerGold;
import buildcraft.transport.pipes.PipePowerHeat;
import buildcraft.transport.pipes.PipePowerIron;
import buildcraft.transport.pipes.PipePowerQuartz;
import buildcraft.transport.pipes.PipePowerStone;
@ -48,6 +51,7 @@ public class PipeTransportPower extends PipeTransport {
powerCapacities.put(PipePowerIron.class, 128);
powerCapacities.put(PipePowerGold.class, 256);
powerCapacities.put(PipePowerDiamond.class, 1024);
powerCapacities.put(PipePowerHeat.class, 1024);
}
private boolean needsInit = true;
private TileEntity[] tiles = new TileEntity[6];
@ -64,10 +68,16 @@ public class PipeTransportPower extends PipeTransport {
private double highestPower;
SafeTimeTracker tracker = new SafeTimeTracker();
public float[] movementStage = new float [] {0, 0, 0};
public PipeTransportPower() {
for (int i = 0; i < 6; ++i) {
powerQuery[i] = 0;
}
for (int i = 0; i < 3; ++i) {
movementStage[i] = (float) Math.random();
}
}
@Override
@ -101,6 +111,10 @@ public class PipeTransportPower extends PipeTransport {
return true;
}
if (ReflectAPI.get_MJ_STORED(tile.getClass()) != null) {
return true;
}
return false;
}
@ -133,8 +147,16 @@ public class PipeTransportPower extends PipeTransport {
@Override
public void updateEntity() {
if (CoreProxy.proxy.isRenderWorld(container.worldObj))
if (CoreProxy.proxy.isRenderWorld(container.worldObj)) {
// updating movement stage. We're only carrying the movement on half
// the things. This is purely for animation purpose.
for (int i = 0; i < 6; i += 2) {
movementStage [i / 2] = (movementStage [i / 2] + 0.01F) % 1.0F;
}
return;
}
step();
@ -151,7 +173,10 @@ public class PipeTransportPower extends PipeTransport {
for (int j = 0; j < 6; ++j) {
if (j != i && powerQuery[j] > 0)
if (tiles[j] instanceof TileGenericPipe || tiles[j] instanceof IPowerReceptor) {
if (tiles[j] != null
&& (tiles[j] instanceof TileGenericPipe
|| tiles[j] instanceof IPowerReceptor || ReflectAPI
.get_MJ_STORED(tiles[j].getClass()) != null)) {
totalPowerQuery += powerQuery[j];
}
}
@ -173,6 +198,29 @@ public class PipeTransportPower extends PipeTransport {
watts = nearbyTransport.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(), watts);
internalPower[i] -= watts;
} else if (tiles[j] != null) {
// Look for the simplified power framework
Field f = ReflectAPI.get_MJ_STORED(tiles [j].getClass());
try {
if (f != null) {
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
float energy = f.getFloat(tiles[j]);
if (energy < 100) {
energy += watts;
f.setFloat(tiles [j], energy);
internalPower[i] -= watts;
}
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
displayPower[j] += watts;
@ -200,13 +248,35 @@ public class PipeTransportPower extends PipeTransport {
// Compute the tiles requesting energy that are not power pipes
for (int i = 0; i < 6; ++i) {
PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[i]);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = tiles [dir.ordinal()];
PowerReceiver prov = getReceiverOnSide(dir);
if (prov != null) {
float request = (float) prov.powerRequest();
if (request > 0) {
requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request);
requestEnergy(dir, request);
}
}
if (tile != null) {
Field f = ReflectAPI.get_MJ_STORED(tile.getClass());
try {
if (f != null) {
float energy = f.getFloat(tile);
if (energy < 100) {
requestEnergy(dir, 100);
}
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@ -260,7 +330,6 @@ public class PipeTransportPower extends PipeTransport {
packet.overload = isOverloaded();
CoreProxy.proxy.sendToPlayers(packet.getPacket(), container.worldObj, container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST);
}
}
private PowerReceiver getReceiverOnSide(ForgeDirection side) {
@ -333,6 +402,7 @@ public class PipeTransportPower extends PipeTransport {
public void requestEnergy(ForgeDirection from, float amount) {
step();
if (this.container.pipe instanceof IPipeTransportPowerHook) {
nextPowerQuery[from.ordinal()] += ((IPipeTransportPowerHook) this.container.pipe).requestEnergy(from, amount);
} else {
@ -412,4 +482,24 @@ public class PipeTransportPower extends PipeTransport {
}
return amount;
}
public float getPistonStage (int i) {
if (movementStage [i] < 0.5F) {
return movementStage [i] * 2;
} else {
return 1 - (movementStage [i] - 0.5F) * 2;
}
}
public double clearInstantPower () {
double amount = 0.0;
for (int i = 0; i < internalPower.length; ++i) {
amount += internalPower [i];
internalPower [i] = 0;
}
return amount;
}
}

View file

@ -8,6 +8,7 @@
package buildcraft.transport;
import buildcraft.api.transport.PipeWire;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@ -31,7 +32,6 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.GateExpansionController;
import buildcraft.api.gates.GateExpansions;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.gates.IOverrideDefaultTriggers;
@ -55,8 +55,10 @@ import buildcraft.transport.gates.GateDefinition;
import buildcraft.transport.gates.GateFactory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.server.management.PlayerInstance;
import net.minecraft.world.WorldServer;

View file

@ -58,6 +58,7 @@ public class TransportProxyClient extends TransportProxy {
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerIron.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerDiamond.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerHeat.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.itemID, pipeItemRenderer);
// MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStipes.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsVoid.itemID, pipeItemRenderer);

View file

@ -0,0 +1,127 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.pipes;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportPower;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
public class PipePowerHeat extends Pipe<PipeTransportPower> {
int zeroAcc = 0;
double powerLevel = 0;
SafeTimeTracker scanTracker = new SafeTimeTracker(40, 5);
public PipePowerHeat(int itemID) {
super(new PipeTransportPower(), itemID);
transport.initFromPipe(getClass());
}
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return BuildCraftTransport.instance.pipeIconProvider;
}
public int getHeatLevel () {
if (powerLevel == 0) {
return 0;
} else if (powerLevel >= 1000) {
return 8;
} else {
return 1 + (int) (powerLevel / 1000F * 7F);
}
}
@Override
public int getIconIndex(ForgeDirection direction) {
if (container == null) {
return PipeIconProvider.TYPE.PipePowerHeat0.ordinal();
} else {
return PipeIconProvider.TYPE.PipePowerHeat0.ordinal()
+ container.worldObj.getBlockMetadata(container.xCoord,
container.yCoord, container.zCoord);
}
}
@Override
public void updateEntity() {
super.updateEntity();
if (!CoreProxy.proxy.isSimulating(container.worldObj)) {
return;
}
PipeTransportPower power = ((PipeTransportPower) transport);
power.requestEnergy(ForgeDirection.UP, 1024);
powerLevel = power.clearInstantPower ();
int meta = container.worldObj.getBlockMetadata(container.xCoord, container.yCoord, container.zCoord);
int newMeta = getHeatLevel();
if (meta != newMeta) {
System.out.println ("SEND NEW META " + newMeta);
container.worldObj.setBlockMetadataWithNotify(container.xCoord,
container.yCoord, container.zCoord, newMeta, 2);
container.scheduleRenderUpdate();
}
if (powerLevel >= 10 && scanTracker.markTimeIfDelay(container.worldObj)) {
int x = container.xCoord;
int y = container.yCoord;
int z = container.zCoord;
for (int xi = x - 1; xi <= x + 1; ++xi) {
for (int yi = y - 1; yi <= y + 1; ++yi) {
for (int zi = z - 1; zi <= z + 1; ++zi) {
if (container.worldObj.getBlockId(xi, yi, zi) == Block.blockRedstone.blockID) {
container.worldObj.setBlock(xi, yi, zi, 0);
for (int i = 0; i < 4; ++i) {
ItemStack stack = new ItemStack(
BuildCraftCore.redstoneCrystal);
EntityItem entityitem = new EntityItem(
container.worldObj, xi + 0.5F,
yi + 0.5F, zi + 0.5F, stack);
entityitem.lifespan = BuildCraftCore.itemLifespan;
entityitem.delayBeforeCanPickup = 10;
float f3 = 0.05F;
entityitem.motionX = (float) (container.worldObj.rand
.nextGaussian() - 0.5F) * f3;
entityitem.motionY = (float) (container.worldObj.rand
.nextGaussian() - 0.5F) * f3;
entityitem.motionZ = (float) (container.worldObj.rand
.nextGaussian() - 0.5F) * f3;
container.worldObj
.spawnEntityInWorld(entityitem);
}
}
}
}
}
}
}
}

View file

@ -156,7 +156,8 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
public float requestEnergy(ForgeDirection from, float amount) {
if (container.getTile(from) instanceof IPipeTile) {
return amount;
}
} else {
return 0;
}
}
}

View file

@ -10,9 +10,9 @@ package buildcraft.transport.render;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftCore.RenderMode;
import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.GateExpansionController;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.core.CoreConstants;
import buildcraft.core.DefaultProps;
import buildcraft.core.render.RenderEntityBlock;
import buildcraft.core.render.RenderEntityBlock.RenderInfo;
import buildcraft.core.utils.EnumColor;
@ -27,13 +27,14 @@ import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.PipeTransportPower;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TravelingItem;
import buildcraft.api.transport.PipeWire;
import com.google.common.collect.Maps;
import java.util.HashMap;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
@ -44,7 +45,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.Timer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@ -74,6 +75,10 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
public int[] displayPowerList = new int[POWER_STAGES];
public int[] displayPowerListOverload = new int[POWER_STAGES];
protected ModelBase model = new ModelBase() {
};
private ModelRenderer box;
public PipeRendererTESR() {
customRenderItem = new RenderItem() {
@Override
@ -87,6 +92,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
}
};
customRenderItem.setRenderManager(RenderManager.instance);
box = new ModelRenderer(model, 0, 0);
//box.addBox(0, 64 + 1, 64 + 1, 16, 128 - 2, 128 - 2);
box.addBox(0, 4 + 1, 4 + 1, 2, 8 - 2, 8 - 2);
box.rotationPointX = 0;
box.rotationPointY = 0;
box.rotationPointZ = 0;
}
private DisplayFluidList getDisplayFluidLists(int liquidId, World world) {
@ -254,7 +266,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
if (BuildCraftCore.render == RenderMode.NoDynamic)
return;
@ -575,6 +586,8 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
return targetOrientation.getOpposite() == direction;
}
public static final ResourceLocation STRIPES_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/stripes.png");
private void renderPower(Pipe<PipeTransportPower> pipe, double x, double y, double z) {
initializeDisplayPowerList(pipe.container.worldObj);
@ -613,6 +626,30 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
GL11.glPopMatrix();
}
/*bindTexture(STRIPES_TEXTURE);
for (int side = 0; side < 6; side += 2) {
if (pipe.container.isPipeConnected(ForgeDirection.values()[side])) {
GL11.glPushMatrix();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(angleY[side], 0, 1, 0);
GL11.glRotatef(angleZ[side], 0, 0, 1);
float scale = 1.0F - side * 0.0001F;
GL11.glScalef(scale, scale, scale);
float movement = (0.50F) * pipe.transport.getPistonStage(side / 2);
GL11.glTranslatef(-0.25F - 1F / 16F - movement, -0.5F, -0.5F);
// float factor = (float) (1.0 / 256.0);
float factor = (float) (1.0 / 16.0);
box.render(factor);
GL11.glPopMatrix();
}
}*/
GL11.glPopAttrib();
GL11.glPopMatrix();
}