Implement the cable. TODO network node.

This commit is contained in:
raoulvdberge
2019-09-19 18:04:25 +02:00
parent 2b82d4cbbb
commit c394be1e1b
19 changed files with 446 additions and 311 deletions

View File

@@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType; import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFluid;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem;
import com.raoulvdberge.refinedstorage.block.CableBlock;
import com.raoulvdberge.refinedstorage.block.ControllerBlock; import com.raoulvdberge.refinedstorage.block.ControllerBlock;
import com.raoulvdberge.refinedstorage.block.MachineCasingBlock; import com.raoulvdberge.refinedstorage.block.MachineCasingBlock;
import com.raoulvdberge.refinedstorage.block.QuartzEnrichedIronBlock; import com.raoulvdberge.refinedstorage.block.QuartzEnrichedIronBlock;
@@ -81,6 +82,7 @@ public final class RS {
e.getRegistry().register(new ControllerBlock(ControllerBlock.Type.NORMAL)); e.getRegistry().register(new ControllerBlock(ControllerBlock.Type.NORMAL));
e.getRegistry().register(new ControllerBlock(ControllerBlock.Type.CREATIVE)); e.getRegistry().register(new ControllerBlock(ControllerBlock.Type.CREATIVE));
e.getRegistry().register(new MachineCasingBlock()); e.getRegistry().register(new MachineCasingBlock());
e.getRegistry().register(new CableBlock());
} }
@SubscribeEvent @SubscribeEvent
@@ -155,6 +157,7 @@ public final class RS {
e.getRegistry().register(new ControllerBlockItem(RSBlocks.CONTROLLER)); e.getRegistry().register(new ControllerBlockItem(RSBlocks.CONTROLLER));
e.getRegistry().register(new ControllerBlockItem(RSBlocks.CREATIVE_CONTROLLER)); e.getRegistry().register(new ControllerBlockItem(RSBlocks.CREATIVE_CONTROLLER));
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.MACHINE_CASING)); e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.MACHINE_CASING));
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.CABLE));
} }
/* TODO /* TODO

View File

@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.block.*;
import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.registries.ObjectHolder;
public final class RSBlocks { public final class RSBlocks {
public static final BlockCable CABLE = new BlockCable();
public static final BlockGrid GRID = new BlockGrid(); public static final BlockGrid GRID = new BlockGrid();
public static final BlockDiskDrive DISK_DRIVE = new BlockDiskDrive(); public static final BlockDiskDrive DISK_DRIVE = new BlockDiskDrive();
public static final BlockExternalStorage EXTERNAL_STORAGE = new BlockExternalStorage(); public static final BlockExternalStorage EXTERNAL_STORAGE = new BlockExternalStorage();
@@ -39,6 +38,9 @@ public final class RSBlocks {
@ObjectHolder(RS.ID + ":creative_controller") @ObjectHolder(RS.ID + ":creative_controller")
public static final ControllerBlock CREATIVE_CONTROLLER = null; public static final ControllerBlock CREATIVE_CONTROLLER = null;
@ObjectHolder(RS.ID + ":cable")
public static final CableBlock CABLE = null;
public static final BlockStorageMonitor STORAGE_MONITOR = new BlockStorageMonitor(); public static final BlockStorageMonitor STORAGE_MONITOR = new BlockStorageMonitor();
public static final BlockPortableGrid PORTABLE_GRID = new BlockPortableGrid(); public static final BlockPortableGrid PORTABLE_GRID = new BlockPortableGrid();
public static final BlockCrafterManager CRAFTER_MANAGER = new BlockCrafterManager(); public static final BlockCrafterManager CRAFTER_MANAGER = new BlockCrafterManager();

View File

@@ -1,16 +1,11 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.block.info.BlockDirection; public class BlockConstructor extends CableBlock {
import com.raoulvdberge.refinedstorage.tile.TileConstructor; /* TODO
import javax.annotation.Nullable;
public class BlockConstructor extends BlockCable {
public BlockConstructor() { public BlockConstructor() {
super(createBuilder("constructor").tileEntity(TileConstructor::new).create()); super(createBuilder("constructor").tileEntity(TileConstructor::new).create());
} }
/* TODO
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {
@@ -18,14 +13,13 @@ public class BlockConstructor extends BlockCable {
registerCoverAndFullbright(modelRegistration, RS.ID + ":blocks/constructor/cutouts/connected"); registerCoverAndFullbright(modelRegistration, RS.ID + ":blocks/constructor/cutouts/connected");
} }
*/
@Override @Override
@Nullable @Nullable
public BlockDirection getDirection() { public BlockDirection getDirection() {
return BlockDirection.ANY; return BlockDirection.ANY;
} }
/* TODO
@Override @Override
public List<CollisionGroup> getCollisions(TileEntity tile, BlockState state) { public List<CollisionGroup> getCollisions(TileEntity tile, BlockState state) {
List<CollisionGroup> groups = super.getCollisions(tile, state); List<CollisionGroup> groups = super.getCollisions(tile, state);
@@ -68,9 +62,10 @@ public class BlockConstructor extends BlockCable {
return openNetworkGui(RSGui.CONSTRUCTOR, player, world, pos, side); return openNetworkGui(RSGui.CONSTRUCTOR, player, world, pos, side);
} }
*/
@Override @Override
public boolean hasConnectedState() { public boolean hasConnectedState() {
return true; return true;
} }
*/
} }

View File

@@ -1,13 +1,11 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.tile.TileDestructor; public class BlockDestructor extends CableBlock {
/* TODO
public class BlockDestructor extends BlockCable {
public BlockDestructor() { public BlockDestructor() {
super(createBuilder("destructor").tileEntity(TileDestructor::new).create()); super(createBuilder("destructor").tileEntity(TileDestructor::new).create());
} }
/* TODO
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {
@@ -34,10 +32,10 @@ public class BlockDestructor extends BlockCable {
} }
return openNetworkGui(RSGui.DESTRUCTOR, player, world, pos, side); return openNetworkGui(RSGui.DESTRUCTOR, player, world, pos, side);
}*/ }
@Override @Override
public boolean hasConnectedState() { public boolean hasConnectedState() {
return true; return true;
} }*/
} }

View File

@@ -1,13 +1,11 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.tile.TileExporter; public class BlockExporter extends CableBlock {
/* TODO
public class BlockExporter extends BlockCable {
public BlockExporter() { public BlockExporter() {
super(createBuilder("exporter").tileEntity(TileExporter::new).create()); super(createBuilder("exporter").tileEntity(TileExporter::new).create());
} }
/* TODO
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {

View File

@@ -1,13 +1,11 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.tile.TileExternalStorage; public class BlockExternalStorage extends CableBlock {
/* TODO
public class BlockExternalStorage extends BlockCable {
public BlockExternalStorage() { public BlockExternalStorage() {
super(createBuilder("external_storage").tileEntity(TileExternalStorage::new).create()); super(createBuilder("external_storage").tileEntity(TileExternalStorage::new).create());
} }
/* TODO
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {

View File

@@ -1,13 +1,11 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.tile.TileImporter; public class BlockImporter extends CableBlock {
/* TODO
public class BlockImporter extends BlockCable {
public BlockImporter() { public BlockImporter() {
super(createBuilder("importer").tileEntity(TileImporter::new).create()); super(createBuilder("importer").tileEntity(TileImporter::new).create());
} }
/* TODO
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {

View File

@@ -1,13 +1,11 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.tile.TileReader; public class BlockReader extends CableBlock {
/* TODO
public class BlockReader extends BlockCable {
public BlockReader() { public BlockReader() {
super(createBuilder("reader").tileEntity(TileReader::new).create()); super(createBuilder("reader").tileEntity(TileReader::new).create());
} }
/* TODO
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {
@@ -57,10 +55,10 @@ public class BlockReader extends BlockCable {
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
return tile instanceof TileReader && side == ((TileReader) tile).getDirection().getOpposite(); return tile instanceof TileReader && side == ((TileReader) tile).getDirection().getOpposite();
}*/ }
@Override @Override
public boolean hasConnectedState() { public boolean hasConnectedState() {
return true; return true;
} }*/
} }

View File

@@ -1,13 +1,11 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.tile.TileWriter; public class BlockWriter extends CableBlock {
/* TODO
public class BlockWriter extends BlockCable {
public BlockWriter() { public BlockWriter() {
super(createBuilder("writer").tileEntity(TileWriter::new).create()); super(createBuilder("writer").tileEntity(TileWriter::new).create());
} }
/* TODO
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void registerModels(IModelRegistration modelRegistration) { public void registerModels(IModelRegistration modelRegistration) {
@@ -77,10 +75,10 @@ public class BlockWriter extends BlockCable {
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
return tile instanceof TileWriter && side == ((TileWriter) tile).getDirection().getOpposite(); return tile instanceof TileWriter && side == ((TileWriter) tile).getDirection().getOpposite();
}*/ }
@Override @Override
public boolean hasConnectedState() { public boolean hasConnectedState() {
return true; return true;
} }*/
} }

View File

@@ -1,37 +1,24 @@
package com.raoulvdberge.refinedstorage.block; package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverType;
import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder;
import com.raoulvdberge.refinedstorage.block.info.IBlockInfo;
import com.raoulvdberge.refinedstorage.render.IModelRegistration;
import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup;
import com.raoulvdberge.refinedstorage.render.constants.ConstantsCable;
import com.raoulvdberge.refinedstorage.tile.TileCable;
import com.raoulvdberge.refinedstorage.tile.TileNode;
import com.raoulvdberge.refinedstorage.util.CollisionUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.ArrayList; import javax.annotation.Nullable;
import java.util.List;
public class BlockCable extends BlockNode { public class CableBlock extends Block {
/* TODO /* TODO
public static final PropertyObject<Cover> COVER_NORTH = new PropertyObject<>("cover_north", Cover.class); public static final PropertyObject<Cover> COVER_NORTH = new PropertyObject<>("cover_north", Cover.class);
public static final PropertyObject<Cover> COVER_EAST = new PropertyObject<>("cover_east", Cover.class); public static final PropertyObject<Cover> COVER_EAST = new PropertyObject<>("cover_east", Cover.class);
@@ -47,26 +34,93 @@ public class BlockCable extends BlockNode {
private static final BooleanProperty UP = BooleanProperty.create("up"); private static final BooleanProperty UP = BooleanProperty.create("up");
private static final BooleanProperty DOWN = BooleanProperty.create("down"); private static final BooleanProperty DOWN = BooleanProperty.create("down");
public BlockCable(IBlockInfo info) { private static final VoxelShape SHAPE_CORE = makeCuboidShape(6, 6, 6, 10, 10, 10);
super(info); private static final VoxelShape SHAPE_NORTH = makeCuboidShape(6, 6, 0, 10, 10, 6);
private static final VoxelShape SHAPE_EAST = makeCuboidShape(10, 6, 6, 16, 10, 10);
private static final VoxelShape SHAPE_SOUTH = makeCuboidShape(6, 6, 10, 10, 10, 16);
private static final VoxelShape SHAPE_WEST = makeCuboidShape(0, 6, 6, 6, 10, 10);
private static final VoxelShape SHAPE_UP = makeCuboidShape(6, 10, 6, 10, 16, 10);
private static final VoxelShape SHAPE_DOWN = makeCuboidShape(6, 0, 6, 10, 6, 10);
public CableBlock() {
super(Block.Properties.create(Material.GLASS).sound(SoundType.GLASS).hardnessAndResistance(0.35F));
this.setRegistryName(RS.ID, "cable");
this.setDefaultState(getDefaultState().with(NORTH, false).with(EAST, false).with(SOUTH, false).with(WEST, false).with(UP, false).with(DOWN, false));
} }
public BlockCable() { @Override
super(createBuilder("cable").tileEntity(TileCable::new).create()); @SuppressWarnings("deprecation")
public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
super.neighborChanged(state, world, pos, block, fromPos, isMoving);
world.setBlockState(pos, getState(world, pos));
} }
static BlockInfoBuilder createBuilder(String id) { @Override
return BlockInfoBuilder.forId(id).material(Material.GLASS).soundType(SoundType.GLASS).hardness(0.35F); @SuppressWarnings("deprecation")
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext ctx) {
VoxelShape shape = SHAPE_CORE;
if (state.get(NORTH)) {
shape = VoxelShapes.or(shape, SHAPE_NORTH);
}
if (state.get(EAST)) {
shape = VoxelShapes.or(shape, SHAPE_EAST);
}
if (state.get(SOUTH)) {
shape = VoxelShapes.or(shape, SHAPE_SOUTH);
}
if (state.get(WEST)) {
shape = VoxelShapes.or(shape, SHAPE_WEST);
}
if (state.get(UP)) {
shape = VoxelShapes.or(shape, SHAPE_UP);
}
if (state.get(DOWN)) {
shape = VoxelShapes.or(shape, SHAPE_DOWN);
}
return shape;
} }
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return getState(ctx.getWorld(), ctx.getPos());
}
private BlockState getState(World world, BlockPos pos) {
Block north = world.getBlockState(pos.north()).getBlock();
Block east = world.getBlockState(pos.east()).getBlock();
Block south = world.getBlockState(pos.south()).getBlock();
Block west = world.getBlockState(pos.west()).getBlock();
Block up = world.getBlockState(pos.up()).getBlock();
Block down = world.getBlockState(pos.down()).getBlock();
return getDefaultState()
.with(NORTH, north instanceof CableBlock)
.with(EAST, east instanceof CableBlock)
.with(SOUTH, south instanceof CableBlock)
.with(WEST, west instanceof CableBlock)
.with(UP, up instanceof CableBlock)
.with(DOWN, down instanceof CableBlock);
}
/* TODO
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
void registerCover(IModelRegistration modelRegistration) { void registerCover(IModelRegistration modelRegistration) {
// TODO modelRegistration.addBakedModelOverride(info.getId(), BakedModelCableCover::new); modelRegistration.addBakedModelOverride(info.getId(), BakedModelCableCover::new);
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
void registerCoverAndFullbright(IModelRegistration modelRegistration, ResourceLocation... textures) { void registerCoverAndFullbright(IModelRegistration modelRegistration, ResourceLocation... textures) {
// TODO modelRegistration.addBakedModelOverride(info.getId(), base -> new BakedModelCableCover(new BakedModelFullbright(base, textures))); modelRegistration.addBakedModelOverride(info.getId(), base -> new BakedModelCableCover(new BakedModelFullbright(base, textures)));
} }
@Override @Override
@@ -75,12 +129,7 @@ public class BlockCable extends BlockNode {
modelRegistration.setModel(this, 0, new ModelResourceLocation(info.getId(), "down=false,east=true,north=false,south=false,up=false,west=true")); modelRegistration.setModel(this, 0, new ModelResourceLocation(info.getId(), "down=false,east=true,north=false,south=false,up=false,west=true"));
registerCover(modelRegistration); registerCover(modelRegistration);
} }*/
@Override
public boolean hasConnectedState() {
return false;
}
@Override @Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
@@ -90,22 +139,6 @@ public class BlockCable extends BlockNode {
} }
/* TODO /* TODO
@Override
@SuppressWarnings("deprecation")
public BlockState getActualState(BlockState state, IBlockAccess world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
state = super.getActualState(state, world, pos)
.withProperty(NORTH, hasConnectionWith(world, pos, this, tile, Direction.NORTH))
.withProperty(EAST, hasConnectionWith(world, pos, this, tile, Direction.EAST))
.withProperty(SOUTH, hasConnectionWith(world, pos, this, tile, Direction.SOUTH))
.withProperty(WEST, hasConnectionWith(world, pos, this, tile, Direction.WEST))
.withProperty(UP, hasConnectionWith(world, pos, this, tile, Direction.UP))
.withProperty(DOWN, hasConnectionWith(world, pos, this, tile, Direction.DOWN));
return state;
}
@Override @Override
public BlockState getExtendedState(BlockState state, IBlockAccess world, BlockPos pos) { public BlockState getExtendedState(BlockState state, IBlockAccess world, BlockPos pos) {
BlockState s = super.getExtendedState(state, world, pos); BlockState s = super.getExtendedState(state, world, pos);
@@ -124,6 +157,7 @@ public class BlockCable extends BlockNode {
return s; return s;
}*/ }*/
/* TODO
private static boolean hasConnectionWith(World world, BlockPos pos, BlockBase block, TileEntity tile, Direction direction) { private static boolean hasConnectionWith(World world, BlockPos pos, BlockBase block, TileEntity tile, Direction direction) {
if (!(tile instanceof TileNode)) { if (!(tile instanceof TileNode)) {
return false; return false;
@@ -149,7 +183,6 @@ public class BlockCable extends BlockNode {
} }
} }
/* TODO
if (otherTile != null && otherTile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite())) { if (otherTile != null && otherTile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite())) {
// Prevent the block adding connections in itself // Prevent the block adding connections in itself
// For example: importer cable connection on the importer face // For example: importer cable connection on the importer face
@@ -158,18 +191,19 @@ public class BlockCable extends BlockNode {
} }
return true; return true;
} */ }
return false; return false;
} }*/
/* TODO
@Override @Override
public List<CollisionGroup> getCollisions(TileEntity tile, BlockState state) { public List<CollisionGroup> getCollisions(TileEntity tile, BlockState state) {
List<CollisionGroup> groups = getCoverCollisions(tile); List<CollisionGroup> groups = getCoverCollisions(tile);
groups.add(ConstantsCable.CORE); groups.add(ConstantsCable.CORE);
/* TODO if (state.getValue(NORTH)) { if (state.getValue(NORTH)) {
groups.add(ConstantsCable.NORTH); groups.add(ConstantsCable.NORTH);
} }
@@ -191,11 +225,12 @@ public class BlockCable extends BlockNode {
if (state.getValue(DOWN)) { if (state.getValue(DOWN)) {
groups.add(ConstantsCable.DOWN); groups.add(ConstantsCable.DOWN);
} */ }
return groups; return groups;
} }*/
/* TODO
private List<CollisionGroup> getCoverCollisions(TileEntity tile) { private List<CollisionGroup> getCoverCollisions(TileEntity tile) {
List<CollisionGroup> groups = new ArrayList<>(); List<CollisionGroup> groups = new ArrayList<>();
@@ -277,41 +312,10 @@ public class BlockCable extends BlockNode {
} }
return groups; return groups;
} }*/
/* TODO
@Override
@SuppressWarnings("deprecation")
public boolean isOpaqueCube(BlockState state) {
return false;
}
@Override
@SuppressWarnings("deprecation")
public boolean isFullCube(BlockState state) {
return false;
}
@Override
@SuppressWarnings("deprecation")
public BlockState getStateForPlacement(World world, BlockPos pos, Direction facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase entity) {
BlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, entity);
if (getDirection() != null) {
return state.withProperty(getDirection().getProperty(), getDirection().getFrom(facing, pos, entity));
}
return state;
}
@Override @Override
public BlockRenderLayer getRenderLayer() { public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT; return BlockRenderLayer.CUTOUT;
} }
@Override
@SuppressWarnings("deprecation")
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
return BlockFaceShape.UNDEFINED;
}*/
} }

View File

@@ -1,107 +0,0 @@
package com.raoulvdberge.refinedstorage.render.collision;
import com.mojang.blaze3d.platform.GlStateManager;
import com.raoulvdberge.refinedstorage.block.BlockBase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockHighlightListener {
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onBlockDrawHighlight(DrawBlockHighlightEvent e) {
if (e.getTarget() == null || e.getInfo().getBlockPos() == null) { // TODO: Still need to check this?
return;
}
PlayerEntity player = (PlayerEntity) e.getInfo().getRenderViewEntity();
BlockPos pos = e.getInfo().getBlockPos();
Block b = player.getEntityWorld().getBlockState(pos).getBlock();
if (!(b instanceof BlockBase)) {
return;
}
BlockBase block = (BlockBase) b;
// TODO BlockState state = block.getActualState(block.getDefaultState(), player.getEntityWorld(), pos);
BlockState state = e.getInfo().getBlockAtCamera();
AdvancedRayTraceResult result = AdvancedRayTracer.rayTrace(
pos,
AdvancedRayTracer.getStart(player),
AdvancedRayTracer.getEnd(player),
block.getCollisions(player.getEntityWorld().getTileEntity(pos), state)
);
e.setCanceled(true);
if (result == null) {
return;
}
GlStateManager.enableBlend();
GlStateManager.blendFuncSeparate(770, 771, 1, 0);
GlStateManager.color4f(0.0F, 0.0F, 0.0F, 0.4F);
GlStateManager.lineWidth(3.0F);
GlStateManager.disableTexture();
GlStateManager.depthMask(false);
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) e.getPartialTicks();
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) e.getPartialTicks();
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) e.getPartialTicks();
for (AxisAlignedBB aabb : result.getGroup().getItems()) {
drawSelectionBoundingBox(aabb.expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2).offset(pos.getX(), pos.getY(), pos.getZ()));
}
GlStateManager.depthMask(true);
GlStateManager.enableTexture();
GlStateManager.disableBlend();
}
private void drawSelectionBoundingBox(AxisAlignedBB aabb) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(3, DefaultVertexFormats.POSITION);
buffer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
buffer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
tessellator.draw();
buffer.begin(3, DefaultVertexFormats.POSITION);
buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
tessellator.draw();
buffer.begin(1, DefaultVertexFormats.POSITION);
buffer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
tessellator.draw();
}
}

View File

@@ -8,14 +8,6 @@ import net.minecraft.util.math.AxisAlignedBB;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public final class ConstantsCable { public final class ConstantsCable {
public static final CollisionGroup CORE = new CollisionGroup().addItem(CollisionUtils.getBounds(6, 6, 6, 10, 10, 10));
public static final CollisionGroup NORTH = new CollisionGroup().addItem(CollisionUtils.getBounds(6, 6, 0, 10, 10, 6));
public static final CollisionGroup EAST = new CollisionGroup().addItem(CollisionUtils.getBounds(10, 6, 6, 16, 10, 10));
public static final CollisionGroup SOUTH = new CollisionGroup().addItem(CollisionUtils.getBounds(6, 6, 10, 10, 10, 16));
public static final CollisionGroup WEST = new CollisionGroup().addItem(CollisionUtils.getBounds(0, 6, 6, 6, 10, 10));
public static final CollisionGroup UP = new CollisionGroup().addItem(CollisionUtils.getBounds(6, 10, 6, 10, 16, 10));
public static final CollisionGroup DOWN = new CollisionGroup().addItem(CollisionUtils.getBounds(6, 0, 6, 10, 6, 10));
public static final CollisionGroup HOLDER_NORTH = new CollisionGroup().addItem(getHolderBounds(Direction.NORTH)); public static final CollisionGroup HOLDER_NORTH = new CollisionGroup().addItem(getHolderBounds(Direction.NORTH));
public static final CollisionGroup HOLDER_EAST = new CollisionGroup().addItem(getHolderBounds(Direction.EAST)); public static final CollisionGroup HOLDER_EAST = new CollisionGroup().addItem(getHolderBounds(Direction.EAST));
public static final CollisionGroup HOLDER_SOUTH = new CollisionGroup().addItem(getHolderBounds(Direction.SOUTH)); public static final CollisionGroup HOLDER_SOUTH = new CollisionGroup().addItem(getHolderBounds(Direction.SOUTH));

View File

@@ -1,61 +1,62 @@
{ {
"forge_marker": 1, "multipart": [
"defaults": { {
"textures": { "apply": {
"cable": "refinedstorage:blocks/cable", "model": "refinedstorage:block/cable_core"
"particle": "refinedstorage:blocks/cable"
},
"model": "refinedstorage:cable_core",
"uvlock": true,
"transform": "forge:default-block"
},
"variants": {
"north": {
"true": {
"submodel": "refinedstorage:cable_extension"
},
"false": {
} }
}, },
"east": { {
"true": { "when": {
"submodel": "refinedstorage:cable_extension", "north": true
},
"apply": {
"model": "refinedstorage:block/cable_extension"
}
},
{
"when": {
"east": true
},
"apply": {
"model": "refinedstorage:block/cable_extension",
"y": 90 "y": 90
},
"false": {
} }
}, },
"south": { {
"true": { "when": {
"submodel": "refinedstorage:cable_extension", "south": true
},
"apply": {
"model": "refinedstorage:block/cable_extension",
"x": 180 "x": 180
},
"false": {
} }
}, },
"west": { {
"true": { "when": {
"submodel": "refinedstorage:cable_extension", "west": true
},
"apply": {
"model": "refinedstorage:block/cable_extension",
"y": 270 "y": 270
},
"false": {
} }
}, },
"up": { {
"true": { "when": {
"submodel": "refinedstorage:cable_extension", "up": true
},
"apply": {
"model": "refinedstorage:block/cable_extension",
"x": 270 "x": 270
},
"false": {
} }
}, },
"down": { {
"true": { "when": {
"submodel": "refinedstorage:cable_extension", "down": true
"x": 90
}, },
"false": { "apply": {
"model": "refinedstorage:block/cable_extension",
"x": 90
} }
} }
} ]
} }

View File

@@ -178,7 +178,7 @@
"sidebutton.refinedstorage:access_type.2": "Extract only", "sidebutton.refinedstorage:access_type.2": "Extract only",
"block.refinedstorage.controller": "Controller", "block.refinedstorage.controller": "Controller",
"block.refinedstorage.creative_controller": "Creative Controller", "block.refinedstorage.creative_controller": "Creative Controller",
"block.refinedstorage:cable": "Cable", "block.refinedstorage.cable": "Cable",
"block.refinedstorage:grid.0": "Grid", "block.refinedstorage:grid.0": "Grid",
"block.refinedstorage:grid.1": "Crafting Grid", "block.refinedstorage:grid.1": "Crafting Grid",
"block.refinedstorage:grid.2": "Pattern Grid", "block.refinedstorage:grid.2": "Pattern Grid",

View File

@@ -1,5 +1,8 @@
{ {
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", "textures": {
"cable": "refinedstorage:block/cable",
"particle": "refinedstorage:block/cable"
},
"elements": [ "elements": [
{ {
"name": "Core", "name": "Core",

View File

@@ -1,5 +1,8 @@
{ {
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", "textures": {
"cable": "refinedstorage:block/cable",
"particle": "refinedstorage:block/cable"
},
"elements": [ "elements": [
{ {
"name": "North", "name": "North",

View File

@@ -0,0 +1,233 @@
{
"parent": "block/block",
"textures": {
"cable": "refinedstorage:block/cable"
},
"elements": [
{
"name": "Core",
"from": [
6,
6,
6
],
"to": [
10,
10,
10
],
"faces": {
"north": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"east": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"south": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"west": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"up": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"down": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
}
}
},
{
"name": "Part1",
"from": [
10,
6,
6
],
"to": [
16,
10,
10
],
"rotation": {
"angle": 0,
"axis": "y",
"origin": [
16,
8,
9
]
},
"faces": {
"north": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
},
"east": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"south": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
},
"west": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"up": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
},
"down": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
}
}
},
{
"name": "Part2",
"from": [
0,
6,
6
],
"to": [
6,
10,
10
],
"rotation": {
"angle": 0,
"axis": "y",
"origin": [
6,
8,
9
]
},
"faces": {
"north": {
"uv": [
10,
6,
16,
10
],
"texture": "#cable"
},
"east": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"south": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
},
"west": {
"uv": [
6,
6,
10,
10
],
"texture": "#cable"
},
"up": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
},
"down": {
"uv": [
0,
6,
6,
10
],
"texture": "#cable"
}
}
}
]
}

View File

@@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "refinedstorage:cable"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@@ -10,8 +10,7 @@
"item": "refinedstorage:quartz_enriched_iron" "item": "refinedstorage:quartz_enriched_iron"
}, },
"G": { "G": {
"type": "forge:ore_dict", "tag": "forge:glass"
"ore": "blockGlass"
}, },
"R": { "R": {
"item": "minecraft:redstone" "item": "minecraft:redstone"