made progress in board parameters, #1732
This commit is contained in:
parent
6150c5b09e
commit
e193d634cf
26 changed files with 532 additions and 77 deletions
20
api/buildcraft/api/boards/IBoardParameter.java
Executable file
20
api/buildcraft/api/boards/IBoardParameter.java
Executable file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IBoardParameter {
|
||||
|
||||
String getName();
|
||||
|
||||
void writeToNBT(NBTTagCompound nbt);
|
||||
|
||||
void readFromNBT(NBTTagCompound nbt);
|
||||
}
|
14
api/buildcraft/api/boards/IBoardParameterArea.java
Executable file
14
api/buildcraft/api/boards/IBoardParameterArea.java
Executable file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
public interface IBoardParameterArea extends IBoardParameter {
|
||||
|
||||
|
||||
}
|
14
api/buildcraft/api/boards/IBoardParameterPath.java
Executable file
14
api/buildcraft/api/boards/IBoardParameterPath.java
Executable file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
public interface IBoardParameterPath extends IBoardParameter {
|
||||
|
||||
|
||||
}
|
14
api/buildcraft/api/boards/IBoardParameterPosition.java
Executable file
14
api/buildcraft/api/boards/IBoardParameterPosition.java
Executable file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
public interface IBoardParameterPosition extends IBoardParameter {
|
||||
|
||||
|
||||
}
|
19
api/buildcraft/api/boards/IBoardParameterStack.java
Executable file
19
api/buildcraft/api/boards/IBoardParameterStack.java
Executable file
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IBoardParameterStack extends IBoardParameter {
|
||||
|
||||
ItemStack getStack();
|
||||
|
||||
void setStack(ItemStack stack);
|
||||
|
||||
}
|
14
api/buildcraft/api/boards/IBoardParameterString.java
Executable file
14
api/buildcraft/api/boards/IBoardParameterString.java
Executable file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
public interface IBoardParameterString extends IBoardParameter {
|
||||
|
||||
|
||||
}
|
|
@ -12,5 +12,5 @@ public interface IRedstoneBoard<T> {
|
|||
|
||||
void updateBoard(T container);
|
||||
|
||||
String getID();
|
||||
RedstoneBoardNBT getNBTHandler();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,9 @@
|
|||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IRedstoneBoardRobot<T> extends IRedstoneBoard<T> {
|
||||
|
||||
ResourceLocation getRobotTexture();
|
||||
@Override
|
||||
RedstoneBoardRobotNBT getNBTHandler();
|
||||
|
||||
}
|
||||
|
|
77
api/buildcraft/api/boards/RedstoneBoardNBT.java
Executable file
77
api/buildcraft/api/boards/RedstoneBoardNBT.java
Executable file
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public abstract class RedstoneBoardNBT {
|
||||
|
||||
public abstract String getID();
|
||||
|
||||
public abstract void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced);
|
||||
|
||||
public abstract IRedstoneBoard create(NBTTagCompound nbt);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void registerIcons(IIconRegister iconRegister);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract IIcon getIcon(NBTTagCompound nbt);
|
||||
|
||||
public abstract void createRandomBoard(NBTTagCompound nbt, Random rand);
|
||||
|
||||
public IBoardParameter[] getParameters(NBTTagCompound nbt) {
|
||||
NBTTagList paramsNBT = nbt.getTagList("parameters", Constants.NBT.TAG_COMPOUND);
|
||||
IBoardParameter[] result = new IBoardParameter[paramsNBT.tagCount()];
|
||||
|
||||
for (int i = 0; i < paramsNBT.tagCount(); ++i) {
|
||||
NBTTagCompound subNBT = paramsNBT.getCompoundTagAt(i);
|
||||
IBoardParameter p = RedstoneBoardRegistry.instance.createParameter(subNBT.getString("kind"));
|
||||
p.readFromNBT(subNBT);
|
||||
result[i] = p;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setParameters(NBTTagCompound nbt, IBoardParameter[] params) {
|
||||
NBTTagList paramsNBT = new NBTTagList();
|
||||
|
||||
for (IBoardParameter p : params) {
|
||||
NBTTagCompound subNBT = new NBTTagCompound();
|
||||
subNBT.setString("kind", RedstoneBoardRegistry.instance.getKindForParam(p));
|
||||
p.writeToNBT(subNBT);
|
||||
paramsNBT.appendTag(subNBT);
|
||||
}
|
||||
|
||||
nbt.setTag("parameters", paramsNBT);
|
||||
}
|
||||
|
||||
public int getParameterNumber(NBTTagCompound nbt) {
|
||||
if (!nbt.hasKey("parameters")) {
|
||||
return 0;
|
||||
} else {
|
||||
return nbt.getTagList("parameters", Constants.NBT.TAG_COMPOUND).tagCount();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -15,13 +15,20 @@ public abstract class RedstoneBoardRegistry {
|
|||
|
||||
public static RedstoneBoardRegistry instance;
|
||||
|
||||
public abstract void registerBoardClass(IRedstoneBoardNBT redstoneBoardNBT, float probability);
|
||||
public abstract void registerBoardClass(RedstoneBoardNBT redstoneBoardNBT, float probability);
|
||||
|
||||
public abstract void createRandomBoard(NBTTagCompound nbt);
|
||||
|
||||
public abstract IRedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt);
|
||||
public abstract RedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt);
|
||||
|
||||
public abstract IRedstoneBoardNBT getRedstoneBoard(String id);
|
||||
public abstract RedstoneBoardNBT getRedstoneBoard(String id);
|
||||
|
||||
public abstract void registerIcons(IIconRegister par1IconRegister);
|
||||
|
||||
public abstract IBoardParameterStack createParameter(String kind);
|
||||
|
||||
public abstract IBoardParameterStack createParameterStack();
|
||||
|
||||
public abstract String getKindForParam(IBoardParameter param);
|
||||
|
||||
}
|
||||
|
|
21
api/buildcraft/api/boards/RedstoneBoardRobotNBT.java
Executable file
21
api/buildcraft/api/boards/RedstoneBoardRobotNBT.java
Executable file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class RedstoneBoardRobotNBT extends RedstoneBoardNBT {
|
||||
|
||||
@Override
|
||||
public abstract IRedstoneBoardRobot create(NBTTagCompound nbt);
|
||||
|
||||
public abstract ResourceLocation getRobotTexture();
|
||||
|
||||
}
|
BIN
buildcraft_resources/assets/buildcraft/textures/gui/slot.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/gui/slot.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -108,7 +108,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
|
||||
RedstoneBoardRegistry.instance = new ImplRedstoneBoardRegistry();
|
||||
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(new BoardRobotPickerNBT(), 10);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPickerNBT.instance, 10);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
|
|
@ -32,6 +32,8 @@ public final class GuiIds {
|
|||
|
||||
public static final int FILTERED_BUFFER = 60;
|
||||
|
||||
public static final int REDSTONE_BOARD = 60;
|
||||
|
||||
/**
|
||||
* Deactivate constructor
|
||||
*/
|
||||
|
|
|
@ -16,10 +16,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobotNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
|
||||
|
@ -36,10 +36,10 @@ public class ItemRobot extends ItemBuildCraft {
|
|||
|
||||
if (nbt.hasKey("board")) {
|
||||
NBTTagCompound boardCpt = nbt.getCompoundTag("board");
|
||||
IRedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(boardCpt);
|
||||
RedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(boardCpt);
|
||||
|
||||
if (boardNBT instanceof IRedstoneBoardRobotNBT) {
|
||||
board = ((IRedstoneBoardRobotNBT) boardNBT).create(boardCpt);
|
||||
if (boardNBT instanceof RedstoneBoardRobotNBT) {
|
||||
board = ((RedstoneBoardRobotNBT) boardNBT).create(boardCpt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,10 +59,10 @@ public class ItemRobot extends ItemBuildCraft {
|
|||
return EntityRobot.ROBOT_BASE;
|
||||
} else {
|
||||
NBTTagCompound board = nbt.getCompoundTag("board");
|
||||
IRedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(board);
|
||||
RedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(board);
|
||||
|
||||
if (boardNBT instanceof IRedstoneBoardRobotNBT) {
|
||||
return ((IRedstoneBoardRobotNBT) boardNBT).getRobotTexture();
|
||||
if (boardNBT instanceof RedstoneBoardRobotNBT) {
|
||||
return ((RedstoneBoardRobotNBT) boardNBT).getRobotTexture();
|
||||
} else {
|
||||
return EntityRobot.ROBOT_BASE;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,16 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
||||
public abstract class AdvancedSlot {
|
||||
|
||||
public int x, y;
|
||||
public GuiAdvancedInterface gui;
|
||||
public boolean drawBackround = false;
|
||||
|
||||
private static final ResourceLocation TEXTURE_SLOT = new ResourceLocation(
|
||||
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/slot.png");
|
||||
|
||||
public AdvancedSlot(GuiAdvancedInterface gui, int x, int y) {
|
||||
this.x = x;
|
||||
|
@ -52,6 +58,11 @@ public abstract class AdvancedSlot {
|
|||
public void drawSprite(int cornerX, int cornerY) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
if (drawBackround) {
|
||||
mc.renderEngine.bindTexture(TEXTURE_SLOT);
|
||||
gui.drawTexturedModalRect(cornerX + x - 1, cornerY + y - 1, 0, 0, 18, 18);
|
||||
}
|
||||
|
||||
if (!isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobotNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.LaserData;
|
||||
|
@ -69,7 +69,7 @@ public class EntityRobot extends EntityLiving implements
|
|||
this(world);
|
||||
|
||||
board = iBoard;
|
||||
dataWatcher.updateObject(16, board.getID());
|
||||
dataWatcher.updateObject(16, board.getNBTHandler().getID());
|
||||
}
|
||||
|
||||
public EntityRobot(World par1World) {
|
||||
|
@ -107,11 +107,11 @@ public class EntityRobot extends EntityLiving implements
|
|||
laser.tail.z = dataWatcher.getWatchableObjectFloat(14);
|
||||
laser.isVisible = dataWatcher.getWatchableObjectByte(15) == 1;
|
||||
|
||||
IRedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(dataWatcher
|
||||
RedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(dataWatcher
|
||||
.getWatchableObjectString(16));
|
||||
|
||||
if (boardNBT != null) {
|
||||
texture = ((IRedstoneBoardRobotNBT) boardNBT).getRobotTexture();
|
||||
texture = ((RedstoneBoardRobotNBT) boardNBT).getRobotTexture();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@ import java.util.Set;
|
|||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.core.inventory.TransactorSimple;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
|
@ -132,12 +132,7 @@ public class BoardRobotPicker implements IRedstoneBoardRobot<EntityRobot> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return EntityRobot.ROBOT_TRANSPORT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "buildcraft:boardRobotPicker";
|
||||
public RedstoneBoardRobotNBT getNBTHandler() {
|
||||
return BoardRobotPickerNBT.instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,17 +18,24 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.api.boards.BoardParameter;
|
||||
import buildcraft.api.boards.IBoardParameter;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobotNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class BoardRobotPickerNBT implements IRedstoneBoardRobotNBT {
|
||||
public class BoardRobotPickerNBT extends RedstoneBoardRobotNBT {
|
||||
|
||||
public IIcon icon;
|
||||
|
||||
public static BoardRobotPickerNBT instance = new BoardRobotPickerNBT();
|
||||
|
||||
private BoardRobotPickerNBT() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "buildcraft:boardRobotPicker";
|
||||
|
@ -40,7 +47,7 @@ public class BoardRobotPickerNBT implements IRedstoneBoardRobotNBT {
|
|||
|
||||
NBTTagCompound nbt = NBTUtils.getItemData(stack);
|
||||
|
||||
if (nbt.getInteger("params") == 1) {
|
||||
if (getParameterNumber(nbt) > 0) {
|
||||
list.add(StringUtils.localize("buildcraft.boardDetail.oneParameter"));
|
||||
}
|
||||
}
|
||||
|
@ -60,29 +67,17 @@ public class BoardRobotPickerNBT implements IRedstoneBoardRobotNBT {
|
|||
icon = iconRegister.registerIcon("buildcraft:board_green");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return EntityRobot.ROBOT_TRANSPORT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoardParameter[] getParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameters(BoardParameter[] parameters) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRandomBoard(NBTTagCompound nbt, Random rand) {
|
||||
float value = rand.nextFloat();
|
||||
|
||||
if (value < 0.5) {
|
||||
nbt.setInteger("params", 0);
|
||||
} else {
|
||||
nbt.setInteger("params", 1);
|
||||
if (value > 0.5) {
|
||||
setParameters(nbt, new IBoardParameter[] {RedstoneBoardRegistry.instance.createParameterStack()});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return EntityRobot.ROBOT_TRANSPORT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,12 +14,15 @@ import net.minecraft.world.World;
|
|||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.silicon.gui.ContainerAdvancedCraftingTable;
|
||||
import buildcraft.silicon.gui.ContainerAssemblyTable;
|
||||
import buildcraft.silicon.gui.ContainerIntegrationTable;
|
||||
import buildcraft.silicon.gui.ContainerRedstoneBoard;
|
||||
import buildcraft.silicon.gui.GuiAdvancedCraftingTable;
|
||||
import buildcraft.silicon.gui.GuiAssemblyTable;
|
||||
import buildcraft.silicon.gui.GuiIntegrationTable;
|
||||
import buildcraft.silicon.gui.GuiRedstoneBoard;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
|
@ -34,28 +37,32 @@ public class GuiHandler implements IGuiHandler {
|
|||
|
||||
switch (id) {
|
||||
|
||||
case 0:
|
||||
if (!(tile instanceof TileAssemblyTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiAssemblyTable(player.inventory, (TileAssemblyTable) tile);
|
||||
}
|
||||
|
||||
case 1:
|
||||
if (!(tile instanceof TileAdvancedCraftingTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiAdvancedCraftingTable(player.inventory, (TileAdvancedCraftingTable) tile);
|
||||
}
|
||||
|
||||
case 2:
|
||||
if (!(tile instanceof TileIntegrationTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiIntegrationTable(player.inventory, (TileIntegrationTable) tile);
|
||||
}
|
||||
default:
|
||||
case 0:
|
||||
if (!(tile instanceof TileAssemblyTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiAssemblyTable(player.inventory, (TileAssemblyTable) tile);
|
||||
}
|
||||
|
||||
case 1:
|
||||
if (!(tile instanceof TileAdvancedCraftingTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiAdvancedCraftingTable(player.inventory, (TileAdvancedCraftingTable) tile);
|
||||
}
|
||||
|
||||
case 2:
|
||||
if (!(tile instanceof TileIntegrationTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiIntegrationTable(player.inventory, (TileIntegrationTable) tile);
|
||||
}
|
||||
|
||||
case GuiIds.REDSTONE_BOARD:
|
||||
return new GuiRedstoneBoard(player, x, y, z);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +97,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
} else {
|
||||
return new ContainerIntegrationTable(player.inventory, (TileIntegrationTable) tile);
|
||||
}
|
||||
|
||||
case GuiIds.REDSTONE_BOARD:
|
||||
return new ContainerRedstoneBoard(player, x, y, z);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,14 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.ItemBuildCraft;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
|
||||
|
@ -71,4 +74,15 @@ public class ItemRedstoneBoard extends ItemBuildCraft {
|
|||
RedstoneBoardRegistry.instance.registerIcons(par1IconRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer entityplayer, World world, int x,
|
||||
int y, int z, int i, float par8, float par9, float par10) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftSilicon.instance, GuiIds.REDSTONE_BOARD, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
26
common/buildcraft/silicon/boards/BoardParameter.java
Executable file
26
common/buildcraft/silicon/boards/BoardParameter.java
Executable file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.silicon.boards;
|
||||
|
||||
import buildcraft.api.boards.IBoardParameter;
|
||||
|
||||
public abstract class BoardParameter implements IBoardParameter {
|
||||
|
||||
private String name = "<unnamed>";
|
||||
|
||||
@Override
|
||||
public final String getName () {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String iName) {
|
||||
name = iName;
|
||||
}
|
||||
|
||||
}
|
44
common/buildcraft/silicon/boards/BoardParameterStack.java
Executable file
44
common/buildcraft/silicon/boards/BoardParameterStack.java
Executable file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.silicon.boards;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.boards.IBoardParameterStack;
|
||||
|
||||
public class BoardParameterStack extends BoardParameter implements IBoardParameterStack {
|
||||
ItemStack stack;
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(ItemStack iStack) {
|
||||
stack = iStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
if (stack != null) {
|
||||
NBTTagCompound stackNBT = new NBTTagCompound();
|
||||
stack.writeToNBT(stackNBT);
|
||||
nbt.setTag("stack", stackNBT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("stack")) {
|
||||
stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,13 +14,15 @@ import java.util.Random;
|
|||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
import buildcraft.api.boards.IBoardParameter;
|
||||
import buildcraft.api.boards.IBoardParameterStack;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
|
||||
public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
||||
|
||||
private static class BoardFactory {
|
||||
public IRedstoneBoardNBT boardNBT;
|
||||
public RedstoneBoardNBT boardNBT;
|
||||
public float probability;
|
||||
}
|
||||
|
||||
|
@ -31,7 +33,7 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
|||
private Random rand = new Random();
|
||||
|
||||
@Override
|
||||
public void registerBoardClass(IRedstoneBoardNBT redstoneBoardNBT, float probability) {
|
||||
public void registerBoardClass(RedstoneBoardNBT redstoneBoardNBT, float probability) {
|
||||
BoardFactory factory = new BoardFactory();
|
||||
factory.boardNBT = redstoneBoardNBT;
|
||||
factory.probability = probability;
|
||||
|
@ -58,12 +60,12 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt) {
|
||||
public RedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt) {
|
||||
return getRedstoneBoard(nbt.getString("id"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneBoardNBT getRedstoneBoard(String id) {
|
||||
public RedstoneBoardNBT getRedstoneBoard(String id) {
|
||||
BoardFactory factory = boards.get(id);
|
||||
|
||||
if (factory != null) {
|
||||
|
@ -80,4 +82,27 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBoardParameterStack createParameterStack() {
|
||||
return new BoardParameterStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBoardParameterStack createParameter(String kind) {
|
||||
if ("stack".equals(kind)) {
|
||||
return createParameterStack();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKindForParam(IBoardParameter param) {
|
||||
if (param instanceof BoardParameterStack) {
|
||||
return "stack";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
37
common/buildcraft/silicon/gui/ContainerRedstoneBoard.java
Executable file
37
common/buildcraft/silicon/gui/ContainerRedstoneBoard.java
Executable file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.silicon.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
|
||||
public class ContainerRedstoneBoard extends BuildCraftContainer {
|
||||
|
||||
public ContainerRedstoneBoard(EntityPlayer player, int x, int y, int z) {
|
||||
super(player.inventory.getSizeInventory());
|
||||
|
||||
for (int sy = 0; sy < 3; sy++) {
|
||||
for (int sx = 0; sx < 9; sx++) {
|
||||
addSlotToContainer(new Slot(player.inventory, sx + sy * 9 + 9, 8 + sx * 18, 140 + sy * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int sx = 0; sx < 9; sx++) {
|
||||
addSlotToContainer(new Slot(player.inventory, sx, 8 + sx * 18, 198));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
96
common/buildcraft/silicon/gui/GuiRedstoneBoard.java
Executable file
96
common/buildcraft/silicon/gui/GuiRedstoneBoard.java
Executable file
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.silicon.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.IBoardParameter;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.AdvancedSlot;
|
||||
import buildcraft.core.gui.GuiAdvancedInterface;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
|
||||
public class GuiRedstoneBoard extends GuiAdvancedInterface {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(
|
||||
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/generic_ui.png");
|
||||
|
||||
private World world;
|
||||
private int x, y, z;
|
||||
RedstoneBoardNBT board;
|
||||
IBoardParameter[] params;
|
||||
|
||||
public GuiRedstoneBoard(EntityPlayer player, int ix, int iy, int iz) {
|
||||
super(new ContainerRedstoneBoard(player, ix, iy, iz), player.inventory, TEXTURE);
|
||||
x = ix;
|
||||
y = iy;
|
||||
z = iz;
|
||||
xSize = 175;
|
||||
ySize = 222;
|
||||
world = player.worldObj;
|
||||
|
||||
NBTTagCompound boardNBT = NBTUtils.getItemData(player.getHeldItem());
|
||||
|
||||
board = RedstoneBoardRegistry.instance.getRedstoneBoard(boardNBT);
|
||||
params = board.getParameters(boardNBT);
|
||||
|
||||
slots = new AdvancedSlot [1];
|
||||
slots[0] = new ItemSlot(10, 10);
|
||||
slots[0].drawBackround = true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int xscreen = (width - xSize) / 2;
|
||||
int yscreen = (height - ySize) / 2;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
int j = (width - xSize) / 2;
|
||||
int k = (height - ySize) / 2;
|
||||
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
|
||||
|
||||
drawBackgroundSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
int position = getSlotAtLocation(i - cornerX, j - cornerY);
|
||||
|
||||
AdvancedSlot slot = null;
|
||||
|
||||
if (position < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
slot = slots[position];
|
||||
|
||||
if (slot instanceof ItemSlot) {
|
||||
((ItemSlot) slot).stack = mc.thePlayer.inventory.getItemStack();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue