Moved configuration stuff to /config/buildcraft

Fixed lots of stuff for core and transport, broke other stuff to get it compiling
This commit is contained in:
Krapht 2012-08-13 01:09:45 +02:00
parent d8b4f0d552
commit e3068f0b96
22 changed files with 304 additions and 204 deletions

View file

@ -72,10 +72,10 @@ public class CoreProxy {
}
public static File getBuildCraftBase() {
return new File(Minecraft.getMinecraftDir(), "/buildcraft/");
return new File(Minecraft.getMinecraftDir(), "/config/buildcraft/");
}
public static void sendToPlayers(Packet packet, World w, int x, int y, int z, int maxDistance, NetworkMod mod) {}
// public static void sendToPlayers(Packet packet, World w, int x, int y, int z, int maxDistance, NetworkMod mod) {}
public static void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {}
@ -126,7 +126,16 @@ public class CoreProxy {
private static EntityPlayer createNewPlayer(World world) {
return new EntityPlayer(world) {
@Override
public void func_6420_o() {}
public void sendChatToPlayer(String var1) {
// TODO Auto-generated method stub
}
@Override
public boolean canCommandSenderUseCommand(String var1) {
// TODO Auto-generated method stub
return false;
}
};
}

View file

@ -3,6 +3,9 @@ package buildcraft.core.network;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import buildcraft.core.network.ISynchronizedTile;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketTileUpdate;
@ -10,33 +13,12 @@ import buildcraft.core.network.PacketTileUpdate;
import net.minecraft.src.ModLoader;
import net.minecraft.src.NetClientHandler;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.forge.IPacketHandler;
public class PacketHandler implements IPacketHandler {
@Override
public void onPacketData(NetworkManager network, String channel, byte[] bytes) {
DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytes));
try {
NetClientHandler net = (NetClientHandler) network.getNetHandler();
int packetID = data.read();
switch (packetID) {
case PacketIds.TILE_UPDATE:
PacketTileUpdate packetT = new PacketTileUpdate();
packetT.readData(data);
onTileUpdate(packetT);
break;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void onTileUpdate(PacketTileUpdate packet) {
World world = ModLoader.getMinecraftInstance().theWorld;
@ -51,4 +33,23 @@ public class PacketHandler implements IPacketHandler {
tile.handleUpdatePacket(packet);
tile.postPacketHandling(packet);
}
@Override
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player) {
DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data));
try {
int packetID = data.read();
switch (packetID) {
case PacketIds.TILE_UPDATE:
PacketTileUpdate packetT = new PacketTileUpdate();
packetT.readData(data);
onTileUpdate(packetT);
break;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View file

@ -25,6 +25,13 @@ import net.minecraftforge.client.MinecraftForgeClient;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import buildcraft.BuildCraftCore;
import buildcraft.core.ClassMapping;
import buildcraft.core.DefaultProps;
@ -38,9 +45,12 @@ import buildcraft.core.RenderEntityBlock;
import buildcraft.core.RenderLaser;
import buildcraft.core.RenderRobot;
import buildcraft.core.Utils;
import buildcraft.core.network.PacketHandler;
import buildcraft.core.utils.Localization;
public class mod_BuildCraftCore extends NetworkMod {
@Mod(name="BuildCraftCore", version="3.2", useMetadata = false, modid = "BC|CORE")
@NetworkMod(channels = {"bc|core"}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
public class mod_BuildCraftCore {
public static mod_BuildCraftCore instance;
@ -96,24 +106,42 @@ public class mod_BuildCraftCore extends NetworkMod {
}
}
@Override
public void modsLoaded() {
mod_BuildCraftCore.initialize();
BuildCraftCore.initializeModel(this);
ModLoader.setInGameHook(this, true, true);
/*
* @Override public void handlePacket(Packet230ModLoader packet) { switch
* (PacketIds.values()[packet.packetType]) { case TileDescription:
* Utils.handleDescriptionPacket(packet,
* ModLoader.getMinecraftInstance().theWorld); break; case TileUpdate:
* Utils.handleUpdatePacket(packet,
* ModLoader.getMinecraftInstance().theWorld); break;
*
* } }
*/
//@Override
@PreInit
public void load(FMLPreInitializationEvent event) {
BuildCraftCore.load();
}
@Override
public String getVersion() {
return version();
// //@Override
@Init
public void modsLoaded(FMLInitializationEvent event) {
mod_BuildCraftCore.initialize();
//BuildCraftCore.initializeModel(this);
// ModLoader.setInGameHook(this, true, true);
}
// @Override
// public String getVersion() {
// return version();
// }
public static String version() {
return DefaultProps.VERSION;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
// @Override
public void addRenderer(Map map) {
map.put(EntityBlock.class, new RenderEntityBlock());
map.put(EntityLaser.class, new RenderLaser());
@ -121,7 +149,7 @@ public class mod_BuildCraftCore extends NetworkMod {
map.put(EntityRobot.class, new RenderRobot());
}
@Override
// @Override
public boolean renderWorldBlock(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) {
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
@ -188,7 +216,7 @@ public class mod_BuildCraftCore extends NetworkMod {
RenderItem itemRenderer = new RenderItem();
@Override
//@Override
public void renderInvBlock(RenderBlocks renderblocks, Block block, int i, int j) {
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
@ -419,7 +447,7 @@ public class mod_BuildCraftCore extends NetworkMod {
long lastReport = 0;
@Override
//@Override
public boolean onTickInGame(float f, Minecraft minecraft) {
if (BuildCraftCore.trackNetworkUsage) {
Date d = new Date();
@ -446,17 +474,12 @@ public class mod_BuildCraftCore extends NetworkMod {
* } }
*/
@Override
public void load() {
BuildCraftCore.load();
}
@Override
//@Override
public boolean clientSideRequired() {
return true;
}
@Override
//@Override
public boolean serverSideRequired() {
return true;
}

View file

@ -9,6 +9,14 @@
package buildcraft;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import buildcraft.BuildCraftTransport;
import buildcraft.core.DefaultProps;
import buildcraft.transport.FacadeItemRenderer;
@ -17,6 +25,7 @@ import buildcraft.transport.PipeItemRenderer;
import buildcraft.transport.PipeWorldRenderer;
import buildcraft.transport.RenderPipe;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.network.PacketHandler;
import net.minecraft.src.Block;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.ModLoader;
@ -25,7 +34,9 @@ import net.minecraft.src.TileEntity;
import net.minecraftforge.client.MinecraftForgeClient;
public class mod_BuildCraftTransport extends NetworkMod {
@Mod(version = "3.2", modid="BC|TRANSPORT", name = "Buildcraft Transport")
@NetworkMod(channels={"BC"}, packetHandler = PacketHandler.class)
public class mod_BuildCraftTransport {
public static mod_BuildCraftTransport instance;
public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
@ -36,9 +47,9 @@ public class mod_BuildCraftTransport extends NetworkMod {
instance = this;
}
@Override
public void modsLoaded() {
super.modsLoaded();
//@Override
@Init
public void modsLoaded(FMLInitializationEvent event) {
BuildCraftTransport.initialize();
BuildCraftTransport.initializeModel(this);
@ -61,41 +72,45 @@ public class mod_BuildCraftTransport extends NetworkMod {
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStipes.shiftedIndex, pipeItemRenderer);
//MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStipes.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsVoid.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsVoid.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsSandstone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsSandstone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem.shiftedIndex, facadeItemRenderer);
RenderingRegistry.instance().registerBlockHandler(pipeWorldRenderer);
}
public static void registerTilePipe(Class<? extends TileEntity> clas, String name) {
ModLoader.registerTileEntity(clas, name, new RenderPipe());
}
@Override
//@Override
public String getVersion() {
return DefaultProps.VERSION;
}
@Override
public void load() {
//@Override
@PreInit
public void load(FMLPreInitializationEvent event) {
BuildCraftTransport.load();
}
@Override
//@Override
public boolean clientSideRequired() {
return true;
}
@Override
//@Override
public boolean serverSideRequired() {
return true;
}
@Override
//@Override
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) {
//cpw.mods.fml.client.registry.RenderingRegistry.instance().registerBlockHandler(new isimpleblockrenderinghandler() {
if (modelID != BuildCraftTransport.pipeModel) return true;
TileEntity tile = world.getBlockTileEntity(x, y, z);

View file

@ -1,17 +1,22 @@
package buildcraft.transport;
import cpw.mods.fml.common.network.IGuiHandler;
import buildcraft.core.GuiIds;
import buildcraft.transport.TileGenericPipe;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.forge.IGuiHandler;
public class GuiHandler implements IGuiHandler {
@Override
public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (!world.blockExists(x, y, z))
return null;
@ -33,5 +38,4 @@ public class GuiHandler implements IGuiHandler {
return null;
}
}
}

View file

@ -7,6 +7,10 @@ import java.util.List;
import java.util.ListIterator;
import java.util.TreeMap;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import buildcraft.BuildCraftTransport;
import buildcraft.mod_BuildCraftTransport;
import buildcraft.api.core.Orientations;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipe.WireColor;
@ -20,10 +24,11 @@ import net.minecraft.src.Item;
import net.minecraft.src.ItemBlock;
import net.minecraft.src.ItemStack;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.TileEntity;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.MinecraftForgeClient;
public class PipeWorldRenderer {
public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
/**
* Mirrors the array on the Y axis by calculating offsets from 0.5F
@ -497,4 +502,33 @@ public class PipeWorldRenderer {
renderblocks.renderStandardBlock(block, x, y, z);
}
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID,
RenderBlocks renderer) {
// TODO Auto-generated method stub
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof IPipeRenderState){
IPipeRenderState pipeTile = (IPipeRenderState) tile;
renderPipe(renderer, world, block, pipeTile.getRenderState(), x, y, z);
}
return true;
}
@Override
public boolean shouldRender3DInInventory() {
// TODO Auto-generated method stub
return false;
}
@Override
public int getRenderId() {
return BuildCraftTransport.pipeModel;
}
}

View file

@ -3,12 +3,14 @@ package buildcraft.transport.network;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import buildcraft.BuildCraftCore;
import buildcraft.core.BlockIndex;
import buildcraft.core.network.ISynchronizedTile;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketNBT;
import buildcraft.core.network.PacketPipeDescription;
import buildcraft.core.network.PacketPipeTransportContent;
import buildcraft.core.network.PacketUpdate;
import buildcraft.transport.CraftingGateInterface;
@ -26,18 +28,17 @@ import net.minecraft.src.Container;
import net.minecraft.src.ModLoader;
import net.minecraft.src.NetClientHandler;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.forge.IPacketHandler;
public class PacketHandler implements IPacketHandler {
@Override
public void onPacketData(NetworkManager network, String channel, byte[] bytes) {
DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytes));
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet2, Player player) {
DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet2.data));
try {
NetClientHandler net = (NetClientHandler) network.getNetHandler();
//NetClientHandler net = (NetClientHandler) network.getNetHandler();
int packetID = data.read();
@ -62,9 +63,6 @@ public class PacketHandler implements IPacketHandler {
PipeRenderStatePacket descPacket = new PipeRenderStatePacket();
descPacket.readData(data);
onPipeDescription(descPacket);
// PacketPipeDescription packetU = new PacketPipeDescription();
// packetU.readData(data);
// onPipeDescription(packetU);
break;
case PacketIds.PIPE_CONTENTS:
PacketPipeTransportContent packetC = new PacketPipeTransportContent();

View file

@ -18,7 +18,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
public class mod_BuildCraftCore extends NetworkMod {
public class mod_BuildCraftCore {
public static mod_BuildCraftCore instance;
@ -32,7 +32,7 @@ public class mod_BuildCraftCore extends NetworkMod {
BuildCraftCore.initialize();
}
@Override
//@Override
public void modsLoaded() {
mod_BuildCraftCore.initialize();
BuildCraftCore.initializeModel(this);
@ -43,14 +43,14 @@ public class mod_BuildCraftCore extends NetworkMod {
return DefaultProps.VERSION;
}
@Override
//@Override
public String getVersion() {
return version();
}
long lastReport = 0;
@Override
//@Override
public boolean onTickInGame(MinecraftServer minecraftserver) {
if (BuildCraftCore.trackNetworkUsage) {
Date d = new Date();
@ -66,17 +66,17 @@ public class mod_BuildCraftCore extends NetworkMod {
return true;
}
@Override
//@Override
public void load() {
BuildCraftCore.load();
}
@Override
//@Override
public boolean clientSideRequired() {
return true;
}
@Override
//@Override
public boolean serverSideRequired() {
return true;
}

View file

@ -36,7 +36,7 @@ import buildcraft.core.TriggerInventory;
import buildcraft.core.TriggerLiquidContainer;
import buildcraft.core.TriggerMachine;
import buildcraft.core.ActionMachineControl.Mode;
import buildcraft.core.network.ConnectionHandler;
//import buildcraft.core.network.ConnectionHandler;
import buildcraft.core.network.PacketUpdate;
import buildcraft.transport.TriggerRedstoneInput;
@ -130,7 +130,7 @@ public class BuildCraftCore {
public static void load() {
MinecraftForge.registerConnectionHandler(new ConnectionHandler());
//MinecraftForge.registerConnectionHandler(new ConnectionHandler());
}
public static void initialize() {

View file

@ -13,6 +13,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import cpw.mods.fml.client.registry.RenderingRegistry;
import buildcraft.mod_BuildCraftCore;
import buildcraft.mod_BuildCraftTransport;
import buildcraft.api.core.BuildCraftAPI;
@ -46,7 +48,6 @@ import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TriggerPipeContents;
import buildcraft.transport.TriggerPipeSignal;
import buildcraft.transport.TriggerPipeContents.Kind;
import buildcraft.transport.network.ConnectionHandler;
import buildcraft.transport.pipes.PipeItemsCobblestone;
import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsGold;
@ -54,7 +55,7 @@ import buildcraft.transport.pipes.PipeItemsIron;
import buildcraft.transport.pipes.PipeItemsObsidian;
import buildcraft.transport.pipes.PipeItemsSandstone;
import buildcraft.transport.pipes.PipeItemsStone;
import buildcraft.transport.pipes.PipeItemsStripes;
//import buildcraft.transport.pipes.PipeItemsStripes;
import buildcraft.transport.pipes.PipeItemsVoid;
import buildcraft.transport.pipes.PipeItemsWood;
import buildcraft.transport.pipes.PipeLiquidsCobblestone;
@ -123,7 +124,7 @@ public class BuildCraftTransport {
public static Item facadeItem;
public static Item pipeItemsStipes;
//public static Item pipeItemsStipes;
public static Item pipeStructureCobblestone;
public static int groupItemsTrigger;
@ -167,10 +168,10 @@ public class BuildCraftTransport {
public static void load() {
// Register connection handler
MinecraftForge.registerConnectionHandler(new ConnectionHandler());
//MinecraftForge.registerConnectionHandler(new ConnectionHandler());
// Register gui handler
MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler());
//MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler());
}
private static class ExtractionHandler implements IExtractionHandler {
@ -317,8 +318,8 @@ public class BuildCraftTransport {
"Cobblestone Structure Pipe", Block.gravel, pipeItemsCobblestone, null);
// Fix the recipe
pipeItemsStipes = createPipe(DefaultProps.PIPE_ITEMS_STRIPES_ID, PipeItemsStripes.class, "Stripes Transport Pipe",
new ItemStack(Item.dyePowder, 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11));
// pipeItemsStipes = createPipe(DefaultProps.PIPE_ITEMS_STRIPES_ID, PipeItemsStripes.class, "Stripes Transport Pipe",
// new ItemStack(Item.dyePowder, 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11));
pipeItemsVoid = createPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe",
new ItemStack(Item.dyePowder, 1, 0), Block.glass, Item.redstone);
@ -444,7 +445,8 @@ public class BuildCraftTransport {
}
public static void initializeModel(mod_BuildCraftTransport mod) {
pipeModel = ModLoader.getUniqueBlockModelID(mod, true);
//pipeModel = ModLoader.getUniqueBlockModelID(mod, true);
pipeModel = RenderingRegistry.instance().getNextAvailableRenderId();
}

View file

@ -19,7 +19,7 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.TreeMap;
import buildcraft.BuildCraftBuilders;
//import buildcraft.BuildCraftBuilders;
import buildcraft.core.CoreProxy;
@ -90,8 +90,8 @@ public class BptRootIndex {
bluePrintsFile.put(maxBpt, newFile);
for (BptPlayerIndex playerIndex : BuildCraftBuilders.playerLibrary.values())
playerIndex.addBlueprint(newFile);
// for (BptPlayerIndex playerIndex : BuildCraftBuilders.playerLibrary.values())
// playerIndex.addBlueprint(newFile);
}
}

View file

@ -43,8 +43,8 @@ public class DefaultTriggerProvider implements ITriggerProvider {
}
if (block != null && block.canProvidePower()) {
res.add(BuildCraftCore.triggerRedstoneActive);
res.add(BuildCraftCore.triggerRedstoneInactive);
// res.add(BuildCraftCore.triggerRedstoneActive);
// res.add(BuildCraftCore.triggerRedstoneInactive);
}
return res;

View file

@ -16,6 +16,8 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.management.RuntimeErrorException;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.core.BuildCraftAPI;
import buildcraft.api.core.Position;
@ -206,9 +208,10 @@ public class EntityRobot extends Entity implements ISpawnHandler {
} else if (target.stackToUse != null) {
worldObj.setBlockWithNotify(target.x, target.y, target.z, 0);
target.stackToUse.getItem().onItemUse(target.stackToUse,
CoreProxy.getBuildCraftPlayer(worldObj), worldObj, target.x, target.y - 1,
target.z, 1);
throw new RuntimeErrorException(null, "NOT IMPLEMENTED");
// target.stackToUse.getItem().onItemUse(target.stackToUse,
// CoreProxy.getBuildCraftPlayer(worldObj), worldObj, target.x, target.y - 1,
// target.z, 1);
} else {
try {

View file

@ -77,10 +77,10 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
}
public void sendNetworkUpdate() {
CoreProxy.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
}
// public void sendNetworkUpdate() {
// CoreProxy.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord,
// DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
// }
@Override
public Packet getDescriptionPacket() {

View file

@ -1,6 +1,7 @@
package buildcraft.core.network;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@ -10,12 +11,13 @@ import net.minecraft.src.Packet;
import net.minecraft.src.Packet250CustomPayload;
public abstract class BuildCraftPacket extends ForgePacket {
public abstract class BuildCraftPacket {
protected boolean isChunkDataPacket = false;
protected String channel = DefaultProps.NET_CHANNEL_NAME;
@Override
public abstract int getID();
public Packet getPacket() {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@ -34,4 +36,7 @@ public abstract class BuildCraftPacket extends ForgePacket {
return packet;
}
public abstract void readData(DataInputStream data) throws IOException;
public abstract void writeData(DataOutputStream data) throws IOException;
}

View file

@ -121,79 +121,79 @@ public class ItemFacade extends ItemBuildCraft {
private static List getCreativeContents(){
List itemList = new ArrayList();
Block[] var2 = new Block[] {Block.cobblestone, Block.stone, Block.oreDiamond, Block.oreGold, Block.oreIron, Block.oreCoal, Block.oreLapis, Block.oreRedstone, Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.blockClay, Block.blockDiamond, Block.blockGold, Block.blockSteel, Block.bedrock, Block.blockLapis, Block.brick, Block.cobblestoneMossy, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.obsidian, Block.netherrack, Block.slowSand, Block.glowStone, Block.wood, Block.wood, Block.wood, Block.wood, Block.leaves, Block.leaves, Block.leaves, Block.leaves, Block.dirt, Block.grass, Block.sand, Block.sandStone, Block.sandStone, Block.sandStone, Block.gravel, Block.web, Block.planks, Block.planks, Block.planks, Block.planks, Block.sapling, Block.sapling, Block.sapling, Block.sapling, Block.deadBush, Block.sponge, Block.ice, Block.blockSnow, Block.plantYellow, Block.plantRed, Block.mushroomBrown, Block.mushroomRed, Block.cactus, Block.melon, Block.pumpkin, Block.pumpkinLantern, Block.vine, Block.fenceIron, Block.thinGlass, Block.netherBrick, Block.netherFence, Block.stairsNetherBrick, Block.whiteStone, Block.mycelium, Block.waterlily, Block.tallGrass, Block.tallGrass, Block.chest, Block.workbench, Block.glass, Block.tnt, Block.bookShelf, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.dispenser, Block.stoneOvenIdle, Block.music, Block.jukebox, Block.pistonStickyBase, Block.pistonBase, Block.fence, Block.fenceGate, Block.ladder, Block.rail, Block.railPowered, Block.railDetector, Block.torchWood, Block.stairCompactPlanks, Block.stairCompactCobblestone, Block.stairsBrick, Block.stairsStoneBrickSmooth, Block.lever, Block.pressurePlateStone, Block.pressurePlatePlanks, Block.torchRedstoneActive, Block.button, Block.trapdoor, Block.enchantmentTable, Block.redstoneLampIdle};
int var3 = 0;
int var4 = 0;
int var5 = 0;
int var6 = 0;
int var7 = 0;
int var8 = 0;
int var9 = 0;
int var10 = 0;
int var11 = 1;
int var12;
int var13;
for (var12 = 0; var12 < var2.length; ++var12)
{
var13 = 0;
if (var2[var12] == Block.cloth)
{
var13 = var3++;
}
else if (var2[var12] == Block.stairSingle)
{
var13 = var4++;
}
else if (var2[var12] == Block.wood)
{
var13 = var5++;
}
else if (var2[var12] == Block.planks)
{
var13 = var6++;
}
else if (var2[var12] == Block.sapling)
{
var13 = var7++;
}
else if (var2[var12] == Block.stoneBrick)
{
var13 = var8++;
}
else if (var2[var12] == Block.sandStone)
{
var13 = var9++;
}
else if (var2[var12] == Block.tallGrass)
{
var13 = var11++;
}
else if (var2[var12] == Block.leaves)
{
var13 = var10++;
}
itemList.add(new ItemStack(var2[var12], 1, var13));
}
for (Block block : Block.blocksList)
{
if (block != null)
{
block.addCreativeItems((ArrayList) itemList);
}
}
int x = 0;
for (Item item : Item.itemsList)
{
if (x++ >= 256 && item != null)
{
item.addCreativeItems((ArrayList) itemList);
}
}
// Block[] var2 = new Block[] {Block.cobblestone, Block.stone, Block.oreDiamond, Block.oreGold, Block.oreIron, Block.oreCoal, Block.oreLapis, Block.oreRedstone, Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.blockClay, Block.blockDiamond, Block.blockGold, Block.blockSteel, Block.bedrock, Block.blockLapis, Block.brick, Block.cobblestoneMossy, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.obsidian, Block.netherrack, Block.slowSand, Block.glowStone, Block.wood, Block.wood, Block.wood, Block.wood, Block.leaves, Block.leaves, Block.leaves, Block.leaves, Block.dirt, Block.grass, Block.sand, Block.sandStone, Block.sandStone, Block.sandStone, Block.gravel, Block.web, Block.planks, Block.planks, Block.planks, Block.planks, Block.sapling, Block.sapling, Block.sapling, Block.sapling, Block.deadBush, Block.sponge, Block.ice, Block.blockSnow, Block.plantYellow, Block.plantRed, Block.mushroomBrown, Block.mushroomRed, Block.cactus, Block.melon, Block.pumpkin, Block.pumpkinLantern, Block.vine, Block.fenceIron, Block.thinGlass, Block.netherBrick, Block.netherFence, Block.stairsNetherBrick, Block.whiteStone, Block.mycelium, Block.waterlily, Block.tallGrass, Block.tallGrass, Block.chest, Block.workbench, Block.glass, Block.tnt, Block.bookShelf, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.dispenser, Block.stoneOvenIdle, Block.music, Block.jukebox, Block.pistonStickyBase, Block.pistonBase, Block.fence, Block.fenceGate, Block.ladder, Block.rail, Block.railPowered, Block.railDetector, Block.torchWood, Block.stairCompactPlanks, Block.stairCompactCobblestone, Block.stairsBrick, Block.stairsStoneBrickSmooth, Block.lever, Block.pressurePlateStone, Block.pressurePlatePlanks, Block.torchRedstoneActive, Block.button, Block.trapdoor, Block.enchantmentTable, Block.redstoneLampIdle};
// int var3 = 0;
// int var4 = 0;
// int var5 = 0;
// int var6 = 0;
// int var7 = 0;
// int var8 = 0;
// int var9 = 0;
// int var10 = 0;
// int var11 = 1;
// int var12;
// int var13;
//
// for (var12 = 0; var12 < var2.length; ++var12)
// {
// var13 = 0;
//
// if (var2[var12] == Block.cloth)
// {
// var13 = var3++;
// }
// else if (var2[var12] == Block.stairSingle)
// {
// var13 = var4++;
// }
// else if (var2[var12] == Block.wood)
// {
// var13 = var5++;
// }
// else if (var2[var12] == Block.planks)
// {
// var13 = var6++;
// }
// else if (var2[var12] == Block.sapling)
// {
// var13 = var7++;
// }
// else if (var2[var12] == Block.stoneBrick)
// {
// var13 = var8++;
// }
// else if (var2[var12] == Block.sandStone)
// {
// var13 = var9++;
// }
// else if (var2[var12] == Block.tallGrass)
// {
// var13 = var11++;
// }
// else if (var2[var12] == Block.leaves)
// {
// var13 = var10++;
// }
//
// itemList.add(new ItemStack(var2[var12], 1, var13));
// }
//
// for (Block block : Block.blocksList)
// {
// if (block != null)
// {
// block.addCreativeItems((ArrayList) itemList);
// }
// }
//
// int x = 0;
// for (Item item : Item.itemsList)
// {
// if (x++ >= 256 && item != null)
// {
// item.addCreativeItems((ArrayList) itemList);
// }
// }
return itemList;
}

View file

@ -9,10 +9,16 @@
package buildcraft.transport;
import java.util.LinkedList;
import java.util.List;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import buildcraft.BuildCraftTransport;
import buildcraft.core.IItemPipe;
import buildcraft.core.ItemBuildCraft;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
@ -25,10 +31,11 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
protected ItemPipe(int i) {
super(i);
this.setTabToDisplayOn(CreativeTabs.tabMisc);
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
public boolean tryPlaceIntoWorld(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l, float par8, float par9, float par10) {
int blockID = BuildCraftTransport.genericPipeBlock.blockID;
if (world.getBlockId(i, j, k) == Block.snow.blockID)
@ -50,13 +57,13 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
if (itemstack.stackSize == 0)
return false;
if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {
if (entityplayer.canPlayerEdit(i, j, k)){
// if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {
Pipe pipe = BlockGenericPipe.createPipe(shiftedIndex);
if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {
Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
//Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
// To move to a proxt
// world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F,
@ -78,5 +85,4 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
public int getTextureIndex() {
return textureIndex;
}
}

View file

@ -116,7 +116,7 @@ public class PipeLogicDiamond extends PipeLogic implements ISpecialInventory {
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.writeToNBT(nbttagcompound);
PacketNBT packet = new PacketNBT(PacketIds.DIAMOND_PIPE_CONTENTS, nbttagcompound, xCoord, yCoord, zCoord);
CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
//CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
}
/* CLIENT SIDE */

View file

@ -9,6 +9,7 @@
package buildcraft.transport;
import java.awt.Dimension;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.TreeMap;
@ -33,12 +34,15 @@ import buildcraft.core.Utils;
import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketPipeTransportContent;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayerMP;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.Packet;
import net.minecraft.src.ServerConfigurationManager;
import net.minecraft.src.TileEntity;
public class PipeTransportItems extends PipeTransport {
@ -92,10 +96,16 @@ public class PipeTransportItems extends PipeTransport {
if (container.pipe instanceof IPipeTransportItemsHook)
((IPipeTransportItemsHook) container.pipe).entityEntered(item, orientation);
if (CoreProxy.isServerSide())
if (item.getSynchroTracker().markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor))
CoreProxy.sendToPlayers(createItemPacket(item, orientation), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
if (!worldObj.isRemote && item.getSynchroTracker().markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor)) {
int dimension = worldObj.provider.worldType;
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, dimension, createItemPacket(item, orientation));
}
// for (Object player : MinecraftServer.getServer().getConfigurationManager().playerEntityList){
//
// }
// CoreProxy.sendToPlayers(createItemPacket(item, orientation), worldObj, xCoord, yCoord, zCoord,
// DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
if (travelingEntities.size() > BuildCraftTransport.groupItemsTrigger) {
groupEntities();

View file

@ -219,8 +219,8 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
PacketLiquidUpdate packet = new PacketLiquidUpdate(xCoord, yCoord, zCoord);
packet.displayLiquid = this.renderCache;
CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
// CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
// DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
}
//this.container.synchronizeIfDelay(1 * BuildCraftCore.updateFactor);

View file

@ -22,12 +22,10 @@ import buildcraft.core.CoreProxy;
import buildcraft.core.DefaultProps;
import buildcraft.core.IMachine;
import buildcraft.core.Utils;
import buildcraft.core.network.TileNetworkData;
import buildcraft.transport.network.PacketPowerUpdate;
public class PipeTransportPower extends PipeTransport {
@TileNetworkData(staticSize = 6)
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
public int[] powerQuery = new int[6];
@ -146,18 +144,15 @@ public class PipeTransportPower extends PipeTransport {
continue;
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyTile.pipe.transport;
nearbyTransport.requestEnergy(Orientations.values()[i].reverse(), transferQuery[i]);
}
}
if (CoreProxy.isServerSide())
if (tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)){
if (!worldObj.isRemote && tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) {
PacketPowerUpdate packet = new PacketPowerUpdate(xCoord, yCoord, zCoord);
packet.displayPower = displayPower;
CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
// CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
// DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
}
}

View file

@ -39,7 +39,7 @@ import buildcraft.core.TileBuffer;
import buildcraft.core.Utils;
import buildcraft.core.network.IndexInPayload;
import buildcraft.core.network.PacketPayload;
import buildcraft.core.network.PacketPipeDescription;
//import buildcraft.core.network.PacketPipeDescription;
import buildcraft.core.network.PacketTileUpdate;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.TileNetworkData;
@ -122,9 +122,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
pipe.invalidate();
}
super.invalidate();
// if (BlockGenericPipe.isValid(pipe))
// BlockGenericPipe.removePipe(pipe);
}
@Override
@ -347,13 +344,11 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
renderState = packet.getRenderState();
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
}
return;
}
public Packet getDescriptionPacket() {
@Override
public Packet getAuxillaryInfoPacket() {
bindPipe();
PipeRenderStatePacket packet = new PipeRenderStatePacket(this.renderState, this.pipeId, xCoord, yCoord, zCoord);
return packet.getPacket();