Relay working!
This commit is contained in:
		| @@ -18,4 +18,5 @@ public final class RefinedStorageBlocks | |||||||
| 	public static final BlockDestructor DESTRUCTOR = new BlockDestructor(); | 	public static final BlockDestructor DESTRUCTOR = new BlockDestructor(); | ||||||
| 	public static final BlockConstructor CONSTRUCTOR = new BlockConstructor(); | 	public static final BlockConstructor CONSTRUCTOR = new BlockConstructor(); | ||||||
| 	public static final BlockStorage STORAGE = new BlockStorage(); | 	public static final BlockStorage STORAGE = new BlockStorage(); | ||||||
|  | 	public static final BlockRelay RELAY = new BlockRelay(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -13,5 +13,5 @@ public final class RefinedStorageGui | |||||||
| 	public static final int DESTRUCTOR = 9; | 	public static final int DESTRUCTOR = 9; | ||||||
| 	public static final int CONSTRUCTOR = 10; | 	public static final int CONSTRUCTOR = 10; | ||||||
| 	public static final int STORAGE = 11; | 	public static final int STORAGE = 11; | ||||||
| 	public static final int CRAFTER = 12; | 	public static final int RELAY = 12; | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										38
									
								
								src/main/java/refinedstorage/block/BlockRelay.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/main/java/refinedstorage/block/BlockRelay.java
									
									
									
									
									
										Normal 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; | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										13
									
								
								src/main/java/refinedstorage/container/ContainerRelay.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/main/java/refinedstorage/container/ContainerRelay.java
									
									
									
									
									
										Normal 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); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -39,6 +39,8 @@ public class GuiHandler implements IGuiHandler | |||||||
| 				return new ContainerConstructor(player, (TileConstructor) tile); | 				return new ContainerConstructor(player, (TileConstructor) tile); | ||||||
| 			case RefinedStorageGui.STORAGE: | 			case RefinedStorageGui.STORAGE: | ||||||
| 				return new ContainerStorage(player, ((IStorageGui) tile).getInventory()); | 				return new ContainerStorage(player, ((IStorageGui) tile).getInventory()); | ||||||
|  | 			case RefinedStorageGui.RELAY: | ||||||
|  | 				return new ContainerRelay(player); | ||||||
| 			default: | 			default: | ||||||
| 				return null; | 				return null; | ||||||
| 		} | 		} | ||||||
| @@ -79,6 +81,8 @@ public class GuiHandler implements IGuiHandler | |||||||
| 				return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), (TileConstructor) tile); | 				return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), (TileConstructor) tile); | ||||||
| 			case RefinedStorageGui.STORAGE: | 			case RefinedStorageGui.STORAGE: | ||||||
| 				return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile); | 				return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile); | ||||||
|  | 			case RefinedStorageGui.RELAY: | ||||||
|  | 				return new GuiRelay((ContainerRelay) getContainer(ID, player, tile), (TileRelay) tile); | ||||||
| 			default: | 			default: | ||||||
| 				return null; | 				return null; | ||||||
| 		} | 		} | ||||||
|   | |||||||
							
								
								
									
										43
									
								
								src/main/java/refinedstorage/gui/GuiRelay.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/main/java/refinedstorage/gui/GuiRelay.java
									
									
									
									
									
										Normal 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")); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -52,6 +52,7 @@ public class CommonProxy | |||||||
| 		GameRegistry.registerTileEntity(TileDestructor.class, "destructor"); | 		GameRegistry.registerTileEntity(TileDestructor.class, "destructor"); | ||||||
| 		GameRegistry.registerTileEntity(TileConstructor.class, "constructor"); | 		GameRegistry.registerTileEntity(TileConstructor.class, "constructor"); | ||||||
| 		GameRegistry.registerTileEntity(TileStorage.class, "storage"); | 		GameRegistry.registerTileEntity(TileStorage.class, "storage"); | ||||||
|  | 		GameRegistry.registerTileEntity(TileRelay.class, "relay"); | ||||||
|  |  | ||||||
| 		GameRegistry.registerBlock(RefinedStorageBlocks.CONTROLLER, ItemBlockController.class, "controller"); | 		GameRegistry.registerBlock(RefinedStorageBlocks.CONTROLLER, ItemBlockController.class, "controller"); | ||||||
| 		GameRegistry.registerBlock(RefinedStorageBlocks.CABLE, "cable"); | 		GameRegistry.registerBlock(RefinedStorageBlocks.CABLE, "cable"); | ||||||
| @@ -67,6 +68,7 @@ public class CommonProxy | |||||||
| 		GameRegistry.registerBlock(RefinedStorageBlocks.DESTRUCTOR, "destructor"); | 		GameRegistry.registerBlock(RefinedStorageBlocks.DESTRUCTOR, "destructor"); | ||||||
| 		GameRegistry.registerBlock(RefinedStorageBlocks.CONSTRUCTOR, "constructor"); | 		GameRegistry.registerBlock(RefinedStorageBlocks.CONSTRUCTOR, "constructor"); | ||||||
| 		GameRegistry.registerBlock(RefinedStorageBlocks.STORAGE, ItemBlockStorage.class, "storage"); | 		GameRegistry.registerBlock(RefinedStorageBlocks.STORAGE, ItemBlockStorage.class, "storage"); | ||||||
|  | 		GameRegistry.registerBlock(RefinedStorageBlocks.RELAY, "relay"); | ||||||
|  |  | ||||||
| 		GameRegistry.registerItem(RefinedStorageItems.STORAGE_CELL, "storage_cell"); | 		GameRegistry.registerItem(RefinedStorageItems.STORAGE_CELL, "storage_cell"); | ||||||
| 		GameRegistry.registerItem(RefinedStorageItems.WIRELESS_GRID, "wireless_grid"); | 		GameRegistry.registerItem(RefinedStorageItems.WIRELESS_GRID, "wireless_grid"); | ||||||
|   | |||||||
| @@ -53,6 +53,19 @@ public class TileCable extends TileBase | |||||||
| 				machines.add((TileMachine) tile); | 				machines.add((TileMachine) tile); | ||||||
|  |  | ||||||
| 				visited.add(newPos); | 				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) | 			else if (tile instanceof TileCable) | ||||||
| 			{ | 			{ | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								src/main/java/refinedstorage/tile/TileRelay.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/main/java/refinedstorage/tile/TileRelay.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | package refinedstorage.tile; | ||||||
|  |  | ||||||
|  | public class TileRelay extends TileMachine | ||||||
|  | { | ||||||
|  | 	@Override | ||||||
|  | 	public int getEnergyUsage() | ||||||
|  | 	{ | ||||||
|  | 		return 1; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	@Override | ||||||
|  | 	public void updateMachine() | ||||||
|  | 	{ | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -12,6 +12,7 @@ gui.refinedstorage:solderer=Solderer | |||||||
| gui.refinedstorage:wireless_transmitter=Wireless Transmitter | gui.refinedstorage:wireless_transmitter=Wireless Transmitter | ||||||
| gui.refinedstorage:destructor=Destructor | gui.refinedstorage:destructor=Destructor | ||||||
| gui.refinedstorage:constructor=Constructor | gui.refinedstorage:constructor=Constructor | ||||||
|  | gui.refinedstorage:relay=Relay | ||||||
|  |  | ||||||
| misc.refinedstorage:energy_stored=%d / %d RF | misc.refinedstorage:energy_stored=%d / %d RF | ||||||
| misc.refinedstorage:energy_usage=Usage: %d RF/t | 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.2.name=16k Storage Block | ||||||
| block.refinedstorage:storage.3.name=64k Storage Block | block.refinedstorage:storage.3.name=64k Storage Block | ||||||
| block.refinedstorage:storage.4.name=Creative 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.0.name=1k Storage Cell | ||||||
| item.refinedstorage:storage_cell.1.name=4k Storage Cell | item.refinedstorage:storage_cell.1.name=4k Storage Cell | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ gui.refinedstorage:solderer=Soldeerder | |||||||
| gui.refinedstorage:wireless_transmitter=Draadloze Zender | gui.refinedstorage:wireless_transmitter=Draadloze Zender | ||||||
| gui.refinedstorage:destructor=Destructor | gui.refinedstorage:destructor=Destructor | ||||||
| gui.refinedstorage:constructor=Constructor | gui.refinedstorage:constructor=Constructor | ||||||
| gui.refinedstorage:crafter=Crafter | gui.refinedstorage:relay=Relais | ||||||
|  |  | ||||||
| misc.refinedstorage:energy_stored=%d / %d RF | misc.refinedstorage:energy_stored=%d / %d RF | ||||||
| misc.refinedstorage:energy_usage=Vebruik: %d RF/t | 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.2.name=16k Opslag Blok | ||||||
| block.refinedstorage:storage.3.name=64k Opslag Blok | block.refinedstorage:storage.3.name=64k Opslag Blok | ||||||
| block.refinedstorage:storage.4.name=Creative 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.0.name=1k Opslagcel | ||||||
| item.refinedstorage:storage_cell.1.name=4k Opslagcel | item.refinedstorage:storage_cell.1.name=4k Opslagcel | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								src/main/resources/assets/refinedstorage/textures/gui/relay.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/main/resources/assets/refinedstorage/textures/gui/relay.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.7 KiB | 
		Reference in New Issue
	
	Block a user
	 Raoul Van den Berge
					Raoul Van den Berge