Added locking to the compacting drawer
This commit is contained in:
parent
fa6437d392
commit
e4735a6ba2
|
@ -5,7 +5,7 @@ a43045b707ae0bac4f3a429efd73225b10e5e02e assets/functionalstorage/blockstates/ar
|
|||
e505e84f33a45dea1ef5dc4f6ab500965a32d1f3 assets/functionalstorage/blockstates/birch_1.json
|
||||
4803730c1801ac8c78703c4db182b2e116d02035 assets/functionalstorage/blockstates/birch_2.json
|
||||
415f30768aa5f298098192b8a887d8b01617566b assets/functionalstorage/blockstates/birch_4.json
|
||||
78ab16e1714fbed8ba98acfe243a89c15587feb0 assets/functionalstorage/blockstates/compacting_drawer.json
|
||||
62bfbb466ae1f92b81db8ad38259b0fb52a56dcd assets/functionalstorage/blockstates/compacting_drawer.json
|
||||
764fd595f14c2f186834a5c073dc40fd783de2d5 assets/functionalstorage/blockstates/crimson_1.json
|
||||
75ec6d10e1cf1e98fb5ec2e20727cac47829b0b4 assets/functionalstorage/blockstates/crimson_2.json
|
||||
51bf3810c4d32ef39cd2a8e8ad8bf677175cbdc8 assets/functionalstorage/blockstates/crimson_4.json
|
||||
|
@ -32,6 +32,7 @@ c7d0376ba2a080ba12c344369ad11538899db176 assets/functionalstorage/models/block/a
|
|||
9c7d840096d63552b9ed9238ca1512e9bf496695 assets/functionalstorage/models/block/birch_1_locked.json
|
||||
73a721da5ce864d7973923ab998d3e038d510a9a assets/functionalstorage/models/block/birch_2_locked.json
|
||||
8b466330111b80833458ae6e23f1f475d4fc0671 assets/functionalstorage/models/block/birch_4_locked.json
|
||||
13eb56026a20e2b83d8aa80ce9b8101c6d191e4a assets/functionalstorage/models/block/compacting_drawer_locked.json
|
||||
ef849e4444f8c1e96b0dc4053cfa6218be305d36 assets/functionalstorage/models/block/crimson_1_locked.json
|
||||
323a60308b46df6110ad0f02bd208e1e449bfa59 assets/functionalstorage/models/block/crimson_2_locked.json
|
||||
48627182bec4a852d8e7db13f77764f626619e72 assets/functionalstorage/models/block/crimson_4_locked.json
|
||||
|
@ -111,5 +112,5 @@ ff234dac4f0b0b4f83ffa92f2d2fb1074c68df43 data/functionalstorage/recipes/spruce_4
|
|||
bcb281904eac23183c45786e3d703d24bba92be6 data/functionalstorage/recipes/warped_1.json
|
||||
8fc3f76a2c57eb4d80ce86947fabebe48fa6f692 data/functionalstorage/recipes/warped_2.json
|
||||
7510a8ca1f1e3bb63f4c4f4add0bb6b713feaa0b data/functionalstorage/recipes/warped_4.json
|
||||
7f1584dd07594822d6db4ec38642d19047a7c73a data/functionalstorage/tags/items/drawer.json
|
||||
0f4c6dba10677b5d217ee704be3d1deb92517fad data/functionalstorage/tags/items/drawer.json
|
||||
12ec935226bf5a6a1493d353ef6dc6c224c256dd data/functionalstorage/tags/items/ignore_crafting_check.json
|
||||
|
|
|
@ -1,19 +1,34 @@
|
|||
{
|
||||
"variants": {
|
||||
"subfacing=north": {
|
||||
"locked=false,subfacing=north": {
|
||||
"model": "functionalstorage:block/compacting_drawer"
|
||||
},
|
||||
"subfacing=south": {
|
||||
"locked=true,subfacing=north": {
|
||||
"model": "functionalstorage:block/compacting_drawer_locked"
|
||||
},
|
||||
"locked=false,subfacing=south": {
|
||||
"model": "functionalstorage:block/compacting_drawer",
|
||||
"y": 180
|
||||
},
|
||||
"subfacing=west": {
|
||||
"locked=true,subfacing=south": {
|
||||
"model": "functionalstorage:block/compacting_drawer_locked",
|
||||
"y": 180
|
||||
},
|
||||
"locked=false,subfacing=west": {
|
||||
"model": "functionalstorage:block/compacting_drawer",
|
||||
"y": 270
|
||||
},
|
||||
"subfacing=east": {
|
||||
"locked=true,subfacing=west": {
|
||||
"model": "functionalstorage:block/compacting_drawer_locked",
|
||||
"y": 270
|
||||
},
|
||||
"locked=false,subfacing=east": {
|
||||
"model": "functionalstorage:block/compacting_drawer",
|
||||
"y": 90
|
||||
},
|
||||
"locked=true,subfacing=east": {
|
||||
"model": "functionalstorage:block/compacting_drawer_locked",
|
||||
"y": 90
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "functionalstorage:block/compacting_drawer",
|
||||
"textures": {
|
||||
"lock_icon": "functionalstorage:blocks/lock"
|
||||
}
|
||||
}
|
|
@ -1,14 +1,6 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"functionalstorage:oak_4",
|
||||
"functionalstorage:spruce_4",
|
||||
"functionalstorage:birch_4",
|
||||
"functionalstorage:jungle_4",
|
||||
"functionalstorage:acacia_4",
|
||||
"functionalstorage:dark_oak_4",
|
||||
"functionalstorage:crimson_4",
|
||||
"functionalstorage:warped_4",
|
||||
"functionalstorage:oak_1",
|
||||
"functionalstorage:spruce_1",
|
||||
"functionalstorage:birch_1",
|
||||
|
@ -24,6 +16,14 @@
|
|||
"functionalstorage:acacia_2",
|
||||
"functionalstorage:dark_oak_2",
|
||||
"functionalstorage:crimson_2",
|
||||
"functionalstorage:warped_2"
|
||||
"functionalstorage:warped_2",
|
||||
"functionalstorage:oak_4",
|
||||
"functionalstorage:spruce_4",
|
||||
"functionalstorage:birch_4",
|
||||
"functionalstorage:jungle_4",
|
||||
"functionalstorage:acacia_4",
|
||||
"functionalstorage:dark_oak_4",
|
||||
"functionalstorage:crimson_4",
|
||||
"functionalstorage:warped_4"
|
||||
]
|
||||
}
|
|
@ -174,6 +174,7 @@ public class FunctionalStorage extends ModuleController {
|
|||
ItemBlockRenderTypes.setRenderLayer(blockRegistryObject.get(), RenderType.cutout());
|
||||
}
|
||||
}
|
||||
ItemBlockRenderTypes.setRenderLayer(COMPACTING_DRAWER.get(), RenderType.cutout());
|
||||
}).subscribe();
|
||||
}
|
||||
|
||||
|
@ -224,6 +225,8 @@ public class FunctionalStorage extends ModuleController {
|
|||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
}
|
||||
}
|
||||
withExistingParent(COMPACTING_DRAWER.get().getRegistryName().getPath() + "_locked", modLoc(COMPACTING_DRAWER.get().getRegistryName().getPath()))
|
||||
.texture("lock_icon", modLoc("blocks/lock"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,9 +25,11 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction;
|
||||
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider;
|
||||
|
@ -70,7 +72,7 @@ public class CompactingDrawerBlock extends RotatableBlock<CompactingDrawerTile>
|
|||
public CompactingDrawerBlock(String name) {
|
||||
super(name, Properties.copy(Blocks.STONE_BRICKS), CompactingDrawerTile.class);
|
||||
setItemGroup(FunctionalStorage.TAB);
|
||||
registerDefaultState(defaultBlockState().setValue(RotatableBlock.FACING_HORIZONTAL, Direction.NORTH));
|
||||
registerDefaultState(defaultBlockState().setValue(RotatableBlock.FACING_HORIZONTAL, Direction.NORTH).setValue(DrawerBlock.LOCKED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,6 +104,12 @@ public class CompactingDrawerBlock extends RotatableBlock<CompactingDrawerTile>
|
|||
return boxes;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_206840_1_) {
|
||||
super.createBlockStateDefinition(p_206840_1_);
|
||||
p_206840_1_.add(DrawerBlock.LOCKED);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
|
||||
|
@ -172,13 +180,15 @@ public class CompactingDrawerBlock extends RotatableBlock<CompactingDrawerTile>
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
TileUtil.getTileEntity(worldIn, pos, DrawerTile.class).ifPresent(tile -> {
|
||||
if (tile.getControllerPos() != null){
|
||||
TileUtil.getTileEntity(worldIn, tile.getControllerPos(), DrawerControllerTile.class).ifPresent(drawerControllerTile -> {
|
||||
drawerControllerTile.addConnectedDrawers(LinkingToolItem.ActionMode.REMOVE, pos);
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!state.is(newState.getBlock())){
|
||||
TileUtil.getTileEntity(worldIn, pos, CompactingDrawerTile.class).ifPresent(tile -> {
|
||||
if (tile.getControllerPos() != null){
|
||||
TileUtil.getTileEntity(worldIn, tile.getControllerPos(), DrawerControllerTile.class).ifPresent(drawerControllerTile -> {
|
||||
drawerControllerTile.addConnectedDrawers(LinkingToolItem.ActionMode.REMOVE, pos);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
super.onRemove(state, worldIn, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,13 +243,15 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
TileUtil.getTileEntity(worldIn, pos, DrawerTile.class).ifPresent(tile -> {
|
||||
if (tile.getControllerPos() != null){
|
||||
TileUtil.getTileEntity(worldIn, tile.getControllerPos(), DrawerControllerTile.class).ifPresent(drawerControllerTile -> {
|
||||
drawerControllerTile.addConnectedDrawers(LinkingToolItem.ActionMode.REMOVE, pos);
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!state.is(newState.getBlock())){
|
||||
TileUtil.getTileEntity(worldIn, pos, DrawerTile.class).ifPresent(tile -> {
|
||||
if (tile.getControllerPos() != null){
|
||||
TileUtil.getTileEntity(worldIn, tile.getControllerPos(), DrawerControllerTile.class).ifPresent(drawerControllerTile -> {
|
||||
drawerControllerTile.addConnectedDrawers(LinkingToolItem.ActionMode.REMOVE, pos);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
super.onRemove(state, worldIn, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,12 @@ package com.buuz135.functionalstorage.block;
|
|||
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||
import com.buuz135.functionalstorage.block.tile.DrawerControllerTile;
|
||||
import com.hrznstudio.titanium.block.RotatableBlock;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DrawerControllerBlock extends RotatableBlock<DrawerControllerTile> {
|
||||
|
@ -12,6 +16,7 @@ public class DrawerControllerBlock extends RotatableBlock<DrawerControllerTile>
|
|||
public DrawerControllerBlock() {
|
||||
super("storage_controller", Properties.copy(Blocks.IRON_BLOCK), DrawerControllerTile.class);
|
||||
setItemGroup(FunctionalStorage.TAB);
|
||||
registerDefaultState(defaultBlockState().setValue(RotatableBlock.FACING_HORIZONTAL, Direction.NORTH).setValue(DrawerBlock.LOCKED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,4 +29,10 @@ public class DrawerControllerBlock extends RotatableBlock<DrawerControllerTile>
|
|||
public RotationType getRotationType() {
|
||||
return RotationType.FOUR_WAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_206840_1_) {
|
||||
super.createBlockStateDefinition(p_206840_1_);
|
||||
p_206840_1_.add(DrawerBlock.LOCKED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
|
|||
|
||||
public void setLocked(boolean locked) {
|
||||
if (this.getBlockState().hasProperty(DrawerBlock.LOCKED) ){
|
||||
this.level.setBlock(this.getBlockPos(), this.getBlockState().setValue(DrawerBlock.LOCKED, locked), 0);
|
||||
this.level.setBlock(this.getBlockPos(), this.getBlockState().setValue(DrawerBlock.LOCKED, locked), 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,10 +79,13 @@ public class DrawerControllerTile extends ControllableDrawerTile<DrawerControlle
|
|||
@Override
|
||||
public void toggleLocking() {
|
||||
super.toggleLocking();
|
||||
for (Long connectedDrawer : this.connectedDrawers.getConnectedDrawers()) {
|
||||
BlockEntity blockEntity = this.level.getBlockEntity(BlockPos.of(connectedDrawer));
|
||||
if (blockEntity instanceof ControllableDrawerTile){
|
||||
((ControllableDrawerTile<?>) blockEntity).setLocked(this.isLocked());
|
||||
if (isServer()){
|
||||
for (Long connectedDrawer : new ArrayList<>(this.connectedDrawers.getConnectedDrawers())) {
|
||||
System.out.println(BlockPos.of(connectedDrawer));
|
||||
BlockEntity blockEntity = this.level.getBlockEntity(BlockPos.of(connectedDrawer));
|
||||
if (blockEntity instanceof ControllableDrawerTile){
|
||||
((ControllableDrawerTile<?>) blockEntity).setLocked(this.isLocked());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.buuz135.functionalstorage.data;
|
||||
|
||||
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||
import com.buuz135.functionalstorage.block.CompactingDrawerBlock;
|
||||
import com.buuz135.functionalstorage.block.DrawerBlock;
|
||||
import com.buuz135.functionalstorage.block.DrawerControllerBlock;
|
||||
import com.buuz135.functionalstorage.block.tile.ControllableDrawerTile;
|
||||
import com.hrznstudio.titanium.block.RotatableBlock;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
|
@ -44,7 +47,7 @@ public class FunctionalStorageBlockstateProvider extends BlockStateProvider {
|
|||
if (rotatableBlock.getRotationType().getProperties().length > 0) {
|
||||
for (DirectionProperty property : rotatableBlock.getRotationType().getProperties()) {
|
||||
for (Direction allowedValue : property.getPossibleValues()) {
|
||||
if (rotatableBlock instanceof DrawerBlock){
|
||||
if (rotatableBlock instanceof DrawerBlock || rotatableBlock instanceof CompactingDrawerBlock || rotatableBlock instanceof CompactingDrawerBlock){
|
||||
builder.partialState().with(property, allowedValue).with(DrawerBlock.LOCKED, false)
|
||||
.addModels(new ConfiguredModel(new ModelFile.UncheckedModelFile(getModel(rotatableBlock)), allowedValue.get2DDataValue() == -1 ? allowedValue.getOpposite().getAxisDirection().getStep() * 90 : 0, (int) allowedValue.getOpposite().toYRot(), false));
|
||||
builder.partialState().with(property, allowedValue).with(DrawerBlock.LOCKED, true)
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
"front": "functionalstorage:blocks/compacting_drawer_front",
|
||||
"particle": "functionalstorage:blocks/compacting_drawer_side",
|
||||
"side": "functionalstorage:blocks/compacting_drawer_side",
|
||||
"top": "functionalstorage:blocks/compacting_drawer_top"
|
||||
"top": "functionalstorage:blocks/compacting_drawer_top",
|
||||
"lock_icon": "functionalstorage:blocks/unlock"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
|
@ -111,6 +112,30 @@
|
|||
"south": {"uv": [0, 0, 2, 6], "texture": "#front"},
|
||||
"west": {"uv": [8, 9, 9, 15], "texture": "#front"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [
|
||||
7.5,
|
||||
15,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
8.5,
|
||||
16,
|
||||
16
|
||||
],
|
||||
"faces": {
|
||||
"north": {
|
||||
"texture": "#lock_icon",
|
||||
"uv": [
|
||||
0.0,
|
||||
0.0,
|
||||
16.0,
|
||||
16.0
|
||||
],
|
||||
"cullface": "north"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"display": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user