Architects create bpts properly now + some bpt library fixes
This commit is contained in:
parent
a00f6129fa
commit
9ae784309e
9 changed files with 283 additions and 87 deletions
|
@ -69,6 +69,7 @@ import buildcraft.builders.TileBuilder;
|
||||||
import buildcraft.builders.TileFiller;
|
import buildcraft.builders.TileFiller;
|
||||||
import buildcraft.builders.TileMarker;
|
import buildcraft.builders.TileMarker;
|
||||||
import buildcraft.builders.TilePathMarker;
|
import buildcraft.builders.TilePathMarker;
|
||||||
|
import buildcraft.builders.network.PacketHandlerBuilders;
|
||||||
import buildcraft.core.DefaultProps;
|
import buildcraft.core.DefaultProps;
|
||||||
import buildcraft.core.Version;
|
import buildcraft.core.Version;
|
||||||
import buildcraft.core.blueprints.BptPlayerIndex;
|
import buildcraft.core.blueprints.BptPlayerIndex;
|
||||||
|
@ -84,12 +85,12 @@ import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.Property;
|
import net.minecraftforge.common.Property;
|
||||||
|
|
||||||
@Mod(name="BuildCraft Builders", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE)
|
@Mod(name="BuildCraft Builders", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||||
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
|
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerBuilders.class, clientSideRequired = true, serverSideRequired = true)
|
||||||
public class BuildCraftBuilders {
|
public class BuildCraftBuilders {
|
||||||
|
|
||||||
public static final int LIBRARY_PAGE_SIZE = 12;
|
public static final int LIBRARY_PAGE_SIZE = 12;
|
||||||
|
|
||||||
public static final int MAX_BLUEPRINTS_NAME_SIZE = 88;
|
public static final int MAX_BLUEPRINTS_NAME_SIZE = 14;
|
||||||
|
|
||||||
public static BlockMarker markerBlock;
|
public static BlockMarker markerBlock;
|
||||||
public static BlockPathMarker pathMarkerBlock;
|
public static BlockPathMarker pathMarkerBlock;
|
||||||
|
|
|
@ -74,9 +74,8 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) {
|
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) {
|
||||||
if (entityliving instanceof EntityPlayer) {
|
if (CoreProxy.proxy.isSimulating(world) && entityliving instanceof EntityPlayer) {
|
||||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getBlockTileEntity(i, j, k);
|
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getBlockTileEntity(i, j, k);
|
||||||
|
|
||||||
tile.owner = ((EntityPlayer) entityliving).username;
|
tile.owner = ((EntityPlayer) entityliving).username;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,13 @@ import buildcraft.core.blueprints.BptBase;
|
||||||
import buildcraft.core.blueprints.BptBlueprint;
|
import buildcraft.core.blueprints.BptBlueprint;
|
||||||
import buildcraft.core.blueprints.BptContext;
|
import buildcraft.core.blueprints.BptContext;
|
||||||
import buildcraft.core.blueprints.BptTemplate;
|
import buildcraft.core.blueprints.BptTemplate;
|
||||||
|
import buildcraft.core.network.PacketIds;
|
||||||
|
import buildcraft.core.network.PacketPayload;
|
||||||
import buildcraft.core.network.PacketUpdate;
|
import buildcraft.core.network.PacketUpdate;
|
||||||
import buildcraft.core.network.TileNetworkData;
|
import buildcraft.core.network.TileNetworkData;
|
||||||
import buildcraft.core.proxy.CoreProxy;
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
|
import buildcraft.factory.TileAssemblyTable;
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
import net.minecraft.src.IInventory;
|
import net.minecraft.src.IInventory;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
|
@ -39,7 +42,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
|
||||||
private boolean isComputing = false;
|
private boolean isComputing = false;
|
||||||
public int computingTime = 0;
|
public int computingTime = 0;
|
||||||
|
|
||||||
public String name = "";
|
public @TileNetworkData String name = "";
|
||||||
|
|
||||||
// Use that field to avoid creating several times the same template if
|
// Use that field to avoid creating several times the same template if
|
||||||
// they're the same!
|
// they're the same!
|
||||||
|
@ -49,7 +52,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (isComputing) {
|
if (CoreProxy.proxy.isSimulating(worldObj) && isComputing) {
|
||||||
if (computingTime < 200) {
|
if (computingTime < 200) {
|
||||||
computingTime++;
|
computingTime++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,6 +177,28 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendClientInput(char c){
|
||||||
|
PacketUpdate packet = new PacketUpdate(PacketIds.ARCHITECT_NAME);
|
||||||
|
PacketPayload payload = new PacketPayload();
|
||||||
|
packet.payload = payload;
|
||||||
|
packet.posX = xCoord;
|
||||||
|
packet.posY = yCoord;
|
||||||
|
packet.posZ = zCoord;
|
||||||
|
payload.intPayload = new int[]{c};
|
||||||
|
CoreProxy.proxy.sendToServer(packet.getPacket());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleClientInput(char c){
|
||||||
|
if (c == 8) {
|
||||||
|
if (name.length() > 0)
|
||||||
|
name = name.substring(0, name.length() - 1);
|
||||||
|
} else if (Character.isLetterOrDigit(c) || c == ' ') {
|
||||||
|
if (name.length() < BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE)
|
||||||
|
name += c;
|
||||||
|
}
|
||||||
|
sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory() {
|
public int getSizeInventory() {
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
package buildcraft.builders;
|
package buildcraft.builders;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import buildcraft.BuildCraftBuilders;
|
import buildcraft.BuildCraftBuilders;
|
||||||
import buildcraft.builders.BuildersProxy;
|
import buildcraft.builders.BuildersProxy;
|
||||||
|
import buildcraft.core.TileBuildCraft;
|
||||||
import buildcraft.core.blueprints.BptBase;
|
import buildcraft.core.blueprints.BptBase;
|
||||||
import buildcraft.core.blueprints.BptPlayerIndex;
|
import buildcraft.core.blueprints.BptPlayerIndex;
|
||||||
|
import buildcraft.core.network.TileNetworkData;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
|
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
|
@ -15,7 +18,7 @@ import net.minecraft.src.ItemStack;
|
||||||
import net.minecraft.src.NBTTagCompound;
|
import net.minecraft.src.NBTTagCompound;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
|
|
||||||
public class TileBlueprintLibrary extends TileEntity implements IInventory {
|
public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
|
||||||
|
|
||||||
public ItemStack[] stack = new ItemStack[4];
|
public ItemStack[] stack = new ItemStack[4];
|
||||||
|
|
||||||
|
@ -24,12 +27,20 @@ public class TileBlueprintLibrary extends TileEntity implements IInventory {
|
||||||
|
|
||||||
public String owner = "";
|
public String owner = "";
|
||||||
|
|
||||||
public BptBase selected = null;
|
private ArrayList<BptBase> currentPage;
|
||||||
|
public @TileNetworkData(staticSize=BuildCraftBuilders.LIBRARY_PAGE_SIZE) String[] currentNames = new String[BuildCraftBuilders.LIBRARY_PAGE_SIZE];
|
||||||
|
public @TileNetworkData int selected = -1;
|
||||||
|
|
||||||
public boolean locked = false;
|
public @TileNetworkData boolean locked = false;
|
||||||
|
|
||||||
public LinkedList<BptBase> getNextPage(String after) {
|
@Override
|
||||||
LinkedList<BptBase> result = new LinkedList<BptBase>();
|
public void initialize() {
|
||||||
|
super.initialize();
|
||||||
|
setCurrentPage(getNextPage(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<BptBase> getNextPage(String after) {
|
||||||
|
ArrayList<BptBase> result = new ArrayList<BptBase>();
|
||||||
|
|
||||||
BptPlayerIndex index = BuildCraftBuilders.getPlayerIndex(BuildersProxy.getOwner(this));
|
BptPlayerIndex index = BuildCraftBuilders.getPlayerIndex(BuildersProxy.getOwner(this));
|
||||||
|
|
||||||
|
@ -52,8 +63,8 @@ public class TileBlueprintLibrary extends TileEntity implements IInventory {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedList<BptBase> getPrevPage(String before) {
|
public ArrayList<BptBase> getPrevPage(String before) {
|
||||||
LinkedList<BptBase> result = new LinkedList<BptBase>();
|
ArrayList<BptBase> result = new ArrayList<BptBase>();
|
||||||
|
|
||||||
BptPlayerIndex index = BuildCraftBuilders.getPlayerIndex(BuildersProxy.getOwner(this));
|
BptPlayerIndex index = BuildCraftBuilders.getPlayerIndex(BuildersProxy.getOwner(this));
|
||||||
|
|
||||||
|
@ -75,6 +86,37 @@ public class TileBlueprintLibrary extends TileEntity implements IInventory {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateCurrentNames(){
|
||||||
|
currentNames = new String[BuildCraftBuilders.LIBRARY_PAGE_SIZE];
|
||||||
|
for(int i = 0; i < currentNames.length; i++){
|
||||||
|
currentNames[i] = currentPage.get(i).getName();
|
||||||
|
}
|
||||||
|
sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<BptBase> getCurrentPage(){
|
||||||
|
return currentPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentPage(ArrayList<BptBase> newPage){
|
||||||
|
currentPage = newPage;
|
||||||
|
updateCurrentNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteSelectedBpt(EntityPlayer player){
|
||||||
|
BptPlayerIndex index = BuildCraftBuilders.getPlayerIndex(player.username);
|
||||||
|
if (selected > -1) {
|
||||||
|
index.deleteBluePrint(currentPage.get(selected).file.getName());
|
||||||
|
if (currentPage.size() > 0) {
|
||||||
|
currentPage = getNextPage(index.prevBpt(currentPage.get(0).file.getName()));
|
||||||
|
} else {
|
||||||
|
currentPage = getNextPage(null);
|
||||||
|
}
|
||||||
|
selected = -1;
|
||||||
|
updateCurrentNames();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
@ -199,8 +241,8 @@ public class TileBlueprintLibrary extends TileEntity implements IInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressOut == 100 && stack[3] == null) {
|
if (progressOut == 100 && stack[3] == null) {
|
||||||
if (selected != null) {
|
if (selected > -1) {
|
||||||
setInventorySlotContents(3, new ItemStack(stack[2].itemID, 1, selected.position));
|
setInventorySlotContents(3, new ItemStack(stack[2].itemID, 1, currentPage.get(selected).position));
|
||||||
} else {
|
} else {
|
||||||
setInventorySlotContents(3, new ItemStack(stack[2].itemID, 1, 0));
|
setInventorySlotContents(3, new ItemStack(stack[2].itemID, 1, 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,7 @@ import net.minecraft.src.IInventory;
|
||||||
import net.minecraft.src.Slot;
|
import net.minecraft.src.Slot;
|
||||||
|
|
||||||
public class ContainerBlueprintLibrary extends BuildCraftContainer {
|
public class ContainerBlueprintLibrary extends BuildCraftContainer {
|
||||||
|
|
||||||
public LinkedList<BptBase> contents = new LinkedList<BptBase>();
|
|
||||||
|
|
||||||
protected IInventory playerInventory;
|
protected IInventory playerInventory;
|
||||||
protected TileBlueprintLibrary library;
|
protected TileBlueprintLibrary library;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,11 @@ import buildcraft.core.DefaultProps;
|
||||||
import buildcraft.core.blueprints.BptBase;
|
import buildcraft.core.blueprints.BptBase;
|
||||||
import buildcraft.core.blueprints.BptPlayerIndex;
|
import buildcraft.core.blueprints.BptPlayerIndex;
|
||||||
import buildcraft.core.gui.GuiBuildCraft;
|
import buildcraft.core.gui.GuiBuildCraft;
|
||||||
|
import buildcraft.core.network.PacketCoordinates;
|
||||||
|
import buildcraft.core.network.PacketIds;
|
||||||
|
import buildcraft.core.network.PacketPayload;
|
||||||
|
import buildcraft.core.network.PacketUpdate;
|
||||||
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
import buildcraft.core.utils.StringUtil;
|
import buildcraft.core.utils.StringUtil;
|
||||||
|
|
||||||
public class GuiBlueprintLibrary extends GuiBuildCraft {
|
public class GuiBlueprintLibrary extends GuiBuildCraft {
|
||||||
|
@ -47,7 +52,6 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
|
||||||
this.library = library;
|
this.library = library;
|
||||||
container = (ContainerBlueprintLibrary) inventorySlots;
|
container = (ContainerBlueprintLibrary) inventorySlots;
|
||||||
|
|
||||||
container.contents = library.getNextPage(null);
|
|
||||||
index = BuildCraftBuilders.getPlayerIndex(player.username);
|
index = BuildCraftBuilders.getPlayerIndex(player.username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +79,6 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
|
||||||
|
|
||||||
lockButton = new GuiButton(3, j + 127, k + 114, 40, 20, StringUtil.localize("gui.lock"));
|
lockButton = new GuiButton(3, j + 127, k + 114, 40, 20, StringUtil.localize("gui.lock"));
|
||||||
controlList.add(lockButton);
|
controlList.add(lockButton);
|
||||||
|
|
||||||
if (library.locked)
|
|
||||||
lockButton.displayString = StringUtil.localize("gui.unlock");
|
|
||||||
else
|
|
||||||
lockButton.displayString = StringUtil.localize("gui.lock");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,16 +89,15 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
|
||||||
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
|
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for (BptBase bpt : container.contents) {
|
String[] currentNames = library.currentNames;
|
||||||
if (bpt == library.selected) {
|
for (int i = 0; i < currentNames.length; i++) {
|
||||||
|
if (i == library.selected) {
|
||||||
int l1 = 8;
|
int l1 = 8;
|
||||||
int i2 = 24;
|
int i2 = 24;
|
||||||
drawGradientRect(l1, i2 + 9 * c, l1 + 88, i2 + 9 * (c + 1), 0x80ffffff, 0x80ffffff);
|
drawGradientRect(l1, i2 + 9 * c, l1 + 88, i2 + 9 * (c + 1), 0x80ffffff, 0x80ffffff);
|
||||||
}
|
}
|
||||||
String name = bpt.getName();
|
String name = currentNames[i];
|
||||||
|
name = name.substring(0, BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE);
|
||||||
while (fontRenderer.getStringWidth(name) > BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE)
|
|
||||||
name = name.substring(0, name.length() - 1);
|
|
||||||
|
|
||||||
fontRenderer.drawString(name, 9, 25 + 9 * c, 0x404040);
|
fontRenderer.drawString(name, 9, 25 + 9 * c, 0x404040);
|
||||||
c++;
|
c++;
|
||||||
|
@ -125,21 +123,43 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
|
||||||
int inP = (int) (library.progressIn / 100.0 * 22.0);
|
int inP = (int) (library.progressIn / 100.0 * 22.0);
|
||||||
int outP = (int) (library.progressOut / 100.0 * 22.0);
|
int outP = (int) (library.progressOut / 100.0 * 22.0);
|
||||||
|
|
||||||
if (inP != 0)
|
|
||||||
computeInput = true;
|
|
||||||
else if (computeInput) {
|
|
||||||
// In this case, there was a store computation that has finished.
|
|
||||||
if (container.contents.size() == 0)
|
|
||||||
container.contents = library.getNextPage(null);
|
|
||||||
else
|
|
||||||
container.contents = library.getNextPage(index.prevBpt(container.contents.getFirst().file.getName()));
|
|
||||||
|
|
||||||
computeInput = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawTexturedModalRect(j + 128 + 22 - inP, k + 61, 176 + 22 - inP, 16, inP, 16);
|
drawTexturedModalRect(j + 128 + 22 - inP, k + 61, 176 + 22 - inP, 16, inP, 16);
|
||||||
drawTexturedModalRect(j + 128, k + 78, 176, 0, outP, 16);
|
drawTexturedModalRect(j + 128, k + 78, 176, 0, outP, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen(){
|
||||||
|
if (library.locked) {
|
||||||
|
lockButton.displayString = StringUtil.localize("gui.unlock");
|
||||||
|
} else {
|
||||||
|
lockButton.displayString = StringUtil.localize("gui.lock");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) {
|
||||||
|
if (button == nextPageButton) {
|
||||||
|
PacketUpdate packet = new PacketUpdate(PacketIds.LIBRARY_COMMAND);
|
||||||
|
PacketPayload payload = new PacketPayload();
|
||||||
|
packet.payload = payload;
|
||||||
|
payload.intPayload = new int[]{0};
|
||||||
|
CoreProxy.proxy.sendToServer(packet.getPacket());
|
||||||
|
} else if (button == prevPageButton) {
|
||||||
|
PacketUpdate packet = new PacketUpdate(PacketIds.LIBRARY_COMMAND);
|
||||||
|
PacketPayload payload = new PacketPayload();
|
||||||
|
packet.payload = payload;
|
||||||
|
payload.intPayload = new int[]{1};
|
||||||
|
CoreProxy.proxy.sendToServer(packet.getPacket());
|
||||||
|
} else if (lockButton != null && button == lockButton) {
|
||||||
|
PacketCoordinates packet = new PacketCoordinates(PacketIds.LIBRARY_LOCK_UPDATE,
|
||||||
|
library.xCoord, library.yCoord, library.zCoord);
|
||||||
|
CoreProxy.proxy.sendToServer(packet.getPacket());
|
||||||
|
} else if (deleteButton != null && button == deleteButton) {
|
||||||
|
PacketCoordinates packet = new PacketCoordinates(PacketIds.LIBRARY_DELETE,
|
||||||
|
library.xCoord, library.yCoord, library.zCoord);
|
||||||
|
CoreProxy.proxy.sendToServer(packet.getPacket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int i, int j, int k) {
|
protected void mouseClicked(int i, int j, int k) {
|
||||||
|
@ -155,35 +175,15 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
|
||||||
if (x >= 8 && x <= 88) {
|
if (x >= 8 && x <= 88) {
|
||||||
int ySlot = (y - 24) / 9;
|
int ySlot = (y - 24) / 9;
|
||||||
|
|
||||||
if (ySlot >= 0 && ySlot <= 11)
|
if (ySlot >= 0 && ySlot <= 11){
|
||||||
if (ySlot < container.contents.size())
|
if (ySlot < library.currentNames.length){
|
||||||
library.selected = container.contents.get(ySlot);
|
PacketUpdate packet = new PacketUpdate(PacketIds.LIBRARY_SELECT);
|
||||||
} else if (nextPageButton.mousePressed(client, i, j)) {
|
PacketPayload payload = new PacketPayload();
|
||||||
if (container.contents.size() > 0)
|
packet.payload = payload;
|
||||||
container.contents = library.getNextPage(container.contents.getLast().file.getName());
|
payload.intPayload = new int[]{ySlot};
|
||||||
else
|
CoreProxy.proxy.sendToServer(packet.getPacket());
|
||||||
container.contents = library.getNextPage(null);
|
}
|
||||||
} else if (prevPageButton.mousePressed(client, i, j)) {
|
|
||||||
if (container.contents.size() > 0)
|
|
||||||
container.contents = library.getPrevPage(container.contents.getFirst().file.getName());
|
|
||||||
else
|
|
||||||
container.contents = library.getNextPage(null);
|
|
||||||
} else if (lockButton != null && lockButton.mousePressed(client, i, j)) {
|
|
||||||
library.locked = !library.locked;
|
|
||||||
|
|
||||||
if (library.locked)
|
|
||||||
lockButton.displayString = StringUtil.localize("gui.unlock");
|
|
||||||
else
|
|
||||||
lockButton.displayString = StringUtil.localize("gui.lock");
|
|
||||||
} else if (deleteButton != null && deleteButton.mousePressed(client, i, j))
|
|
||||||
if (library.selected != null) {
|
|
||||||
index.deleteBluePrint(library.selected.file.getName());
|
|
||||||
if (container.contents.size() > 0)
|
|
||||||
container.contents = library.getNextPage(index.prevBpt(container.contents.getFirst().file.getName()));
|
|
||||||
else
|
|
||||||
container.contents = library.getNextPage(null);
|
|
||||||
|
|
||||||
library.selected = null;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ import buildcraft.BuildCraftBuilders;
|
||||||
import buildcraft.builders.TileArchitect;
|
import buildcraft.builders.TileArchitect;
|
||||||
import buildcraft.core.DefaultProps;
|
import buildcraft.core.DefaultProps;
|
||||||
import buildcraft.core.gui.GuiBuildCraft;
|
import buildcraft.core.gui.GuiBuildCraft;
|
||||||
|
import buildcraft.core.network.PacketUpdate;
|
||||||
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
import buildcraft.core.utils.StringUtil;
|
import buildcraft.core.utils.StringUtil;
|
||||||
|
|
||||||
public class GuiTemplate extends GuiBuildCraft {
|
public class GuiTemplate extends GuiBuildCraft {
|
||||||
|
@ -77,24 +79,14 @@ public class GuiTemplate extends GuiBuildCraft {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void keyTyped(char c, int i) {
|
protected void keyTyped(char c, int i) {
|
||||||
if (editMode)
|
if (i != 1 && editMode) {
|
||||||
if (c == 13) {
|
if (c == 13) {
|
||||||
editMode = false;
|
editMode = false;
|
||||||
|
|
||||||
return;
|
|
||||||
} else if (c == 8) {
|
|
||||||
if (template.name.length() > 0)
|
|
||||||
template.name = template.name.substring(0, template.name.length() - 1);
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else if (Character.isLetterOrDigit(c) || c == ' ') {
|
|
||||||
if (fontRenderer.getStringWidth(template.name + c) <= BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE)
|
|
||||||
template.name += c;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
template.sendClientInput(c);
|
||||||
super.keyTyped(c, i);
|
} else {
|
||||||
|
super.keyTyped(c, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
134
common/buildcraft/builders/network/PacketHandlerBuilders.java
Normal file
134
common/buildcraft/builders/network/PacketHandlerBuilders.java
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
package buildcraft.builders.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.builders.TileArchitect;
|
||||||
|
import buildcraft.builders.TileBlueprintLibrary;
|
||||||
|
import buildcraft.core.network.PacketCoordinates;
|
||||||
|
import buildcraft.core.network.PacketIds;
|
||||||
|
import buildcraft.core.network.PacketPayload;
|
||||||
|
import buildcraft.core.network.PacketUpdate;
|
||||||
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
|
import buildcraft.factory.TileAssemblyTable;
|
||||||
|
import buildcraft.factory.TileAssemblyTable.SelectionMessage;
|
||||||
|
import buildcraft.silicon.gui.ContainerAssemblyTable;
|
||||||
|
|
||||||
|
import net.minecraft.src.Container;
|
||||||
|
import net.minecraft.src.EntityPlayer;
|
||||||
|
import net.minecraft.src.NetworkManager;
|
||||||
|
import net.minecraft.src.Packet250CustomPayload;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
import net.minecraft.src.World;
|
||||||
|
|
||||||
|
public class PacketHandlerBuilders implements IPacketHandler {
|
||||||
|
|
||||||
|
@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.ARCHITECT_NAME:
|
||||||
|
PacketUpdate packetA = new PacketUpdate();
|
||||||
|
packetA.readData(data);
|
||||||
|
onArchitectName((EntityPlayer)player, packetA);
|
||||||
|
break;
|
||||||
|
case PacketIds.LIBRARY_COMMAND:
|
||||||
|
PacketUpdate packetB = new PacketUpdate();
|
||||||
|
packetB.readData(data);
|
||||||
|
onLibraryCommand((EntityPlayer)player, packetB);
|
||||||
|
break;
|
||||||
|
case PacketIds.LIBRARY_LOCK_UPDATE:
|
||||||
|
PacketCoordinates packetC = new PacketCoordinates();
|
||||||
|
packetC.readData(data);
|
||||||
|
onLockUpdate((EntityPlayer)player, packetC);
|
||||||
|
break;
|
||||||
|
case PacketIds.LIBRARY_DELETE:
|
||||||
|
PacketCoordinates packetD = new PacketCoordinates();
|
||||||
|
packetD.readData(data);
|
||||||
|
onDeleteBpt((EntityPlayer)player, packetD);
|
||||||
|
break;
|
||||||
|
case PacketIds.LIBRARY_SELECT:
|
||||||
|
PacketUpdate packetE = new PacketUpdate();
|
||||||
|
packetE.readData(data);
|
||||||
|
onLibrarySelect((EntityPlayer)player, packetE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onArchitectName(EntityPlayer player, PacketUpdate packet) {
|
||||||
|
TileEntity te = player.worldObj.getBlockTileEntity(packet.posX,
|
||||||
|
packet.posY, packet.posZ);
|
||||||
|
if(te instanceof TileArchitect){
|
||||||
|
((TileArchitect) te).handleClientInput((char) packet.payload.intPayload[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onLibraryCommand(EntityPlayer player, PacketUpdate packet) {
|
||||||
|
TileEntity te = player.worldObj.getBlockTileEntity(packet.posX,
|
||||||
|
packet.posY, packet.posZ);
|
||||||
|
if(te instanceof TileArchitect) {
|
||||||
|
TileBlueprintLibrary tbl = (TileBlueprintLibrary) te;
|
||||||
|
boolean nextPage = packet.payload.intPayload[0] == 0;
|
||||||
|
if (nextPage) {
|
||||||
|
if (tbl.getCurrentPage().size() > 0) {
|
||||||
|
tbl.setCurrentPage(tbl.getNextPage(tbl.getCurrentPage().get(tbl.currentNames.length - 1).file.getName()));
|
||||||
|
} else {
|
||||||
|
tbl.setCurrentPage(tbl.getNextPage(null));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tbl.getCurrentPage().size() > 0) {
|
||||||
|
tbl.setCurrentPage(tbl.getPrevPage(tbl.getCurrentPage().get(0).file.getName()));
|
||||||
|
} else {
|
||||||
|
tbl.setCurrentPage(tbl.getNextPage(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tbl.sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onLibrarySelect(EntityPlayer player, PacketUpdate packet) {
|
||||||
|
TileEntity te = player.worldObj.getBlockTileEntity(packet.posX,
|
||||||
|
packet.posY, packet.posZ);
|
||||||
|
if(te instanceof TileBlueprintLibrary){
|
||||||
|
TileBlueprintLibrary tbl = (TileBlueprintLibrary) te;
|
||||||
|
int ySlot = packet.payload.intPayload[0];
|
||||||
|
if (ySlot < tbl.currentNames.length){
|
||||||
|
tbl.selected = ySlot;
|
||||||
|
}
|
||||||
|
tbl.sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onLockUpdate(EntityPlayer player, PacketCoordinates packet) {
|
||||||
|
TileEntity te = player.worldObj.getBlockTileEntity(packet.posX,
|
||||||
|
packet.posY, packet.posZ);
|
||||||
|
if(te instanceof TileBlueprintLibrary){
|
||||||
|
TileBlueprintLibrary tbl = (TileBlueprintLibrary) te;
|
||||||
|
tbl.locked = !tbl.locked;
|
||||||
|
tbl.sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onDeleteBpt(EntityPlayer player, PacketCoordinates packet) {
|
||||||
|
TileEntity te = player.worldObj.getBlockTileEntity(packet.posX,
|
||||||
|
packet.posY, packet.posZ);
|
||||||
|
if(te instanceof TileBlueprintLibrary){
|
||||||
|
TileBlueprintLibrary tbl = (TileBlueprintLibrary) te;
|
||||||
|
tbl.deleteSelectedBpt(player);
|
||||||
|
tbl.sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,11 @@ public class PacketIds {
|
||||||
public static final int GATE_SELECTION_CHANGE = 44;
|
public static final int GATE_SELECTION_CHANGE = 44;
|
||||||
public static final int GATE_TRIGGERS = 45;
|
public static final int GATE_TRIGGERS = 45;
|
||||||
public static final int REFINERY_FILTER_SET = 50;
|
public static final int REFINERY_FILTER_SET = 50;
|
||||||
|
public static final int ARCHITECT_NAME = 60;
|
||||||
|
public static final int LIBRARY_COMMAND = 61;
|
||||||
|
public static final int LIBRARY_LOCK_UPDATE = 62;
|
||||||
|
public static final int LIBRARY_DELETE = 63;
|
||||||
|
public static final int LIBRARY_SELECT = 64;
|
||||||
|
|
||||||
public static final int STATE_UPDATE = 100;
|
public static final int STATE_UPDATE = 100;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue