push for water

This commit is contained in:
Mysticpasta1 2022-06-29 21:10:07 -05:00
parent 1e6dc60724
commit 0ed8dba783
7 changed files with 41 additions and 68 deletions

View File

@ -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;

View File

@ -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<DefaultPeripheral> 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<? extends BlockEntity> 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;

View File

@ -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<DefaultPeripheral> 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<? extends BlockEntity> 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;

View File

@ -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;

View File

@ -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<DefaultPeripheral> 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<? extends BlockEntity> 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

View File

@ -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;
}
}

View File

@ -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)