Some placeholder blocks.
@@ -2,4 +2,6 @@ package li.cil.oc2;
|
||||
|
||||
public final class Constants {
|
||||
public static final String COMPUTER_BLOCK_NAME = "computer";
|
||||
public static final String REDSTONE_INTERFACE_BLOCK_NAME = "redstone_interface";
|
||||
public static final String SCREEN_BLOCK_NAME = "screen";
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.client.ClientSetup;
|
||||
import li.cil.oc2.common.CommonSetup;
|
||||
import li.cil.oc2.common.block.ComputerBlock;
|
||||
import li.cil.oc2.common.block.RedstoneInterfaceBlock;
|
||||
import li.cil.oc2.common.block.ScreenBlock;
|
||||
import li.cil.oc2.common.container.ComputerContainer;
|
||||
import li.cil.oc2.common.item.RISCVTesterItem;
|
||||
import li.cil.oc2.common.tile.ComputerTileEntity;
|
||||
@@ -34,10 +36,14 @@ public final class OpenComputers {
|
||||
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, API.MOD_ID);
|
||||
public static final RegistryObject<Block> COMPUTER_BLOCK = BLOCKS.register(Constants.COMPUTER_BLOCK_NAME, ComputerBlock::new);
|
||||
public static final RegistryObject<Block> REDSTONE_INTERFACE_BLOCK = BLOCKS.register(Constants.REDSTONE_INTERFACE_BLOCK_NAME, RedstoneInterfaceBlock::new);
|
||||
public static final RegistryObject<Block> SCREEN_BLOCK = BLOCKS.register(Constants.SCREEN_BLOCK_NAME, ScreenBlock::new);
|
||||
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, API.MOD_ID);
|
||||
public static final RegistryObject<Item> RISCV_TESTER = ITEMS.register("riscv_tester", RISCVTesterItem::new);
|
||||
public static final RegistryObject<Item> COMPUTER_ITEM = ITEMS.register(Constants.COMPUTER_BLOCK_NAME, () -> new BlockItem(COMPUTER_BLOCK.get(), new Item.Properties().group(ITEM_GROUP)));
|
||||
public static final RegistryObject<Item> REDSTONE_INTERFACE_ITEM = ITEMS.register(Constants.REDSTONE_INTERFACE_BLOCK_NAME, () -> new BlockItem(REDSTONE_INTERFACE_BLOCK.get(), new Item.Properties().group(ITEM_GROUP)));
|
||||
public static final RegistryObject<Item> SCREEN_ITEM = ITEMS.register(Constants.SCREEN_BLOCK_NAME, () -> new BlockItem(SCREEN_BLOCK.get(), new Item.Properties().group(ITEM_GROUP)));
|
||||
|
||||
public static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, API.MOD_ID);
|
||||
public static final RegistryObject<TileEntityType<ComputerTileEntity>> COMPUTER_TILE_ENTITY = TILES.register(Constants.COMPUTER_BLOCK_NAME, () -> TileEntityType.Builder.create(ComputerTileEntity::new, COMPUTER_BLOCK.get()).build(null));
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class ComputerTileEntityRenderer extends TileEntityRenderer<Compute
|
||||
|
||||
@Override
|
||||
public void render(final ComputerTileEntity tileEntity, final float partialTicks, final MatrixStack stack, final IRenderTypeBuffer buffer, final int combinedLightIn, final int combinedOverlayIn) {
|
||||
final Direction blockFacing = tileEntity.getBlockState().get(ComputerBlock.FACING);
|
||||
final Direction blockFacing = tileEntity.getBlockState().get(ComputerBlock.HORIZONTAL_FACING);
|
||||
final Vec3d cameraPosition = renderDispatcher.renderInfo.getRenderViewEntity().getEyePosition(partialTicks);
|
||||
|
||||
// If viewer is not in front of the block we can skip all of the rest, it cannot be visible.
|
||||
|
||||
@@ -16,48 +16,35 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ComputerBlock extends Block {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public final class ComputerBlock extends HorizontalBlock {
|
||||
public ComputerBlock() {
|
||||
super(Properties.create(Material.IRON).sound(SoundType.METAL));
|
||||
setDefaultState(getStateContainer().getBaseState().with(FACING, Direction.NORTH));
|
||||
setDefaultState(getStateContainer().getBaseState().with(HORIZONTAL_FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(final StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(FACING);
|
||||
builder.add(HORIZONTAL_FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(final BlockItemUseContext context) {
|
||||
return super.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(final BlockState state, final IWorld world, final BlockPos pos, final Rotation direction) {
|
||||
return state.with(FACING, direction.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public BlockState mirror(final BlockState state, final Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
||||
return super.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package li.cil.oc2.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public final class RedstoneInterfaceBlock extends HorizontalBlock {
|
||||
public RedstoneInterfaceBlock() {
|
||||
super(Properties.create(Material.IRON).sound(SoundType.METAL));
|
||||
setDefaultState(getStateContainer().getBaseState().with(HORIZONTAL_FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(final StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(HORIZONTAL_FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(final BlockItemUseContext context) {
|
||||
return super.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
}
|
||||
28
src/main/java/li/cil/oc2/common/block/ScreenBlock.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package li.cil.oc2.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public final class ScreenBlock extends HorizontalBlock {
|
||||
public ScreenBlock() {
|
||||
super(Properties.create(Material.IRON).sound(SoundType.METAL));
|
||||
setDefaultState(getStateContainer().getBaseState().with(HORIZONTAL_FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(final StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(HORIZONTAL_FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(final BlockItemUseContext context) {
|
||||
return super.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,12 @@ package li.cil.oc2.data;
|
||||
|
||||
import li.cil.oc2.OpenComputers;
|
||||
import li.cil.oc2.api.API;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ExistingFileHelper;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
public class BlockStates extends BlockStateProvider {
|
||||
public BlockStates(final DataGenerator generator, final ExistingFileHelper existingFileHelper) {
|
||||
@@ -13,9 +16,13 @@ public class BlockStates extends BlockStateProvider {
|
||||
|
||||
@Override
|
||||
protected void registerStatesAndModels() {
|
||||
horizontalBlock(OpenComputers.COMPUTER_BLOCK.get(), models().getBuilder(OpenComputers.COMPUTER_BLOCK.getId().getPath()));
|
||||
horizontalBlock(OpenComputers.COMPUTER_BLOCK, OpenComputers.COMPUTER_ITEM);
|
||||
horizontalBlock(OpenComputers.REDSTONE_INTERFACE_BLOCK, OpenComputers.REDSTONE_INTERFACE_ITEM);
|
||||
horizontalBlock(OpenComputers.SCREEN_BLOCK, OpenComputers.SCREEN_ITEM);
|
||||
}
|
||||
|
||||
itemModels().getBuilder(OpenComputers.COMPUTER_ITEM.getId().getPath())
|
||||
.parent(models().getExistingFile(OpenComputers.COMPUTER_BLOCK.getId()));
|
||||
private void horizontalBlock(final RegistryObject<Block> block, final RegistryObject<Item> item) {
|
||||
horizontalBlock(block.get(), models().getBuilder(block.getId().getPath()));
|
||||
itemModels().getBuilder(item.getId().getPath()).parent(models().getExistingFile(block.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"variants": {
|
||||
"facing=north": {
|
||||
"model": "oc2:block/redstone_interface"
|
||||
},
|
||||
"facing=south": {
|
||||
"model": "oc2:block/redstone_interface",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west": {
|
||||
"model": "oc2:block/redstone_interface",
|
||||
"y": 270
|
||||
},
|
||||
"facing=east": {
|
||||
"model": "oc2:block/redstone_interface",
|
||||
"y": 90
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/main/resources/assets/oc2/blockstates/screen.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"variants": {
|
||||
"facing=north": {
|
||||
"model": "oc2:block/screen"
|
||||
},
|
||||
"facing=south": {
|
||||
"model": "oc2:block/screen",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west": {
|
||||
"model": "oc2:block/screen",
|
||||
"y": 270
|
||||
},
|
||||
"facing=east": {
|
||||
"model": "oc2:block/screen",
|
||||
"y": 90
|
||||
}
|
||||
}
|
||||
}
|
||||
1
src/main/resources/assets/oc2/models/block/screen.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "oc2:block/redstone_interface"
|
||||
}
|
||||
3
src/main/resources/assets/oc2/models/item/screen.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "oc2:block/screen"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 384 B |
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 288 B After Width: | Height: | Size: 386 B |
|
Before Width: | Height: | Size: 281 B After Width: | Height: | Size: 352 B |
|
Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 441 B |
|
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 335 B |
|
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 392 B |
|
After Width: | Height: | Size: 302 B |
|
After Width: | Height: | Size: 223 B |
|
After Width: | Height: | Size: 323 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 415 B |
|
After Width: | Height: | Size: 436 B |
|
After Width: | Height: | Size: 343 B |
|
After Width: | Height: | Size: 425 B |
|
After Width: | Height: | Size: 379 B |
|
After Width: | Height: | Size: 256 B |
|
After Width: | Height: | Size: 323 B |
|
After Width: | Height: | Size: 411 B |
|
After Width: | Height: | Size: 354 B |
|
After Width: | Height: | Size: 420 B |
|
After Width: | Height: | Size: 340 B |
|
After Width: | Height: | Size: 423 B |