made progress for implementation of testing framework, #1846
This commit is contained in:
parent
c23a5573f4
commit
e9b84c7121
Binary file not shown.
After Width: | Height: | Size: 204 B |
Binary file not shown.
After Width: | Height: | Size: 784 B |
|
@ -40,6 +40,8 @@ import buildcraft.transport.Pipe;
|
|||
*/
|
||||
public final class RPCHandler {
|
||||
|
||||
Class handledClass;
|
||||
|
||||
public static int MAX_PACKET_SIZE = 30 * 1024;
|
||||
|
||||
private static Map<String, RPCHandler> handlers = new TreeMap<String, RPCHandler>();
|
||||
|
@ -56,6 +58,7 @@ public final class RPCHandler {
|
|||
private MethodMapping [] methods;
|
||||
|
||||
private RPCHandler(Class c) {
|
||||
handledClass = c;
|
||||
Method [] sortedMethods = JavaTools.getAllMethods (c).toArray(new Method [0]);
|
||||
|
||||
LinkedList<MethodMapping> mappings = new LinkedList<MethodMapping>();
|
||||
|
@ -258,7 +261,7 @@ public final class RPCHandler {
|
|||
IllegalAccessException {
|
||||
if (!methodsMap.containsKey(method)) {
|
||||
throw new RuntimeException(method + " is not a callable method of "
|
||||
+ getClass().getName());
|
||||
+ handledClass.getName());
|
||||
}
|
||||
|
||||
int methodIndex = methodsMap.get(method);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import xml.etree.ElementTree as et
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
forgeRoot = sys.argv [1]
|
||||
|
||||
root = et.parse (forgeRoot + ".classpath")
|
||||
classpath = forgeRoot + "bin"
|
||||
|
||||
for e in root.findall (".//classpathentry"):
|
||||
path = e.attrib ["path"]
|
||||
classpath = classpath + ";" + path
|
||||
|
||||
testRoot = "testsuite"
|
||||
testDir = testRoot + "/" + sys.argv [2]
|
||||
|
||||
os.chdir (testDir)
|
||||
|
||||
shutil.rmtree ("world", True)
|
||||
shutil.copytree ("../base/world", "world")
|
||||
shutil.copy ("../base/server.properties", "server.properties")
|
||||
|
||||
command = "java -Xincgc -Xmx1024M -Xms1024M -classpath \"" + classpath + "\" cpw.mods.fml.relauncher.ServerLaunchWrapper --nogui --world world --test test.seq "
|
||||
print command
|
||||
os.system (command)
|
|
@ -8,21 +8,47 @@
|
|||
*/
|
||||
package buildcraft.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
import buildcraft.BuildCraftMod;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.tests.testcase.BlockTestCase;
|
||||
import buildcraft.tests.testcase.Sequence;
|
||||
import buildcraft.tests.testcase.TileTestCase;
|
||||
|
||||
@Mod(name = "BuildCraft Tests", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Tests", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
public class BuildCraftTests extends BuildCraftMod {
|
||||
|
||||
private long startTestTime = 0;
|
||||
private String testFile = "";
|
||||
private Sequence testSequence;
|
||||
|
||||
public static Block blockTestPathfinding;
|
||||
public static Block blockTestCase;
|
||||
|
||||
public static Item tester;
|
||||
|
||||
|
@ -35,8 +61,67 @@ public class BuildCraftTests extends BuildCraftMod {
|
|||
CoreProxy.proxy.registerBlock(blockTestPathfinding);
|
||||
CoreProxy.proxy.registerTileEntity(TileTestPathfinding.class, "net.minecraft.src.builders.TileTestPathfinding");
|
||||
|
||||
blockTestCase = new BlockTestCase();
|
||||
blockTestCase.setBlockName("testCase");
|
||||
CoreProxy.proxy.registerBlock(blockTestCase);
|
||||
CoreProxy.proxy.registerTileEntity(TileTestCase.class, "buildcraft.tests.testcase.TileTestCase");
|
||||
|
||||
tester = new ItemTester();
|
||||
tester.setUnlocalizedName("tester");
|
||||
CoreProxy.proxy.registerItem(tester);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void load(FMLInitializationEvent evt) {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
String commandLine = System.getProperty("sun.java.command");
|
||||
OptionParser optionparser = new OptionParser();
|
||||
optionparser.allowsUnrecognizedOptions();
|
||||
|
||||
ArgumentAcceptingOptionSpec<String> testOption = optionparser.accepts("test").withRequiredArg();
|
||||
|
||||
OptionSet optionset = optionparser.parse(commandLine.split(" "));
|
||||
testFile = optionset.valueOf(testOption);
|
||||
System.out.println("LOADING TEST: " + testFile);
|
||||
|
||||
if (testFile != null && !"".equals(testFile)) {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tick(WorldTickEvent evt) {
|
||||
WorldServer world = MinecraftServer.getServer().worldServers[0];
|
||||
long time = world.getTotalWorldTime();
|
||||
|
||||
if (startTestTime == 0) {
|
||||
startTestTime = time;
|
||||
} else if (testSequence == null) {
|
||||
if (time - startTestTime > 10) {
|
||||
|
||||
try {
|
||||
testSequence = new Sequence(world);
|
||||
|
||||
File file = new File(testFile);
|
||||
FileInputStream f = new FileInputStream(file);
|
||||
byte[] data = new byte[(int) file.length()];
|
||||
f.read(data);
|
||||
f.close();
|
||||
|
||||
NBTTagCompound nbt = CompressedStreamTools.decompress(data);
|
||||
|
||||
testSequence.readFromNBT(nbt);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!testSequence.done()) {
|
||||
testSequence.iterate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* 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.tests;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class ContainerTester extends Container {
|
||||
|
||||
public ContainerTester(EntityPlayer player, int x, int y, int z) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* 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.tests;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
import buildcraft.tests.testcase.ContainerTestCase;
|
||||
import buildcraft.tests.testcase.GuiTestCase;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (id) {
|
||||
case GuiTestIds.TESTER_ID:
|
||||
return new GuiTester(player, x, y, z);
|
||||
case GuiTestIds.TESTCASE_ID:
|
||||
return new GuiTestCase(player, x, y, z);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (id) {
|
||||
case GuiTestIds.TESTER_ID:
|
||||
return new ContainerTester(player, x, y, z);
|
||||
case GuiTestIds.TESTCASE_ID:
|
||||
return new ContainerTestCase(player, x, y, z);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package buildcraft.tests;
|
||||
|
||||
public class GuiTestIds {
|
||||
|
||||
public static final int TESTER_ID = 0;
|
||||
public static final int TESTCASE_ID = 1;
|
||||
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* 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.tests;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class GuiTester extends GuiContainer {
|
||||
|
||||
private static final int TEXT_X = 90;
|
||||
private static final int TEXT_Y = 62;
|
||||
private static final int TEXT_WIDTH = 156;
|
||||
private static final int TEXT_HEIGHT = 12;
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(
|
||||
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/tester.png");
|
||||
|
||||
private GuiButton optionRotate;
|
||||
private GuiButton optionReadMods;
|
||||
private GuiButton optionReadBlocks;
|
||||
private GuiButton optionExcavate;
|
||||
private GuiButton optionExplicit;
|
||||
|
||||
private GuiTextField textField;
|
||||
|
||||
public GuiTester(EntityPlayer player, int x, int y, int z) {
|
||||
super(new ContainerTester(player, x, y, z));
|
||||
xSize = 256;
|
||||
ySize = 166;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
optionRotate = new GuiButton(0, x + 5, y + 30, 77, 20, "");
|
||||
buttonList.add(optionRotate);
|
||||
|
||||
optionReadBlocks = new GuiButton(1, x + 5, y + 55, 77, 20, "");
|
||||
buttonList.add(optionReadBlocks);
|
||||
|
||||
optionExcavate = new GuiButton(2, x + 5, y + 80, 77, 20, "");
|
||||
buttonList.add(optionExcavate);
|
||||
|
||||
optionExplicit = new GuiButton(3, x + 5, y + 105, 77, 20, "");
|
||||
buttonList.add(optionExplicit);
|
||||
|
||||
textField = new GuiTextField(this.fontRendererObj, TEXT_X, TEXT_Y, TEXT_WIDTH, TEXT_HEIGHT);
|
||||
textField.setMaxStringLength(BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE);
|
||||
textField.setText("");
|
||||
textField.setFocused(true);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
private void updateButtons () {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
String title = StringUtils.localize("tile.architectBlock.name");
|
||||
// fontRendererObj.drawString(title, getCenteredOffset(title), 6,
|
||||
// 0x404040);
|
||||
|
||||
/*
|
||||
* if (editMode && ((new Date()).getTime() / 100) % 8 >= 4) {
|
||||
* fontRendererObj.drawString(architect.name + "|", 131, 62, 0x404040);
|
||||
* } else { fontRendererObj.drawString(architect.name, 131, 62,
|
||||
* 0x404040); }
|
||||
*/
|
||||
|
||||
textField.drawTextBox();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
int xMin = (width - xSize) / 2;
|
||||
int yMin = (height - ySize) / 2;
|
||||
int x = i - xMin;
|
||||
int y = j - yMin;
|
||||
|
||||
if (x >= TEXT_X && y >= TEXT_Y
|
||||
&& x <= TEXT_X + TEXT_WIDTH && y <= TEXT_Y + TEXT_HEIGHT) {
|
||||
textField.setFocused(true);
|
||||
} else {
|
||||
textField.setFocused(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char c, int i) {
|
||||
if (textField.isFocused()) {
|
||||
if (c == 13 || c == 27) {
|
||||
textField.setFocused(false);
|
||||
} else {
|
||||
textField.textboxKeyTyped(c, i);
|
||||
|
||||
}
|
||||
} else {
|
||||
super.keyTyped(c, i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,18 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.tests;
|
||||
|
||||
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;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -17,7 +28,18 @@ public class ItemTester extends Item {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
this.itemIcon = par1IconRegister.registerIcon("buildcraft:tester");
|
||||
this.itemIcon = par1IconRegister.registerIcon("buildcraft:test");
|
||||
}
|
||||
|
||||
@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(BuildCraftTests.instance, GuiTestIds.TESTER_ID, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* 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.tests.testcase;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.tests.BuildCraftTests;
|
||||
import buildcraft.tests.GuiTestIds;
|
||||
|
||||
public class BlockTestCase extends BlockContainer {
|
||||
|
||||
public BlockTestCase() {
|
||||
super(Material.ground);
|
||||
|
||||
setCreativeTab(CreativeTabBuildCraft.BLOCKS.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileTestCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
this.blockIcon = par1IconRegister.registerIcon("buildcraft:testcase");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7,
|
||||
float par8, float par9) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftTests.instance, GuiTestIds.TESTCASE_ID, world, i, j, k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* 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.tests.testcase;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class ContainerTestCase extends Container {
|
||||
|
||||
public ContainerTestCase(EntityPlayer player, int x, int y, int z) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/**
|
||||
* 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.tests.testcase;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class GuiTestCase extends GuiContainer {
|
||||
|
||||
private static final int TEXT_X = 10;
|
||||
private static final int TEXT_Y = 10;
|
||||
private static final int TEXT_WIDTH = 156;
|
||||
private static final int TEXT_HEIGHT = 12;
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(
|
||||
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/tester.png");
|
||||
|
||||
private GuiTextField textField;
|
||||
|
||||
TileTestCase testCase;
|
||||
|
||||
public GuiTestCase(EntityPlayer player, int x, int y, int z) {
|
||||
super(new ContainerTestCase(player, x, y, z));
|
||||
xSize = 256;
|
||||
ySize = 166;
|
||||
|
||||
testCase = (TileTestCase) player.worldObj.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
textField = new GuiTextField(this.fontRendererObj, TEXT_X, TEXT_Y, TEXT_WIDTH, TEXT_HEIGHT);
|
||||
textField.setMaxStringLength(BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE);
|
||||
textField.setText("");
|
||||
textField.setFocused(true);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
private void updateButtons () {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
String title = StringUtils.localize("tile.architectBlock.name");
|
||||
// fontRendererObj.drawString(title, getCenteredOffset(title), 6,
|
||||
// 0x404040);
|
||||
|
||||
/*
|
||||
* if (editMode && ((new Date()).getTime() / 100) % 8 >= 4) {
|
||||
* fontRendererObj.drawString(architect.name + "|", 131, 62, 0x404040);
|
||||
* } else { fontRendererObj.drawString(architect.name, 131, 62,
|
||||
* 0x404040); }
|
||||
*/
|
||||
|
||||
textField.drawTextBox();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
int xMin = (width - xSize) / 2;
|
||||
int yMin = (height - ySize) / 2;
|
||||
int x = i - xMin;
|
||||
int y = j - yMin;
|
||||
|
||||
if (x >= TEXT_X && y >= TEXT_Y
|
||||
&& x <= TEXT_X + TEXT_WIDTH && y <= TEXT_Y + TEXT_HEIGHT) {
|
||||
textField.setFocused(true);
|
||||
} else {
|
||||
textField.setFocused(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char c, int i) {
|
||||
if (textField.isFocused()) {
|
||||
if (c == 13 || c == 27) {
|
||||
textField.setFocused(false);
|
||||
} else {
|
||||
textField.textboxKeyTyped(c, i);
|
||||
}
|
||||
|
||||
RPCHandler.rpcServer(testCase, "setName", textField.getText());
|
||||
} else {
|
||||
super.keyTyped(c, i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* 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.tests.testcase;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import buildcraft.api.blueprints.MappingNotFoundException;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
|
||||
public class Sequence {
|
||||
|
||||
public LinkedList<SequenceAction> actions = new LinkedList<SequenceAction>();
|
||||
|
||||
public World world;
|
||||
|
||||
public Sequence(World iWorld) {
|
||||
world = iWorld;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
MappingRegistry registry = new MappingRegistry();
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for (SequenceAction action : actions) {
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
action.writeToNBT(cpt);
|
||||
cpt.setString("class", action.getClass().getCanonicalName());
|
||||
registry.scanAndTranslateStacksToRegistry(cpt);
|
||||
list.appendTag(cpt);
|
||||
}
|
||||
|
||||
nbt.setTag("actions", list);
|
||||
|
||||
NBTTagCompound registryNBT = new NBTTagCompound();
|
||||
registry.write(registryNBT);
|
||||
nbt.setTag("registry", registryNBT);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
MappingRegistry registry = new MappingRegistry();
|
||||
registry.read(nbt.getCompoundTag("registry"));
|
||||
|
||||
NBTTagList list = nbt.getTagList("actions", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound cpt = list.getCompoundTagAt(i);
|
||||
|
||||
try {
|
||||
registry.scanAndTranslateStacksToWorld(cpt);
|
||||
SequenceAction action = (SequenceAction) Class.forName(cpt.getString("class")).newInstance();
|
||||
action.world = world;
|
||||
action.readFromNBT(cpt);
|
||||
actions.add(action);
|
||||
} catch (MappingNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean done() {
|
||||
return actions.size() == 0;
|
||||
}
|
||||
|
||||
public void iterate() {
|
||||
actions.pop().execute();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* 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.tests.testcase;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SequenceAction {
|
||||
|
||||
public World world;
|
||||
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* 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.tests.testcase;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
public class SequenceActionUseItem extends SequenceAction {
|
||||
|
||||
ItemStack stack;
|
||||
int x, y, z;
|
||||
|
||||
public SequenceActionUseItem() {
|
||||
|
||||
}
|
||||
|
||||
public SequenceActionUseItem(World iWorld, ItemStack iStack, int ix, int iy, int iz) {
|
||||
stack = iStack;
|
||||
x = ix;
|
||||
y = iy;
|
||||
z = iz;
|
||||
world = iWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
stack.getItem().onItemUse(stack, CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world).get(), world, x, y,
|
||||
z, 1, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("x", x);
|
||||
nbt.setInteger("y", y);
|
||||
nbt.setInteger("z", z);
|
||||
|
||||
NBTTagCompound stackNBT = new NBTTagCompound();
|
||||
stack.writeToNBT(stackNBT);
|
||||
nbt.setTag("stack", stackNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
x = nbt.getInteger("x");
|
||||
y = nbt.getInteger("y");
|
||||
z = nbt.getInteger("z");
|
||||
stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* 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.tests.testcase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import buildcraft.core.network.RPC;
|
||||
import buildcraft.core.network.RPCSide;
|
||||
import buildcraft.tests.ItemTester;
|
||||
|
||||
public class TileTestCase extends TileEntity {
|
||||
|
||||
Sequence sequence;
|
||||
String testName = "test";
|
||||
|
||||
public TileTestCase() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void itemUsed(PlayerInteractEvent evt) {
|
||||
if (!evt.entity.worldObj.isRemote) {
|
||||
if (sequence == null) {
|
||||
sequence = new Sequence(evt.entity.worldObj);
|
||||
}
|
||||
|
||||
if (evt.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
ItemStack usedItem = evt.entityPlayer.inventory.getCurrentItem();
|
||||
|
||||
if (usedItem != null && !(usedItem.getItem() instanceof ItemTester)) {
|
||||
sequence.actions.add(new SequenceActionUseItem(evt.entity.worldObj, usedItem, evt.x, evt.y, evt.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
|
||||
if (sequence != null) {
|
||||
File sequenceFile = new File(testName + ".seq");
|
||||
|
||||
OutputStream gzOs = null;
|
||||
try {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
sequence.writeToNBT(nbt);
|
||||
|
||||
FileOutputStream f = new FileOutputStream(sequenceFile);
|
||||
f.write(CompressedStreamTools.compress(nbt));
|
||||
f.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger("Buildcraft").log(Level.SEVERE,
|
||||
String.format("Failed to save Sequence file: %s %s", sequenceFile, ex.getMessage()));
|
||||
} finally {
|
||||
try {
|
||||
if (gzOs != null) {
|
||||
gzOs.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RPC(RPCSide.SERVER)
|
||||
private void setName(String name) {
|
||||
testName = name;
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
#Minecraft server properties
|
||||
#Sat May 24 20:39:27 CEST 2014
|
||||
generator-settings=
|
||||
op-permission-level=4
|
||||
allow-nether=true
|
||||
level-name=world
|
||||
enable-query=false
|
||||
allow-flight=false
|
||||
announce-player-achievements=true
|
||||
server-port=25565
|
||||
level-type=DEFAULT
|
||||
enable-rcon=false
|
||||
force-gamemode=false
|
||||
level-seed=
|
||||
server-ip=
|
||||
max-build-height=256
|
||||
spawn-npcs=false
|
||||
white-list=false
|
||||
spawn-animals=false
|
||||
snooper-enabled=true
|
||||
hardcore=false
|
||||
online-mode=false
|
||||
resource-pack=
|
||||
pvp=true
|
||||
difficulty=0
|
||||
enable-command-block=false
|
||||
player-idle-timeout=0
|
||||
gamemode=1
|
||||
max-players=20
|
||||
spawn-monsters=false
|
||||
view-distance=10
|
||||
generate-structures=false
|
||||
motd=Test Server
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
{"achievement.exploreAllBiomes":{"value":0,"progress":["Plains"]},"stat.playOneMinute":757}
|
Loading…
Reference in New Issue