modernize naming pt1

This commit is contained in:
GiantLuigi4 2023-11-10 23:58:05 -05:00
parent a2f81aeeac
commit a4b4162fa9
14 changed files with 56 additions and 56 deletions

View File

@ -32,7 +32,7 @@ import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
import org.jetbrains.annotations.NotNull;
public class BlockKeyboardLeft extends BlockPeripheral {
public class KeyboardBlockLeft extends PeripheralBlock {
public static final EnumProperty<DefaultPeripheral> TYPE = EnumProperty.create("type", DefaultPeripheral.class);
public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST);
// public static final DirectionProperty HALF = DirectionProperty.create("facing", Direction.EAST, Direction.WEST);
@ -46,22 +46,22 @@ public class BlockKeyboardLeft extends BlockPeripheral {
private static final Property<?>[] properties = new Property<?>[] {TYPE, FACING};
public BlockKeyboardLeft() {
public KeyboardBlockLeft() {
super(DefaultPeripheral.KEYBOARD);
}
// TODO: make non static (for extensibility purposes)
public static KeyboardBlockEntity getTileEntity(BlockState state, Level world, BlockPos pos) {
if (state.getBlock() instanceof BlockKeyboardLeft) {
if (state.getBlock() instanceof KeyboardBlockLeft) {
BlockEntity te = world.getBlockEntity(pos); // TODO: check?
if (te instanceof KeyboardBlockEntity)
return (KeyboardBlockEntity) te;
}
BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING).getOpposite()));
BlockPos relative = pos.relative(KeyboardBlockLeft.mapDirection(state.getValue(FACING).getOpposite()));
BlockState ns = world.getBlockState(relative);
if (ns.getBlock() instanceof BlockPeripheral) {
if (ns.getBlock() instanceof PeripheralBlock) {
BlockEntity te = world.getBlockEntity(relative); // TODO: check?
if (te instanceof KeyboardBlockEntity)
return (KeyboardBlockEntity) te;
@ -89,7 +89,7 @@ public class BlockKeyboardLeft extends BlockPeripheral {
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
double rpos = (entity.getY() - ((double) pos.getY())) * 16.0;
if (!world.isClientSide && rpos >= 1.0 && rpos <= 2.0 && Math.random() < 0.25) {
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, world, pos);
KeyboardBlockEntity tek = KeyboardBlockLeft.getTileEntity(state, world, pos);
if (tek != null)
tek.simulateCat(entity);
@ -101,7 +101,7 @@ public class BlockKeyboardLeft extends BlockPeripheral {
if (player.getItemInHand(hand).getItem() instanceof ItemLinker)
return InteractionResult.PASS;
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, level, pos);
KeyboardBlockEntity tek = KeyboardBlockLeft.getTileEntity(state, level, pos);
if (tek != null)
return tek.onRightClick(player, hand);
@ -119,10 +119,10 @@ public class BlockKeyboardLeft extends BlockPeripheral {
}
private static void removeRightPiece(BlockState state, Level world, BlockPos pos) {
BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING)));
BlockPos relative = pos.relative(KeyboardBlockLeft.mapDirection(state.getValue(FACING)));
BlockState ns = world.getBlockState(relative);
if (ns.getBlock() instanceof BlockKeyboardRight)
if (ns.getBlock() instanceof KeyboardBlockRight)
world.setBlock(relative, Blocks.AIR.defaultBlockState(), 3);
}

View File

@ -31,23 +31,23 @@ import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Vector3i;
import org.jetbrains.annotations.NotNull;
import static net.montoyo.wd.block.BlockKeyboardLeft.KEYBOARD_AABBS;
import static net.montoyo.wd.block.BlockPeripheral.point;
import static net.montoyo.wd.block.KeyboardBlockLeft.KEYBOARD_AABBS;
import static net.montoyo.wd.block.PeripheralBlock.point;
// TODO: merge into KeyboardLeft
public class BlockKeyboardRight extends Block implements IPeripheral {
public class KeyboardBlockRight extends Block implements IPeripheral {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public BlockKeyboardRight() {
public KeyboardBlockRight() {
super(Properties.copy(Blocks.STONE)
.strength(1.5f, 10.f));
}
private static void removeLeftPiece(BlockState state, Level world, BlockPos pos) {
BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING).getOpposite()));
BlockPos relative = pos.relative(KeyboardBlockLeft.mapDirection(state.getValue(FACING).getOpposite()));
BlockState ns = world.getBlockState(relative);
if (ns.getBlock() instanceof BlockKeyboardLeft)
if (ns.getBlock() instanceof KeyboardBlockLeft)
world.setBlock(relative, Blocks.AIR.defaultBlockState(), 3);
}
@ -82,7 +82,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
@Override
public boolean connect(Level world, BlockPos pos, BlockState state, Vector3i scrPos, BlockSide scrSide) {
KeyboardBlockEntity keyboard = BlockKeyboardLeft.getTileEntity(state, world, pos);
KeyboardBlockEntity keyboard = KeyboardBlockLeft.getTileEntity(state, world, pos);
return keyboard != null && keyboard.connect(world, pos, state, scrPos, scrSide);
}
@ -90,7 +90,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
double rpos = (entity.getY() - ((double) pos.getY())) * 16.0;
if (!world.isClientSide && rpos >= 1.0 && rpos <= 2.0 && Math.random() < 0.25) {
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, world, pos);
KeyboardBlockEntity tek = KeyboardBlockLeft.getTileEntity(state, world, pos);
if (tek != null)
tek.simulateCat(entity);
@ -102,7 +102,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
if (player.getItemInHand(hand).getItem() instanceof ItemLinker)
return InteractionResult.PASS;
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, level, pos);
KeyboardBlockEntity tek = KeyboardBlockLeft.getTileEntity(state, level, pos);
if (tek != null)
return tek.onRightClick(player, hand);

View File

@ -37,10 +37,10 @@ import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
import net.montoyo.wd.utilities.Log;
import org.jetbrains.annotations.Nullable;
public class BlockPeripheral extends WDBlockContainer {
public class PeripheralBlock extends WDContainerBlock {
DefaultPeripheral type;
public BlockPeripheral(DefaultPeripheral type) {
public PeripheralBlock(DefaultPeripheral type) {
super(BlockBehaviour.Properties.copy(Blocks.STONE).strength(1.5f, 10.f));
this.type = type;
}

View File

@ -37,12 +37,12 @@ import net.montoyo.wd.item.ItemLaserPointer;
import net.montoyo.wd.utilities.*;
import org.jetbrains.annotations.NotNull;
public class BlockScreen extends BaseEntityBlock {
public class ScreenBlock extends BaseEntityBlock {
public static final BooleanProperty hasTE = BooleanProperty.create("haste");
public static final BooleanProperty emitting = BooleanProperty.create("emitting");
private static final Property<?>[] properties = new Property<?>[]{hasTE, emitting};
public BlockScreen(Properties properties) {
public ScreenBlock(Properties properties) {
super(properties.strength(1.5f, 10.f));
this.registerDefaultState(this.defaultBlockState().setValue(hasTE, false).setValue(emitting, false));
}
@ -289,7 +289,7 @@ public class BlockScreen extends BaseEntityBlock {
neighbors[5] = new Vector3i(pos.getX(), pos.getY(), pos.getZ() - 1);
for (Vector3i neighbor : neighbors) {
if (world.getBlockState(neighbor.toBlock()).getBlock() instanceof BlockScreen) {
if (world.getBlockState(neighbor.toBlock()).getBlock() instanceof ScreenBlock) {
for (BlockSide bs : BlockSide.values())
destroySide(world, neighbor.clone(), bs, override, (whoDidThisShit instanceof Player) ? ((Player) whoDidThisShit) : null);
}

View File

@ -7,11 +7,11 @@ package net.montoyo.wd.block;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.BaseEntityBlock;
public abstract class WDBlockContainer extends BaseEntityBlock {
public abstract class WDContainerBlock extends BaseEntityBlock {
protected static BlockItem itemBlock;
public WDBlockContainer(Properties arg) {
public WDContainerBlock(Properties arg) {
super(arg);
}

View File

@ -7,7 +7,7 @@ import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.block.BlockKeyboardLeft;
import net.montoyo.wd.block.KeyboardBlockLeft;
import net.montoyo.wd.registry.BlockRegistry;
public class KeyboardItem extends BlockItem {
@ -18,15 +18,15 @@ public class KeyboardItem extends BlockItem {
@Override
protected boolean placeBlock(BlockPlaceContext arg, BlockState arg2) {
Direction facing = arg.getHorizontalDirection();
arg2 = arg2.setValue(BlockKeyboardLeft.FACING, facing);
arg2 = arg2.setValue(KeyboardBlockLeft.FACING, facing);
Direction d = BlockKeyboardLeft.mapDirection(facing);
Direction d = KeyboardBlockLeft.mapDirection(facing);
if (isValid(arg.getClickedPos(), arg.getLevel(), arg2, d)) {
Block kbRight = BlockRegistry.blockKbRight.get();
BlockState rightState = kbRight.defaultBlockState();
rightState = rightState.setValue(BlockKeyboardLeft.FACING, facing);
rightState = rightState.setValue(KeyboardBlockLeft.FACING, facing);
if (!arg.getLevel().setBlock(
arg.getClickedPos().relative(d),
rightState,
@ -37,7 +37,7 @@ public class KeyboardItem extends BlockItem {
Block kbRight = BlockRegistry.blockKbRight.get();
BlockState rightState = kbRight.defaultBlockState();
rightState = rightState.setValue(BlockKeyboardLeft.FACING, facing);
rightState = rightState.setValue(KeyboardBlockLeft.FACING, facing);
if (!arg.getLevel().setBlock(
arg.getClickedPos(),
rightState,

View File

@ -58,7 +58,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.network.NetworkEvent;
import net.montoyo.wd.SharedProxy;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.client.gui.*;
import net.montoyo.wd.client.gui.loading.GuiLoader;
import net.montoyo.wd.client.renderers.*;
@ -898,7 +898,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
public static void onDrawSelection(RenderHighlightEvent event) {
if (event.getTarget() instanceof BlockHitResult bhr) {
BlockState state = Minecraft.getInstance().level.getBlockState(bhr.getBlockPos());
if (state.getBlock() instanceof BlockScreen screen) {
if (state.getBlock() instanceof ScreenBlock screen) {
Vector3i vec = new Vector3i(bhr.getBlockPos().getX(), bhr.getBlockPos().getY(), bhr.getBlockPos().getZ());
BlockSide side = BlockSide.fromInt(bhr.getDirection().ordinal());
Multiblock.findOrigin(

View File

@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.network.PacketDistributor;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.client.ClientProxy;
import net.montoyo.wd.config.CommonConfig;
import net.montoyo.wd.controls.builtin.ClickControl;
@ -51,7 +51,7 @@ import java.util.List;
import java.util.UUID;
import java.util.function.Consumer;
import static net.montoyo.wd.block.BlockPeripheral.point;
import static net.montoyo.wd.block.PeripheralBlock.point;
public class ScreenBlockEntity extends BlockEntity {
public ScreenBlockEntity(BlockPos arg2, BlockState arg3) {
@ -481,7 +481,7 @@ public class ScreenBlockEntity extends BlockEntity {
if (!level.isClientSide) {
if (screens.isEmpty()) //No more screens: remove tile entity
level.setBlockAndUpdate(getBlockPos(), BlockRegistry.SCREEN_BLOCk.get().defaultBlockState().setValue(BlockScreen.hasTE, false));
level.setBlockAndUpdate(getBlockPos(), BlockRegistry.SCREEN_BLOCk.get().defaultBlockState().setValue(ScreenBlock.hasTE, false));
else
setChanged();
}

View File

@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.client.ClientProxy;
import net.montoyo.wd.config.ClientConfig;
import net.montoyo.wd.controls.builtin.ClickControl;
@ -69,7 +69,7 @@ public class ItemLaserPointer extends Item implements WDItem {
float hitZ = ((float) result.getLocation().z) - (float) pos.z;
Vector2i tmp = new Vector2i();
if (BlockScreen.hit2pixels(side, bpos, new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
if (ScreenBlock.hit2pixels(side, bpos, new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
laserClick(te, side, scr, tmp);
}
}
@ -135,7 +135,7 @@ public class ItemLaserPointer extends Item implements WDItem {
ScreenBlockEntity.Screen scr = te.getScreen(side);
if (scr.browser != null) {
if (BlockScreen.hit2pixels(side, result.getBlockPos(), new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
if (ScreenBlock.hit2pixels(side, result.getBlockPos(), new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
te.handleMouseEvent(side, ClickControl.ControlType.MOVE, tmp, -1);
te.handleMouseEvent(side, press ? ClickControl.ControlType.DOWN : ClickControl.ControlType.UP, tmp, button);

View File

@ -14,7 +14,7 @@ import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.core.IPeripheral;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.entity.ScreenBlockEntity;
@ -80,7 +80,7 @@ public class ItemLinker extends Item implements WDItem {
}
}
if (!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof BlockScreen)) {
if (!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof ScreenBlock)) {
Util.toast(context.getPlayer(), "notAScreen");
return InteractionResult.SUCCESS;
}

View File

@ -12,7 +12,7 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.config.CommonConfig;
import net.montoyo.wd.entity.ScreenBlockEntity;
import net.montoyo.wd.utilities.*;
@ -50,7 +50,7 @@ public class ItemOwnershipThief extends Item implements WDItem {
BlockPos bp = new BlockPos(tag.getInt("PosX"), tag.getInt("PosY"), tag.getInt("PosZ"));
BlockSide side = BlockSide.values()[tag.getByte("Side")];
if (!(context.getLevel().getBlockState(bp).getBlock() instanceof BlockScreen))
if (!(context.getLevel().getBlockState(bp).getBlock() instanceof ScreenBlock))
return InteractionResult.SUCCESS;
BlockEntity te = context.getLevel().getBlockEntity(bp);
@ -70,7 +70,7 @@ public class ItemOwnershipThief extends Item implements WDItem {
}
}
if (!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof BlockScreen))
if (!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof ScreenBlock))
return InteractionResult.SUCCESS;
Vector3i pos = new Vector3i(context.getClickedPos());

View File

@ -10,7 +10,7 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.data.ScreenConfigData;
import net.montoyo.wd.entity.ScreenBlockEntity;
import net.montoyo.wd.utilities.BlockSide;
@ -29,7 +29,7 @@ public class ItemScreenConfigurator extends Item implements WDItem {
@Override
public InteractionResult useOn(UseOnContext context) {
if (context.getPlayer().isShiftKeyDown() || !(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof BlockScreen))
if (context.getPlayer().isShiftKeyDown() || !(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof ScreenBlock))
return InteractionResult.PASS;
if (context.getLevel().isClientSide)

View File

@ -17,7 +17,7 @@ import net.montoyo.wd.utilities.*;
import java.io.IOException;
import java.util.ArrayList;
import static net.montoyo.wd.block.BlockScreen.hasTE;
import static net.montoyo.wd.block.ScreenBlock.hasTE;
public class S2CMessageAddScreen extends Packet {
private boolean clear;

View File

@ -7,10 +7,10 @@ import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.montoyo.wd.block.BlockKeyboardLeft;
import net.montoyo.wd.block.BlockKeyboardRight;
import net.montoyo.wd.block.BlockPeripheral;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.block.KeyboardBlockLeft;
import net.montoyo.wd.block.KeyboardBlockRight;
import net.montoyo.wd.block.PeripheralBlock;
import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.core.DefaultPeripheral;
public class BlockRegistry {
@ -20,12 +20,12 @@ public class BlockRegistry {
public static DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "webdisplays");
public static final RegistryObject<BlockScreen> SCREEN_BLOCk = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.copy(Blocks.STONE)));
public static final RegistryObject<ScreenBlock> SCREEN_BLOCk = BLOCKS.register("screen", () -> new ScreenBlock(BlockBehaviour.Properties.copy(Blocks.STONE)));
public static final RegistryObject<BlockKeyboardLeft> KEYBOARD_BLOCK = BlockRegistry.BLOCKS.register("kb_left", BlockKeyboardLeft::new);
public static final RegistryObject<BlockKeyboardRight> blockKbRight = BLOCKS.register("kb_right", BlockKeyboardRight::new);
public static final RegistryObject<KeyboardBlockLeft> KEYBOARD_BLOCK = BlockRegistry.BLOCKS.register("kb_left", KeyboardBlockLeft::new);
public static final RegistryObject<KeyboardBlockRight> blockKbRight = BLOCKS.register("kb_right", KeyboardBlockRight::new);
public static final RegistryObject<BlockPeripheral> REDSTONE_CONTROL_BLOCK = BlockRegistry.BLOCKS.register("redctrl", () -> new BlockPeripheral(DefaultPeripheral.REDSTONE_CONTROLLER));
public static final RegistryObject<BlockPeripheral> REMOTE_CONTROLLER_BLOCK = BlockRegistry.BLOCKS.register("rctrl", () -> new BlockPeripheral(DefaultPeripheral.REMOTE_CONTROLLER));
public static final RegistryObject<BlockPeripheral> SERVER_BLOCK = BlockRegistry.BLOCKS.register("server", () -> new BlockPeripheral(DefaultPeripheral.SERVER));
public static final RegistryObject<PeripheralBlock> REDSTONE_CONTROL_BLOCK = BlockRegistry.BLOCKS.register("redctrl", () -> new PeripheralBlock(DefaultPeripheral.REDSTONE_CONTROLLER));
public static final RegistryObject<PeripheralBlock> REMOTE_CONTROLLER_BLOCK = BlockRegistry.BLOCKS.register("rctrl", () -> new PeripheralBlock(DefaultPeripheral.REMOTE_CONTROLLER));
public static final RegistryObject<PeripheralBlock> SERVER_BLOCK = BlockRegistry.BLOCKS.register("server", () -> new PeripheralBlock(DefaultPeripheral.SERVER));
}