1
0
Fork 0

add pipe display item

This commit is contained in:
Sen 2025-08-13 17:10:55 +02:00
parent 6e5a1b7e37
commit b4daadcb45
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
17 changed files with 322 additions and 112 deletions

View file

@ -119,6 +119,7 @@ import common.packet.SPacketTimeUpdate;
import common.packet.SPacketTrades;
import common.packet.SPacketUpdateDisplay;
import common.packet.SPacketUpdateHealth;
import common.packet.SPacketUpdatePipe;
import common.rng.Random;
import common.sound.PositionedSound;
import common.sound.Sound;
@ -126,6 +127,7 @@ import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.tileentity.Device;
import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntityItemPipe;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.util.Pair;
@ -1267,6 +1269,15 @@ public class ClientPlayer implements IClientPlayer
}
}
public void handleUpdatePipe(SPacketUpdatePipe packet) {
NetHandler.checkThread(packet, this, this.gm, this.world);
if(this.gm.world.isBlockLoaded(packet.getPos())) {
TileEntity te = this.gm.world.getTileEntity(packet.getPos());
if(te instanceof TileEntityItemPipe pipe)
pipe.setDisplayedItem(packet.getItem());
}
}
/**
* Sets the progressbar of the opened window to the specified value
*/

View file

@ -0,0 +1,34 @@
package client.renderer.tileentity;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.GlState;
import client.renderer.blockmodel.IBakedModel;
import client.renderer.entity.RenderItem;
import client.renderer.texture.TextureMap;
import common.item.ItemStack;
import common.tileentity.TileEntityItemPipe;
public class ItemPipeRenderer extends ElementRenderer<TileEntityItemPipe> {
public void renderElements(TileEntityItemPipe te, double x, double y, double z, float partialTicks) {
ItemStack itemstack = te.getDisplayedItem();
if(itemstack == null)
return;
Client.CLIENT.getTextureManager().bindTexture(TextureMap.BLOCKS);
GlState.enableRescaleNormal();
GlState.alphaFunc(GL11.GL_GREATER, 0.1F);
GlState.enableBlend();
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
RenderItem itemRenderer = Client.CLIENT.getRenderItem();
IBakedModel ibakedmodel = itemRenderer.getItemModelMesher().getItemModel(itemstack);
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 0.5f, (float)z + 0.5F);
if(ibakedmodel.isGui3d())
GL11.glScalef(0.5F, 0.5F, 0.5F);
itemRenderer.renderItem(itemstack, ibakedmodel);
GL11.glPopMatrix();
GlState.disableRescaleNormal();
GlState.disableBlend();
}
}

View file

@ -9,6 +9,7 @@ import common.collect.Maps;
import common.entity.Entity;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntityItemPipe;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.world.World;
@ -29,6 +30,7 @@ public class SpecialRenderer {
private SpecialRenderer() {
this.renderers.put(TileEntitySign.class, new SignRenderer());
this.renderers.put(TileEntityDisplay.class, new DisplayRenderer());
this.renderers.put(TileEntityItemPipe.class, new ItemPipeRenderer());
}
private <T extends TileEntity> ElementRenderer<T> getRenderer(Class<? extends TileEntity> clazz) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

View file

@ -0,0 +1,57 @@
package common.block.tech;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.properties.Property;
import common.properties.PropertyBool;
import common.util.BlockPos;
import common.util.Clientside;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
public abstract class BlockDirectionalPipe extends BlockPipe {
public static final PropertyBool DOWN = PropertyBool.create("down");
public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool WEST = PropertyBool.create("west");
public BlockDirectionalPipe() {
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN).withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false));
}
public State getState(State state, IWorldAccess world, BlockPos pos) {
return state.withProperty(DOWN, this.canConnectTo(world.getState(pos.down()).getBlock()))
.withProperty(UP, this.canConnectTo(world.getState(pos.up()).getBlock()))
.withProperty(NORTH, this.canConnectTo(world.getState(pos.north()).getBlock()))
.withProperty(EAST, this.canConnectTo(world.getState(pos.east()).getBlock()))
.withProperty(SOUTH, this.canConnectTo(world.getState(pos.south()).getBlock()))
.withProperty(WEST, this.canConnectTo(world.getState(pos.west()).getBlock()));
}
public State getItemState() {
return this.getState().withProperty(FACING, Facing.EAST).withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, true).withProperty(SOUTH, false).withProperty(WEST, true);
}
protected Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, DOWN, UP, WEST, EAST};
}
protected Property[] getProperties() {
return new Property[] {FACING, DOWN, UP, NORTH, EAST, WEST, SOUTH};
}
@Clientside
public Model getModel(ModelProvider provider, String name, State state) {
Facing dir = state.getValue(FACING);
boolean down = state.getValue(DOWN);
boolean up = state.getValue(UP);
boolean north = state.getValue(NORTH);
boolean south = state.getValue(SOUTH);
boolean west = state.getValue(WEST);
boolean east = state.getValue(EAST);
return getPipeModel(provider, name, dir, down, up, north, south, west, east);
}
}

View file

@ -0,0 +1,15 @@
package common.block.tech;
import common.block.Block;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityItemPipe;
public class BlockItemPipe extends BlockDirectionalPipe {
public boolean canConnectTo(Block block) {
return block instanceof BlockMachine || block instanceof BlockItemPipe || block instanceof BlockSuctionPipe || block instanceof BlockChest;
}
public TileEntity createNewTileEntity() {
return new TileEntityItemPipe(false);
}
}

View file

@ -9,13 +9,13 @@ import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.item.CheatTab;
import common.item.ItemStack;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.properties.Property;
import common.properties.PropertyBool;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityPipe;
import common.tileentity.TileEntityItemPipe;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Clientside;
@ -25,51 +25,24 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockPipe extends Block implements ITileEntityProvider, Directional {
public static final PropertyBool DOWN = PropertyBool.create("down");
public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool WEST = PropertyBool.create("west");
public abstract class BlockPipe extends Block implements ITileEntityProvider, Directional {
private static boolean keepInventory;
public BlockPipe() {
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN).withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false));
this.setTab(CheatTab.TECHNOLOGY);
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
}
public boolean canConnectTo(Block block) {
return block instanceof BlockMachine || block instanceof BlockPipe || block instanceof BlockChest;
}
public abstract boolean canConnectTo(Block block);
public State getState(State state, IWorldAccess world, BlockPos pos) {
return state.withProperty(DOWN, this.canConnectTo(world.getState(pos.down()).getBlock()))
.withProperty(UP, this.canConnectTo(world.getState(pos.up()).getBlock()))
.withProperty(NORTH, this.canConnectTo(world.getState(pos.north()).getBlock()))
.withProperty(EAST, this.canConnectTo(world.getState(pos.east()).getBlock()))
.withProperty(SOUTH, this.canConnectTo(world.getState(pos.south()).getBlock()))
.withProperty(WEST, this.canConnectTo(world.getState(pos.west()).getBlock()));
}
public State getItemState() {
return this.getState().withProperty(FACING, Facing.EAST).withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, true).withProperty(SOUTH, false).withProperty(WEST, true);
}
protected Property[] getUnsavedProperties() {
return new Property[] {NORTH, SOUTH, DOWN, UP, WEST, EAST};
}
public void setBlockBounds(IWorldAccess world, BlockPos pos) {
public final void setBlockBounds(IWorldAccess world, BlockPos pos) {
this.setBlockBounds(this.canConnectTo(world.getState(pos.west()).getBlock()) ? 0.0f : 0.25f, this.canConnectTo(world.getState(pos.down()).getBlock()) ? 0.0f : 0.25f,
this.canConnectTo(world.getState(pos.north()).getBlock()) ? 0.0f : 0.25f, this.canConnectTo(world.getState(pos.east()).getBlock()) ? 1.0f : 0.75f,
this.canConnectTo(world.getState(pos.up()).getBlock()) ? 1.0f : 0.75f, this.canConnectTo(world.getState(pos.south()).getBlock()) ? 1.0f : 0.75f);
}
public void getCollisionBoxes(World world, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity) {
public final void getCollisionBoxes(World world, BlockPos pos, State state, BoundingBox mask, List<BoundingBox> list, Entity collidingEntity) {
this.setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
super.getCollisionBoxes(world, pos, state, mask, list, collidingEntity);
if(this.canConnectTo(world.getState(pos.west()).getBlock())) {
@ -103,19 +76,27 @@ public class BlockPipe extends Block implements ITileEntityProvider, Directional
return this.getState().withProperty(FACING, facing.getOpposite());
}
public TileEntity createNewTileEntity() {
return new TileEntityPipe();
}
public boolean onUse(World world, BlockPos pos, State state, EntityNPC player, Facing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem();
if(stack == null || stack.getItem() != Items.hoe)
return false;
if(world.client)
return true;
TileEntity te = world.getTileEntity(pos);
if(te instanceof TileEntityPipe) {
state = state.cycleProperty(FACING);
if(te instanceof TileEntityItemPipe) {
Facing face = state.getValue(FACING);
for(int z = 0; z < Facing.values().length; z++) {
Facing dir = Facing.values()[(face.ordinal() + 1 + z) % Facing.values().length];
if(this.canConnectTo(world.getState(pos.offset(dir)).getBlock())) {
face = dir;
break;
}
}
if(face == state.getValue(FACING))
return true;
keepInventory = true;
world.setState(pos, state, 3);
world.setState(pos, state, 3);
world.setState(pos, state.withProperty(FACING, face), 3);
world.setState(pos, state.withProperty(FACING, face), 3);
keepInventory = false;
te.validate();
world.setTileEntity(pos, te);
@ -126,46 +107,35 @@ public class BlockPipe extends Block implements ITileEntityProvider, Directional
public void onRemoved(AWorldServer worldIn, BlockPos pos, State state) {
if(!keepInventory) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof TileEntityPipe)
dropItems(worldIn, pos, (TileEntityPipe)tileentity);
if(tileentity instanceof TileEntityItemPipe)
dropItems(worldIn, pos, (TileEntityItemPipe)tileentity);
}
}
public boolean isFullCube() {
public final boolean isFullCube() {
return false;
}
public boolean isOpaqueCube() {
public final boolean isOpaqueCube() {
return false;
}
@Clientside
public boolean canRender(IWorldAccess worldIn, BlockPos pos, Facing side) {
public final boolean canRender(IWorldAccess worldIn, BlockPos pos, Facing side) {
return true;
}
@Clientside
public boolean hasTransparency() {
public final boolean hasTransparency() {
return true;
}
protected Property[] getProperties() {
return new Property[] {FACING, DOWN, UP, NORTH, EAST, WEST, SOUTH};
}
public boolean isMagnetic() {
public final boolean isMagnetic() {
return true;
}
@Clientside
public Model getModel(ModelProvider provider, String name, State state) {
Facing dir = state.getValue(FACING);
boolean down = state.getValue(DOWN);
boolean up = state.getValue(UP);
boolean north = state.getValue(NORTH);
boolean south = state.getValue(SOUTH);
boolean west = state.getValue(WEST);
boolean east = state.getValue(EAST);
protected static Model getPipeModel(ModelProvider provider, String name, Facing dir, boolean down, boolean up, boolean north, boolean south, boolean west, boolean east) {
String sel = name + "_selected";
Model model = provider.getModel(name);
if(!down || !up || !north || !south || !west || !east) {

View file

@ -0,0 +1,32 @@
package common.block.tech;
import common.model.Model;
import common.model.Model.ModelProvider;
import common.properties.Property;
import common.util.Clientside;
import common.util.Facing;
import common.util.Facing.Axis;
import common.world.State;
public abstract class BlockStraightPipe extends BlockPipe {
public BlockStraightPipe() {
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.DOWN));
}
public State getItemState() {
return this.getState().withProperty(FACING, Facing.EAST);
}
protected Property[] getProperties() {
return new Property[] {FACING};
}
@Clientside
public Model getModel(ModelProvider provider, String name, State state) {
Facing dir = state.getValue(FACING);
boolean y = dir.getAxis() == Axis.Y;
boolean z = dir.getAxis() == Axis.Z;
boolean x = dir.getAxis() == Axis.X;
return getPipeModel(provider, name, dir, y, y, z, z, x, x);
}
}

View file

@ -0,0 +1,15 @@
package common.block.tech;
import common.block.Block;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityItemPipe;
public class BlockSuctionPipe extends BlockStraightPipe {
public boolean canConnectTo(Block block) {
return block instanceof BlockMachine || block instanceof BlockItemPipe || block instanceof BlockChest;
}
public TileEntity createNewTileEntity() {
return new TileEntityItemPipe(true);
}
}

View file

@ -592,7 +592,8 @@ public abstract class BlockRegistry {
register("sticky_piston_head", (new BlockPistonHead(true)).setDisplay("Klebriger Kolben"));
register("dispenser", (new BlockDispenser(false)).setHardness(3.5F).setSound(SoundType.STONE).setDisplay("Werfer"));
register("dropper", (new BlockDispenser(true)).setHardness(3.5F).setSound(SoundType.STONE).setDisplay("Spender"));
register("pipe", (new BlockPipe()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Rohr"));
register("pipe", (new BlockItemPipe()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Rohr"));
register("suction_pipe", (new BlockSuctionPipe()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Saugrohr"));
register("tian_reactor", (new BlockTianReactor()).setHardness(3.0F).setResistance(8.0F).setSound(SoundType.STONE).setDisplay("Tianreaktor"));
register("rail", (new BlockRail()).setHardness(0.7F).setSound(SoundType.STONE).setDisplay("Schiene").setMiningTool(Equipment.PICKAXE, 0));

View file

@ -867,7 +867,8 @@ public abstract class Blocks {
public static final BlockFurnace neptunium_furnace = get("neptunium_furnace");
public static final BlockFurnace plutonium_furnace = get("plutonium_furnace");
public static final BlockFurnace titanium_furnace = get("titanium_furnace");
public static final BlockPipe pipe = get("pipe");
public static final BlockItemPipe pipe = get("pipe");
public static final BlockSuctionPipe suction_pipe = get("suction_pipe");
private static <T extends Block> T get(String id) {
T block = (T)BlockRegistry.byNameExact(id);

View file

@ -1245,6 +1245,7 @@ public abstract class Items {
public static final Item plutonium_furnace = get("plutonium_furnace");
public static final Item titanium_furnace = get("titanium_furnace");
public static final Item pipe = get("pipe");
public static final Item suction_pipe = get("suction_pipe");
private static <T extends Item> T get(String id) {
T item = (T)ItemRegistry.byName(id);

View file

@ -62,6 +62,7 @@ import common.packet.SPacketTimeUpdate;
import common.packet.SPacketTrades;
import common.packet.SPacketUpdateDisplay;
import common.packet.SPacketUpdateHealth;
import common.packet.SPacketUpdatePipe;
import common.sound.Sound;
public interface IClientPlayer extends NetHandler {
@ -139,4 +140,5 @@ public interface IClientPlayer extends NetHandler {
void handleServerConfig(SPacketServerConfig packet);
void handleCelestials(SPacketCelestials packet);
void handleDimensions(SPacketDimensions packet);
void handleUpdatePipe(SPacketUpdatePipe packet);
}

View file

@ -99,6 +99,7 @@ import common.packet.SPacketTimeUpdate;
import common.packet.SPacketTrades;
import common.packet.SPacketUpdateDisplay;
import common.packet.SPacketUpdateHealth;
import common.packet.SPacketUpdatePipe;
public enum PacketRegistry {
HANDSHAKE {{
@ -184,6 +185,7 @@ public enum PacketRegistry {
this.server(SPacketServerConfig.class);
this.server(SPacketCelestials.class);
this.server(SPacketDimensions.class);
this.server(SPacketUpdatePipe.class);
this.client(CPacketKeepAlive.class);
this.client(CPacketMessage.class);

View file

@ -0,0 +1,45 @@
package common.packet;
import java.io.IOException;
import common.item.ItemStack;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.tileentity.TileEntityItemPipe;
import common.util.BlockPos;
public class SPacketUpdatePipe implements Packet<IClientPlayer> {
private BlockPos position;
private ItemStack item;
public SPacketUpdatePipe() {
}
public SPacketUpdatePipe(TileEntityItemPipe tile) {
this.position = tile.getPos();
this.item = tile.getDisplayedItem();
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.position = buf.readBlockPos();
this.item = buf.readItemStack();
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeBlockPos(this.position);
buf.writeItemStack(this.item);
}
public void processPacket(IClientPlayer handler) {
handler.handleUpdatePipe(this);
}
public BlockPos getPos() {
return this.position;
}
public ItemStack getItem() {
return this.item;
}
}

View file

@ -9,22 +9,42 @@ import common.block.tech.BlockChest;
import common.block.tech.BlockPipe;
import common.entity.Entity;
import common.entity.item.EntityItem;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.inventory.IInventory;
import common.inventory.ISidedInventory;
import common.item.ItemStack;
import common.network.Packet;
import common.packet.SPacketUpdatePipe;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.util.Serverside;
import common.vars.Vars;
import common.world.State;
public class TileEntityPipe extends TileEntity implements IInventory, ITickable {
public class TileEntityItemPipe extends TileEntity implements IInventory, ITickable {
private final boolean suck;
private ItemStack stack = null;
@Serverside
private ItemStack last = null;
private ItemStack display = null;
private ItemStack prevDisplay = null;
private int cooldown = -1;
public TileEntityItemPipe(boolean suck) {
this.suck = suck;
}
public ItemStack getDisplayedItem() {
return this.display == null ? this.prevDisplay : this.display;
}
public void setDisplayedItem(ItemStack item) {
this.display = item;
}
public void readTags(TagObject tag) {
super.readTags(tag);
this.cooldown = tag.getInt("Cooldown");
@ -90,25 +110,25 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
this.stack = null;
}
public boolean isUseableByPlayer(EntityNPC player) {
return this.world.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}
public void update() {
if(this.world != null && !this.world.client) {
--this.cooldown;
this.prevDisplay = this.display;
this.display = ItemStack.copy(this.stack);
--this.cooldown;
if(!this.isOnTransferCooldown()) {
this.setTransferCooldown(0);
this.updatePipe();
this.transferItems();
}
if(!ItemStack.allEquals(this.last, this.getDisplayedItem()))
this.world.markBlockForUpdate(this.pos);
this.last = this.getDisplayedItem();
}
}
protected boolean updatePipe() {
if(!this.isOnTransferCooldown()) {
State state = this.getState();
if(!(state.getBlock() instanceof BlockPipe) /* || !this.decrPower() */) // TODO: power
protected boolean transferItems() {
if(!(this.getState().getBlock() instanceof BlockPipe) /* || !this.decrPower() */) // TODO: power
return false;
boolean flag = false;
@ -117,17 +137,15 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
}
if(!this.isFull()) {
flag |= this.transferIn(false);
flag |= this.transferIn();
}
if(flag) {
this.setTransferCooldown(Vars.pipeDelay);
this.markDirty();
return true;
}
}
return false;
return flag;
}
private boolean isEmpty() {
@ -145,15 +163,19 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
public boolean isOnTransferCooldown() {
return this.cooldown > 0;
}
public boolean mayTransfer() {
return this.cooldown <= 1;
}
//
// public boolean mayTransfer() {
// return this.cooldown <= 1;
// }
public int getColor() {
return 0x0040ff;
}
public Packet getDescriptionPacket() {
return new SPacketUpdatePipe(this);
}
// out
private static boolean isInventoryFull(IInventory inv, Facing side) {
@ -185,7 +207,7 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
protected boolean transferOut() {
State state = this.getState();
IInventory iinventory = this.getInventory(this.pos.offset(state.getValue(BlockPipe.FACING)), false);
IInventory iinventory = this.getInventory(this.pos.offset(state.getValue(BlockPipe.FACING)), true, false);
if(iinventory == null)
return false;
Facing dir = state.getValue(BlockPipe.FACING).getOpposite();
@ -285,11 +307,11 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
});
}
protected boolean transferIn(boolean suck) {
protected boolean transferIn() {
State state = this.getState();
Facing facing = state.getValue(BlockPipe.FACING);
for(Facing dir : Facing.values()) {
IInventory inv = dir == facing ? null : this.getInventory(this.pos.offset(dir), suck && dir == facing.getOpposite());
IInventory inv = (this.suck ? dir == facing.getOpposite() : dir != facing) ? this.getInventory(this.pos.offset(dir), false, this.suck) : null;
if(inv != null) {
Facing opposite = dir.getOpposite();
@ -316,7 +338,7 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
}
}
}
else if(suck && dir == facing.getOpposite()) {
else if(this.suck && dir == facing.getOpposite()) {
for(EntityItem entity : this.findDroppedItems(this.pos.offset(dir))) {
if(putDropInInventoryAllSlots(this, entity)) {
return true;
@ -358,15 +380,15 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
}
if(flag) {
if(inventoryIn instanceof TileEntityPipe) {
TileEntityPipe pipe = (TileEntityPipe)inventoryIn;
if(pipe.mayTransfer()) {
pipe.setTransferCooldown(Vars.pipeDelay);
}
inventoryIn.markDirty();
}
// if(inventoryIn instanceof TileEntityItemPipe) {
// TileEntityItemPipe pipe = (TileEntityItemPipe)inventoryIn;
//
// if(pipe.mayTransfer()) {
// pipe.setTransferCooldown(Vars.pipeDelay);
// }
//
// inventoryIn.markDirty();
// }
inventoryIn.markDirty();
}
@ -409,13 +431,13 @@ public class TileEntityPipe extends TileEntity implements IInventory, ITickable
return list.size() > 0 ? (IInventory)list.get(this.world.rand.zrange(list.size())) : null;
}
private IInventory getInventory(BlockPos blockpos, boolean suck) {
private IInventory getInventory(BlockPos blockpos, boolean pipe, boolean suck) {
IInventory inv = null;
Block block = this.world.getState(blockpos).getBlock();
if(block instanceof ITileEntityProvider) {
TileEntity te = this.world.getTileEntity(blockpos);
if(te instanceof IInventory) {
if(te instanceof IInventory && (pipe || !(te instanceof TileEntityItemPipe))) {
inv = (IInventory)te;
if(inv instanceof TileEntityChest && block instanceof BlockChest) {