diff --git a/src/main/java/com/hbm/blocks/machine/SoyuzLauncher.java b/src/main/java/com/hbm/blocks/machine/SoyuzLauncher.java index 480073153..6ed230464 100644 --- a/src/main/java/com/hbm/blocks/machine/SoyuzLauncher.java +++ b/src/main/java/com/hbm/blocks/machine/SoyuzLauncher.java @@ -7,6 +7,7 @@ import com.hbm.blocks.ModBlocks; import com.hbm.handler.BossSpawnHandler; import com.hbm.handler.MultiblockHandlerXR; import com.hbm.main.MainRegistry; +import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntitySoyuzLauncher; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; @@ -31,9 +32,9 @@ public class SoyuzLauncher extends BlockDummyable { @Override public TileEntity createNewTileEntity(World world, int meta) { - - if(meta >= ForgeDirection.UNKNOWN.ordinal()) - return new TileEntitySoyuzLauncher(); + + if(meta >= 12) return new TileEntitySoyuzLauncher(); + if(meta >= 6) return new TileEntityProxyCombo().power().fluid(); return null; } @@ -143,6 +144,13 @@ public class SoyuzLauncher extends BlockDummyable { MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { -2, 4, -3, 6, 6, -3 }, this, dir); MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { 0, 4, 1, 1, -6, 8 }, this, dir); MultiblockHandlerXR.fillSpace(world, x, y, z, new int[] { 0, 4, 2, 2, 9, -5 }, this, dir); + + for(int ix = x - 6; ix <= x + 6; ix++) { + for(int iz = z - 6; iz <= z + 6; iz++) { + this.makeExtra(world, ix, y, iz); + this.makeExtra(world, ix, y + 1, iz); + } + } } @Override diff --git a/src/main/java/com/hbm/blocks/network/RadioTorchBase.java b/src/main/java/com/hbm/blocks/network/RadioTorchBase.java new file mode 100644 index 000000000..1f0f44b43 --- /dev/null +++ b/src/main/java/com/hbm/blocks/network/RadioTorchBase.java @@ -0,0 +1,44 @@ +package com.hbm.blocks.network; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class RadioTorchBase extends BlockContainer { + + public RadioTorchBase() { + super(Material.circuits); + } + + public static int renderID = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public int getRenderType() { + return renderID; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + return true; + } + + @Override + public int onBlockPlaced(World world, int x, int y, int z, int side, float fX, float fY, float fZ, int meta) { + return side; + } +} diff --git a/src/main/java/com/hbm/blocks/network/RadioTorchSender.java b/src/main/java/com/hbm/blocks/network/RadioTorchSender.java new file mode 100644 index 000000000..c456e2b2b --- /dev/null +++ b/src/main/java/com/hbm/blocks/network/RadioTorchSender.java @@ -0,0 +1,16 @@ +package com.hbm.blocks.network; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class RadioTorchSender extends RadioTorchBase { + + public RadioTorchSender() { + super(); + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return null; + } +} diff --git a/src/main/java/com/hbm/inventory/transfer/ITransferFilter.java b/src/main/java/com/hbm/inventory/transfer/ITransferFilter.java new file mode 100644 index 000000000..8f5e91cae --- /dev/null +++ b/src/main/java/com/hbm/inventory/transfer/ITransferFilter.java @@ -0,0 +1,11 @@ +package com.hbm.inventory.transfer; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public interface ITransferFilter { + + /** Returns a list of valid ItemStacks that pass the filter and can be added. The returned list is what is added to the target and removed from the source. */ + public List select(List offer); +} diff --git a/src/main/java/com/hbm/inventory/transfer/ITransferSource.java b/src/main/java/com/hbm/inventory/transfer/ITransferSource.java new file mode 100644 index 000000000..27891800f --- /dev/null +++ b/src/main/java/com/hbm/inventory/transfer/ITransferSource.java @@ -0,0 +1,13 @@ +package com.hbm.inventory.transfer; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public interface ITransferSource { + + /** Returns a list of ItemStacks accessible from this source */ + public List offer(); + /** Removes the selected ItemStacks */ + public void remove(List toRem); +} diff --git a/src/main/java/com/hbm/inventory/transfer/ITransferTarget.java b/src/main/java/com/hbm/inventory/transfer/ITransferTarget.java new file mode 100644 index 000000000..28bba3987 --- /dev/null +++ b/src/main/java/com/hbm/inventory/transfer/ITransferTarget.java @@ -0,0 +1,11 @@ +package com.hbm.inventory.transfer; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public interface ITransferTarget { + + /** Adds the selected ItemStacks to the target */ + public void fill(List offer); +} diff --git a/src/main/java/com/hbm/inventory/transfer/TransferSourceSided.java b/src/main/java/com/hbm/inventory/transfer/TransferSourceSided.java new file mode 100644 index 000000000..8c0dfb998 --- /dev/null +++ b/src/main/java/com/hbm/inventory/transfer/TransferSourceSided.java @@ -0,0 +1,13 @@ +package com.hbm.inventory.transfer; + +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class TransferSourceSided implements ITransferSource { + + protected ForgeDirection fromSide; + + public TransferSourceSided fromSide(ForgeDirection side) { + this.fromSide = side; + return this; + } +} diff --git a/src/main/java/com/hbm/inventory/transfer/TransferSourceTileEntity.java b/src/main/java/com/hbm/inventory/transfer/TransferSourceTileEntity.java new file mode 100644 index 000000000..11a92d06c --- /dev/null +++ b/src/main/java/com/hbm/inventory/transfer/TransferSourceTileEntity.java @@ -0,0 +1,70 @@ +package com.hbm.inventory.transfer; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; + +public class TransferSourceTileEntity extends TransferSourceSided { + + protected TileEntity tile; + + public TransferSourceTileEntity fromTile(TileEntity tile) { + this.tile = tile; + return this; + } + + @Override + public List offer() { + + List list = new ArrayList(); + + if(tile instanceof ISidedInventory) { + ISidedInventory inventory = (ISidedInventory) tile; + int[] access = masquerade(inventory, fromSide.ordinal()); + + for(int i : access) { + ItemStack stack = inventory.getStackInSlot(i); + + if(stack != null && inventory.canExtractItem(i, stack, fromSide.ordinal())) { + list.add(stack.copy()); + } + } + + return list; + } + + if(tile instanceof IInventory) { + IInventory inventory = (IInventory) tile; + + for(int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack stack = inventory.getStackInSlot(i); + + if(stack != null) { + list.add(stack.copy()); + } + } + + return list; + } + + return list; + } + + public static int[] masquerade(ISidedInventory sided, int side) { + + if(sided instanceof TileEntityFurnace) { + return new int[] {2}; + } + + return sided.getAccessibleSlotsFromSide(side); + } + + @Override + public void remove(List toRem) { + } +} diff --git a/src/main/java/com/hbm/inventory/transfer/TransferUtil.java b/src/main/java/com/hbm/inventory/transfer/TransferUtil.java new file mode 100644 index 000000000..2ab5c8576 --- /dev/null +++ b/src/main/java/com/hbm/inventory/transfer/TransferUtil.java @@ -0,0 +1,15 @@ +package com.hbm.inventory.transfer; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public class TransferUtil { + + public static void transfer(ITransferSource source, ITransferFilter filter, ITransferTarget target) { + + List filtered = filter.select(source.offer()); + source.remove(filtered); + target.fill(filtered); + } +} diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntitySoyuzLauncher.java b/src/main/java/com/hbm/tileentity/machine/TileEntitySoyuzLauncher.java index b4ca97203..f870f9cfe 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntitySoyuzLauncher.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntitySoyuzLauncher.java @@ -15,8 +15,10 @@ import com.hbm.lib.Library; import com.hbm.main.MainRegistry; import com.hbm.sound.AudioWrapper; import com.hbm.tileentity.TileEntityMachineBase; +import com.hbm.util.fauxpointtwelve.DirPos; import api.hbm.energy.IEnergyUser; +import api.hbm.fluid.IFluidStandardReceiver; import api.hbm.item.IDesignatorItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -29,7 +31,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntitySoyuzLauncher extends TileEntityMachineBase implements ISidedInventory, IEnergyUser, IFluidContainer, IFluidAcceptor { +public class TileEntitySoyuzLauncher extends TileEntityMachineBase implements ISidedInventory, IEnergyUser, IFluidContainer, IFluidAcceptor, IFluidStandardReceiver { public long power; public static final long maxPower = 1000000; @@ -62,8 +64,14 @@ public class TileEntitySoyuzLauncher extends TileEntityMachineBase implements IS if (!worldObj.isRemote) { - this.trySubscribe(worldObj, xCoord, yCoord - 1, zCoord, ForgeDirection.DOWN); - + if(worldObj.getTotalWorldTime() % 20 == 0) { + for(DirPos pos : getConPos()) { + this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + this.trySubscribe(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + } + } + tanks[0].loadTank(4, 5, slots); tanks[1].loadTank(6, 7, slots); @@ -134,6 +142,26 @@ public class TileEntitySoyuzLauncher extends TileEntityMachineBase implements IS } } + protected List conPos; + protected List getConPos() { + + if(conPos != null) + return conPos; + + conPos = new ArrayList(); + + for(ForgeDirection dir : new ForgeDirection[] {Library.POS_X, Library.POS_Z, Library.NEG_X, Library.NEG_Z}) { + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + for(int i = -6; i <= 6; i++) { + conPos.add(new DirPos(xCoord + dir.offsetX * 7 + rot.offsetX * i, yCoord + 0, zCoord + dir.offsetX * 7 + rot.offsetZ * i, dir)); + conPos.add(new DirPos(xCoord + dir.offsetX * 7 + rot.offsetX * i, yCoord + 1, zCoord + dir.offsetX * 7 + rot.offsetZ * i, dir)); + } + } + + return conPos; + } + @Override public AudioWrapper createAudioLoop() { return MainRegistry.proxy.getLoopedSound("hbm:block.soyuzReady", xCoord, yCoord, zCoord, 1.0F, 1.0F); @@ -429,4 +457,19 @@ public class TileEntitySoyuzLauncher extends TileEntityMachineBase implements IS public long getMaxPower() { return this.maxPower; } + + @Override + public FluidTank[] getAllTanks() { + return tanks; + } + + @Override + public FluidTank[] getReceivingTanks() { + return tanks; + } + + @Override + public boolean canConnect(FluidType type, ForgeDirection dir) { + return dir != ForgeDirection.UNKNOWN && dir != ForgeDirection.UP && dir != ForgeDirection.DOWN; + } } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityRadioTorchBase.java b/src/main/java/com/hbm/tileentity/network/TileEntityRadioTorchBase.java new file mode 100644 index 000000000..d57223822 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/TileEntityRadioTorchBase.java @@ -0,0 +1,9 @@ +package com.hbm.tileentity.network; + +import net.minecraft.tileentity.TileEntity; + +public class TileEntityRadioTorchBase extends TileEntity { + + public String channel = ""; + protected long lastUpdate; +} diff --git a/src/main/resources/assets/hbm/textures/blocks/rtty_rec_off.png b/src/main/resources/assets/hbm/textures/blocks/rtty_rec_off.png new file mode 100644 index 000000000..6e823d5f0 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rtty_rec_off.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rtty_rec_on.png b/src/main/resources/assets/hbm/textures/blocks/rtty_rec_on.png new file mode 100644 index 000000000..3dd5d38c5 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rtty_rec_on.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rtty_sender_off.png b/src/main/resources/assets/hbm/textures/blocks/rtty_sender_off.png new file mode 100644 index 000000000..6019674be Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rtty_sender_off.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rtty_sender_on.png b/src/main/resources/assets/hbm/textures/blocks/rtty_sender_on.png new file mode 100644 index 000000000..6899d1439 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rtty_sender_on.png differ