Relay working!

This commit is contained in:
Raoul Van den Berge
2016-03-20 16:28:18 +01:00
parent 2dc790edf0
commit e187a2c54d
12 changed files with 134 additions and 3 deletions

View File

@@ -18,4 +18,5 @@ public final class RefinedStorageBlocks
public static final BlockDestructor DESTRUCTOR = new BlockDestructor();
public static final BlockConstructor CONSTRUCTOR = new BlockConstructor();
public static final BlockStorage STORAGE = new BlockStorage();
public static final BlockRelay RELAY = new BlockRelay();
}

View File

@@ -13,5 +13,5 @@ public final class RefinedStorageGui
public static final int DESTRUCTOR = 9;
public static final int CONSTRUCTOR = 10;
public static final int STORAGE = 11;
public static final int CRAFTER = 12;
public static final int RELAY = 12;
}

View File

@@ -0,0 +1,38 @@
package refinedstorage.block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileRelay;
public class BlockRelay extends BlockMachine
{
public BlockRelay()
{
super("relay");
}
@Override
public TileEntity createTileEntity(World world, IBlockState state)
{
return new TileRelay();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.RELAY, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
}

View File

@@ -0,0 +1,13 @@
package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer;
public class ContainerRelay extends ContainerBase
{
public ContainerRelay(EntityPlayer player)
{
super(player);
addPlayerInventory(8, 50);
}
}

View File

@@ -39,6 +39,8 @@ public class GuiHandler implements IGuiHandler
return new ContainerConstructor(player, (TileConstructor) tile);
case RefinedStorageGui.STORAGE:
return new ContainerStorage(player, ((IStorageGui) tile).getInventory());
case RefinedStorageGui.RELAY:
return new ContainerRelay(player);
default:
return null;
}
@@ -79,6 +81,8 @@ public class GuiHandler implements IGuiHandler
return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), (TileConstructor) tile);
case RefinedStorageGui.STORAGE:
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile);
case RefinedStorageGui.RELAY:
return new GuiRelay((ContainerRelay) getContainer(ID, player, tile), (TileRelay) tile);
default:
return null;
}

View File

@@ -0,0 +1,43 @@
package refinedstorage.gui;
import refinedstorage.container.ContainerRelay;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.tile.TileRelay;
public class GuiRelay extends GuiBase
{
private TileRelay relay;
public GuiRelay(ContainerRelay container, TileRelay relay)
{
super(container, 176, 131);
this.relay = relay;
}
@Override
public void init(int x, int y)
{
addSideButton(new SideButtonRedstoneMode(relay));
}
@Override
public void update(int x, int y)
{
}
@Override
public void drawBackground(int x, int y, int mouseX, int mouseY)
{
bindTexture("gui/relay.png");
drawTexture(x, y, 0, 0, width, height);
}
@Override
public void drawForeground(int mouseX, int mouseY)
{
drawString(7, 7, t("gui.refinedstorage:relay"));
drawString(7, 39, t("container.inventory"));
}
}

View File

@@ -52,6 +52,7 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileDestructor.class, "destructor");
GameRegistry.registerTileEntity(TileConstructor.class, "constructor");
GameRegistry.registerTileEntity(TileStorage.class, "storage");
GameRegistry.registerTileEntity(TileRelay.class, "relay");
GameRegistry.registerBlock(RefinedStorageBlocks.CONTROLLER, ItemBlockController.class, "controller");
GameRegistry.registerBlock(RefinedStorageBlocks.CABLE, "cable");
@@ -67,6 +68,7 @@ public class CommonProxy
GameRegistry.registerBlock(RefinedStorageBlocks.DESTRUCTOR, "destructor");
GameRegistry.registerBlock(RefinedStorageBlocks.CONSTRUCTOR, "constructor");
GameRegistry.registerBlock(RefinedStorageBlocks.STORAGE, ItemBlockStorage.class, "storage");
GameRegistry.registerBlock(RefinedStorageBlocks.RELAY, "relay");
GameRegistry.registerItem(RefinedStorageItems.STORAGE_CELL, "storage_cell");
GameRegistry.registerItem(RefinedStorageItems.WIRELESS_GRID, "wireless_grid");

View File

@@ -53,6 +53,19 @@ public class TileCable extends TileBase
machines.add((TileMachine) tile);
visited.add(newPos);
if (tile instanceof TileRelay)
{
for (EnumFacing relayDir : EnumFacing.VALUES)
{
TileEntity nextToRelay = worldObj.getTileEntity(newPos.offset(relayDir));
if (nextToRelay instanceof TileCable)
{
((TileCable) nextToRelay).addMachines(visited, machines, controller);
}
}
}
}
else if (tile instanceof TileCable)
{

View File

@@ -0,0 +1,15 @@
package refinedstorage.tile;
public class TileRelay extends TileMachine
{
@Override
public int getEnergyUsage()
{
return 1;
}
@Override
public void updateMachine()
{
}
}

View File

@@ -12,6 +12,7 @@ gui.refinedstorage:solderer=Solderer
gui.refinedstorage:wireless_transmitter=Wireless Transmitter
gui.refinedstorage:destructor=Destructor
gui.refinedstorage:constructor=Constructor
gui.refinedstorage:relay=Relay
misc.refinedstorage:energy_stored=%d / %d RF
misc.refinedstorage:energy_usage=Usage: %d RF/t
@@ -81,7 +82,7 @@ block.refinedstorage:storage.1.name=4k Storage Block
block.refinedstorage:storage.2.name=16k Storage Block
block.refinedstorage:storage.3.name=64k Storage Block
block.refinedstorage:storage.4.name=Creative Storage Block
block.refinedstorage:crafter.name=Crafter
block.refinedstorage:relay.name=Relay
item.refinedstorage:storage_cell.0.name=1k Storage Cell
item.refinedstorage:storage_cell.1.name=4k Storage Cell

View File

@@ -12,7 +12,7 @@ gui.refinedstorage:solderer=Soldeerder
gui.refinedstorage:wireless_transmitter=Draadloze Zender
gui.refinedstorage:destructor=Destructor
gui.refinedstorage:constructor=Constructor
gui.refinedstorage:crafter=Crafter
gui.refinedstorage:relay=Relais
misc.refinedstorage:energy_stored=%d / %d RF
misc.refinedstorage:energy_usage=Vebruik: %d RF/t
@@ -82,6 +82,7 @@ block.refinedstorage:storage.1.name=4k Opslag Blok
block.refinedstorage:storage.2.name=16k Opslag Blok
block.refinedstorage:storage.3.name=64k Opslag Blok
block.refinedstorage:storage.4.name=Creative Opslag Blok
block.refinedstorage:relay.name=Relais
item.refinedstorage:storage_cell.0.name=1k Opslagcel
item.refinedstorage:storage_cell.1.name=4k Opslagcel

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB