From 0ed8dba783b65ec8512f2008f034e532d15abe2b Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 29 Jun 2022 21:10:07 -0500 Subject: [PATCH] push for water --- .../montoyo/wd/block/BlockKeyboardLeft.java | 4 +-- .../java/net/montoyo/wd/block/BlockRCTRL.java | 33 +++++++------------ .../net/montoyo/wd/block/BlockRedCTRL.java | 31 +++++++---------- .../net/montoyo/wd/block/BlockScreen.java | 2 +- .../net/montoyo/wd/block/BlockServer.java | 26 +++++---------- .../wd/entity/TileEntityPeripheralBase.java | 7 ++-- .../wd/net/server/SMessageScreenCtrl.java | 6 ++-- 7 files changed, 41 insertions(+), 68 deletions(-) diff --git a/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java b/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java index a7dec1f..a3942cb 100644 --- a/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java +++ b/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java @@ -132,8 +132,8 @@ public class BlockKeyboardLeft extends BlockPeripheral { BlockEntity te = world.getBlockEntity(pos); - if(te instanceof TileEntityPeripheralBase) - return ((TileEntityPeripheralBase) te).onRightClick(player, hand); + if(te instanceof TileEntityKeyboard) + return ((TileEntityKeyboard) te).onRightClick(player, hand); else if(te instanceof TileEntityServer) { ((TileEntityServer) te).onPlayerRightClick(player); return InteractionResult.PASS; diff --git a/src/main/java/net/montoyo/wd/block/BlockRCTRL.java b/src/main/java/net/montoyo/wd/block/BlockRCTRL.java index 2b39ad8..37d9308 100644 --- a/src/main/java/net/montoyo/wd/block/BlockRCTRL.java +++ b/src/main/java/net/montoyo/wd/block/BlockRCTRL.java @@ -20,6 +20,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.DirectionProperty; @@ -32,24 +34,23 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.network.PacketDistributor; +import net.montoyo.mcef.utilities.Log; import net.montoyo.wd.core.DefaultPeripheral; -import net.montoyo.wd.entity.TileEntityInterfaceBase; -import net.montoyo.wd.entity.TileEntityKeyboard; -import net.montoyo.wd.entity.TileEntityPeripheralBase; -import net.montoyo.wd.entity.TileEntityServer; +import net.montoyo.wd.entity.*; import net.montoyo.wd.init.BlockInit; import net.montoyo.wd.item.ItemLinker; import net.montoyo.wd.net.Messages; import net.montoyo.wd.net.client.CMessageCloseGui; import org.jetbrains.annotations.Nullable; -public class BlockRCTRL extends BlockPeripheral { +public class BlockRCTRL extends WDBlockContainer { public static final EnumProperty type = BlockPeripheral.type; public static final DirectionProperty facing = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST); private static final Property[] properties = new Property[] {type, facing}; public BlockRCTRL() { + super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f)); } @Override @@ -95,21 +96,11 @@ public class BlockRCTRL extends BlockPeripheral { // } - /*@Nullable + @Nullable @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - BlockEntityType.BlockEntitySupplier cls = state.getValue(type).getTEClass(); - if(cls == null) - return null; - - try { - return cls.create(pos, state); - } catch(Throwable t) { - Log.errorEx("Couldn't instantiate peripheral TileEntity:", t); - } - - return null; - } */ + return new TileEntityRCtrl(pos, state); + } @Override public RenderShape getRenderShape(BlockState state) { @@ -131,9 +122,9 @@ public class BlockRCTRL extends BlockPeripheral { return InteractionResult.FAIL; BlockEntity te = world.getBlockEntity(pos); - - if(te instanceof TileEntityPeripheralBase) - return ((TileEntityPeripheralBase) te).onRightClick(player, hand); + System.out.println(te); + if(te instanceof TileEntityRCtrl) + return ((TileEntityRCtrl) te).onRightClick(player, hand); else if(te instanceof TileEntityServer) { ((TileEntityServer) te).onPlayerRightClick(player); return InteractionResult.PASS; diff --git a/src/main/java/net/montoyo/wd/block/BlockRedCTRL.java b/src/main/java/net/montoyo/wd/block/BlockRedCTRL.java index 4bfed1c..6abe27a 100644 --- a/src/main/java/net/montoyo/wd/block/BlockRedCTRL.java +++ b/src/main/java/net/montoyo/wd/block/BlockRedCTRL.java @@ -20,6 +20,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.DirectionProperty; @@ -32,24 +34,23 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.network.PacketDistributor; +import net.montoyo.mcef.utilities.Log; import net.montoyo.wd.core.DefaultPeripheral; -import net.montoyo.wd.entity.TileEntityInterfaceBase; -import net.montoyo.wd.entity.TileEntityKeyboard; -import net.montoyo.wd.entity.TileEntityPeripheralBase; -import net.montoyo.wd.entity.TileEntityServer; +import net.montoyo.wd.entity.*; import net.montoyo.wd.init.BlockInit; import net.montoyo.wd.item.ItemLinker; import net.montoyo.wd.net.Messages; import net.montoyo.wd.net.client.CMessageCloseGui; import org.jetbrains.annotations.Nullable; -public class BlockRedCTRL extends BlockPeripheral { +public class BlockRedCTRL extends WDBlockContainer { public static final EnumProperty type = BlockPeripheral.type; public static final DirectionProperty facing = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST); private static final Property[] properties = new Property[] {type, facing}; public BlockRedCTRL() { + super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f)); } @Override @@ -95,21 +96,11 @@ public class BlockRedCTRL extends BlockPeripheral { // } - /*@Nullable + @Nullable @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - BlockEntityType.BlockEntitySupplier cls = state.getValue(type).getTEClass(); - if(cls == null) - return null; - - try { - return cls.create(pos, state); - } catch(Throwable t) { - Log.errorEx("Couldn't instantiate peripheral TileEntity:", t); - } - - return null; - } */ + return new TileEntityRedCtrl(pos, state); + } @Override public RenderShape getRenderShape(BlockState state) { @@ -132,8 +123,8 @@ public class BlockRedCTRL extends BlockPeripheral { BlockEntity te = world.getBlockEntity(pos); - if(te instanceof TileEntityPeripheralBase) - return ((TileEntityPeripheralBase) te).onRightClick(player, hand); + if(te instanceof TileEntityRedCtrl) + return ((TileEntityRedCtrl) te).onRightClick(player, hand); else if(te instanceof TileEntityServer) { ((TileEntityServer) te).onPlayerRightClick(player); return InteractionResult.PASS; diff --git a/src/main/java/net/montoyo/wd/block/BlockScreen.java b/src/main/java/net/montoyo/wd/block/BlockScreen.java index 00ee9df..cda8d6e 100644 --- a/src/main/java/net/montoyo/wd/block/BlockScreen.java +++ b/src/main/java/net/montoyo/wd/block/BlockScreen.java @@ -179,7 +179,7 @@ public class BlockScreen extends BaseEntityBlock { } Vector2i tmp = new Vector2i(); - if(hit2pixels(side, hit.getBlockPos(), pos, scr, (float) hit.getLocation().x, (float) hit.getLocation().y, (float) hit.getLocation().z, tmp)) + if(hit2pixels(side, hit.getBlockPos(), pos, scr, (float) hit.getBlockPos().getX(), (float) hit.getBlockPos().getY(), (float) hit.getBlockPos().getZ(), tmp)) te.click(side, tmp); return InteractionResult.SUCCESS; diff --git a/src/main/java/net/montoyo/wd/block/BlockServer.java b/src/main/java/net/montoyo/wd/block/BlockServer.java index b8723b8..ad03573 100644 --- a/src/main/java/net/montoyo/wd/block/BlockServer.java +++ b/src/main/java/net/montoyo/wd/block/BlockServer.java @@ -20,6 +20,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.DirectionProperty; @@ -32,6 +34,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.network.PacketDistributor; +import net.montoyo.mcef.utilities.Log; import net.montoyo.wd.core.DefaultPeripheral; import net.montoyo.wd.entity.TileEntityInterfaceBase; import net.montoyo.wd.entity.TileEntityKeyboard; @@ -43,13 +46,14 @@ import net.montoyo.wd.net.Messages; import net.montoyo.wd.net.client.CMessageCloseGui; import org.jetbrains.annotations.Nullable; -public class BlockServer extends BlockPeripheral { +public class BlockServer extends WDBlockContainer{ public static final EnumProperty type = BlockPeripheral.type; public static final DirectionProperty facing = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST); private static final Property[] properties = new Property[] {type, facing}; public BlockServer() { + super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f)); } @Override @@ -95,21 +99,11 @@ public class BlockServer extends BlockPeripheral { // } - /*@Nullable + @Nullable @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - BlockEntityType.BlockEntitySupplier cls = state.getValue(type).getTEClass(); - if(cls == null) - return null; - - try { - return cls.create(pos, state); - } catch(Throwable t) { - Log.errorEx("Couldn't instantiate peripheral TileEntity:", t); - } - - return null; - } */ + return new TileEntityServer(pos, state); + } @Override public RenderShape getRenderShape(BlockState state) { @@ -132,9 +126,7 @@ public class BlockServer extends BlockPeripheral { BlockEntity te = world.getBlockEntity(pos); - if(te instanceof TileEntityPeripheralBase) - return ((TileEntityPeripheralBase) te).onRightClick(player, hand); - else if(te instanceof TileEntityServer) { + if(te instanceof TileEntityServer) { ((TileEntityServer) te).onPlayerRightClick(player); return InteractionResult.PASS; } else diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java b/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java index 5144e08..843002b 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java +++ b/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java @@ -139,11 +139,10 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP return screenSide; } - public InteractionResult onRightClick(Player player, InteractionHand hand) { - return InteractionResult.PASS; - } - public void onNeighborChange(Block neighborType, BlockPos neighborPos) { } + public InteractionResult onRightClick(Player player, InteractionHand hand) { + return InteractionResult.PASS; + } } diff --git a/src/main/java/net/montoyo/wd/net/server/SMessageScreenCtrl.java b/src/main/java/net/montoyo/wd/net/server/SMessageScreenCtrl.java index 6052027..aa23bf1 100644 --- a/src/main/java/net/montoyo/wd/net/server/SMessageScreenCtrl.java +++ b/src/main/java/net/montoyo/wd/net/server/SMessageScreenCtrl.java @@ -292,9 +292,9 @@ public class SMessageScreenCtrl implements Runnable { return; //Out of range (player reach distance) BlockState bs = world.getBlockState(blockPos); - if(bs.getBlock() != BlockInit.blockServer.get() || bs.getBlock() != BlockInit.blockRControl.get() || - bs.getBlock() != BlockInit.blockKeyBoard.get() || bs.getBlock() != BlockInit.blockRedControl.get() - || bs.getValue(BlockPeripheral.type) != DefaultPeripheral.REMOTE_CONTROLLER) + if(bs.getBlock() != BlockInit.blockServer.get() && bs.getBlock() != BlockInit.blockRControl.get() && + bs.getBlock() != BlockInit.blockKeyBoard.get() && bs.getBlock() != BlockInit.blockRedControl.get() + && bs.getValue(BlockPeripheral.type) != DefaultPeripheral.REMOTE_CONTROLLER) return; //I call it hax... } else if(player.shouldRenderAtSqrDistance(player.distanceToSqr(bp.getX(), bp.getY(), bp.getZ()))) return; //Out of range (range problem)