diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 354d96eb..aa51aae3 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -94,7 +94,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6.4,1.7)", dependencies = "required-after:Forge@[9.11.1.953,)") +@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.2,1.8)", dependencies = "required-after:Forge@[9.11.1.953,)") public class BuildCraftCore extends BuildCraftMod { public static enum RenderMode { Full, NoDynamic @@ -132,7 +132,6 @@ public class BuildCraftCore extends BuildCraftMod { public static int blockByEntityModel; public static int legacyPipeModel; public static int markerModel; - public static int oilModel; public static BCTrigger triggerMachineActive = new TriggerMachine(true); public static BCTrigger triggerMachineInactive = new TriggerMachine(false); public static BCTrigger triggerEmptyInventory = new TriggerInventory(TriggerInventory.State.Empty); diff --git a/common/buildcraft/BuildCraftMod.java b/common/buildcraft/BuildCraftMod.java index 091810a4..a85162da 100755 --- a/common/buildcraft/BuildCraftMod.java +++ b/common/buildcraft/BuildCraftMod.java @@ -19,6 +19,11 @@ public class BuildCraftMod { channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); channels.get(Side.SERVER).writeOutbound(packet); } + + public void sendToPlayers(BuildCraftPacket packet, World world, int x, int y, int z, int maxDistance) { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + channels.get(Side.SERVER).writeOutbound(packet); + } public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) { channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 012955eb..0bd3bb6f 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -45,6 +45,7 @@ import buildcraft.transport.ItemPipeWire; import buildcraft.transport.gates.GateExpansionRedstoneFader; import buildcraft.transport.gates.GateExpansionTimer; import buildcraft.transport.network.PacketHandlerTransport; +import buildcraft.transport.network.PacketPipeTransportTraveler; import buildcraft.transport.pipes.PipeFluidsCobblestone; import buildcraft.transport.pipes.PipeFluidsEmerald; import buildcraft.transport.pipes.PipeFluidsGold; @@ -212,14 +213,17 @@ public class BuildCraftTransport extends BuildCraftMod { int meta = world.getBlockMetadata(i, j, k); - for (String excluded : excludedBlocks) { + // TODO: the exculded list is not taken into account. This probably + // needs to be migrated to an implementation based on names instead + // of ids, low priority for now. + /*for (String excluded : excludedBlocks) { if (excluded.equals(block.getUnlocalizedName())) return false; String[] tokens = excluded.split(":"); if (tokens[0].equals(Integer.toString(id)) && (tokens.length == 1 || tokens[1].equals(Integer.toString(meta)))) return false; - } + }*/ return true; } } @@ -473,4 +477,5 @@ public class BuildCraftTransport extends BuildCraftMod { return res; } + } diff --git a/common/buildcraft/api/core/StackWrapper.java b/common/buildcraft/api/core/StackWrapper.java index 040eff09..3da94754 100644 --- a/common/buildcraft/api/core/StackWrapper.java +++ b/common/buildcraft/api/core/StackWrapper.java @@ -8,6 +8,7 @@ */ package buildcraft.api.core; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; /** @@ -25,7 +26,10 @@ public class StackWrapper { @Override public int hashCode() { int hash = 5; - hash = 67 * hash + stack.itemID; + + // TODO: this may have a speed impact. To be checked. + hash = 67 * hash + Item.itemRegistry.getIDForObject(stack.getItem()); + hash = 67 * hash + stack.getItemDamage(); if (stack.stackTagCompound != null) hash = 67 * hash + stack.stackTagCompound.hashCode(); diff --git a/common/buildcraft/builders/BlockMarker.java b/common/buildcraft/builders/BlockMarker.java index 81ead8d7..35106e60 100644 --- a/common/buildcraft/builders/BlockMarker.java +++ b/common/buildcraft/builders/BlockMarker.java @@ -33,7 +33,7 @@ public class BlockMarker extends BlockContainer { public BlockMarker() { super(Material.circuits); - setLightValue(0.5F); + setLightLevel(0.5F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index c9b04a09..038f2ce2 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -191,7 +191,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP for (BlockIndex b : path) { worldObj.setBlock(b.x, b.y, b.z, null); - BuildCraftBuilders.pathMarkerBlock.dropBlockAsItem(worldObj, b.x, b.y, b.z, BuildCraftBuilders.pathMarkerBlock, 0); + BuildCraftBuilders.pathMarkerBlock.dropBlockAsItem(worldObj, b.x, b.y, b.z, 0, 0); } break; diff --git a/common/buildcraft/builders/filler/pattern/FillerPattern.java b/common/buildcraft/builders/filler/pattern/FillerPattern.java index a69a6da8..11a327a0 100644 --- a/common/buildcraft/builders/filler/pattern/FillerPattern.java +++ b/common/buildcraft/builders/filler/pattern/FillerPattern.java @@ -196,8 +196,11 @@ public abstract class FillerPattern implements IFillerPattern { private static void breakBlock(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (block != null) - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + if (block != null) { + // TODO: fix sound + //world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + } + if (BuildCraftBuilders.fillerDestroy) { world.setBlockToAir(x, y, z); } else if (BlockUtil.isToughBlock(world, x, y, z)) { diff --git a/common/buildcraft/core/BlockSpring.java b/common/buildcraft/core/BlockSpring.java index e5549834..69d481d3 100644 --- a/common/buildcraft/core/BlockSpring.java +++ b/common/buildcraft/core/BlockSpring.java @@ -46,7 +46,10 @@ public class BlockSpring extends Block { super(Material.rock); setBlockUnbreakable(); setResistance(6000000.0F); - setStepSound(soundStoneFootstep); + + // TODO: set proper sound + //setStepSound(soundStoneFootstep); + disableStats(); setTickRandomly(true); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); @@ -98,7 +101,7 @@ public class BlockSpring extends Block { // Prevents updates on chunk generation @Override - public boolean func_82506_l() { + public boolean func_149698_L () { return false; } diff --git a/common/buildcraft/core/ItemBuildCraft.java b/common/buildcraft/core/ItemBuildCraft.java index 13874083..8ce6e79e 100644 --- a/common/buildcraft/core/ItemBuildCraft.java +++ b/common/buildcraft/core/ItemBuildCraft.java @@ -11,6 +11,7 @@ import buildcraft.core.utils.StringUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -48,7 +49,7 @@ public class ItemBuildCraft extends Item { } @Override - public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return passSneakClick; } } diff --git a/common/buildcraft/core/ItemWrench.java b/common/buildcraft/core/ItemWrench.java index 7a74d039..7f519c65 100644 --- a/common/buildcraft/core/ItemWrench.java +++ b/common/buildcraft/core/ItemWrench.java @@ -61,7 +61,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { } @Override - public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return true; } } diff --git a/common/buildcraft/core/TickHandlerCoreClient.java b/common/buildcraft/core/TickHandlerCoreClient.java index b405ebfa..af481a15 100644 --- a/common/buildcraft/core/TickHandlerCoreClient.java +++ b/common/buildcraft/core/TickHandlerCoreClient.java @@ -10,6 +10,7 @@ import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; public class TickHandlerCoreClient { @@ -28,12 +29,16 @@ public class TickHandlerCoreClient { // if(!Config.disableVersionCheck) { if (Version.needsUpdateNoticeAndMarkAsSeen()) { - player.addChatMessage(String.format("\u00A7cNew version of BuildCraft available: %s for Minecraft %s", Version.getRecommendedVersion(), - CoreProxy.proxy.getMinecraftVersion())); + player.addChatMessage(new ChatComponentText( + String.format( + "\u00A7cNew version of BuildCraft available: %s for Minecraft %s", + Version.getRecommendedVersion(), + CoreProxy.proxy.getMinecraftVersion()))); for (String updateLine : Version.getChangelog()) { - player.addChatMessage("\u00A79" + updateLine); + player.addChatMessage(new ChatComponentText("\u00A79" + updateLine)); } - player.addChatMessage("\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again."); + player.addChatMessage(new ChatComponentText( + "\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again.")); } // } diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index 60bea7fb..d65375a5 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -7,8 +7,10 @@ */ package buildcraft.core; +import buildcraft.BuildCraftCore; import buildcraft.BuildCraftMod; import buildcraft.api.power.IPowerReceptor; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.ISynchronizedTile; import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadArrays; @@ -98,7 +100,11 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized @Override public Packet getDescriptionPacket() { - return new PacketTileUpdate(this).getPacket(); + // TODO: The description packet mechanism seems to have completely be replaced by other means, e.g. + // the update packet. If confirmed, remove the buffer packet mechanism in Utils as well, that is + // BuildCraftCore.bufferedDescriptions. + //return new PacketTileUpdate(this).getPacket(); + return null; } @Override @@ -107,14 +113,15 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized } @Override - public Packet getUpdatePacket() { - return new PacketTileUpdate(this).getPacket(); + public BuildCraftPacket getUpdatePacket() { + return new PacketTileUpdate(this); } @Override public void handleDescriptionPacket(PacketUpdate packet) throws IOException { - if (packet.payload instanceof PacketPayloadArrays) + if (packet.payload instanceof PacketPayloadArrays) { descriptionPacket.fromPayload(this, (PacketPayloadArrays) packet.payload); + } } @Override @@ -140,11 +147,6 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized owner = nbt.getString("owner"); } - public boolean isInvNameLocalized() { - // TODO Auto-generated method stub - return false; - } - public World getWorld() { return worldObj; } diff --git a/common/buildcraft/core/gui/BuildCraftContainer.java b/common/buildcraft/core/gui/BuildCraftContainer.java index 161e04ec..e34c394b 100644 --- a/common/buildcraft/core/gui/BuildCraftContainer.java +++ b/common/buildcraft/core/gui/BuildCraftContainer.java @@ -7,15 +7,22 @@ */ package buildcraft.core.gui; +import buildcraft.BuildCraftCore; import buildcraft.core.gui.slots.IPhantomSlot; import buildcraft.core.gui.slots.SlotBase; import buildcraft.core.gui.widgets.Widget; import buildcraft.core.inventory.StackHelper; import buildcraft.core.network.PacketGuiWidget; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; + import java.io.DataInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; + +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -47,11 +54,18 @@ public abstract class BuildCraftContainer extends Container { public void sendWidgetDataToClient(Widget widget, ICrafting player, byte[] data) { PacketGuiWidget pkt = new PacketGuiWidget(windowId, widgets.indexOf(widget), data); - PacketDispatcher.sendPacketToPlayer(pkt.getPacket(), (Player) player); + BuildCraftCore.instance.sendToPlayer((EntityPlayer) player, pkt); } - public void handleWidgetClientData(int widgetId, DataInputStream data) throws IOException { - widgets.get(widgetId).handleClientPacketData(data); + public void handleWidgetClientData(int widgetId, ByteBuf data) { + InputStream input = new ByteBufInputStream (data); + DataInputStream stream = new DataInputStream(input); + + try { + widgets.get(widgetId).handleClientPacketData(stream); + } catch (IOException e) { + e.printStackTrace(); + } } @Override diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index 83ad8545..34656dc3 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -67,10 +67,10 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; - itemRenderer.zLevel = 200F; - itemRenderer.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, cornerX + x, cornerY + y); - itemRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, cornerX + x, cornerY + y); - itemRenderer.zLevel = 0.0F; + itemRender.zLevel = 200F; + itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, cornerX + x, cornerY + y); + itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, cornerX + x, cornerY + y); + itemRender.zLevel = 0.0F; } } } diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java index 65164482..2a860ef9 100644 --- a/common/buildcraft/core/gui/GuiBuildCraft.java +++ b/common/buildcraft/core/gui/GuiBuildCraft.java @@ -230,7 +230,7 @@ public abstract class GuiBuildCraft extends GuiContainer { } this.zLevel = 300.0F; - itemRendererObj.zLevel = 300.0F; + itemRender.zLevel = 300.0F; int var15 = -267386864; this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15); this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15); @@ -259,7 +259,7 @@ public abstract class GuiBuildCraft extends GuiContainer { } this.zLevel = 0.0F; - itemRenderer.zLevel = 0.0F; + itemRender.zLevel = 0.0F; } } diff --git a/common/buildcraft/core/inventory/InvUtils.java b/common/buildcraft/core/inventory/InvUtils.java index 300c5908..4aa04ad4 100644 --- a/common/buildcraft/core/inventory/InvUtils.java +++ b/common/buildcraft/core/inventory/InvUtils.java @@ -198,7 +198,7 @@ public class InvUtils { public static ItemStack consumeItem(ItemStack stack) { if (stack.stackSize == 1) { if (stack.getItem().hasContainerItem()) { - return stack.getItem().getContainerItemStack(stack); + return stack.getItem().getContainerItem(stack); } else { return null; } diff --git a/common/buildcraft/core/inventory/InventoryWrapper.java b/common/buildcraft/core/inventory/InventoryWrapper.java index 89443d3a..1aec2cb9 100644 --- a/common/buildcraft/core/inventory/InventoryWrapper.java +++ b/common/buildcraft/core/inventory/InventoryWrapper.java @@ -20,13 +20,13 @@ public abstract class InventoryWrapper implements ISidedInventory { @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { return inventory.getStackInSlotOnClosing(slotIndex); } @Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { inventory.setInventorySlotContents(slotIndex, itemstack); } @Override public String getInventoryName() { return inventory.getInventoryName(); } - @Override public boolean isInvNameLocalized() { return inventory.isInvNameLocalized(); } @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } @Override public void markDirty() { inventory.markDirty(); } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return inventory.isUseableByPlayer(entityplayer); } @Override public void openInventory() { inventory.openInventory(); } @Override public void closeInventory() { inventory.closeInventory(); } @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { return inventory.isItemValidForSlot(slotIndex, itemstack); } + @Override public boolean hasCustomInventoryName() { return inventory.hasCustomInventoryName(); }; /* STATIC HELPER */ public static ISidedInventory getWrappedInventory(Object inventory) { diff --git a/common/buildcraft/core/inventory/InventoryWrapperSimple.java b/common/buildcraft/core/inventory/InventoryWrapperSimple.java index 5a66c930..2da6af71 100644 --- a/common/buildcraft/core/inventory/InventoryWrapperSimple.java +++ b/common/buildcraft/core/inventory/InventoryWrapperSimple.java @@ -28,13 +28,4 @@ public class InventoryWrapperSimple extends InventoryWrapper { return true; } - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void markDirty() { - } - } diff --git a/common/buildcraft/core/network/ISynchronizedTile.java b/common/buildcraft/core/network/ISynchronizedTile.java index 4e5c2a44..b6141b60 100644 --- a/common/buildcraft/core/network/ISynchronizedTile.java +++ b/common/buildcraft/core/network/ISynchronizedTile.java @@ -18,7 +18,7 @@ public interface ISynchronizedTile { public void postPacketHandling(PacketUpdate packet); - public Packet getUpdatePacket(); + public BuildCraftPacket getUpdatePacket(); public Packet getDescriptionPacket(); diff --git a/common/buildcraft/core/network/PacketGuiReturn.java b/common/buildcraft/core/network/PacketGuiReturn.java index e2889dcb..6a313eca 100644 --- a/common/buildcraft/core/network/PacketGuiReturn.java +++ b/common/buildcraft/core/network/PacketGuiReturn.java @@ -6,6 +6,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import buildcraft.BuildCraftCore; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; @@ -87,7 +88,7 @@ public class PacketGuiReturn extends BuildCraftPacket { } public void sendPacket() { - PacketDispatcher.sendPacketToServer(getPacket()); + BuildCraftCore.instance.sendToServer(this); } @Override diff --git a/common/buildcraft/core/network/PacketGuiWidget.java b/common/buildcraft/core/network/PacketGuiWidget.java index bdc1c4c8..fdb734e1 100644 --- a/common/buildcraft/core/network/PacketGuiWidget.java +++ b/common/buildcraft/core/network/PacketGuiWidget.java @@ -40,7 +40,7 @@ public class PacketGuiWidget extends BuildCraftPacket { public void writeData(ByteBuf data) { data.writeByte(windowId); data.writeByte(widgetId); - data.write(payload); + data.writeBytes(payload); } @Override @@ -50,8 +50,9 @@ public class PacketGuiWidget extends BuildCraftPacket { EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer; - if (player.openContainer instanceof BuildCraftContainer && player.openContainer.windowId == windowId) + if (player.openContainer instanceof BuildCraftContainer && player.openContainer.windowId == windowId) { ((BuildCraftContainer) player.openContainer).handleWidgetClientData(widgetId, data); + } } @Override diff --git a/common/buildcraft/core/network/PacketSlotChange.java b/common/buildcraft/core/network/PacketSlotChange.java index 6490ea1f..905a6540 100644 --- a/common/buildcraft/core/network/PacketSlotChange.java +++ b/common/buildcraft/core/network/PacketSlotChange.java @@ -6,6 +6,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import buildcraft.core.utils.Utils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; @@ -26,53 +27,17 @@ public class PacketSlotChange extends PacketCoordinates { @Override public void writeData(ByteBuf data) { - super.writeData(data); data.writeInt(slot); - if (stack != null) { - data.writeInt(Item.itemRegistry.getIDForObject(stack.getItem())); - data.writeInt(stack.stackSize); - data.writeInt(stack.getItemDamage()); - - if(stack.hasTagCompound()) { - byte[] compressed = CompressedStreamTools.compress(stack.getTagCompound()); - data.writeShort(compressed.length); - data.write(compressed); - } else { - data.writeShort(0); - } - - } else { - data.writeInt(0); - } + Utils.writeStack(data, stack); } @Override public void readData(ByteBuf data) { - super.readData(data); this.slot = data.readInt(); - int id = data.readInt(); - - if (id != 0) { - Item item = Item.getItemById(id); - stack = new ItemStack(item, data.readInt(), data.readInt()); - - // Yes, this stuff may indeed have NBT and don't you forget it. - short length = data.readShort(); - - if(length > 0) { - byte[] compressed = new byte[length]; - data.readFully(compressed); - stack.setTagCompound(CompressedStreamTools.decompress(compressed)); - } - - - } else { - stack = null; - } + stack = Utils.readStack(data); } - } diff --git a/common/buildcraft/core/network/PacketTileState.java b/common/buildcraft/core/network/PacketTileState.java index b84361d7..058a067e 100644 --- a/common/buildcraft/core/network/PacketTileState.java +++ b/common/buildcraft/core/network/PacketTileState.java @@ -23,7 +23,7 @@ public class PacketTileState extends PacketCoordinates { private List stateList = new LinkedList(); /** - * Default constructor for incomming packets + * Default constructor for incoming packets */ public PacketTileState() { } diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index 014fab44..7d7e7153 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -19,6 +19,8 @@ import java.io.File; import java.util.List; import java.util.Random; +import com.mojang.authlib.GameProfile; + import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -35,6 +37,7 @@ import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; @@ -138,10 +141,6 @@ public class CoreProxy { return 0; } - public void TakenFromCrafting(EntityPlayer thePlayer, ItemStack itemstack, IInventory craftMatrix) { - GameRegistry.onItemCrafted(thePlayer, itemstack, craftMatrix); - } - public Random createNewRandom(World world) { return new Random(world.getSeed()); } @@ -154,9 +153,9 @@ public class CoreProxy { } private EntityPlayer createNewPlayer(World world) { - EntityPlayer player = new EntityPlayer(world, "[BuildCraft]") { + EntityPlayer player = new EntityPlayer(world, new GameProfile (null, "[BuildCraft]")) { @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } @Override @@ -173,11 +172,11 @@ public class CoreProxy { } private EntityPlayer createNewPlayer(World world, int x, int y, int z) { - EntityPlayer player = new EntityPlayer(world, "[BuildCraft]") { + EntityPlayer player = new EntityPlayer(world, new GameProfile (null, "[BuildCraft]")) { @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } - + @Override public boolean canCommandSenderUseCommand(int var1, String var2) { return false; @@ -186,7 +185,7 @@ public class CoreProxy { @Override public ChunkCoordinates getPlayerCoordinates() { return null; - } + } }; player.posX = x; player.posY = y; diff --git a/common/buildcraft/core/proxy/CoreProxyClient.java b/common/buildcraft/core/proxy/CoreProxyClient.java index b7343eb6..df801110 100644 --- a/common/buildcraft/core/proxy/CoreProxyClient.java +++ b/common/buildcraft/core/proxy/CoreProxyClient.java @@ -21,7 +21,6 @@ import buildcraft.core.render.RenderLaser; import buildcraft.core.render.RenderRobot; import buildcraft.core.render.RenderingEntityBlocks; import buildcraft.core.render.RenderingMarkers; -import buildcraft.core.render.RenderingOil; import buildcraft.transport.render.TileEntityPickupFX; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -30,6 +29,8 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import java.io.File; import java.util.List; +import com.mojang.authlib.GameProfile; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; @@ -45,6 +46,7 @@ import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; import net.minecraft.world.World; public class CoreProxyClient extends CoreProxy { @@ -115,11 +117,9 @@ public class CoreProxyClient extends CoreProxy { BuildCraftCore.blockByEntityModel = RenderingRegistry.getNextAvailableRenderId(); BuildCraftCore.legacyPipeModel = RenderingRegistry.getNextAvailableRenderId(); BuildCraftCore.markerModel = RenderingRegistry.getNextAvailableRenderId(); - BuildCraftCore.oilModel = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderingEntityBlocks()); RenderingRegistry.registerBlockHandler(BuildCraftCore.legacyPipeModel, new RenderingEntityBlocks()); - RenderingRegistry.registerBlockHandler(new RenderingOil()); RenderingRegistry.registerBlockHandler(new RenderingMarkers()); } @@ -131,12 +131,6 @@ public class CoreProxyClient extends CoreProxy { RenderingRegistry.registerEntityRenderingHandler(EntityRobot.class, new RenderRobot()); } - /* NETWORKING */ - @Override - public void sendToServer(Packet packet) { - FMLClientHandler.instance().getClient().getNetHandler().addToSendQueue(packet); - } - /* BUILDCRAFT PLAYER */ @Override public String playerName() { @@ -144,9 +138,9 @@ public class CoreProxyClient extends CoreProxy { } private EntityPlayer createNewPlayer(World world) { - EntityPlayer player = new EntityPlayer(world, "[BuildCraft]") { + EntityPlayer player = new EntityPlayer(world, new GameProfile(null, "[BuildCraft]")) { @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } @Override @@ -159,6 +153,7 @@ public class CoreProxyClient extends CoreProxy { return null; } }; + return player; } diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java index e46459d1..12d94aff 100644 --- a/common/buildcraft/core/render/RenderEntityBlock.java +++ b/common/buildcraft/core/render/RenderEntityBlock.java @@ -195,7 +195,9 @@ public class RenderEntityBlock extends Render { if (blockAccess == null) doLight = false; - if (doTessellating && !tessellator.isDrawing) + // TODO: needs to cancel the test because the variable is now private... May need to + // duplicate the tessellator code. + //if (doTessellating && !tessellator.isDrawing) tessellator.startDrawingQuads(); float light = 0; @@ -253,7 +255,9 @@ public class RenderEntityBlock extends Render { if (info.renderSide[5]) renderBlocks.renderFaceXPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(5)); - if (doTessellating && tessellator.isDrawing) + // TODO: needs to cancel the test because the variable is now private... May need to + // duplicate the tessellator code. + //if (doTessellating && tessellator.isDrawing) tessellator.draw(); } } diff --git a/common/buildcraft/core/render/RenderingOil.java b/common/buildcraft/core/render/RenderingOil.java deleted file mode 100644 index 892f53d8..00000000 --- a/common/buildcraft/core/render/RenderingOil.java +++ /dev/null @@ -1,34 +0,0 @@ -package buildcraft.core.render; - -import buildcraft.BuildCraftCore; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.world.IBlockAccess; - -public class RenderingOil implements ISimpleBlockRenderingHandler { - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - - if (block.getRenderType() != BuildCraftCore.oilModel) - return true; - - renderer.renderBlockFluids(block, x, y, z); - return true; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } - - @Override - public int getRenderId() { - return BuildCraftCore.oilModel; - } -} diff --git a/common/buildcraft/core/utils/BCLog.java b/common/buildcraft/core/utils/BCLog.java index e987345e..ee916fc7 100644 --- a/common/buildcraft/core/utils/BCLog.java +++ b/common/buildcraft/core/utils/BCLog.java @@ -22,7 +22,9 @@ public class BCLog { public static final Logger logger = Logger.getLogger("Buildcraft"); public static void initLog() { - logger.setParent(FMLLog.getLogger()); + // TODO: check if the code below is still useful and remove otherwise. + //logger.setParent(FMLLog.getLogger()); + logger.info("Starting BuildCraft " + Version.getVersion()); logger.info("Copyright (c) SpaceToad, 2011"); logger.info("http://www.mod-buildcraft.com"); diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java index eba17df0..a602dc8c 100644 --- a/common/buildcraft/core/utils/BlockUtil.java +++ b/common/buildcraft/core/utils/BlockUtil.java @@ -22,6 +22,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S27PacketExplosion; import net.minecraft.world.ChunkPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; @@ -190,7 +191,7 @@ public class BlockUtil { continue; if (player.getDistanceSq(x, y, z) < 4096) { - ((EntityPlayerMP) player).playerNetServerHandler.sendPacketToPlayer(new Packet60Explosion(x + .5, y + .5, z + .5, 3f, explosion.affectedBlockPositions, null)); + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S27PacketExplosion(x + .5, y + .5, z + .5, 3f, explosion.affectedBlockPositions, null)); } } } diff --git a/common/buildcraft/energy/BlockBuildcraftFluid.java b/common/buildcraft/energy/BlockBuildcraftFluid.java index c1cd6116..04045ef1 100644 --- a/common/buildcraft/energy/BlockBuildcraftFluid.java +++ b/common/buildcraft/energy/BlockBuildcraftFluid.java @@ -75,22 +75,22 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { } @Override - public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) { + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return flammable ? 300 : 0; } @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return flammability; } @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return flammable; } @Override - public boolean isFireSource(World world, int x, int y, int z, int metadata, ForgeDirection side) { + public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { return flammable && flammability == 0; } @@ -106,7 +106,10 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { public void randomDisplayTick(World world, int x, int y, int z, Random rand) { super.randomDisplayTick(world, x, y, z, rand); - if (rand.nextInt(10) == 0 && world.doesBlockHaveSolidTopSurface(x, y - 1, z) && !world.getBlock(x, y - 2, z).getMaterial().blocksMovement()) { + if (rand.nextInt(10) == 0 + && World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) + && !world.getBlock(x, y - 2, z).getMaterial().blocksMovement()) { + double px = (double) ((float) x + rand.nextFloat()); double py = (double) y - 1.05D; double pz = (double) ((float) z + rand.nextFloat()); diff --git a/common/buildcraft/energy/render/EntityDropParticleFX.java b/common/buildcraft/energy/render/EntityDropParticleFX.java index ed0b16b0..f0337a62 100644 --- a/common/buildcraft/energy/render/EntityDropParticleFX.java +++ b/common/buildcraft/energy/render/EntityDropParticleFX.java @@ -3,6 +3,7 @@ package buildcraft.energy.render; import net.minecraft.client.particle.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -80,10 +81,16 @@ public class EntityDropParticleFX extends EntityFX { this.motionZ *= 0.699999988079071D; } - Material material = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial(); + int x = MathHelper.floor_double(this.posX); + int y = MathHelper.floor_double(this.posY); + int z = MathHelper.floor_double(this.posZ); + Block block = worldObj.getBlock(x, y, z); + + Material material = block.getMaterial(); if (material.isLiquid() || material.isSolid()) { - double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - BlockFluidBase.getFluidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))); + double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - ((BlockFluidBase) block) + .getFilledPercentage(worldObj, x, y, z)); if (this.posY < d0) { this.setDead(); diff --git a/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java b/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java index 170c50f7..82a46c89 100644 --- a/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java +++ b/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java @@ -1,5 +1,6 @@ package buildcraft.energy.worldgen; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenDesert; import net.minecraftforge.common.BiomeDictionary; @@ -9,6 +10,8 @@ import net.minecraftforge.common.BiomeDictionary; */ public class BiomeGenOilDesert extends BiomeGenDesert { + protected static final BiomeGenBase.Height height_OilDesert = new BiomeGenBase.Height(0.1F, 0.2F); + public static BiomeGenOilDesert makeBiome(int id) { BiomeGenOilDesert biome = new BiomeGenOilDesert(id); BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); @@ -23,6 +26,6 @@ public class BiomeGenOilDesert extends BiomeGenDesert { setBiomeName("Desert Oil Field"); setDisableRain(); setTemperatureRainfall(2.0F, 0.0F); - setMinMaxHeight(0.1F, 0.2F); + setHeight(height_OilDesert); } } diff --git a/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java b/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java index 963a4108..7d8b48f8 100644 --- a/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java +++ b/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java @@ -1,5 +1,6 @@ package buildcraft.energy.worldgen; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenOcean; import net.minecraftforge.common.BiomeDictionary; @@ -9,6 +10,8 @@ import net.minecraftforge.common.BiomeDictionary; */ public class BiomeGenOilOcean extends BiomeGenOcean { + protected static final BiomeGenBase.Height height_OilOcean = new BiomeGenBase.Height(0.1F, 0.2F); + public static BiomeGenOilOcean makeBiome(int id) { BiomeGenOilOcean biome = new BiomeGenOilOcean(id); BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.WATER); @@ -21,6 +24,6 @@ public class BiomeGenOilOcean extends BiomeGenOcean { super(id); setBiomeName("Ocean Oil Field"); setColor(112); - setMinMaxHeight(-1.0F, 0.4F); + setHeight(height_Oceans); } } diff --git a/common/buildcraft/energy/worldgen/OilPopulate.java b/common/buildcraft/energy/worldgen/OilPopulate.java index 40662598..52c12eee 100644 --- a/common/buildcraft/energy/worldgen/OilPopulate.java +++ b/common/buildcraft/energy/worldgen/OilPopulate.java @@ -33,6 +33,7 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType import net.minecraftforge.event.terraingen.TerrainGen; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.IFluidBlock; +import net.minecraftforge.common.util.EnumHelper; public class OilPopulate { @@ -279,15 +280,17 @@ public class OilPopulate { return true; } - if (block.isGenMineableReplaceable(world, x, y, z, Blocks.stone)) { - return true; - } + // TODO: The code below doesn't seem to have been replaced by something + // in 1.7.2 - to update or remove. + //if (block.isGenMineableReplaceable(world, x, y, z, Blocks.stone)) { + // return true; + //} if (block instanceof BlockFlower) { return true; } - if (!world.isBlockOpaqueCube(x, y, z)) { + if (!block.isOpaqueCube()) { return true; } diff --git a/common/buildcraft/factory/BlockMiningWell.java b/common/buildcraft/factory/BlockMiningWell.java index cd66d308..33125b5d 100644 --- a/common/buildcraft/factory/BlockMiningWell.java +++ b/common/buildcraft/factory/BlockMiningWell.java @@ -37,7 +37,9 @@ public class BlockMiningWell extends BlockBuildCraft { setHardness(5F); setResistance(10F); - setStepSound(soundStoneFootstep); + + // TODO: set proper sound + //setStepSound(soundStoneFootstep); } @Override diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index cc260ba3..6867dcda 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -43,7 +43,8 @@ public class BlockQuarry extends BlockBuildCraft { setHardness(10F); setResistance(10F); - setStepSound(soundAnvilFootstep); + // TODO: set proper sound + //setStepSound(soundAnvilFootstep); } @Override @@ -197,12 +198,6 @@ public class BlockQuarry extends BlockBuildCraft { return false; } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { diff --git a/common/buildcraft/factory/TileAutoWorkbench.java b/common/buildcraft/factory/TileAutoWorkbench.java index 72722496..61f08438 100644 --- a/common/buildcraft/factory/TileAutoWorkbench.java +++ b/common/buildcraft/factory/TileAutoWorkbench.java @@ -7,6 +7,8 @@ */ package buildcraft.factory; +import com.mojang.authlib.GameProfile; + import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.InvUtils; import buildcraft.core.inventory.InventoryConcatenator; @@ -62,7 +64,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory private final class InternalPlayer extends EntityPlayer { public InternalPlayer() { - super(TileAutoWorkbench.this.worldObj, "[BuildCraft]"); + super(TileAutoWorkbench.this.worldObj, new GameProfile(null, "[BuildCraft]")); posX = TileAutoWorkbench.this.xCoord; posY = TileAutoWorkbench.this.yCoord + 1; posZ = TileAutoWorkbench.this.zCoord; @@ -278,11 +280,6 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory public void closeInventory() { } - @Override - public boolean isInvNameLocalized() { - return false; - } - @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { if (slot == SLOT_RESULT) diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 106f8950..3fec53a2 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -12,11 +12,14 @@ import java.util.List; import java.util.Set; import net.minecraft.block.Block; +import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; import net.minecraft.world.ChunkCoordIntPair; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; @@ -429,7 +432,8 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } } - worldObj.playAuxSFXAtEntity(null, 2001, i, j, k, blockId + (worldObj.getBlockMetadata(i, j, k) << 12)); + // FIXME: fix sound here + //worldObj.playAuxSFXAtEntity(null, 2001, i, j, k, blockId + (worldObj.getBlockMetadata(i, j, k) << 12)); worldObj.setBlockToAir(i, j, k); } @@ -527,9 +531,11 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (chunkTicket == null) { isAlive = false; if (placedBy != null && CoreProxy.proxy.isSimulating(worldObj)) { - PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", - xCoord, yCoord, zCoord))), (Player) placedBy); + ((EntityPlayerMP) placedBy) + .addChatMessage(new ChatComponentText( + String.format( + "[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", + xCoord, yCoord, zCoord))); } sendNetworkUpdate(BuildCraftFactory.instance); return; @@ -556,10 +562,14 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth()) { if (placedBy != null) { - PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.createFromText(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize, - chunkTicket.getMaxChunkListDepth()))), (Player) placedBy); + ((EntityPlayerMP) placedBy) + .addChatMessage(new ChatComponentText( + String.format( + "Quarry size is outside of chunkloading bounds or too small %d %d (%d)", + xSize, zSize, + chunkTicket.getMaxChunkListDepth()))); } + a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); useDefault = true; @@ -845,11 +855,15 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept chunks.add(chunk); } } + if (placedBy != null) { - PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", xCoord, yCoord, zCoord, chunks.size()))), - (Player) placedBy); + ((EntityPlayerMP) placedBy) + .addChatMessage(new ChatComponentText( + String.format( + "[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", + xCoord, yCoord, zCoord, chunks.size()))); } + sendNetworkUpdate(BuildCraftFactory.instance); } diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java index f0d37210..c73f1860 100644 --- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java @@ -26,6 +26,7 @@ import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.Utils; import com.google.common.collect.Lists; +import com.mojang.authlib.GameProfile; import java.util.Arrays; import java.util.EnumSet; @@ -140,7 +141,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn private final class InternalPlayer extends EntityPlayer { public InternalPlayer() { - super(TileAdvancedCraftingTable.this.getWorldObj(), "[BuildCraft]"); + super(TileAdvancedCraftingTable.this.getWorldObj(), new GameProfile(null, "[BuildCraft]")); posX = TileAdvancedCraftingTable.this.xCoord; posY = TileAdvancedCraftingTable.this.yCoord + 1; posZ = TileAdvancedCraftingTable.this.zCoord; @@ -441,12 +442,6 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn return action == BuildCraftCore.actionOn || action == BuildCraftCore.actionOff; } - @Override - public boolean isInvNameLocalized() { - // TODO Auto-generated method stub - return false; - } - @Override public int[] getAccessibleSlotsFromSide(int side) { return SLOTS; diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index 67418952..13e5047b 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -305,11 +305,6 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I return currentRecipe != null; } - @Override - public boolean isInvNameLocalized() { - return false; - } - @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return true; diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 12099a01..e24906e5 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -45,7 +45,8 @@ public class ItemFacade extends ItemBuildCraft { setCreativeTab(CreativeTabBuildCraft.FACADES.get()); } - @Override + //TODO: how to control name of items? + /*@Override public String getItemDisplayName(ItemStack itemstack) { String name = super.getItemDisplayName(itemstack); Block decodedBlock = ItemFacade.getBlock(itemstack); @@ -60,7 +61,7 @@ public class ItemFacade extends ItemBuildCraft { name += " < BROKEN (" + decodedBlock.getLocalizedName() + ":" + decodedMeta + " )>"; } return name; - } + }*/ @Override public String getUnlocalizedName(ItemStack itemstack) { @@ -156,7 +157,7 @@ public class ItemFacade extends ItemBuildCraft { } @Override - public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { // Simply send shift click to the pipe / mod block. return true; } diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index 97dc656d..23b0e335 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -80,10 +80,13 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { if (BlockGenericPipe.placePipe(pipe, world, i, j, k, block, 0)) { block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack); - world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, - block.stepSound.getPlaceSound(), - (block.stepSound.getVolume() + 1.0F) / 2.0F, - block.stepSound.getPitch() * 0.8F); + + // TODO: Fix sound + //world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, + // block.stepSound.getPlaceSound(), + // (block.stepSound.getVolume() + 1.0F) / 2.0F, + // block.stepSound.getPitch() * 0.8F); + itemstack.stackSize--; } diff --git a/common/buildcraft/transport/ItemPlug.java b/common/buildcraft/transport/ItemPlug.java index 4557417e..5eaa493d 100644 --- a/common/buildcraft/transport/ItemPlug.java +++ b/common/buildcraft/transport/ItemPlug.java @@ -4,6 +4,7 @@ import buildcraft.core.ItemBuildCraft; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -44,7 +45,7 @@ public class ItemPlug extends ItemBuildCraft { // } @Override - public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return true; } diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index fefd7d7c..184c529b 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -424,7 +424,7 @@ public class PipeTransportItems extends PipeTransport { items.add(item); if (packet.forceStackRefresh() || item.getItemStack() == null) { - PacketDispatcher.sendPacketToServer(new PacketPipeTransportItemStackRequest(packet.getTravelingEntityId()).getPacket()); + BuildCraftTransport.instance.sendToServer(new PacketPipeTransportItemStackRequest(packet.getTravelingEntityId())); } item.setPosition(packet.getItemX(), packet.getItemY(), packet.getItemZ()); @@ -440,8 +440,7 @@ public class PipeTransportItems extends PipeTransport { private void sendTravelerPacket(TravelingItem data, boolean forceStackRefresh) { PacketPipeTransportTraveler packet = new PacketPipeTransportTraveler(data, forceStackRefresh); - int dimension = container.getWorldObj().provider.dimensionId; - PacketDispatcher.sendPacketToAllAround(container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST, dimension, packet.getPacket()); + BuildCraftTransport.instance.sendToPlayers(packet, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); } public int getNumberOfStacks() { diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index bcca462d..aff37790 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -221,16 +221,18 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (provider != null) provider.update(); - if (sendClientUpdate) { + // TODO: pipe synchronization with 1.7.2 needs to be reviewed. + /*if (sendClientUpdate) { sendClientUpdate = false; if (worldObj instanceof WorldServer) { WorldServer world = (WorldServer) worldObj; PlayerInstance playerInstance = world.getPlayerManager().getOrCreateChunkWatcher(xCoord >> 4, zCoord >> 4, false); + if (playerInstance != null) { playerInstance.sendToAllPlayersWatchingChunk(getDescriptionPacket()); } } - } + }*/ } // PRECONDITION: worldObj must not be null @@ -389,6 +391,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord); coreState.expansions.clear(); + if (pipe != null && pipe.gate != null) { coreState.gateMaterial = pipe.gate.material.ordinal(); coreState.gateLogic = pipe.gate.logic.ordinal(); @@ -405,9 +408,15 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui packet.addStateForSerialization((byte) 0, coreState); packet.addStateForSerialization((byte) 1, renderState); - if (pipe instanceof IClientState) + + if (pipe instanceof IClientState) { packet.addStateForSerialization((byte) 2, (IClientState) pipe); - return packet.getPacket(); + } + + // TODO: pipe synchronization with 1.7.2 needs to be reviewed. + //return packet.getPacket(); + + return null; } public void sendUpdateToClient() { @@ -713,8 +722,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } @Override - public boolean shouldRefresh(int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z) { - return oldID != newID; + public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { + return oldBlock != newBlock; } @Override diff --git a/common/buildcraft/transport/network/PacketHandlerTransport.java b/common/buildcraft/transport/network/PacketHandlerTransport.java index ca566373..dd3f1873 100644 --- a/common/buildcraft/transport/network/PacketHandlerTransport.java +++ b/common/buildcraft/transport/network/PacketHandlerTransport.java @@ -104,7 +104,7 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler { break; case PacketIds.PIPE_ITEMSTACK_REQUEST: { - // action will have happened already at read time + ((PacketPipeTransportItemStackRequest) packet).sendDataToPlayer((EntityPlayer) player); break; } } diff --git a/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java b/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java index e0942379..1dc18992 100644 --- a/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java +++ b/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java @@ -1,5 +1,6 @@ package buildcraft.transport.network; +import buildcraft.BuildCraftTransport; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.transport.TravelingItem; @@ -9,15 +10,13 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import net.minecraft.entity.player.EntityPlayer; + public class PacketPipeTransportItemStackRequest extends BuildCraftPacket { public int travelerID; - public Player player; - - public PacketPipeTransportItemStackRequest(Player player) { - this.player = player; - } - + TravelingItem item; + public PacketPipeTransportItemStackRequest(int travelerID) { this.travelerID = travelerID; } @@ -31,12 +30,18 @@ public class PacketPipeTransportItemStackRequest extends BuildCraftPacket { public void readData(ByteBuf data) { travelerID = data.readShort(); TravelingItem.TravelingItemCache cache = TravelingItem.serverCache; - TravelingItem item = cache.get(travelerID); - if (item == null) - return; - PacketDispatcher.sendPacketToPlayer(new PacketPipeTransportItemStack(travelerID, item.getItemStack()).getPacket(), player); + item = cache.get(travelerID); } + public void sendDataToPlayer (EntityPlayer player) { + if (item != null) { + BuildCraftTransport.instance.sendToPlayer( + player, + new PacketPipeTransportItemStack(travelerID, item + .getItemStack())); + } + } + @Override public int getID() { return PacketIds.PIPE_ITEMSTACK_REQUEST; diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java index c1913451..ee72aaa9 100644 --- a/common/buildcraft/transport/pipes/PipePowerIron.java +++ b/common/buildcraft/transport/pipes/PipePowerIron.java @@ -18,10 +18,13 @@ import buildcraft.transport.PipeTransportPower; import buildcraft.transport.triggers.ActionPowerLimiter; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.LinkedList; import java.util.Map; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.util.ChatComponentText; import net.minecraftforge.common.util.ForgeDirection; public class PipePowerIron extends Pipe { @@ -76,7 +79,9 @@ public class PipePowerIron extends Pipe { setMode(getMode().getNext()); } if (getWorld().isRemote) - player.addChatMessage(String.format(StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower)); + player.addChatMessage(new ChatComponentText(String.format( + StringUtils.localize("chat.pipe.power.iron.mode"), + getMode().maxPower))); ((IToolWrench) equipped).wrenchUsed(player, container.xCoord, container.yCoord, container.zCoord); return true;