Added Cover Collision
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
package com.refinedmods.refinedstorage.block;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.node.ICoverable;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.Cover;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverType;
|
||||
import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.CableTile;
|
||||
import com.refinedmods.refinedstorage.tile.NetworkNodeTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -69,7 +75,7 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext ctx) {
|
||||
return ShapeCache.getOrCreate(state, CableBlock::getCableShape);
|
||||
return ConstantsCable.addCoverVoxelShapes(ShapeCache.getOrCreate(state, CableBlock::getCableShape), world, pos);
|
||||
}
|
||||
|
||||
protected static VoxelShape getCableShape(BlockState state) {
|
||||
|
@@ -3,6 +3,7 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.container.ConstructorContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.ConstructorTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
@@ -56,7 +57,7 @@ public class ConstructorBlock extends CableBlock {
|
||||
|
||||
shape = VoxelShapes.or(shape, getHeadShape(s));
|
||||
|
||||
return shape;
|
||||
return ConstantsCable.addCoverVoxelShapes(shape, world, pos);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.container.DestructorContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.DestructorTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
@@ -56,7 +57,7 @@ public class DestructorBlock extends CableBlock {
|
||||
|
||||
shape = VoxelShapes.or(shape, getHeadShape(s));
|
||||
|
||||
return shape;
|
||||
return ConstantsCable.addCoverVoxelShapes(shape, world, pos);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.container.ExporterContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.ExporterTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
@@ -73,7 +74,7 @@ public class ExporterBlock extends CableBlock {
|
||||
|
||||
shape = VoxelShapes.or(shape, getLineShape(s));
|
||||
|
||||
return shape;
|
||||
return ConstantsCable.addCoverVoxelShapes(shape, world, pos);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ import com.refinedmods.refinedstorage.apiimpl.network.node.ExternalStorageNetwor
|
||||
import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.container.ExternalStorageContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.ExternalStorageTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
@@ -54,7 +55,7 @@ public class ExternalStorageBlock extends CableBlock {
|
||||
|
||||
shape = VoxelShapes.or(shape, getHeadShape(s));
|
||||
|
||||
return shape;
|
||||
return ConstantsCable.addCoverVoxelShapes(shape, world, pos);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.container.ImporterContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.ImporterTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
@@ -73,7 +74,7 @@ public class ImporterBlock extends CableBlock {
|
||||
|
||||
shape = VoxelShapes.or(shape, getLineShape(s));
|
||||
|
||||
return shape;
|
||||
return ConstantsCable.addCoverVoxelShapes(shape, world, pos);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,20 @@
|
||||
package com.refinedmods.refinedstorage.render;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.node.ICoverable;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.Cover;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverType;
|
||||
import com.refinedmods.refinedstorage.render.collision.CollisionGroup;
|
||||
import com.refinedmods.refinedstorage.tile.NetworkNodeTile;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -63,5 +74,24 @@ public class ConstantsCable {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static VoxelShape addCoverVoxelShapes(VoxelShape shape, IBlockReader world, BlockPos pos){
|
||||
if (world != null){
|
||||
TileEntity entity = world.getTileEntity(pos);
|
||||
if (entity instanceof NetworkNodeTile && ((NetworkNodeTile<?>) entity).getNode() instanceof ICoverable){
|
||||
CoverManager coverManager = ((ICoverable) ((NetworkNodeTile<?>) entity).getNode()).getCoverManager();
|
||||
for (Direction value : Direction.values()) {
|
||||
Cover cover = coverManager.getCover(value);
|
||||
if (cover != null){
|
||||
shape = VoxelShapes.or(shape, VoxelShapes.create(ConstantsCable.getCoverBounds(value)));
|
||||
if (cover.getType() == CoverType.NORMAL){
|
||||
shape = VoxelShapes.or(shape, VoxelShapes.create(ConstantsCable.getHolderBounds(value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user