added the whole exporter. does nothing yet though

This commit is contained in:
Raoul Van den Berge
2015-12-19 00:47:09 +01:00
parent cfcb518ddd
commit 2e9862d339
12 changed files with 252 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ public class StorageCraft {
public static final int DRIVE = 2; public static final int DRIVE = 2;
public static final int STORAGE_PROXY = 3; public static final int STORAGE_PROXY = 3;
public static final int IMPORTER = 4; public static final int IMPORTER = 4;
public static final int EXPORTER = 5;
} }
public static final String ID = "storagecraft"; public static final String ID = "storagecraft";

View File

@@ -3,6 +3,7 @@ package storagecraft;
import storagecraft.block.BlockCable; import storagecraft.block.BlockCable;
import storagecraft.block.BlockController; import storagecraft.block.BlockController;
import storagecraft.block.BlockDrive; import storagecraft.block.BlockDrive;
import storagecraft.block.BlockExporter;
import storagecraft.block.BlockGrid; import storagecraft.block.BlockGrid;
import storagecraft.block.BlockImporter; import storagecraft.block.BlockImporter;
import storagecraft.block.BlockStorageProxy; import storagecraft.block.BlockStorageProxy;
@@ -14,4 +15,5 @@ public class StorageCraftBlocks {
public static final BlockDrive DRIVE = new BlockDrive(); public static final BlockDrive DRIVE = new BlockDrive();
public static final BlockStorageProxy STORAGE_PROXY = new BlockStorageProxy(); public static final BlockStorageProxy STORAGE_PROXY = new BlockStorageProxy();
public static final BlockImporter IMPORTER = new BlockImporter(); public static final BlockImporter IMPORTER = new BlockImporter();
public static final BlockExporter EXPORTER = new BlockExporter();
} }

View File

@@ -0,0 +1,60 @@
package storagecraft.block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import storagecraft.StorageCraft;
import storagecraft.tile.TileExporter;
public class BlockExporter extends BlockBase implements ITileEntityProvider {
private IIcon frontIcon;
private IIcon sideIcon;
public BlockExporter() {
super("exporter");
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileExporter();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
player.openGui(StorageCraft.INSTANCE, StorageCraft.GUI.EXPORTER, world, x, y, z);
}
return true;
}
@Override
public void registerBlockIcons(IIconRegister register) {
frontIcon = register.registerIcon("storagecraft:exporter");
sideIcon = register.registerIcon("storagecraft:generic");
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileExporter tile = (TileExporter) world.getTileEntity(x, y, z);
if (side == tile.getDirection().ordinal()) {
return frontIcon;
}
return sideIcon;
}
@Override
public IIcon getIcon(int side, int meta) {
if (side == 3) {
return frontIcon;
}
return sideIcon;
}
}

View File

@@ -0,0 +1,15 @@
package storagecraft.container;
import net.minecraft.entity.player.EntityPlayer;
import storagecraft.container.slot.SlotSpecimen;
import storagecraft.tile.TileExporter;
public class ContainerExporter extends ContainerBase {
public ContainerExporter(EntityPlayer player, TileExporter exporter) {
super(player);
addSlotToContainer(new SlotSpecimen(exporter, 0, 80, 20));
addPlayerInventory(8, 104);
}
}

View File

@@ -0,0 +1,95 @@
package storagecraft.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import storagecraft.StorageCraft;
import storagecraft.container.ContainerExporter;
import storagecraft.network.MessageExporterUpdate;
import storagecraft.tile.TileExporter;
import storagecraft.util.InventoryUtils;
public class GuiExporter extends GuiMachine {
public static final ResourceLocation EXPORTER_RESOURCE = new ResourceLocation("storagecraft:textures/gui/exporter.png");
private TileExporter exporter;
private GuiButton compareNBT;
private GuiButton compareDamage;
public GuiExporter(ContainerExporter container, TileExporter exporter) {
super(container, exporter);
this.xSize = 176;
this.ySize = 186;
this.exporter = exporter;
}
@Override
public void initGui() {
super.initGui();
int x = (this.width - xSize) / 2;
int y = (this.height - ySize) / 2;
buttonList.add(compareNBT = new GuiButton(1, x + 7, y + 41, 100, 20, ""));
buttonList.add(compareDamage = new GuiButton(2, x + 7, y + 63, 120, 20, ""));
}
@Override
public void updateScreen() {
super.updateScreen();
compareNBT.displayString = getTextForCompareToggle("NBT", InventoryUtils.COMPARE_NBT);
compareDamage.displayString = getTextForCompareToggle("Damage", InventoryUtils.COMPARE_DAMAGE);
}
private String getTextForCompareToggle(String which, int flag) {
StringBuilder builder = new StringBuilder();
builder.append(StatCollector.translateToLocal("misc.storagecraft:compare" + which));
builder.append(": ");
if ((exporter.getCompareFlags() & flag) == flag) {
builder.append(StatCollector.translateToLocal("misc.storagecraft:on"));
} else {
builder.append(StatCollector.translateToLocal("misc.storagecraft:off"));
}
return builder.toString();
}
@Override
protected void drawGuiContainerBackgroundLayer(float renderPartialTicks, int mouseX, int mouseY) {
GL11.glColor3f(1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(EXPORTER_RESOURCE);
drawTexturedModalRect((this.width - xSize) / 2, (this.height - ySize) / 2, 0, 0, xSize, ySize);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
fontRendererObj.drawString(StatCollector.translateToLocal("gui.storagecraft:exporter"), 7, 7, 4210752);
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, 93, 4210752);
}
@Override
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
int flags = exporter.getCompareFlags();
if (button.id == compareNBT.id) {
flags ^= InventoryUtils.COMPARE_NBT;
} else if (button.id == compareDamage.id) {
flags ^= InventoryUtils.COMPARE_DAMAGE;
}
StorageCraft.NETWORK.sendToServer(new MessageExporterUpdate(exporter.xCoord, exporter.yCoord, exporter.zCoord, flags));
}
}

View File

@@ -8,11 +8,13 @@ import net.minecraft.world.World;
import storagecraft.StorageCraft; import storagecraft.StorageCraft;
import storagecraft.container.ContainerController; import storagecraft.container.ContainerController;
import storagecraft.container.ContainerDrive; import storagecraft.container.ContainerDrive;
import storagecraft.container.ContainerExporter;
import storagecraft.container.ContainerGrid; import storagecraft.container.ContainerGrid;
import storagecraft.container.ContainerImporter; import storagecraft.container.ContainerImporter;
import storagecraft.container.ContainerStorageProxy; import storagecraft.container.ContainerStorageProxy;
import storagecraft.tile.TileController; import storagecraft.tile.TileController;
import storagecraft.tile.TileDrive; import storagecraft.tile.TileDrive;
import storagecraft.tile.TileExporter;
import storagecraft.tile.TileGrid; import storagecraft.tile.TileGrid;
import storagecraft.tile.TileImporter; import storagecraft.tile.TileImporter;
import storagecraft.tile.TileStorageProxy; import storagecraft.tile.TileStorageProxy;
@@ -30,6 +32,8 @@ public class GuiHandler implements IGuiHandler {
return new ContainerStorageProxy(player); return new ContainerStorageProxy(player);
case StorageCraft.GUI.IMPORTER: case StorageCraft.GUI.IMPORTER:
return new ContainerImporter(player, (TileImporter) tile); return new ContainerImporter(player, (TileImporter) tile);
case StorageCraft.GUI.EXPORTER:
return new ContainerExporter(player, (TileExporter) tile);
default: default:
return null; return null;
} }
@@ -55,6 +59,8 @@ public class GuiHandler implements IGuiHandler {
return new GuiStorageProxy((ContainerStorageProxy) getContainer(ID, player, tile), (TileStorageProxy) tile); return new GuiStorageProxy((ContainerStorageProxy) getContainer(ID, player, tile), (TileStorageProxy) tile);
case StorageCraft.GUI.IMPORTER: case StorageCraft.GUI.IMPORTER:
return new GuiImporter((ContainerImporter) getContainer(ID, player, tile), (TileImporter) tile); return new GuiImporter((ContainerImporter) getContainer(ID, player, tile), (TileImporter) tile);
case StorageCraft.GUI.EXPORTER:
return new GuiExporter((ContainerExporter) getContainer(ID, player, tile), (TileExporter) tile);
default: default:
return null; return null;
} }

View File

@@ -0,0 +1,57 @@
package storagecraft.network;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import storagecraft.tile.TileExporter;
public class MessageExporterUpdate implements IMessage, IMessageHandler<MessageExporterUpdate, IMessage> {
private int x;
private int y;
private int z;
private int compareFlags;
public MessageExporterUpdate() {
}
public MessageExporterUpdate(int x, int y, int z, int compareFlags) {
this.x = x;
this.y = y;
this.z = z;
this.compareFlags = compareFlags;
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
compareFlags = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeInt(compareFlags);
}
@Override
public IMessage onMessage(MessageExporterUpdate message, MessageContext context) {
EntityPlayerMP player = context.getServerHandler().playerEntity;
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (tile instanceof TileExporter) {
TileExporter exporter = (TileExporter) tile;
exporter.setCompareFlags(message.compareFlags);
}
return null;
}
}

View File

@@ -10,6 +10,7 @@ import storagecraft.StorageCraft;
import storagecraft.StorageCraftBlocks; import storagecraft.StorageCraftBlocks;
import storagecraft.StorageCraftItems; import storagecraft.StorageCraftItems;
import storagecraft.gui.GuiHandler; import storagecraft.gui.GuiHandler;
import storagecraft.network.MessageExporterUpdate;
import storagecraft.network.MessageImporterUpdate; import storagecraft.network.MessageImporterUpdate;
import storagecraft.network.MessageRedstoneModeUpdate; import storagecraft.network.MessageRedstoneModeUpdate;
import storagecraft.network.MessageStoragePull; import storagecraft.network.MessageStoragePull;
@@ -18,6 +19,7 @@ import storagecraft.network.MessageTileUpdate;
import storagecraft.tile.TileCable; import storagecraft.tile.TileCable;
import storagecraft.tile.TileController; import storagecraft.tile.TileController;
import storagecraft.tile.TileDrive; import storagecraft.tile.TileDrive;
import storagecraft.tile.TileExporter;
import storagecraft.tile.TileGrid; import storagecraft.tile.TileGrid;
import storagecraft.tile.TileImporter; import storagecraft.tile.TileImporter;
import storagecraft.tile.TileStorageProxy; import storagecraft.tile.TileStorageProxy;
@@ -25,10 +27,11 @@ import storagecraft.tile.TileStorageProxy;
public class CommonProxy { public class CommonProxy {
public void preInit(FMLPreInitializationEvent e) { public void preInit(FMLPreInitializationEvent e) {
StorageCraft.NETWORK.registerMessage(MessageTileUpdate.class, MessageTileUpdate.class, 0, Side.CLIENT); StorageCraft.NETWORK.registerMessage(MessageTileUpdate.class, MessageTileUpdate.class, 0, Side.CLIENT);
StorageCraft.NETWORK.registerMessage(MessageStoragePush.class, MessageStoragePush.class, 1, Side.SERVER); StorageCraft.NETWORK.registerMessage(MessageRedstoneModeUpdate.class, MessageRedstoneModeUpdate.class, 1, Side.SERVER);
StorageCraft.NETWORK.registerMessage(MessageStoragePull.class, MessageStoragePull.class, 2, Side.SERVER); StorageCraft.NETWORK.registerMessage(MessageStoragePush.class, MessageStoragePush.class, 2, Side.SERVER);
StorageCraft.NETWORK.registerMessage(MessageImporterUpdate.class, MessageImporterUpdate.class, 3, Side.SERVER); StorageCraft.NETWORK.registerMessage(MessageStoragePull.class, MessageStoragePull.class, 3, Side.SERVER);
StorageCraft.NETWORK.registerMessage(MessageRedstoneModeUpdate.class, MessageRedstoneModeUpdate.class, 4, Side.SERVER); StorageCraft.NETWORK.registerMessage(MessageImporterUpdate.class, MessageImporterUpdate.class, 4, Side.SERVER);
StorageCraft.NETWORK.registerMessage(MessageExporterUpdate.class, MessageExporterUpdate.class, 5, Side.SERVER);
NetworkRegistry.INSTANCE.registerGuiHandler(StorageCraft.INSTANCE, new GuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(StorageCraft.INSTANCE, new GuiHandler());
@@ -38,6 +41,7 @@ public class CommonProxy {
GameRegistry.registerTileEntity(TileDrive.class, "drive"); GameRegistry.registerTileEntity(TileDrive.class, "drive");
GameRegistry.registerTileEntity(TileStorageProxy.class, "storageProxy"); GameRegistry.registerTileEntity(TileStorageProxy.class, "storageProxy");
GameRegistry.registerTileEntity(TileImporter.class, "importer"); GameRegistry.registerTileEntity(TileImporter.class, "importer");
GameRegistry.registerTileEntity(TileExporter.class, "exporter");
GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, "controller"); GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, "controller");
GameRegistry.registerBlock(StorageCraftBlocks.CABLE, "cable"); GameRegistry.registerBlock(StorageCraftBlocks.CABLE, "cable");
@@ -45,6 +49,7 @@ public class CommonProxy {
GameRegistry.registerBlock(StorageCraftBlocks.DRIVE, "drive"); GameRegistry.registerBlock(StorageCraftBlocks.DRIVE, "drive");
GameRegistry.registerBlock(StorageCraftBlocks.STORAGE_PROXY, "storageProxy"); GameRegistry.registerBlock(StorageCraftBlocks.STORAGE_PROXY, "storageProxy");
GameRegistry.registerBlock(StorageCraftBlocks.IMPORTER, "importer"); GameRegistry.registerBlock(StorageCraftBlocks.IMPORTER, "importer");
GameRegistry.registerBlock(StorageCraftBlocks.EXPORTER, "exporter");
GameRegistry.registerItem(StorageCraftItems.STORAGE_CELL, "storageCell"); GameRegistry.registerItem(StorageCraftItems.STORAGE_CELL, "storageCell");
} }

View File

@@ -98,7 +98,9 @@ public abstract class TileMachine extends TileBase implements INetworkTile {
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
redstoneMode = RedstoneMode.getById(nbt.getInteger(NBT_REDSTONE_MODE)); if (nbt.hasKey(NBT_REDSTONE_MODE)) {
redstoneMode = RedstoneMode.getById(nbt.getInteger(NBT_REDSTONE_MODE));
}
} }
@Override @Override

View File

@@ -5,6 +5,7 @@ gui.storagecraft:grid=Grid
gui.storagecraft:drive=Drive gui.storagecraft:drive=Drive
gui.storagecraft:storageProxy=Storage Proxy gui.storagecraft:storageProxy=Storage Proxy
gui.storagecraft:importer=Importer gui.storagecraft:importer=Importer
gui.storagecraft:exporter=Exporter
misc.storagecraft:energyStored=%d / %d RF misc.storagecraft:energyStored=%d / %d RF
misc.storagecraft:energyUsage=Usage: %d RF/t misc.storagecraft:energyUsage=Usage: %d RF/t
@@ -31,6 +32,7 @@ block.storagecraft:grid.name=Grid
block.storagecraft:drive.name=Drive block.storagecraft:drive.name=Drive
block.storagecraft:storageProxy.name=Storage Proxy block.storagecraft:storageProxy.name=Storage Proxy
block.storagecraft:importer.name=Importer block.storagecraft:importer.name=Importer
block.storagecraft:exporter.name=Exporter
item.storagecraft:storageCell.0.name=1k Storage Cell item.storagecraft:storageCell.0.name=1k Storage Cell
item.storagecraft:storageCell.1.name=4k Storage Cell item.storagecraft:storageCell.1.name=4k Storage Cell

View File

@@ -5,6 +5,7 @@ gui.storagecraft:grid=Rooster
gui.storagecraft:drive=Schijf gui.storagecraft:drive=Schijf
gui.storagecraft:storageProxy=Opslag Proxy gui.storagecraft:storageProxy=Opslag Proxy
gui.storagecraft:importer=Importeur gui.storagecraft:importer=Importeur
gui.storagecraft:exporter=Exporteur
misc.storagecraft:energyStored=%d / %d RF misc.storagecraft:energyStored=%d / %d RF
misc.storagecraft:energyUsage=Verbruik: %d RF/t misc.storagecraft:energyUsage=Verbruik: %d RF/t
@@ -31,6 +32,7 @@ block.storagecraft:grid.name=Rooster
block.storagecraft:drive.name=Schijf block.storagecraft:drive.name=Schijf
block.storagecraft:storageProxy.name=Opslag Proxy block.storagecraft:storageProxy.name=Opslag Proxy
block.storagecraft:importer.name=Importeur block.storagecraft:importer.name=Importeur
block.storagecraft:exporter.name=Exporteur
item.storagecraft:storageCell.0.name=1k Opslagcel item.storagecraft:storageCell.0.name=1k Opslagcel
item.storagecraft:storageCell.1.name=4k Opslagcel item.storagecraft:storageCell.1.name=4k Opslagcel

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB