mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
proper fluid IO for soyuz launcher, item transfer BS
This commit is contained in:
parent
afaedaca95
commit
ed219824f9
@ -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
|
||||
|
||||
44
src/main/java/com/hbm/blocks/network/RadioTorchBase.java
Normal file
44
src/main/java/com/hbm/blocks/network/RadioTorchBase.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
16
src/main/java/com/hbm/blocks/network/RadioTorchSender.java
Normal file
16
src/main/java/com/hbm/blocks/network/RadioTorchSender.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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<ItemStack> select(List<ItemStack> offer);
|
||||
}
|
||||
@ -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<ItemStack> offer();
|
||||
/** Removes the selected ItemStacks */
|
||||
public void remove(List<ItemStack> toRem);
|
||||
}
|
||||
@ -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<ItemStack> offer);
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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<ItemStack> offer() {
|
||||
|
||||
List<ItemStack> 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<ItemStack> toRem) {
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/hbm/inventory/transfer/TransferUtil.java
Normal file
15
src/main/java/com/hbm/inventory/transfer/TransferUtil.java
Normal file
@ -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<ItemStack> filtered = filter.select(source.offer());
|
||||
source.remove(filtered);
|
||||
target.fill(filtered);
|
||||
}
|
||||
}
|
||||
@ -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<DirPos> conPos;
|
||||
protected List<DirPos> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
BIN
src/main/resources/assets/hbm/textures/blocks/rtty_rec_off.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/rtty_rec_off.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 301 B |
BIN
src/main/resources/assets/hbm/textures/blocks/rtty_rec_on.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/rtty_rec_on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
Binary file not shown.
|
After Width: | Height: | Size: 313 B |
BIN
src/main/resources/assets/hbm/textures/blocks/rtty_sender_on.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/rtty_sender_on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 291 B |
Loading…
x
Reference in New Issue
Block a user