loot tables, and some code cleanup
This commit is contained in:
parent
f16414f724
commit
0dda6eafb7
|
|
@ -75,9 +75,9 @@ dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.19.2-43.2.10'
|
minecraft 'net.minecraftforge:forge:1.19.2-43.2.10'
|
||||||
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
||||||
|
|
||||||
implementation fg.deobf("com.github.Mysticpasta1:mcef-forge:17731a6bbb")
|
implementation fg.deobf("com.github.Mysticpasta1:mcef-forge:0b89f5faab")
|
||||||
// implementation fg.deobf("curse.maven:cloth_config_forge-348521:3972423")
|
// implementation fg.deobf("curse.maven:cloth_config_forge-348521:3972423")
|
||||||
implementation fg.deobf("curse.maven:SU-370704:4410614")
|
implementation fg.deobf("curse.maven:SU-370704:4485052")
|
||||||
implementation fg.deobf("curse.maven:spark-361579:4381167")
|
implementation fg.deobf("curse.maven:spark-361579:4381167")
|
||||||
|
|
||||||
compileOnly fg.deobf("curse.maven:vivecraft-667903:4409427")
|
compileOnly fg.deobf("curse.maven:vivecraft-667903:4409427")
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,6 @@ public class BlockKeyboardLeft extends BlockPeripheral {
|
||||||
public static void remove(BlockState state, Level world, BlockPos pos, boolean setState, boolean drop) {
|
public static void remove(BlockState state, Level world, BlockPos pos, boolean setState, boolean drop) {
|
||||||
removeRightPiece(state, world, pos);
|
removeRightPiece(state, world, pos);
|
||||||
if (setState) {
|
if (setState) {
|
||||||
if (drop) {
|
|
||||||
// TODO: force drop item
|
|
||||||
}
|
|
||||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
}
|
}
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,6 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
public static void remove(BlockState state, Level world, BlockPos pos, boolean setState, boolean drop) {
|
public static void remove(BlockState state, Level world, BlockPos pos, boolean setState, boolean drop) {
|
||||||
removeLeftPiece(state, world, pos);
|
removeLeftPiece(state, world, pos);
|
||||||
if (setState) {
|
if (setState) {
|
||||||
if (drop) {
|
|
||||||
// TODO: force drop item
|
|
||||||
}
|
|
||||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
}
|
}
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> BlockKeyboardLeft.point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> BlockKeyboardLeft.point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
|
|
||||||
public BlockPeripheral() {
|
public BlockPeripheral() {
|
||||||
super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f));
|
super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f));
|
||||||
// setName("peripheral");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -60,44 +59,6 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
builder.add(properties);
|
builder.add(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Nullable TODO: Fix
|
|
||||||
// @Override
|
|
||||||
// public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
||||||
// Direction rot = Direction.fromYRot(placer.getYHeadRot());
|
|
||||||
// return defaultBlockState().setValue(type, DefaultPeripheral.fromMetadata(meta)).setValue(facing, rot);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return getStateForPlacement(context);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public BlockState getStateForPlacement(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction nocare, float hitX,
|
|
||||||
// float hitY, float hitZ, int meta, @Nonnull LivingEntity placer, InteractionHand hand) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
||||||
// for(DefaultPeripheral dp : DefaultPeripheral.values())
|
|
||||||
// list.add(new ItemStack(getItem(), 1, dp.toMetadata(0)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// @Nonnull
|
|
||||||
// public IBlockState getStateFromMeta(int meta) {
|
|
||||||
// DefaultPeripheral dp = DefaultPeripheral.fromMetadata(meta);
|
|
||||||
// IBlockState state = getDefaultState().withProperty(type, dp);
|
|
||||||
//
|
|
||||||
// if(dp.hasFacing())
|
|
||||||
// state = state.withProperty(facing, (meta >> 2) & 3);
|
|
||||||
//
|
|
||||||
// return state;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int getMetaFromState(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(state.getValue(facing));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
|
@ -119,12 +80,6 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
return RenderShape.MODEL;
|
return RenderShape.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public int damageDropped(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
if(player.isShiftKeyDown())
|
if(player.isShiftKeyDown())
|
||||||
|
|
@ -144,31 +99,6 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullCube(IBlockState state) { TODO: FIx.
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullBlock(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isOpaqueCube(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||||
return state.getValue(type) == DefaultPeripheral.KEYBOARD ? BlockKeyboardRight.KEYBOARD_AABB : Shapes.block();
|
return state.getValue(type) == DefaultPeripheral.KEYBOARD ? BlockKeyboardRight.KEYBOARD_AABB : Shapes.block();
|
||||||
|
|
@ -217,7 +147,6 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
||||||
removeRightPiece(world, pos);
|
removeRightPiece(world, pos);
|
||||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
// dropBlockAsItem(world, pos, state, 0); //TODO Loottable
|
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -230,6 +159,7 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
|
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
|
super.playerDestroy(world, player, pos, state, blockEntity, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -50,44 +50,6 @@ public class BlockRCTRL extends WDBlockContainer {
|
||||||
builder.add(properties);
|
builder.add(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Nullable TODO: Fix
|
|
||||||
// @Override
|
|
||||||
// public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
||||||
// Direction rot = Direction.fromYRot(placer.getYHeadRot());
|
|
||||||
// return defaultBlockState().setValue(type, DefaultPeripheral.fromMetadata(meta)).setValue(facing, rot);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return getStateForPlacement(context);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public BlockState getStateForPlacement(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction nocare, float hitX,
|
|
||||||
// float hitY, float hitZ, int meta, @Nonnull LivingEntity placer, InteractionHand hand) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
||||||
// for(DefaultPeripheral dp : DefaultPeripheral.values())
|
|
||||||
// list.add(new ItemStack(getItem(), 1, dp.toMetadata(0)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// @Nonnull
|
|
||||||
// public IBlockState getStateFromMeta(int meta) {
|
|
||||||
// DefaultPeripheral dp = DefaultPeripheral.fromMetadata(meta);
|
|
||||||
// IBlockState state = getDefaultState().withProperty(type, dp);
|
|
||||||
//
|
|
||||||
// if(dp.hasFacing())
|
|
||||||
// state = state.withProperty(facing, (meta >> 2) & 3);
|
|
||||||
//
|
|
||||||
// return state;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int getMetaFromState(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(state.getValue(facing));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
|
@ -99,12 +61,6 @@ public class BlockRCTRL extends WDBlockContainer {
|
||||||
return RenderShape.MODEL;
|
return RenderShape.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public int damageDropped(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
if(player.isShiftKeyDown())
|
if(player.isShiftKeyDown())
|
||||||
|
|
@ -124,31 +80,6 @@ public class BlockRCTRL extends WDBlockContainer {
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullCube(IBlockState state) { TODO: FIx.
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullBlock(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isOpaqueCube(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||||
if(world.isClientSide)
|
if(world.isClientSide)
|
||||||
|
|
@ -179,7 +110,6 @@ public class BlockRCTRL extends WDBlockContainer {
|
||||||
|
|
||||||
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
||||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
// dropBlockAsItem(world, pos, state, 0); //TODO Loottable
|
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +119,7 @@ public class BlockRCTRL extends WDBlockContainer {
|
||||||
if(!world.isClientSide) {
|
if(!world.isClientSide) {
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
|
super.playerDestroy(world, player, pos, state, blockEntity, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -50,44 +50,6 @@ public class BlockRedCTRL extends WDBlockContainer {
|
||||||
builder.add(properties);
|
builder.add(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Nullable TODO: Fix
|
|
||||||
// @Override
|
|
||||||
// public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
||||||
// Direction rot = Direction.fromYRot(placer.getYHeadRot());
|
|
||||||
// return defaultBlockState().setValue(type, DefaultPeripheral.fromMetadata(meta)).setValue(facing, rot);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return getStateForPlacement(context);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public BlockState getStateForPlacement(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction nocare, float hitX,
|
|
||||||
// float hitY, float hitZ, int meta, @Nonnull LivingEntity placer, InteractionHand hand) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
||||||
// for(DefaultPeripheral dp : DefaultPeripheral.values())
|
|
||||||
// list.add(new ItemStack(getItem(), 1, dp.toMetadata(0)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// @Nonnull
|
|
||||||
// public IBlockState getStateFromMeta(int meta) {
|
|
||||||
// DefaultPeripheral dp = DefaultPeripheral.fromMetadata(meta);
|
|
||||||
// IBlockState state = getDefaultState().withProperty(type, dp);
|
|
||||||
//
|
|
||||||
// if(dp.hasFacing())
|
|
||||||
// state = state.withProperty(facing, (meta >> 2) & 3);
|
|
||||||
//
|
|
||||||
// return state;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int getMetaFromState(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(state.getValue(facing));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
|
@ -99,12 +61,6 @@ public class BlockRedCTRL extends WDBlockContainer {
|
||||||
return RenderShape.MODEL;
|
return RenderShape.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public int damageDropped(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
if(player.isShiftKeyDown())
|
if(player.isShiftKeyDown())
|
||||||
|
|
@ -124,31 +80,6 @@ public class BlockRedCTRL extends WDBlockContainer {
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullCube(IBlockState state) { TODO: FIx.
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullBlock(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isOpaqueCube(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||||
if(world.isClientSide)
|
if(world.isClientSide)
|
||||||
|
|
@ -179,7 +110,6 @@ public class BlockRedCTRL extends WDBlockContainer {
|
||||||
|
|
||||||
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
||||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
// dropBlockAsItem(world, pos, state, 0); //TODO Loottable
|
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +119,7 @@ public class BlockRedCTRL extends WDBlockContainer {
|
||||||
if(!world.isClientSide) {
|
if(!world.isClientSide) {
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
|
super.playerDestroy(world, player, pos, state, blockEntity, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,6 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
|
|
||||||
public BlockScreen(Properties properties) {
|
public BlockScreen(Properties properties) {
|
||||||
super(properties.strength(1.5f, 10.f));
|
super(properties.strength(1.5f, 10.f));
|
||||||
// setCreativeTab(WebDisplays.CREATIVE_TAB);
|
|
||||||
// setName("screen");
|
|
||||||
this.registerDefaultState(this.defaultBlockState().setValue(hasTE, false).setValue(emitting, false));
|
this.registerDefaultState(this.defaultBlockState().setValue(hasTE, false).setValue(emitting, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +77,6 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
return world.getBlockState(pos.toBlock()).getBlock() != BlockInit.blockScreen.get();
|
return world.getBlockState(pos.toBlock()).getBlock() != BlockInit.blockScreen.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||||
|
|
@ -91,31 +88,6 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
return super.updateShape(state, direction, neighborState, level, currentPos, neighborPos);
|
return super.updateShape(state, direction, neighborState, level, currentPos, neighborPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
|
||||||
@Nonnull
|
|
||||||
public BlockState getExtendedState(@Nonnull BlockState ret, Level world, BlockPos bpos) {
|
|
||||||
Vector3i pos = new Vector3i(bpos);
|
|
||||||
|
|
||||||
for(BlockSide side : BlockSide.values()) {
|
|
||||||
int icon = 0;
|
|
||||||
if(isntScreenBlock(world, side.up.clone().add(pos))) icon |= BAR_TOP;
|
|
||||||
if(isntScreenBlock(world, side.down.clone().add(pos))) icon |= BAR_BOT;
|
|
||||||
if(isntScreenBlock(world, side.left.clone().add(pos))) icon |= BAR_LEFT;
|
|
||||||
if(isntScreenBlock(world, side.right.clone().add(pos))) icon |= BAR_RIGHT;
|
|
||||||
|
|
||||||
ret = ret.setValue(sideFlags[side.ordinal()], icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// @Nonnull
|
|
||||||
// public IBlockState getStateFromMeta(int meta) {
|
|
||||||
// return getDefaultState().withProperty(hasTE, (meta & 1) != 0).withProperty(emitting, (meta & 2) != 0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
public int getMetaFromState(BlockState state) {
|
public int getMetaFromState(BlockState state) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (state.getValue(hasTE))
|
if (state.getValue(hasTE))
|
||||||
|
|
@ -216,54 +188,54 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
// return InteractionResult.SUCCESS;
|
// return InteractionResult.SUCCESS;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Vector2i size = Multiblock.measure(world, pos, side);
|
Vector2i size = Multiblock.measure(world, pos, side);
|
||||||
if (size.x < 2 && size.y < 2) {
|
if (size.x < 2 && size.y < 2) {
|
||||||
Util.toast(player, "tooSmall");
|
Util.toast(player, "tooSmall");
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size.x > CommonConfig.Screen.maxScreenSizeX || size.y > CommonConfig.Screen.maxScreenSizeY) {
|
|
||||||
Util.toast(player, "tooBig", CommonConfig.Screen.maxScreenSizeX, CommonConfig.Screen.maxScreenSizeY);
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3i err = Multiblock.check(world, pos, size, side);
|
|
||||||
if (err != null) {
|
|
||||||
Util.toast(player, "invalid", err.toString());
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean created = false;
|
|
||||||
Log.info("Player %s (UUID %s) created a screen at %s of size %dx%d", player.getName(), player.getGameProfile().getId().toString(), pos.toString(), size.x, size.y);
|
|
||||||
|
|
||||||
if (te == null) {
|
|
||||||
BlockPos bp = pos.toBlock();
|
|
||||||
world.setBlockAndUpdate(bp, world.getBlockState(bp).setValue(hasTE, true));
|
|
||||||
te = (TileEntityScreen) world.getBlockEntity(bp);
|
|
||||||
created = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
te.addScreen(side, size, null, player, true);
|
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (size.x > CommonConfig.Screen.maxScreenSizeX || size.y > CommonConfig.Screen.maxScreenSizeY) {
|
||||||
public void neighborChanged (BlockState state, Level world, BlockPos pos, Block block, BlockPos source,
|
Util.toast(player, "tooBig", CommonConfig.Screen.maxScreenSizeX, CommonConfig.Screen.maxScreenSizeY);
|
||||||
boolean isMoving){
|
return InteractionResult.SUCCESS;
|
||||||
if (block != this && !world.isClientSide && !state.getValue(emitting)) {
|
}
|
||||||
for (BlockSide side : BlockSide.values()) {
|
|
||||||
Vector3i vec = new Vector3i(pos);
|
|
||||||
Multiblock.findOrigin(world, vec, side, null);
|
|
||||||
|
|
||||||
TileEntityScreen tes = (TileEntityScreen) world.getBlockEntity(vec.toBlock());
|
Vector3i err = Multiblock.check(world, pos, size, side);
|
||||||
if (tes != null && tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
if (err != null) {
|
||||||
Direction facing = Direction.from2DDataValue(side.reverse().ordinal()); //Opposite face
|
Util.toast(player, "invalid", err.toString());
|
||||||
vec.sub(pos.getX(), pos.getY(), pos.getZ()).neg();
|
return InteractionResult.SUCCESS;
|
||||||
tes.updateJSRedstone(side, new Vector2i(vec.dot(side.right), vec.dot(side.up)), world.getSignal(pos, facing));
|
}
|
||||||
}
|
|
||||||
|
boolean created = false;
|
||||||
|
Log.info("Player %s (UUID %s) created a screen at %s of size %dx%d", player.getName(), player.getGameProfile().getId().toString(), pos.toString(), size.x, size.y);
|
||||||
|
|
||||||
|
if (te == null) {
|
||||||
|
BlockPos bp = pos.toBlock();
|
||||||
|
world.setBlockAndUpdate(bp, world.getBlockState(bp).setValue(hasTE, true));
|
||||||
|
te = (TileEntityScreen) world.getBlockEntity(bp);
|
||||||
|
created = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
te.addScreen(side, size, null, player, true);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos source,
|
||||||
|
boolean isMoving){
|
||||||
|
if (block != this && !world.isClientSide && !state.getValue(emitting)) {
|
||||||
|
for (BlockSide side : BlockSide.values()) {
|
||||||
|
Vector3i vec = new Vector3i(pos);
|
||||||
|
Multiblock.findOrigin(world, vec, side, null);
|
||||||
|
|
||||||
|
TileEntityScreen tes = (TileEntityScreen) world.getBlockEntity(vec.toBlock());
|
||||||
|
if (tes != null && tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
||||||
|
Direction facing = Direction.from2DDataValue(side.reverse().ordinal()); //Opposite face
|
||||||
|
vec.sub(pos.getX(), pos.getY(), pos.getZ()).neg();
|
||||||
|
tes.updateJSRedstone(side, new Vector2i(vec.dot(side.right), vec.dot(side.up)), world.getSignal(pos, facing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean hit2pixels(BlockSide side, BlockPos bpos, Vector3i pos, TileEntityScreen.Screen scr, float hitX, float hitY, float hitZ, Vector2i dst) {
|
public static boolean hit2pixels(BlockSide side, BlockPos bpos, Vector3i pos, TileEntityScreen.Screen scr, float hitX, float hitY, float hitZ, Vector2i dst) {
|
||||||
if(side.right.x < 0)
|
if(side.right.x < 0)
|
||||||
|
|
@ -323,104 +295,98 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity (BlockPos pos, BlockState state){
|
public BlockEntity newBlockEntity (BlockPos pos, BlockState state){
|
||||||
int meta = getMetaFromState(state);
|
int meta = getMetaFromState(state);
|
||||||
|
|
||||||
if ((meta & 1) == 0)
|
if ((meta & 1) == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return ((meta & 1) == 0) ? null : new TileEntityScreen(pos, state);
|
return ((meta & 1) == 0) ? null : new TileEntityScreen(pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************* DESTRUCTION HANDLING *************************************************/
|
||||||
|
|
||||||
|
private void onDestroy (Level world, BlockPos pos, Player ply){
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
Vector3i bp = new Vector3i(pos);
|
||||||
|
Multiblock.BlockOverride override = new Multiblock.BlockOverride(bp, Multiblock.OverrideAction.SIMULATE);
|
||||||
|
|
||||||
|
for (BlockSide bs : BlockSide.values())
|
||||||
|
destroySide(world, bp.clone(), bs, override, ply);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************* DESTRUCTION HANDLING *************************************************/
|
private void destroySide (Level world, Vector3i pos, BlockSide side, Multiblock.BlockOverride override, Player
|
||||||
|
source){
|
||||||
|
Multiblock.findOrigin(world, pos, side, override);
|
||||||
|
BlockPos bp = pos.toBlock();
|
||||||
|
BlockEntity te = world.getBlockEntity(bp);
|
||||||
|
|
||||||
private void onDestroy (Level world, BlockPos pos, Player ply){
|
if (te != null && te instanceof TileEntityScreen) {
|
||||||
if (!world.isClientSide) {
|
((TileEntityScreen) te).onDestroy(source);
|
||||||
Vector3i bp = new Vector3i(pos);
|
world.setBlock(bp, world.getBlockState(bp).setValue(hasTE, false), Block.UPDATE_ALL_IMMEDIATE); //Destroy tile entity.
|
||||||
Multiblock.BlockOverride override = new Multiblock.BlockOverride(bp, Multiblock.OverrideAction.SIMULATE);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onDestroyedByPlayer (BlockState state, Level level, BlockPos pos, Player player,
|
||||||
|
boolean willHarvest, FluidState fluid){
|
||||||
|
onDestroy(level, pos, player);
|
||||||
|
return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlacedBy (Level world, @NotNull BlockPos pos, @NotNull BlockState
|
||||||
|
state, @org.jetbrains.annotations.Nullable LivingEntity whoDidThisShit, @NotNull ItemStack stack){
|
||||||
|
if (world.isClientSide)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Multiblock.BlockOverride override = new Multiblock.BlockOverride(new Vector3i(pos), Multiblock.OverrideAction.IGNORE);
|
||||||
|
Vector3i[] neighbors = new Vector3i[6];
|
||||||
|
|
||||||
|
neighbors[0] = new Vector3i(pos.getX() + 1, pos.getY(), pos.getZ());
|
||||||
|
neighbors[1] = new Vector3i(pos.getX() - 1, pos.getY(), pos.getZ());
|
||||||
|
neighbors[2] = new Vector3i(pos.getX(), pos.getY() + 1, pos.getZ());
|
||||||
|
neighbors[3] = new Vector3i(pos.getX(), pos.getY() - 1, pos.getZ());
|
||||||
|
neighbors[4] = new Vector3i(pos.getX(), pos.getY(), pos.getZ() + 1);
|
||||||
|
neighbors[5] = new Vector3i(pos.getX(), pos.getY(), pos.getZ() - 1);
|
||||||
|
|
||||||
|
for (Vector3i neighbor : neighbors) {
|
||||||
|
if (world.getBlockState(neighbor.toBlock()).getBlock() instanceof BlockScreen) {
|
||||||
for (BlockSide bs : BlockSide.values())
|
for (BlockSide bs : BlockSide.values())
|
||||||
destroySide(world, bp.clone(), bs, override, ply);
|
destroySide(world, neighbor.clone(), bs, override, (whoDidThisShit instanceof Player) ? ((Player) whoDidThisShit) : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void destroySide (Level world, Vector3i pos, BlockSide side, Multiblock.BlockOverride override, Player
|
@Override
|
||||||
source){
|
public @NotNull PushReaction getPistonPushReaction (BlockState state){
|
||||||
Multiblock.findOrigin(world, pos, side, override);
|
return PushReaction.IGNORE;
|
||||||
BlockPos bp = pos.toBlock();
|
}
|
||||||
BlockEntity te = world.getBlockEntity(bp);
|
|
||||||
|
|
||||||
if (te != null && te instanceof TileEntityScreen) {
|
@Override
|
||||||
((TileEntityScreen) te).onDestroy(source);
|
public int getSignal (BlockState state, BlockGetter level, BlockPos pos, Direction direction){
|
||||||
world.setBlock(bp, world.getBlockState(bp).setValue(hasTE, false), Block.UPDATE_ALL_IMMEDIATE); //Destroy tile entity.
|
return state.getValue(emitting) ? 15 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSignalSource (BlockState state){
|
||||||
|
return state.getValue(emitting);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ItemBlockScreen extends BlockItem implements WDItem {
|
||||||
|
|
||||||
|
public ItemBlockScreen(BlockScreen screen) {
|
||||||
|
super(screen, new Properties());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public boolean onDestroyedByPlayer (BlockState state, Level level, BlockPos pos, Player player,
|
public String getWikiName(@Nonnull ItemStack is) {
|
||||||
boolean willHarvest, FluidState fluid){
|
return is.getItem().getName(is).getString();
|
||||||
onDestroy(level, pos, player);
|
|
||||||
return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPlacedBy (Level world, @NotNull BlockPos pos, @NotNull BlockState
|
|
||||||
state, @org.jetbrains.annotations.Nullable LivingEntity whoDidThisShit, @NotNull ItemStack stack){
|
|
||||||
if (world.isClientSide)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Multiblock.BlockOverride override = new Multiblock.BlockOverride(new Vector3i(pos), Multiblock.OverrideAction.IGNORE);
|
|
||||||
Vector3i[] neighbors = new Vector3i[6];
|
|
||||||
|
|
||||||
neighbors[0] = new Vector3i(pos.getX() + 1, pos.getY(), pos.getZ());
|
|
||||||
neighbors[1] = new Vector3i(pos.getX() - 1, pos.getY(), pos.getZ());
|
|
||||||
neighbors[2] = new Vector3i(pos.getX(), pos.getY() + 1, pos.getZ());
|
|
||||||
neighbors[3] = new Vector3i(pos.getX(), pos.getY() - 1, pos.getZ());
|
|
||||||
neighbors[4] = new Vector3i(pos.getX(), pos.getY(), pos.getZ() + 1);
|
|
||||||
neighbors[5] = new Vector3i(pos.getX(), pos.getY(), pos.getZ() - 1);
|
|
||||||
|
|
||||||
for (Vector3i neighbor : neighbors) {
|
|
||||||
if (world.getBlockState(neighbor.toBlock()).getBlock() instanceof BlockScreen) {
|
|
||||||
for (BlockSide bs : BlockSide.values())
|
|
||||||
destroySide(world, neighbor.clone(), bs, override, (whoDidThisShit instanceof Player) ? ((Player) whoDidThisShit) : null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull PushReaction getPistonPushReaction (BlockState state){
|
|
||||||
return PushReaction.IGNORE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSignal (BlockState state, BlockGetter level, BlockPos pos, Direction direction){
|
|
||||||
return state.getValue(emitting) ? 15 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSignalSource (BlockState state){
|
|
||||||
return state.getValue(emitting);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override //TODO: Add this
|
|
||||||
// protected BlockItem createItemBlock() {
|
|
||||||
// return new ItemBlockScreen(this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static class ItemBlockScreen extends BlockItem implements WDItem {
|
|
||||||
|
|
||||||
public ItemBlockScreen(BlockScreen screen) {
|
|
||||||
super(screen, new Properties());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public String getWikiName(@Nonnull ItemStack is) {
|
|
||||||
return is.getItem().getName(is).getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,44 +53,6 @@ public class BlockServer extends WDBlockContainer{
|
||||||
builder.add(properties);
|
builder.add(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Nullable TODO: Fix
|
|
||||||
// @Override
|
|
||||||
// public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
||||||
// Direction rot = Direction.fromYRot(placer.getYHeadRot());
|
|
||||||
// return defaultBlockState().setValue(type, DefaultPeripheral.fromMetadata(meta)).setValue(facing, rot);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return getStateForPlacement(context);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public BlockState getStateForPlacement(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction nocare, float hitX,
|
|
||||||
// float hitY, float hitZ, int meta, @Nonnull LivingEntity placer, InteractionHand hand) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
||||||
// for(DefaultPeripheral dp : DefaultPeripheral.values())
|
|
||||||
// list.add(new ItemStack(getItem(), 1, dp.toMetadata(0)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// @Nonnull
|
|
||||||
// public IBlockState getStateFromMeta(int meta) {
|
|
||||||
// DefaultPeripheral dp = DefaultPeripheral.fromMetadata(meta);
|
|
||||||
// IBlockState state = getDefaultState().withProperty(type, dp);
|
|
||||||
//
|
|
||||||
// if(dp.hasFacing())
|
|
||||||
// state = state.withProperty(facing, (meta >> 2) & 3);
|
|
||||||
//
|
|
||||||
// return state;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int getMetaFromState(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(state.getValue(facing));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
|
@ -102,12 +64,6 @@ public class BlockServer extends WDBlockContainer{
|
||||||
return RenderShape.MODEL;
|
return RenderShape.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public int damageDropped(IBlockState state) {
|
|
||||||
// return state.getValue(type).toMetadata(0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
if(player.isShiftKeyDown())
|
if(player.isShiftKeyDown())
|
||||||
|
|
@ -125,31 +81,6 @@ public class BlockServer extends WDBlockContainer{
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullCube(IBlockState state) { TODO: FIx.
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isFullBlock(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isOpaqueCube(IBlockState state) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
|
|
||||||
// return state.getValue(type) != DefaultPeripheral.KEYBOARD;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||||
if(world.isClientSide)
|
if(world.isClientSide)
|
||||||
|
|
@ -180,7 +111,6 @@ public class BlockServer extends WDBlockContainer{
|
||||||
|
|
||||||
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
if(neighbor.getX() == pos.getX() && neighbor.getY() == pos.getY() - 1 && neighbor.getZ() == pos.getZ() && world.isEmptyBlock(neighbor)) {
|
||||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
// dropBlockAsItem(world, pos, state, 0); //TODO Loottable
|
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -190,6 +120,7 @@ public class BlockServer extends WDBlockContainer{
|
||||||
if(!world.isClientSide) {
|
if(!world.isClientSide) {
|
||||||
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
|
||||||
}
|
}
|
||||||
|
super.playerDestroy(world, player, pos, state, blockEntity, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -214,5 +145,4 @@ public class BlockServer extends WDBlockContainer{
|
||||||
public static PacketDistributor.TargetPoint point(Level world, BlockPos bp) {
|
public static PacketDistributor.TargetPoint point(Level world, BlockPos bp) {
|
||||||
return new PacketDistributor.TargetPoint(bp.getX(), bp.getY(), bp.getZ(), 64.0, world.dimension());
|
return new PacketDistributor.TargetPoint(bp.getX(), bp.getY(), bp.getZ(), 64.0, world.dimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,7 @@
|
||||||
package net.montoyo.wd.block;
|
package net.montoyo.wd.block;
|
||||||
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.montoyo.wd.WebDisplays;
|
|
||||||
|
|
||||||
public abstract class WDBlockContainer extends BaseEntityBlock {
|
public abstract class WDBlockContainer extends BaseEntityBlock {
|
||||||
|
|
||||||
|
|
@ -18,22 +15,6 @@ public abstract class WDBlockContainer extends BaseEntityBlock {
|
||||||
super(arg);
|
super(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setName(String name) {
|
|
||||||
// setRegistryName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static BlockItem createItemBlock(Block block) {
|
|
||||||
return new BlockItem(block, new Item.Properties().tab(WebDisplays.CREATIVE_TAB));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void makeItemBlock(Block block) {
|
|
||||||
if(itemBlock != null)
|
|
||||||
throw new RuntimeException("WDBlockContainer.makeItemBlock() called twice!");
|
|
||||||
|
|
||||||
itemBlock = createItemBlock(block);
|
|
||||||
// itemBlock.setRegistryName(getName().getString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockItem getItem() {
|
public BlockItem getItem() {
|
||||||
return itemBlock;
|
return itemBlock;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.client.event.ModelEvent;
|
import net.minecraftforge.client.event.ModelEvent;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.client.event.RenderHighlightEvent;
|
import net.minecraftforge.client.event.RenderHighlightEvent;
|
||||||
|
|
@ -48,6 +47,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.event.level.LevelEvent;
|
import net.minecraftforge.event.level.LevelEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
@ -533,125 +533,142 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
|
||||||
registerItemMultiModels(wd.itemAdvIcon);
|
registerItemMultiModels(wd.itemAdvIcon);
|
||||||
} */
|
} */
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@OnlyIn(Dist.CLIENT)
|
public void onLevelTick(TickEvent.LevelTickEvent ev) {
|
||||||
public void onTick(TickEvent.ClientTickEvent ev) {
|
if (!ev.side.equals(LogicalSide.CLIENT)) return;
|
||||||
if(ev.phase == TickEvent.Phase.END) {
|
if(ev.phase != TickEvent.Phase.END) return;
|
||||||
//Help
|
|
||||||
if(InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_F1)) {
|
//Unload/load screens depending on client player distance
|
||||||
if(!isF1Down) {
|
if (mc.player != null || !screenTracking.isEmpty())
|
||||||
isF1Down = true;
|
return;
|
||||||
|
|
||||||
String wikiName = null;
|
int id = lastTracked % screenTracking.size();
|
||||||
if(mc.screen instanceof WDScreen)
|
|
||||||
wikiName = ((WDScreen) mc.screen).getWikiPageName();
|
TileEntityScreen tes = screenTracking.get(id);
|
||||||
else if(mc.screen instanceof ContainerScreen) {
|
|
||||||
Slot slot = ((ContainerScreen) mc.screen).getSlotUnderMouse();
|
if (!tes.getLevel().equals(ev.level))
|
||||||
|
return;
|
||||||
if(slot != null && slot.hasItem() && slot.getItem().getItem() instanceof WDItem)
|
|
||||||
wikiName = ((WDItem) slot.getItem().getItem()).getWikiName(slot.getItem());
|
lastTracked++;
|
||||||
}
|
if (tes.getLevel() != mc.player.level) {
|
||||||
|
// TODO: properly handle this
|
||||||
if(wikiName != null)
|
// probably gonna want a helper class for cross-dimensional distances
|
||||||
mcef.openExampleBrowser("https://montoyo.net/wdwiki/index.php/" + wikiName);
|
if (!tes.isLoaded())
|
||||||
}
|
tes.load();
|
||||||
} else if(isF1Down)
|
} else {
|
||||||
isF1Down = false;
|
double dist2 = mc.player.distanceToSqr(tes.getBlockPos().getX(), tes.getBlockPos().getY(), tes.getBlockPos().getZ());
|
||||||
|
|
||||||
//Workaround cuz chat sux
|
if (tes.isLoaded()) {
|
||||||
if(nextScreen != null && mc.screen == null) {
|
if (dist2 > WebDisplays.INSTANCE.unloadDistance2)
|
||||||
mc.setScreen(nextScreen);
|
tes.unload();
|
||||||
nextScreen = null;
|
else if (ClientConfig.AutoVolumeControl.enableAutoVolume)
|
||||||
}
|
tes.updateTrackDistance(dist2, 80); //ToDo find master volume
|
||||||
|
} else if (dist2 <= WebDisplays.INSTANCE.loadDistance2)
|
||||||
//Unload/load screens depending on client player distance
|
tes.load();
|
||||||
if(mc.player != null && !screenTracking.isEmpty()) {
|
}
|
||||||
int id = lastTracked % screenTracking.size();
|
}
|
||||||
lastTracked++;
|
|
||||||
|
|
||||||
TileEntityScreen tes = screenTracking.get(id);
|
|
||||||
double dist2 = mc.player.distanceToSqr(tes.getBlockPos().getX(), tes.getBlockPos().getY(), tes.getBlockPos().getZ());
|
|
||||||
|
|
||||||
if(tes.isLoaded()) {
|
|
||||||
if(dist2 > WebDisplays.INSTANCE.unloadDistance2)
|
|
||||||
tes.unload();
|
|
||||||
else if(ClientConfig.AutoVolumeControl.enableAutoVolume)
|
|
||||||
tes.updateTrackDistance(dist2, 80); //ToDo find master volume
|
|
||||||
} else if(dist2 <= WebDisplays.INSTANCE.loadDistance2)
|
|
||||||
tes.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Load/unload minePads depending on which item is in the player's hand
|
|
||||||
if(++minePadTickCounter >= 10) {
|
|
||||||
minePadTickCounter = 0;
|
|
||||||
Player ep = mc.player;
|
|
||||||
|
|
||||||
for(PadData pd: padList)
|
|
||||||
pd.isInHotbar = false;
|
|
||||||
|
|
||||||
if(ep != null) {
|
|
||||||
updateInventory(ep.getInventory().items, ep.getItemInHand(InteractionHand.MAIN_HAND), 9);
|
|
||||||
updateInventory(ep.getInventory().offhand, ep.getItemInHand(InteractionHand.OFF_HAND), 1); //Is this okay?
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Check for GuiContainer.draggedStack
|
|
||||||
|
|
||||||
for(int i = padList.size() - 1; i >= 0; i--) {
|
|
||||||
PadData pd = padList.get(i);
|
|
||||||
|
|
||||||
if(!pd.isInHotbar) {
|
|
||||||
pd.view.close();
|
|
||||||
pd.view = null; //This is for GuiMinePad, in case the player dies with the GUI open
|
|
||||||
padList.remove(i);
|
|
||||||
padMap.remove(pd.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Laser pointer raycast
|
|
||||||
if(mc.player != null && mc.level != null && ItemInit.itemLaserPointer.isPresent() && mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.itemLaserPointer.get())
|
|
||||||
&& mc.options.keyUse.isDown()
|
|
||||||
&& (mc.hitResult == null || mc.hitResult.getType() == HitResult.Type.BLOCK || mc.hitResult.getType() == HitResult.Type.MISS)) {
|
|
||||||
laserPointerRenderer.isOn = true;
|
|
||||||
BlockHitResult result = raycast(64.0); //TODO: Make that distance configurable
|
|
||||||
|
|
||||||
BlockPos bpos = result.getBlockPos();
|
|
||||||
|
|
||||||
if(result.getType() == HitResult.Type.BLOCK && mc.level.getBlockState(bpos).getBlock() == BlockInit.blockScreen.get()) {
|
|
||||||
Vector3i pos = new Vector3i(result.getBlockPos());
|
|
||||||
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
|
|
||||||
|
|
||||||
Multiblock.findOrigin(mc.level, pos, side, null);
|
|
||||||
TileEntityScreen te = (TileEntityScreen) mc.level.getBlockEntity(pos.toBlock());
|
|
||||||
|
|
||||||
if(te != null && te.hasUpgrade(side, DefaultUpgrade.LASERMOUSE)) { //hasUpgrade returns false is there's no screen on side 'side'
|
|
||||||
//Since rights aren't synchronized, let the server check them for us...
|
|
||||||
TileEntityScreen.Screen scr = te.getScreen(side);
|
|
||||||
|
|
||||||
if(scr.browser != null) {
|
|
||||||
float hitX = ((float) result.getLocation().x) - (float) bpos.getX();
|
|
||||||
float hitY = ((float) result.getLocation().y) - (float) bpos.getY();
|
|
||||||
float hitZ = ((float) result.getLocation().z) - (float) bpos.getZ();
|
|
||||||
Vector2i tmp = new Vector2i();
|
|
||||||
|
|
||||||
if(BlockScreen.hit2pixels(side, bpos, new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
|
@SubscribeEvent
|
||||||
laserClick(te, side, scr, tmp);
|
public void onTick(TickEvent.ClientTickEvent ev) {
|
||||||
}
|
if(ev.phase != TickEvent.Phase.END) return;
|
||||||
|
|
||||||
|
//Help
|
||||||
|
if(InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_F1)) {
|
||||||
|
if(!isF1Down) {
|
||||||
|
isF1Down = true;
|
||||||
|
|
||||||
|
String wikiName = null;
|
||||||
|
if(mc.screen instanceof WDScreen)
|
||||||
|
wikiName = ((WDScreen) mc.screen).getWikiPageName();
|
||||||
|
else if(mc.screen instanceof ContainerScreen) {
|
||||||
|
Slot slot = ((ContainerScreen) mc.screen).getSlotUnderMouse();
|
||||||
|
|
||||||
|
if(slot != null && slot.hasItem() && slot.getItem().getItem() instanceof WDItem)
|
||||||
|
wikiName = ((WDItem) slot.getItem().getItem()).getWikiName(slot.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wikiName != null)
|
||||||
|
mcef.openExampleBrowser("https://montoyo.net/wdwiki/index.php/" + wikiName);
|
||||||
|
}
|
||||||
|
} else if(isF1Down)
|
||||||
|
isF1Down = false;
|
||||||
|
|
||||||
|
//Workaround cuz chat sux
|
||||||
|
if(nextScreen != null && mc.screen == null) {
|
||||||
|
mc.setScreen(nextScreen);
|
||||||
|
nextScreen = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load/unload minePads depending on which item is in the player's hand
|
||||||
|
if(++minePadTickCounter >= 10) {
|
||||||
|
minePadTickCounter = 0;
|
||||||
|
Player ep = mc.player;
|
||||||
|
|
||||||
|
for(PadData pd: padList)
|
||||||
|
pd.isInHotbar = false;
|
||||||
|
|
||||||
|
if(ep != null) {
|
||||||
|
updateInventory(ep.getInventory().items, ep.getItemInHand(InteractionHand.MAIN_HAND), 9);
|
||||||
|
updateInventory(ep.getInventory().offhand, ep.getItemInHand(InteractionHand.OFF_HAND), 1); //Is this okay?
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Check for GuiContainer.draggedStack
|
||||||
|
|
||||||
|
for(int i = padList.size() - 1; i >= 0; i--) {
|
||||||
|
PadData pd = padList.get(i);
|
||||||
|
|
||||||
|
if(!pd.isInHotbar) {
|
||||||
|
pd.view.close();
|
||||||
|
pd.view = null; //This is for GuiMinePad, in case the player dies with the GUI open
|
||||||
|
padList.remove(i);
|
||||||
|
padMap.remove(pd.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Laser pointer raycast
|
||||||
|
if(mc.player != null && mc.level != null && ItemInit.itemLaserPointer.isPresent() && mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.itemLaserPointer.get())
|
||||||
|
&& mc.options.keyUse.isDown()
|
||||||
|
&& (mc.hitResult == null || mc.hitResult.getType() == HitResult.Type.BLOCK || mc.hitResult.getType() == HitResult.Type.MISS)) {
|
||||||
|
laserPointerRenderer.isOn = true;
|
||||||
|
BlockHitResult result = raycast(64.0); //TODO: Make that distance configurable
|
||||||
|
|
||||||
|
BlockPos bpos = result.getBlockPos();
|
||||||
|
|
||||||
|
if(result.getType() == HitResult.Type.BLOCK && mc.level.getBlockState(bpos).getBlock() == BlockInit.blockScreen.get()) {
|
||||||
|
Vector3i pos = new Vector3i(result.getBlockPos());
|
||||||
|
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
|
||||||
|
|
||||||
|
Multiblock.findOrigin(mc.level, pos, side, null);
|
||||||
|
TileEntityScreen te = (TileEntityScreen) mc.level.getBlockEntity(pos.toBlock());
|
||||||
|
|
||||||
|
if(te != null && te.hasUpgrade(side, DefaultUpgrade.LASERMOUSE)) { //hasUpgrade returns false is there's no screen on side 'side'
|
||||||
|
//Since rights aren't synchronized, let the server check them for us...
|
||||||
|
TileEntityScreen.Screen scr = te.getScreen(side);
|
||||||
|
|
||||||
|
if(scr.browser != null) {
|
||||||
|
float hitX = ((float) result.getLocation().x) - (float) bpos.getX();
|
||||||
|
float hitY = ((float) result.getLocation().y) - (float) bpos.getY();
|
||||||
|
float hitZ = ((float) result.getLocation().z) - (float) bpos.getZ();
|
||||||
|
Vector2i tmp = new Vector2i();
|
||||||
|
|
||||||
|
if(BlockScreen.hit2pixels(side, bpos, new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
|
||||||
|
laserClick(te, side, scr, tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
laserPointerRenderer.isOn = false;
|
} else {
|
||||||
deselectScreen();
|
laserPointerRenderer.isOn = false;
|
||||||
|
deselectScreen();
|
||||||
|
|
||||||
//Handle JS queries
|
//Handle JS queries
|
||||||
jsDispatcher.handleQueries();
|
jsDispatcher.handleQueries();
|
||||||
|
|
||||||
//Miniserv
|
//Miniserv
|
||||||
if (msClientStarted && mc.player == null) {
|
if (msClientStarted && mc.player == null) {
|
||||||
msClientStarted = false;
|
msClientStarted = false;
|
||||||
Client.getInstance().stop();
|
Client.getInstance().stop();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ public class GuiKeyboard extends WDScreen {
|
||||||
evStack.add(new TypeData(TypeData.Action.PRESS, keyCode, modifiers));
|
evStack.add(new TypeData(TypeData.Action.PRESS, keyCode, modifiers));
|
||||||
if (!evStack.isEmpty() && !syncRequested())
|
if (!evStack.isEmpty() && !syncRequested())
|
||||||
requestSync();
|
requestSync();
|
||||||
|
sync();
|
||||||
return super.keyPressed(keyCode, scanCode, modifiers);
|
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,6 +166,7 @@ public class GuiKeyboard extends WDScreen {
|
||||||
evStack.add(new TypeData(TypeData.Action.TYPE, codePoint, modifiers));
|
evStack.add(new TypeData(TypeData.Action.TYPE, codePoint, modifiers));
|
||||||
if (!evStack.isEmpty() && !syncRequested())
|
if (!evStack.isEmpty() && !syncRequested())
|
||||||
requestSync();
|
requestSync();
|
||||||
|
sync();
|
||||||
return super.charTyped(codePoint, modifiers);
|
return super.charTyped(codePoint, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,6 +175,7 @@ public class GuiKeyboard extends WDScreen {
|
||||||
evStack.add(new TypeData(TypeData.Action.RELEASE, keyCode, modifiers));
|
evStack.add(new TypeData(TypeData.Action.RELEASE, keyCode, modifiers));
|
||||||
if (!evStack.isEmpty() && !syncRequested())
|
if (!evStack.isEmpty() && !syncRequested())
|
||||||
requestSync();
|
requestSync();
|
||||||
|
sync();
|
||||||
return super.keyPressed(keyCode, scanCode, modifiers);
|
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import net.minecraft.world.level.Level;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.config.CommonConfig;
|
import net.montoyo.wd.config.CommonConfig;
|
||||||
import net.montoyo.wd.core.CraftComponent;
|
import net.montoyo.wd.core.CraftComponent;
|
||||||
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
|
import net.montoyo.wd.net.server_bound.C2SMinepadUrl;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
@ -59,8 +61,15 @@ public class ItemMinePad2 extends Item implements WDItem {
|
||||||
WebDisplays.PROXY.openMinePadGui(is.getTag().getUUID("PadID"));
|
WebDisplays.PROXY.openMinePadGui(is.getTag().getUUID("PadID"));
|
||||||
|
|
||||||
ok = true;
|
ok = true;
|
||||||
} else
|
} else {
|
||||||
ok = false;
|
UUID uuid = UUID.randomUUID();
|
||||||
|
String url = CommonConfig.Browser.homepage;
|
||||||
|
WDNetworkRegistry.INSTANCE.sendToServer(new C2SMinepadUrl(uuid, url));
|
||||||
|
is.getOrCreateTag().putUUID("PadID", uuid);
|
||||||
|
is.getTag().putString("PadURL", url);
|
||||||
|
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
return new InteractionResultHolder<>(ok ? InteractionResult.SUCCESS : InteractionResult.PASS, is);
|
return new InteractionResultHolder<>(ok ? InteractionResult.SUCCESS : InteractionResult.PASS, is);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "webdisplays:keyboard"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "webdisplays:keyboard"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "webdisplays:rctrl"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "webdisplays:redctrl"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "webdisplays:screen"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "webdisplays:server"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user