From a2f81aeeac18a59def467c50c88a49e524f8f6e9 Mon Sep 17 00:00:00 2001 From: GiantLuigi4 <49770992+GiantLuigi4@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:57:02 -0500 Subject: [PATCH] modernize naming pt0 --- src/main/java/net/montoyo/wd/SharedProxy.java | 5 ++- .../montoyo/wd/block/BlockKeyboardLeft.java | 16 ++++----- .../montoyo/wd/block/BlockKeyboardRight.java | 8 ++--- .../net/montoyo/wd/block/BlockPeripheral.java | 26 +++++++------- .../net/montoyo/wd/block/BlockScreen.java | 18 +++++----- .../net/montoyo/wd/client/ClientProxy.java | 26 +++++++------- .../montoyo/wd/client/gui/GuiKeyboard.java | 6 ++-- .../wd/client/gui/GuiScreenConfig.java | 10 +++--- .../net/montoyo/wd/client/gui/GuiSetURL2.java | 8 ++--- .../wd/client/renderers/ScreenRenderer.java | 13 ++++--- .../montoyo/wd/controls/ScreenControl.java | 6 ++-- .../wd/controls/ScreenControlRegistry.java | 4 +-- .../controls/builtin/AutoVolumeControl.java | 6 ++-- .../wd/controls/builtin/ClickControl.java | 6 ++-- .../wd/controls/builtin/JSRequestControl.java | 7 ++-- .../wd/controls/builtin/KeyTypedControl.java | 6 ++-- .../wd/controls/builtin/LaserControl.java | 6 ++-- .../ManageRightsAndUpdgradesControl.java | 10 +++--- .../builtin/ModifyFriendListControl.java | 6 ++-- .../wd/controls/builtin/OwnerControl.java | 6 ++-- .../controls/builtin/ScreenModifyControl.java | 6 ++-- .../wd/controls/builtin/SetURLControl.java | 6 ++-- .../wd/controls/builtin/TurnOffControl.java | 7 ++-- .../montoyo/wd/core/DefaultPeripheral.java | 16 ++++----- .../java/net/montoyo/wd/core/IUpgrade.java | 6 ++-- .../net/montoyo/wd/data/KeyboardData.java | 8 ++--- .../net/montoyo/wd/data/ScreenConfigData.java | 8 ++--- .../java/net/montoyo/wd/data/SetURLData.java | 6 ++-- ...java => AbstractInterfaceBlockEntity.java} | 30 ++++++++-------- ...ava => AbstractPeripheralBlockEntity.java} | 20 +++++------ ...rface.java => CCInterfaceBlockEntity.java} | 7 ++-- ...Keyboard.java => KeyboardBlockEntity.java} | 12 +++---- ...rface.java => OCInterfaceBlockEntity.java} | 4 +-- ...l.java => RedstoneControlBlockEntity.java} | 10 +++--- ...trl.java => RemoteControlBlockEntity.java} | 8 ++--- ...tityScreen.java => ScreenBlockEntity.java} | 6 ++-- ...tityServer.java => ServerBlockEntity.java} | 4 +-- .../net/montoyo/wd/item/ItemLaserPointer.java | 16 ++++----- .../java/net/montoyo/wd/item/ItemLinker.java | 6 ++-- .../montoyo/wd/item/ItemOwnershipThief.java | 13 ++++--- .../wd/item/ItemScreenConfigurator.java | 7 ++-- .../java/net/montoyo/wd/item/ItemUpgrade.java | 7 ++-- .../net/client_bound/S2CMessageAddScreen.java | 30 ++++++++-------- .../client_bound/S2CMessageScreenUpdate.java | 20 +++++------ .../server_bound/C2SMessageRedstoneCtrl.java | 10 +++--- .../server_bound/C2SMessageScreenCtrl.java | 36 +++++++++---------- .../net/montoyo/wd/registry/TileRegistry.java | 12 +++---- 47 files changed, 256 insertions(+), 264 deletions(-) rename src/main/java/net/montoyo/wd/entity/{TileEntityInterfaceBase.java => AbstractInterfaceBlockEntity.java} (92%) rename src/main/java/net/montoyo/wd/entity/{TileEntityPeripheralBase.java => AbstractPeripheralBlockEntity.java} (85%) rename src/main/java/net/montoyo/wd/entity/{TileEntityCCInterface.java => CCInterfaceBlockEntity.java} (90%) rename src/main/java/net/montoyo/wd/entity/{TileEntityKeyboard.java => KeyboardBlockEntity.java} (86%) rename src/main/java/net/montoyo/wd/entity/{TileEntityOCInterface.java => OCInterfaceBlockEntity.java} (97%) rename src/main/java/net/montoyo/wd/entity/{TileEntityRedCtrl.java => RedstoneControlBlockEntity.java} (90%) rename src/main/java/net/montoyo/wd/entity/{TileEntityRCtrl.java => RemoteControlBlockEntity.java} (83%) rename src/main/java/net/montoyo/wd/entity/{TileEntityScreen.java => ScreenBlockEntity.java} (99%) rename src/main/java/net/montoyo/wd/entity/{TileEntityServer.java => ServerBlockEntity.java} (92%) diff --git a/src/main/java/net/montoyo/wd/SharedProxy.java b/src/main/java/net/montoyo/wd/SharedProxy.java index 899f91a..b828642 100644 --- a/src/main/java/net/montoyo/wd/SharedProxy.java +++ b/src/main/java/net/montoyo/wd/SharedProxy.java @@ -14,13 +14,12 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.server.ServerLifecycleHooks; import net.montoyo.wd.core.HasAdvancement; import net.montoyo.wd.core.JSServerRequest; import net.montoyo.wd.data.GuiData; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.*; import javax.annotation.Nonnull; @@ -58,7 +57,7 @@ public class SharedProxy { Log.error("Called SharedProxy.displayGui() on server side..."); } - public void trackScreen(TileEntityScreen tes, boolean track) { + public void trackScreen(ScreenBlockEntity tes, boolean track) { } public void onAutocompleteResult(NameUUIDPair pairs[]) { diff --git a/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java b/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java index d33d15f..53d3f0a 100644 --- a/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java +++ b/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java @@ -26,7 +26,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.network.PacketDistributor; import net.montoyo.wd.core.DefaultPeripheral; -import net.montoyo.wd.entity.TileEntityKeyboard; +import net.montoyo.wd.entity.KeyboardBlockEntity; import net.montoyo.wd.item.ItemLinker; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.client_bound.S2CMessageCloseGui; @@ -51,11 +51,11 @@ public class BlockKeyboardLeft extends BlockPeripheral { } // TODO: make non static (for extensibility purposes) - public static TileEntityKeyboard getTileEntity(BlockState state, Level world, BlockPos pos) { + public static KeyboardBlockEntity getTileEntity(BlockState state, Level world, BlockPos pos) { if (state.getBlock() instanceof BlockKeyboardLeft) { BlockEntity te = world.getBlockEntity(pos); // TODO: check? - if (te instanceof TileEntityKeyboard) - return (TileEntityKeyboard) te; + if (te instanceof KeyboardBlockEntity) + return (KeyboardBlockEntity) te; } BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING).getOpposite())); @@ -63,8 +63,8 @@ public class BlockKeyboardLeft extends BlockPeripheral { if (ns.getBlock() instanceof BlockPeripheral) { BlockEntity te = world.getBlockEntity(relative); // TODO: check? - if (te instanceof TileEntityKeyboard) - return (TileEntityKeyboard) te; + if (te instanceof KeyboardBlockEntity) + return (KeyboardBlockEntity) te; } return null; @@ -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) { - TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, world, pos); + KeyboardBlockEntity tek = BlockKeyboardLeft.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; - TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, level, pos); + KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, level, pos); if (tek != null) return tek.onRightClick(player, hand); diff --git a/src/main/java/net/montoyo/wd/block/BlockKeyboardRight.java b/src/main/java/net/montoyo/wd/block/BlockKeyboardRight.java index 4498563..06b75f5 100644 --- a/src/main/java/net/montoyo/wd/block/BlockKeyboardRight.java +++ b/src/main/java/net/montoyo/wd/block/BlockKeyboardRight.java @@ -23,7 +23,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.network.PacketDistributor; import net.montoyo.wd.core.IPeripheral; -import net.montoyo.wd.entity.TileEntityKeyboard; +import net.montoyo.wd.entity.KeyboardBlockEntity; import net.montoyo.wd.item.ItemLinker; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.client_bound.S2CMessageCloseGui; @@ -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) { - TileEntityKeyboard keyboard = BlockKeyboardLeft.getTileEntity(state, world, pos); + KeyboardBlockEntity keyboard = BlockKeyboardLeft.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) { - TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, world, pos); + KeyboardBlockEntity tek = BlockKeyboardLeft.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; - TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, level, pos); + KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, level, pos); if (tek != null) return tek.onRightClick(player, hand); diff --git a/src/main/java/net/montoyo/wd/block/BlockPeripheral.java b/src/main/java/net/montoyo/wd/block/BlockPeripheral.java index dd8eecb..5c7f23f 100644 --- a/src/main/java/net/montoyo/wd/block/BlockPeripheral.java +++ b/src/main/java/net/montoyo/wd/block/BlockPeripheral.java @@ -28,9 +28,9 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.network.PacketDistributor; import net.montoyo.wd.core.DefaultPeripheral; -import net.montoyo.wd.entity.TileEntityInterfaceBase; -import net.montoyo.wd.entity.TileEntityPeripheralBase; -import net.montoyo.wd.entity.TileEntityServer; +import net.montoyo.wd.entity.AbstractInterfaceBlockEntity; +import net.montoyo.wd.entity.AbstractPeripheralBlockEntity; +import net.montoyo.wd.entity.ServerBlockEntity; import net.montoyo.wd.item.ItemLinker; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.client_bound.S2CMessageCloseGui; @@ -76,10 +76,10 @@ public class BlockPeripheral extends WDBlockContainer { BlockEntity te = world.getBlockEntity(pos); - if (te instanceof TileEntityPeripheralBase) - return ((TileEntityPeripheralBase) te).onRightClick(player, hand); - else if (te instanceof TileEntityServer) { - ((TileEntityServer) te).onPlayerRightClick(player); + if (te instanceof AbstractPeripheralBlockEntity) + return ((AbstractPeripheralBlockEntity) te).onRightClick(player, hand); + else if (te instanceof ServerBlockEntity) { + ((ServerBlockEntity) te).onPlayerRightClick(player); return InteractionResult.SUCCESS; } else return InteractionResult.FAIL; @@ -98,10 +98,10 @@ public class BlockPeripheral extends WDBlockContainer { if (placer instanceof Player) { BlockEntity te = world.getBlockEntity(pos); - if (te instanceof TileEntityServer) - ((TileEntityServer) te).setOwner((Player) placer); - else if (te instanceof TileEntityInterfaceBase) - ((TileEntityInterfaceBase) te).setOwner((Player) placer); + if (te instanceof ServerBlockEntity) + ((ServerBlockEntity) te).setOwner((Player) placer); + else if (te instanceof AbstractInterfaceBlockEntity) + ((AbstractInterfaceBlockEntity) te).setOwner((Player) placer); } } @@ -113,8 +113,8 @@ public class BlockPeripheral extends WDBlockContainer { @Override public void neighborChanged(BlockState state, Level world, BlockPos pos, Block neighborType, BlockPos neighbor, boolean isMoving) { BlockEntity te = world.getBlockEntity(pos); - if (te instanceof TileEntityPeripheralBase) - ((TileEntityPeripheralBase) te).onNeighborChange(neighborType, neighbor); + if (te instanceof AbstractPeripheralBlockEntity) + ((AbstractPeripheralBlockEntity) te).onNeighborChange(neighborType, neighbor); } @Override diff --git a/src/main/java/net/montoyo/wd/block/BlockScreen.java b/src/main/java/net/montoyo/wd/block/BlockScreen.java index a992e1c..8d96ff0 100644 --- a/src/main/java/net/montoyo/wd/block/BlockScreen.java +++ b/src/main/java/net/montoyo/wd/block/BlockScreen.java @@ -32,7 +32,7 @@ import net.montoyo.wd.core.DefaultUpgrade; import net.montoyo.wd.core.IUpgrade; import net.montoyo.wd.core.ScreenRights; import net.montoyo.wd.data.SetURLData; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.item.ItemLaserPointer; import net.montoyo.wd.utilities.*; import org.jetbrains.annotations.NotNull; @@ -92,10 +92,10 @@ public class BlockScreen extends BaseEntityBlock { BlockSide side = BlockSide.values()[hit.getDirection().ordinal()]; Multiblock.findOrigin(world, pos, side, null); - TileEntityScreen te = (TileEntityScreen) world.getBlockEntity(pos.toBlock()); + ScreenBlockEntity te = (ScreenBlockEntity) world.getBlockEntity(pos.toBlock()); if (te != null && te.getScreen(side) != null) { - TileEntityScreen.Screen scr = te.getScreen(side); + ScreenBlockEntity.Screen scr = te.getScreen(side); if (sneaking) { //Right Click if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) @@ -168,7 +168,7 @@ public class BlockScreen extends BaseEntityBlock { if (te == null) { BlockPos bp = pos.toBlock(); world.setBlockAndUpdate(bp, world.getBlockState(bp).setValue(hasTE, true)); - te = (TileEntityScreen) world.getBlockEntity(bp); + te = (ScreenBlockEntity) world.getBlockEntity(bp); created = true; } @@ -184,7 +184,7 @@ public class BlockScreen extends BaseEntityBlock { Vector3i vec = new Vector3i(pos); Multiblock.findOrigin(world, vec, side, null); - TileEntityScreen tes = (TileEntityScreen) world.getBlockEntity(vec.toBlock()); + ScreenBlockEntity tes = (ScreenBlockEntity) 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(); @@ -194,7 +194,7 @@ public class BlockScreen extends BaseEntityBlock { } } - 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, ScreenBlockEntity.Screen scr, float hitX, float hitY, float hitZ, Vector2i dst) { Vector3f rel = new Vector3f(hitX, hitY, hitZ); // how these dot products come in is beyond me @@ -259,8 +259,8 @@ public class BlockScreen extends BaseEntityBlock { BlockPos bp = pos.toBlock(); BlockEntity te = world.getBlockEntity(bp); - if (te instanceof TileEntityScreen) { - ((TileEntityScreen) te).onDestroy(source); + if (te instanceof ScreenBlockEntity) { + ((ScreenBlockEntity) te).onDestroy(source); world.setBlock(bp, world.getBlockState(bp).setValue(hasTE, false), Block.UPDATE_ALL_IMMEDIATE); //Destroy tile entity. } } @@ -315,7 +315,7 @@ public class BlockScreen extends BaseEntityBlock { @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return state.getValue(hasTE) ? new TileEntityScreen(pos, state) : null; + return state.getValue(hasTE) ? new ScreenBlockEntity(pos, state) : null; } @Override diff --git a/src/main/java/net/montoyo/wd/client/ClientProxy.java b/src/main/java/net/montoyo/wd/client/ClientProxy.java index 5106536..f35f436 100644 --- a/src/main/java/net/montoyo/wd/client/ClientProxy.java +++ b/src/main/java/net/montoyo/wd/client/ClientProxy.java @@ -64,7 +64,7 @@ import net.montoyo.wd.client.gui.loading.GuiLoader; import net.montoyo.wd.client.renderers.*; import net.montoyo.wd.core.HasAdvancement; import net.montoyo.wd.data.GuiData; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.registry.BlockRegistry; import net.montoyo.wd.registry.ItemRegistry; import net.montoyo.wd.registry.TileRegistry; @@ -157,9 +157,9 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS BlockSide side = BlockSide.values()[result.getDirection().ordinal()]; Multiblock.findOrigin(mc.level, pos, side, null); - TileEntityScreen te = (TileEntityScreen) mc.level.getBlockEntity(pos.toBlock()); + ScreenBlockEntity te = (ScreenBlockEntity) mc.level.getBlockEntity(pos.toBlock()); - TileEntityScreen.Screen sc = te.getScreen(side); + ScreenBlockEntity.Screen sc = te.getScreen(side); if (sc == null) return; @@ -191,7 +191,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS private PadData(String url, UUID id) { String webUrl; try { - webUrl = TileEntityScreen.url(url); + webUrl = ScreenBlockEntity.url(url); } catch (IOException e) { throw new RuntimeException(e); } @@ -224,7 +224,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS private Map advancementToProgress; //Tracking - private final ArrayList screenTracking = new ArrayList<>(); + private final ArrayList screenTracking = new ArrayList<>(); private int lastTracked = 0; //MinePads Management @@ -313,7 +313,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS } @Override - public void trackScreen(TileEntityScreen tes, boolean track) { + public void trackScreen(ScreenBlockEntity tes, boolean track) { int idx = -1; for (int i = 0; i < screenTracking.size(); i++) { if (screenTracking.get(i) == tes) { @@ -534,7 +534,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS } } - for (TileEntityScreen tes : screenTracking) + for (ScreenBlockEntity tes : screenTracking) tes.updateClientSideURL(browser, url); } } @@ -644,7 +644,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS int id = lastTracked % screenTracking.size(); - TileEntityScreen tes = screenTracking.get(id); + ScreenBlockEntity tes = screenTracking.get(id); if (!tes.getLevel().equals(ev.level)) return; @@ -658,7 +658,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS } else { double dist = Double.POSITIVE_INFINITY; for (int i = 0; i < tes.screenCount(); i++) { - TileEntityScreen.Screen scrn = tes.getScreen(i); + ScreenBlockEntity.Screen scrn = tes.getScreen(i); Vector3d pos = new Vector3d( scrn.side.right.x * scrn.size.x + scrn.size.y * scrn.side.up.x, @@ -849,15 +849,15 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS public static final class ScreenSidePair { - public TileEntityScreen tes; + public ScreenBlockEntity tes; public BlockSide side; } public boolean findScreenFromBrowser(CefBrowser browser, ScreenSidePair pair) { - for (TileEntityScreen tes : screenTracking) { + for (ScreenBlockEntity tes : screenTracking) { for (int i = 0; i < tes.screenCount(); i++) { - TileEntityScreen.Screen scr = tes.getScreen(i); + ScreenBlockEntity.Screen scr = tes.getScreen(i); if (scr.browser == browser) { pair.tes = tes; @@ -910,7 +910,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS BlockEntity be = Minecraft.getInstance().level.getBlockEntity( pos ); - if (be instanceof TileEntityScreen tes) { + if (be instanceof ScreenBlockEntity tes) { if (tes.getScreen(side) != null) { event.setCanceled(true); } diff --git a/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java b/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java index 04c8e95..2eff89d 100644 --- a/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java +++ b/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java @@ -17,7 +17,7 @@ import net.montoyo.wd.client.gui.controls.Button; import net.montoyo.wd.client.gui.controls.Control; import net.montoyo.wd.client.gui.controls.Label; import net.montoyo.wd.client.gui.loading.FillControl; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl; import net.montoyo.wd.utilities.BlockSide; @@ -40,7 +40,7 @@ public class GuiKeyboard extends WDScreen { private static final String WARNING_FNAME = "wd_keyboard_warning.txt"; - private TileEntityScreen tes; + private ScreenBlockEntity tes; private BlockSide side; private final ArrayList evStack = new ArrayList<>(); private BlockPos kbPos; @@ -56,7 +56,7 @@ public class GuiKeyboard extends WDScreen { super(Component.nullToEmpty(null)); } - public GuiKeyboard(TileEntityScreen tes, BlockSide side, BlockPos kbPos) { + public GuiKeyboard(ScreenBlockEntity tes, BlockSide side, BlockPos kbPos) { this(); this.tes = tes; this.side = side; diff --git a/src/main/java/net/montoyo/wd/client/gui/GuiScreenConfig.java b/src/main/java/net/montoyo/wd/client/gui/GuiScreenConfig.java index b1057b9..29cd77a 100644 --- a/src/main/java/net/montoyo/wd/client/gui/GuiScreenConfig.java +++ b/src/main/java/net/montoyo/wd/client/gui/GuiScreenConfig.java @@ -15,7 +15,7 @@ import net.montoyo.wd.WebDisplays; import net.montoyo.wd.client.gui.controls.*; import net.montoyo.wd.client.gui.loading.FillControl; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.item.WDItem; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl; @@ -30,7 +30,7 @@ import java.util.UUID; public class GuiScreenConfig extends WDScreen { //Screen data - private final TileEntityScreen tes; + private final ScreenBlockEntity tes; private final BlockSide side; private NameUUIDPair owner; private NameUUIDPair[] friends; @@ -119,7 +119,7 @@ public class GuiScreenConfig extends WDScreen { private CheckBox[] friendBoxes; private CheckBox[] otherBoxes; - public GuiScreenConfig(Component component, TileEntityScreen tes, BlockSide side, NameUUIDPair[] friends, int fr, int or) { + public GuiScreenConfig(Component component, ScreenBlockEntity tes, BlockSide side, NameUUIDPair[] friends, int fr, int or) { super(component); this.tes = tes; this.side = side; @@ -147,7 +147,7 @@ public class GuiScreenConfig extends WDScreen { boxOClick.setUserdata(ScreenRights.INTERACT); boxOSetUrl.setUserdata(ScreenRights.CHANGE_URL); - TileEntityScreen.Screen scr = tes.getScreen(side); + ScreenBlockEntity.Screen scr = tes.getScreen(side); if(scr != null) { owner = scr.owner; rotation = scr.rotation; @@ -191,7 +191,7 @@ public class GuiScreenConfig extends WDScreen { } private void clickSetRes() { - TileEntityScreen.Screen scr = tes.getScreen(side); + ScreenBlockEntity.Screen scr = tes.getScreen(side); if(scr == null) return; //WHATDAFUQ? diff --git a/src/main/java/net/montoyo/wd/client/gui/GuiSetURL2.java b/src/main/java/net/montoyo/wd/client/gui/GuiSetURL2.java index 96ffe4c..ce47fd9 100644 --- a/src/main/java/net/montoyo/wd/client/gui/GuiSetURL2.java +++ b/src/main/java/net/montoyo/wd/client/gui/GuiSetURL2.java @@ -15,7 +15,7 @@ import net.montoyo.wd.client.ClientProxy; import net.montoyo.wd.client.gui.controls.Button; import net.montoyo.wd.client.gui.controls.TextField; import net.montoyo.wd.client.gui.loading.FillControl; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.item.ItemMinePad2; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.server_bound.C2SMessageMinepadUrl; @@ -32,7 +32,7 @@ import java.util.UUID; public class GuiSetURL2 extends WDScreen { //Screen data - private TileEntityScreen tileEntity; + private ScreenBlockEntity tileEntity; private BlockSide screenSide; private Vector3i remoteLocation; @@ -55,7 +55,7 @@ public class GuiSetURL2 extends WDScreen { @FillControl private Button btnOk; - public GuiSetURL2(TileEntityScreen tes, BlockSide side, String url, Vector3i rl) { + public GuiSetURL2(ScreenBlockEntity tes, BlockSide side, String url, Vector3i rl) { super(Component.nullToEmpty(null)); tileEntity = tes; screenSide = side; @@ -120,7 +120,7 @@ public class GuiSetURL2 extends WDScreen { if (!url.isEmpty()) { try { - TileEntityScreen.url(url); + ScreenBlockEntity.url(url); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/net/montoyo/wd/client/renderers/ScreenRenderer.java b/src/main/java/net/montoyo/wd/client/renderers/ScreenRenderer.java index 5bf19c8..595bbcd 100644 --- a/src/main/java/net/montoyo/wd/client/renderers/ScreenRenderer.java +++ b/src/main/java/net/montoyo/wd/client/renderers/ScreenRenderer.java @@ -11,21 +11,20 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.Vector3f; import net.montoyo.wd.utilities.Vector3i; import org.jetbrains.annotations.NotNull; -import org.lwjgl.opengl.GL11; import static com.mojang.math.Axis.*; -public class ScreenRenderer implements BlockEntityRenderer { +public class ScreenRenderer implements BlockEntityRenderer { public ScreenRenderer() { } - public static class ScreenRendererProvider implements BlockEntityRendererProvider { + public static class ScreenRendererProvider implements BlockEntityRendererProvider { @Override - public @NotNull BlockEntityRenderer create(@NotNull Context arg) { + public @NotNull BlockEntityRenderer create(@NotNull Context arg) { return new ScreenRenderer(); } } @@ -35,7 +34,7 @@ public class ScreenRenderer implements BlockEntityRenderer { private final Vector3f tmpf = new Vector3f(); @Override - public void render(TileEntityScreen te, float partialTick, @NotNull PoseStack poseStack, @NotNull MultiBufferSource bufferSource, int packedLight, int packedOverlay) { + public void render(ScreenBlockEntity te, float partialTick, @NotNull PoseStack poseStack, @NotNull MultiBufferSource bufferSource, int packedLight, int packedOverlay) { if (!te.isLoaded()) return; @@ -45,7 +44,7 @@ public class ScreenRenderer implements BlockEntityRenderer { RenderSystem.disableBlend(); for (int i = 0; i < te.screenCount(); i++) { - TileEntityScreen.Screen scr = te.getScreen(i); + ScreenBlockEntity.Screen scr = te.getScreen(i); if (scr.browser == null) { scr.createBrowser(true); } diff --git a/src/main/java/net/montoyo/wd/controls/ScreenControl.java b/src/main/java/net/montoyo/wd/controls/ScreenControl.java index a1c2410..8cff930 100644 --- a/src/main/java/net/montoyo/wd/controls/ScreenControl.java +++ b/src/main/java/net/montoyo/wd/controls/ScreenControl.java @@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.core.MissingPermissionException; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import java.util.Objects; @@ -22,9 +22,9 @@ public abstract class ScreenControl { } public abstract void write(FriendlyByteBuf buf); - public abstract void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException; + public abstract void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException; @OnlyIn(Dist.CLIENT) - public abstract void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx); + public abstract void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx); public void checkPerms(int perms, Function checker, ServerPlayer player) throws MissingPermissionException { if (!checker.apply(perms)) { diff --git a/src/main/java/net/montoyo/wd/controls/ScreenControlRegistry.java b/src/main/java/net/montoyo/wd/controls/ScreenControlRegistry.java index 3d85d8e..aae3347 100644 --- a/src/main/java/net/montoyo/wd/controls/ScreenControlRegistry.java +++ b/src/main/java/net/montoyo/wd/controls/ScreenControlRegistry.java @@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.builtin.*; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Log; @@ -32,7 +32,7 @@ public class ScreenControlRegistry { if (FMLEnvironment.dist.isClient()) { boolean shouldThrow = false; try { - Method m = type.clazz.getMethod("handleClient", BlockPos.class, BlockSide.class, TileEntityScreen.class, NetworkEvent.Context.class); + Method m = type.clazz.getMethod("handleClient", BlockPos.class, BlockSide.class, ScreenBlockEntity.class, NetworkEvent.Context.class); OnlyIn onlyIn = m.getAnnotation(OnlyIn.class); if (onlyIn == null) shouldThrow = true; Dist d = onlyIn.value(); // idc if this throws, lol diff --git a/src/main/java/net/montoyo/wd/controls/builtin/AutoVolumeControl.java b/src/main/java/net/montoyo/wd/controls/builtin/AutoVolumeControl.java index 7b3aac1..b79e579 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/AutoVolumeControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/AutoVolumeControl.java @@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import java.util.function.Function; @@ -35,7 +35,7 @@ public class AutoVolumeControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { // I feel like there's probably a better permission category checkPerms(ScreenRights.MANAGE_UPGRADES, permissionChecker, ctx.getSender()); tes.setAutoVolume(side, autoVol); @@ -43,7 +43,7 @@ public class AutoVolumeControl extends ScreenControl { @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { tes.setAutoVolume(side, autoVol); } } diff --git a/src/main/java/net/montoyo/wd/controls/builtin/ClickControl.java b/src/main/java/net/montoyo/wd/controls/builtin/ClickControl.java index dd35c4f..6366bc3 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/ClickControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/ClickControl.java @@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Vector2i; @@ -47,13 +47,13 @@ public class ClickControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { throw new RuntimeException("Cannot call click control on server"); } @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { if (coord != null) tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, coord, -1); diff --git a/src/main/java/net/montoyo/wd/controls/builtin/JSRequestControl.java b/src/main/java/net/montoyo/wd/controls/builtin/JSRequestControl.java index 282b3dc..e2730ff 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/JSRequestControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/JSRequestControl.java @@ -10,9 +10,8 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.JSServerRequest; import net.montoyo.wd.core.MissingPermissionException; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; -import net.montoyo.wd.utilities.Log; import java.util.function.Function; @@ -49,7 +48,7 @@ public class JSRequestControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { ServerPlayer player = ctx.getSender(); // if (reqType == null || data == null) Log.warning("Caught invalid JS request from player %s (UUID %s)", player.getName(), player.getGameProfile().getId().toString()); // else tes.handleJSRequest(player, side, reqId, reqType, data); @@ -57,7 +56,7 @@ public class JSRequestControl extends ScreenControl { @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { throw new RuntimeException("TODO"); } } diff --git a/src/main/java/net/montoyo/wd/controls/builtin/KeyTypedControl.java b/src/main/java/net/montoyo/wd/controls/builtin/KeyTypedControl.java index d38c94e..e96097c 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/KeyTypedControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/KeyTypedControl.java @@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import java.util.function.Function; @@ -39,14 +39,14 @@ public class KeyTypedControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { checkPerms(ScreenRights.INTERACT, permissionChecker, ctx.getSender()); tes.type(side, text, soundPos, ctx.getSender()); } @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { tes.type(side, text, soundPos); } } diff --git a/src/main/java/net/montoyo/wd/controls/builtin/LaserControl.java b/src/main/java/net/montoyo/wd/controls/builtin/LaserControl.java index 6233b96..5cbf78b 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/LaserControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/LaserControl.java @@ -9,7 +9,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Vector2i; @@ -54,7 +54,7 @@ public class LaserControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { // feel like this makes sense, but I wanna get opinions first // checkPerms(ScreenRights.INTERACT, permissionChecker, ctx.getSender()); ServerPlayer sender = ctx.getSender(); @@ -67,7 +67,7 @@ public class LaserControl extends ScreenControl { @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { if (coord != null) tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, coord, -1); diff --git a/src/main/java/net/montoyo/wd/controls/builtin/ManageRightsAndUpdgradesControl.java b/src/main/java/net/montoyo/wd/controls/builtin/ManageRightsAndUpdgradesControl.java index 2a56d08..d8d9083 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/ManageRightsAndUpdgradesControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/ManageRightsAndUpdgradesControl.java @@ -11,7 +11,7 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import java.util.function.Function; @@ -79,7 +79,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { ServerPlayer player = ctx.getSender(); switch (type) { case UPGRADES -> { @@ -89,7 +89,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl { else tes.removeUpgrade(side, toRemove, player); } case RIGHTS -> { - TileEntityScreen.Screen scr = tes.getScreen(side); + ScreenBlockEntity.Screen scr = tes.getScreen(side); int fr = scr.owner.uuid.equals(player.getGameProfile().getId()) ? friendRights : scr.friendRights; int or = (scr.rightsFor(player) & ScreenRights.MANAGE_OTHER_RIGHTS) == 0 ? scr.otherRights : otherRights; @@ -102,7 +102,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl { @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { ServerPlayer player = ctx.getSender(); switch (type) { case UPGRADES -> { @@ -111,7 +111,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl { else tes.removeUpgrade(side, toRemove, player); } case RIGHTS -> { - TileEntityScreen.Screen scr = tes.getScreen(side); + ScreenBlockEntity.Screen scr = tes.getScreen(side); int fr = friendRights; int or = otherRights; diff --git a/src/main/java/net/montoyo/wd/controls/builtin/ModifyFriendListControl.java b/src/main/java/net/montoyo/wd/controls/builtin/ModifyFriendListControl.java index 56a5364..89846cb 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/ModifyFriendListControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/ModifyFriendListControl.java @@ -10,7 +10,7 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.NameUUIDPair; @@ -41,7 +41,7 @@ public class ModifyFriendListControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { ServerPlayer player = ctx.getSender(); checkPerms(ScreenRights.MANAGE_FRIEND_LIST, permissionChecker, ctx.getSender()); if (adding) tes.addFriend(player, side, friend); @@ -50,7 +50,7 @@ public class ModifyFriendListControl extends ScreenControl { @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { throw new RuntimeException("TODO"); } } diff --git a/src/main/java/net/montoyo/wd/controls/builtin/OwnerControl.java b/src/main/java/net/montoyo/wd/controls/builtin/OwnerControl.java index 4f0c0af..1a96c9a 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/OwnerControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/OwnerControl.java @@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.NameUUIDPair; @@ -35,13 +35,13 @@ public class OwnerControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { throw new RuntimeException("Cannot handle ownership theft packet from server"); } @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { tes.getScreen(side).owner = owner; } } diff --git a/src/main/java/net/montoyo/wd/controls/builtin/ScreenModifyControl.java b/src/main/java/net/montoyo/wd/controls/builtin/ScreenModifyControl.java index 1709f28..15d56ea 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/ScreenModifyControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/ScreenModifyControl.java @@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Rotation; import net.montoyo.wd.utilities.Vector2i; @@ -55,7 +55,7 @@ public class ScreenModifyControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { checkPerms(ScreenRights.MODIFY_SCREEN, permissionChecker, ctx.getSender()); switch (type) { case RESOLUTION -> tes.setResolution(side, res); @@ -65,7 +65,7 @@ public class ScreenModifyControl extends ScreenControl { @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { switch (type) { case RESOLUTION -> tes.setResolution(side, res); case ROTATION -> tes.setRotation(side, rotation); diff --git a/src/main/java/net/montoyo/wd/controls/builtin/SetURLControl.java b/src/main/java/net/montoyo/wd/controls/builtin/SetURLControl.java index 44b1187..06f0628 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/SetURLControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/SetURLControl.java @@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Vector3i; @@ -41,7 +41,7 @@ public class SetURLControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { // TODO: deal with remote checkPerms(ScreenRights.CHANGE_URL, permissionChecker, ctx.getSender()); try { @@ -53,7 +53,7 @@ public class SetURLControl extends ScreenControl { @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { try { tes.setScreenURL(side, url); } catch (Throwable err) { diff --git a/src/main/java/net/montoyo/wd/controls/builtin/TurnOffControl.java b/src/main/java/net/montoyo/wd/controls/builtin/TurnOffControl.java index 13a5d13..99c3f77 100644 --- a/src/main/java/net/montoyo/wd/controls/builtin/TurnOffControl.java +++ b/src/main/java/net/montoyo/wd/controls/builtin/TurnOffControl.java @@ -9,9 +9,8 @@ import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.WebDisplays; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.core.MissingPermissionException; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; -import net.montoyo.wd.utilities.NameUUIDPair; import java.util.function.Function; @@ -29,13 +28,13 @@ public class TurnOffControl extends ScreenControl { } @Override - public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { + public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function permissionChecker) throws MissingPermissionException { throw new RuntimeException("Cannot handle deactivation packet from server"); } @Override @OnlyIn(Dist.CLIENT) - public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) { + public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) { if (side != null) { WebDisplays.PROXY.closeGui(pos, side); tes.disableScreen(side); diff --git a/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java b/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java index 4987c3d..bf7e3b2 100644 --- a/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java +++ b/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java @@ -8,22 +8,22 @@ import net.minecraft.util.StringRepresentable; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import net.montoyo.wd.entity.TileEntityKeyboard; -import net.montoyo.wd.entity.TileEntityRCtrl; -import net.montoyo.wd.entity.TileEntityRedCtrl; -import net.montoyo.wd.entity.TileEntityServer; +import net.montoyo.wd.entity.KeyboardBlockEntity; +import net.montoyo.wd.entity.RemoteControlBlockEntity; +import net.montoyo.wd.entity.RedstoneControlBlockEntity; +import net.montoyo.wd.entity.ServerBlockEntity; import net.montoyo.wd.registry.BlockRegistry; import org.jetbrains.annotations.NotNull; import java.util.function.Supplier; public enum DefaultPeripheral implements StringRepresentable { - KEYBOARD("keyboard", "Keyboard", TileEntityKeyboard::new, BlockRegistry.KEYBOARD_BLOCK), //WITH FACING (< 3) + KEYBOARD("keyboard", "Keyboard", KeyboardBlockEntity::new, BlockRegistry.KEYBOARD_BLOCK), //WITH FACING (< 3) // CC_INTERFACE("ccinterface", "ComputerCraft_Interface", TileEntityCCInterface.class), // OC_INTERFACE("cointerface", "OpenComputers_Interface", TileEntityOCInterface.class), - REMOTE_CONTROLLER("remotectrl", "Remote_Controller", TileEntityRCtrl::new , BlockRegistry.REMOTE_CONTROLLER_BLOCK), //WITHOUT FACING (>= 3) - REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl::new , BlockRegistry.REDSTONE_CONTROL_BLOCK), - SERVER("server", "Server", TileEntityServer::new, BlockRegistry.SERVER_BLOCK); + REMOTE_CONTROLLER("remotectrl", "Remote_Controller", RemoteControlBlockEntity::new , BlockRegistry.REMOTE_CONTROLLER_BLOCK), //WITHOUT FACING (>= 3) + REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", RedstoneControlBlockEntity::new , BlockRegistry.REDSTONE_CONTROL_BLOCK), + SERVER("server", "Server", ServerBlockEntity::new, BlockRegistry.SERVER_BLOCK); private final String name; private final String wikiName; diff --git a/src/main/java/net/montoyo/wd/core/IUpgrade.java b/src/main/java/net/montoyo/wd/core/IUpgrade.java index 26810da..f54cff6 100644 --- a/src/main/java/net/montoyo/wd/core/IUpgrade.java +++ b/src/main/java/net/montoyo/wd/core/IUpgrade.java @@ -6,15 +6,15 @@ package net.montoyo.wd.core; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import javax.annotation.Nonnull; import javax.annotation.Nullable; public interface IUpgrade { - void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is); - boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is); //Return true to prevent dropping + void onInstall(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is); + boolean onRemove(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is); //Return true to prevent dropping boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack); //myStack.getItem() is an instance of this class String getJSName(@Nonnull ItemStack is); //modname:upgradename } diff --git a/src/main/java/net/montoyo/wd/data/KeyboardData.java b/src/main/java/net/montoyo/wd/data/KeyboardData.java index a12937d..24977b2 100644 --- a/src/main/java/net/montoyo/wd/data/KeyboardData.java +++ b/src/main/java/net/montoyo/wd/data/KeyboardData.java @@ -12,7 +12,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.montoyo.wd.client.gui.GuiKeyboard; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Log; import net.montoyo.wd.utilities.Vector3i; @@ -27,7 +27,7 @@ public class KeyboardData extends GuiData { public KeyboardData() { } - public KeyboardData(TileEntityScreen tes, BlockSide side, BlockPos kbPos) { + public KeyboardData(ScreenBlockEntity tes, BlockSide side, BlockPos kbPos) { pos = new Vector3i(tes.getBlockPos()); this.side = side; kbX = kbPos.getX(); @@ -39,12 +39,12 @@ public class KeyboardData extends GuiData { @Override public Screen createGui(Screen old, Level world) { BlockEntity te = world.getBlockEntity(pos.toBlock()); - if (te == null || !(te instanceof TileEntityScreen)) { + if (te == null || !(te instanceof ScreenBlockEntity)) { Log.error("TileEntity at %s is not a screen; can't open keyboard!", pos.toString()); return null; } - return new GuiKeyboard((TileEntityScreen) te, side, new BlockPos(kbX, kbY, kbZ)); + return new GuiKeyboard((ScreenBlockEntity) te, side, new BlockPos(kbX, kbY, kbZ)); } @Override diff --git a/src/main/java/net/montoyo/wd/data/ScreenConfigData.java b/src/main/java/net/montoyo/wd/data/ScreenConfigData.java index 9d53829..916b74b 100644 --- a/src/main/java/net/montoyo/wd/data/ScreenConfigData.java +++ b/src/main/java/net/montoyo/wd/data/ScreenConfigData.java @@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.network.PacketDistributor; import net.montoyo.wd.client.gui.GuiScreenConfig; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.net.BufferUtils; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.client_bound.S2CMessageOpenGui; @@ -33,7 +33,7 @@ public class ScreenConfigData extends GuiData { public ScreenConfigData() { } - public ScreenConfigData(Vector3i pos, BlockSide side, TileEntityScreen.Screen scr) { + public ScreenConfigData(Vector3i pos, BlockSide side, ScreenBlockEntity.Screen scr) { this.pos = pos; this.side = side; friends = scr.friends.toArray(new NameUUIDPair[0]); @@ -62,12 +62,12 @@ public class ScreenConfigData extends GuiData { return null; BlockEntity te = world.getBlockEntity(pos.toBlock()); - if (te == null || !(te instanceof TileEntityScreen)) { + if (te == null || !(te instanceof ScreenBlockEntity)) { Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString()); return null; } - return new GuiScreenConfig(Component.nullToEmpty(""), (TileEntityScreen) te, side, friends, friendRights, otherRights); + return new GuiScreenConfig(Component.nullToEmpty(""), (ScreenBlockEntity) te, side, friends, friendRights, otherRights); } @Override diff --git a/src/main/java/net/montoyo/wd/data/SetURLData.java b/src/main/java/net/montoyo/wd/data/SetURLData.java index 6fc81fe..e6d8c2d 100644 --- a/src/main/java/net/montoyo/wd/data/SetURLData.java +++ b/src/main/java/net/montoyo/wd/data/SetURLData.java @@ -12,7 +12,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.montoyo.wd.client.gui.GuiSetURL2; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.net.BufferUtils; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Log; @@ -49,12 +49,12 @@ public class SetURLData extends GuiData { @Override public Screen createGui(Screen old, Level world) { BlockEntity te = world.getBlockEntity(pos.toBlock()); - if (te == null || !(te instanceof TileEntityScreen)) { + if (te == null || !(te instanceof ScreenBlockEntity)) { Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString()); return null; } - return new GuiSetURL2((TileEntityScreen) te, side, url, isRemote ? remoteLocation : null); + return new GuiSetURL2((ScreenBlockEntity) te, side, url, isRemote ? remoteLocation : null); } @Override diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityInterfaceBase.java b/src/main/java/net/montoyo/wd/entity/AbstractInterfaceBlockEntity.java similarity index 92% rename from src/main/java/net/montoyo/wd/entity/TileEntityInterfaceBase.java rename to src/main/java/net/montoyo/wd/entity/AbstractInterfaceBlockEntity.java index e9ecf14..7869ceb 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityInterfaceBase.java +++ b/src/main/java/net/montoyo/wd/entity/AbstractInterfaceBlockEntity.java @@ -23,8 +23,8 @@ import java.lang.annotation.Target; import java.util.ArrayList; import java.util.Map; -public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { - public TileEntityInterfaceBase(BlockEntityType arg, BlockPos arg2, BlockState arg3) { +public abstract class AbstractInterfaceBlockEntity extends AbstractPeripheralBlockEntity { + public AbstractInterfaceBlockEntity(BlockEntityType arg, BlockPos arg2, BlockState arg3) { super(arg, arg2, arg3); } @@ -107,7 +107,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { throw new IllegalArgumentException("invalid right name"); } - TileEntityScreen tes = getConnectedScreenEx(); + ScreenBlockEntity tes = getConnectedScreenEx(); if(owner == null || tes == null) return null; else @@ -118,7 +118,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { public Object[] hasUpgrade(IComputerArgs args) { String name = args.checkString(0); - TileEntityScreen tes = getConnectedScreenEx(); + ScreenBlockEntity tes = getConnectedScreenEx(); if(owner == null || tes == null) return null; else @@ -127,7 +127,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { @ComputerFunc public Object[] getSize(IComputerArgs args) { - TileEntityScreen tes = getConnectedScreenEx(); + ScreenBlockEntity tes = getConnectedScreenEx(); if(owner == null || tes == null) return null; @@ -139,7 +139,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { @ComputerFunc public Object[] getResolution(IComputerArgs args) { - TileEntityScreen tes = getConnectedScreenEx(); + ScreenBlockEntity tes = getConnectedScreenEx(); if(owner == null || tes == null) return null; @@ -151,7 +151,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { @ComputerFunc public Object[] getRotation(IComputerArgs args) { - TileEntityScreen tes = getConnectedScreenEx(); + ScreenBlockEntity tes = getConnectedScreenEx(); if(owner == null || tes == null) return null; @@ -161,7 +161,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { @ComputerFunc public Object[] getURL(IComputerArgs args) { - TileEntityScreen tes = getConnectedScreenEx(); + ScreenBlockEntity tes = getConnectedScreenEx(); if(owner == null || tes == null) return null; @@ -205,12 +205,12 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { // throw new IllegalArgumentException("bad action name"); // } - TileEntityScreen scr = getConnectedScreenEx(); + ScreenBlockEntity scr = getConnectedScreenEx(); if(owner == null || scr == null) return err("notlinked"); else { - TileEntityScreen.Screen scrscr = scr.getScreen(screenSide); + ScreenBlockEntity.Screen scrscr = scr.getScreen(screenSide); if((scrscr.rightsFor(owner.uuid) & ScreenRights.INTERACT) == 0) return err("restrictions"); @@ -244,7 +244,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { } private Object[] realType(String what) { - TileEntityScreen scr = getConnectedScreenEx(); + ScreenBlockEntity scr = getConnectedScreenEx(); if(owner == null || scr == null) return err("notlinked"); @@ -325,7 +325,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { @ComputerFunc public Object[] setURL(IComputerArgs args) { String url = args.checkString(0); - TileEntityScreen scr = getConnectedScreenEx(); + ScreenBlockEntity scr = getConnectedScreenEx(); if(owner == null || scr == null) return err("notlinked"); @@ -345,7 +345,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { public Object[] setResolution(IComputerArgs args) { int rx = args.checkInteger(0); int ry = args.checkInteger(1); - TileEntityScreen scr = getConnectedScreenEx(); + ScreenBlockEntity scr = getConnectedScreenEx(); if(owner == null || scr == null) return err("notlinked"); @@ -368,7 +368,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { rot /= 90; rot &= 3; - TileEntityScreen scr = getConnectedScreenEx(); + ScreenBlockEntity scr = getConnectedScreenEx(); if(owner == null || scr == null) return err("notlinked"); @@ -383,7 +383,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase { @ComputerFunc public Object[] runJS(IComputerArgs args) { String code = args.checkString(0); - TileEntityScreen scr = getConnectedScreenEx(); + ScreenBlockEntity scr = getConnectedScreenEx(); if(owner == null || scr == null) return err("notlinked"); diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java b/src/main/java/net/montoyo/wd/entity/AbstractPeripheralBlockEntity.java similarity index 85% rename from src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java rename to src/main/java/net/montoyo/wd/entity/AbstractPeripheralBlockEntity.java index ef7c5bf..0c8c94a 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java +++ b/src/main/java/net/montoyo/wd/entity/AbstractPeripheralBlockEntity.java @@ -24,11 +24,11 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Objects; -public abstract class TileEntityPeripheralBase extends BlockEntity implements IPeripheral { +public abstract class AbstractPeripheralBlockEntity extends BlockEntity implements IPeripheral { protected Vector3i screenPos; protected BlockSide screenSide; - public TileEntityPeripheralBase(BlockEntityType arg, BlockPos arg2, BlockState arg3) { + public AbstractPeripheralBlockEntity(BlockEntityType arg, BlockPos arg2, BlockState arg3) { super(arg, arg2, arg3); } @@ -78,12 +78,12 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP @Override public boolean connect(Level world_, BlockPos blockPos, BlockState blockState, Vector3i pos, BlockSide side) { BlockEntity te = world_.getBlockEntity(pos.toBlock()); - if (!(te instanceof TileEntityScreen)) { + if (!(te instanceof ScreenBlockEntity)) { Log.error("TileEntityPeripheralBase.connect(): Tile entity at %s is not a screen!", pos.toString()); return false; } - if (((TileEntityScreen) te).getScreen(side) == null) { + if (((ScreenBlockEntity) te).getScreen(side) == null) { Log.error("TileEntityPeripheralBase.connect(): There is no screen at %s on side %s!", pos.toString(), side.toString()); return false; } @@ -107,31 +107,31 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP } @Nullable - public TileEntityScreen getConnectedScreen() { + public ScreenBlockEntity getConnectedScreen() { if (screenPos == null || screenSide == null) return null; BlockEntity te = level.getBlockEntity(screenPos.toBlock()); - if (!(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null) { + if (!(te instanceof ScreenBlockEntity) || ((ScreenBlockEntity) te).getScreen(screenSide) == null) { screenPos = null; screenSide = null; setChanged(); return null; } - return (TileEntityScreen) te; + return (ScreenBlockEntity) te; } @Nullable - public TileEntityScreen getConnectedScreenEx() { + public ScreenBlockEntity getConnectedScreenEx() { if (screenPos == null || screenSide == null) return null; BlockEntity te = level.getBlockEntity(screenPos.toBlock()); - if (!(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null) + if (!(te instanceof ScreenBlockEntity) || ((ScreenBlockEntity) te).getScreen(screenSide) == null) return null; - return (TileEntityScreen) te; + return (ScreenBlockEntity) te; } @Nullable diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityCCInterface.java b/src/main/java/net/montoyo/wd/entity/CCInterfaceBlockEntity.java similarity index 90% rename from src/main/java/net/montoyo/wd/entity/TileEntityCCInterface.java rename to src/main/java/net/montoyo/wd/entity/CCInterfaceBlockEntity.java index 0af19c8..21baa13 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityCCInterface.java +++ b/src/main/java/net/montoyo/wd/entity/CCInterfaceBlockEntity.java @@ -3,6 +3,7 @@ */ package net.montoyo.wd.entity; + /* import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.LuaException; @@ -19,17 +20,17 @@ import java.lang.reflect.Method; import java.util.ArrayList; @Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "computercraft") -public class TileEntityCCInterface extends TileEntityInterfaceBase implements IPeripheral { +public class CCInterfaceBlockEntity extends AbstractInterfaceBlockEntity implements IPeripheral { private static final String[] METHOD_NAMES; private static final Method[] METHODS; static { ArrayList names = new ArrayList<>(); ArrayList methods = new ArrayList<>(); - Method[] src = TileEntityInterfaceBase.class.getMethods(); + Method[] src = AbstractInterfaceBlockEntity.class.getMethods(); for(Method m: src) { - if(m.getAnnotation(TileEntityInterfaceBase.ComputerFunc.class) != null) { + if(m.getAnnotation(AbstractInterfaceBlockEntity.ComputerFunc.class) != null) { if(m.getParameterCount() != 1 || m.getParameterTypes()[0] != IComputerArgs.class) throw new RuntimeException("Found @ComputerFunc method with invalid arguments"); diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityKeyboard.java b/src/main/java/net/montoyo/wd/entity/KeyboardBlockEntity.java similarity index 86% rename from src/main/java/net/montoyo/wd/entity/TileEntityKeyboard.java rename to src/main/java/net/montoyo/wd/entity/KeyboardBlockEntity.java index 00c114c..40cf24d 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityKeyboard.java +++ b/src/main/java/net/montoyo/wd/entity/KeyboardBlockEntity.java @@ -18,10 +18,10 @@ import net.montoyo.wd.data.KeyboardData; import net.montoyo.wd.registry.TileRegistry; import net.montoyo.wd.utilities.Util; -public class TileEntityKeyboard extends TileEntityPeripheralBase { +public class KeyboardBlockEntity extends AbstractPeripheralBlockEntity { private static final String RANDOM_CHARS = "AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn0123456789"; //Yes I have an AZERTY keyboard, u care? - public TileEntityKeyboard(BlockPos arg2, BlockState arg3) { + public KeyboardBlockEntity(BlockPos arg2, BlockState arg3) { super(TileRegistry.KEYBOARD.get(), arg2, arg3); } @@ -35,13 +35,13 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase { return InteractionResult.SUCCESS; } - TileEntityScreen tes = getConnectedScreen(); + ScreenBlockEntity tes = getConnectedScreen(); if(tes == null) { Util.toast(player, "notLinked"); return InteractionResult.SUCCESS; } - TileEntityScreen.Screen scr = tes.getScreen(screenSide); + ScreenBlockEntity.Screen scr = tes.getScreen(screenSide); if((scr.rightsFor(player) & ScreenRights.INTERACT) == 0) { Util.toast(player, "restrictions"); return InteractionResult.SUCCESS; @@ -55,10 +55,10 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase { if(!isScreenChunkLoaded()) return; - TileEntityScreen tes = getConnectedScreen(); + ScreenBlockEntity tes = getConnectedScreen(); if(tes != null) { - TileEntityScreen.Screen scr = tes.getScreen(screenSide); + ScreenBlockEntity.Screen scr = tes.getScreen(screenSide); boolean ok; if(ent instanceof Player) diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityOCInterface.java b/src/main/java/net/montoyo/wd/entity/OCInterfaceBlockEntity.java similarity index 97% rename from src/main/java/net/montoyo/wd/entity/TileEntityOCInterface.java rename to src/main/java/net/montoyo/wd/entity/OCInterfaceBlockEntity.java index 16b83d1..272dccc 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityOCInterface.java +++ b/src/main/java/net/montoyo/wd/entity/OCInterfaceBlockEntity.java @@ -13,8 +13,7 @@ import net.minecraftforge.fml.common.Optional; import net.montoyo.wd.core.OCArguments; @Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers") -public class TileEntityOCInterface extends TileEntityInterfaceBase implements SimpleComponent { - +public class OCInterfaceBlockEntity extends AbstractInterfaceBlockEntity implements SimpleComponent { @Override public String getComponentName() { return "webdisplays"; @@ -133,5 +132,4 @@ public class TileEntityOCInterface extends TileEntityInterfaceBase implements Si public Object[] unlink(Context ctx, Arguments args) { return unlink(new OCArguments(args)); } - }*/ diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityRedCtrl.java b/src/main/java/net/montoyo/wd/entity/RedstoneControlBlockEntity.java similarity index 90% rename from src/main/java/net/montoyo/wd/entity/TileEntityRedCtrl.java rename to src/main/java/net/montoyo/wd/entity/RedstoneControlBlockEntity.java index c68e454..df1ebe8 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityRedCtrl.java +++ b/src/main/java/net/montoyo/wd/entity/RedstoneControlBlockEntity.java @@ -19,12 +19,12 @@ import net.montoyo.wd.utilities.Util; import java.io.IOException; -public class TileEntityRedCtrl extends TileEntityPeripheralBase { +public class RedstoneControlBlockEntity extends AbstractPeripheralBlockEntity { private String risingEdgeURL = ""; private String fallingEdgeURL = ""; private boolean state = false; - public TileEntityRedCtrl(BlockPos arg2, BlockState arg3) { + public RedstoneControlBlockEntity(BlockPos arg2, BlockState arg3) { super(TileRegistry.REDSTONE_CONTROLLER.get(), arg2, arg3); } @@ -55,13 +55,13 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase { return InteractionResult.SUCCESS; } - TileEntityScreen tes = getConnectedScreen(); + ScreenBlockEntity tes = getConnectedScreen(); if (tes == null) { Util.toast(player, "notLinked"); return InteractionResult.SUCCESS; } - TileEntityScreen.Screen scr = tes.getScreen(screenSide); + ScreenBlockEntity.Screen scr = tes.getScreen(screenSide); if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) { Util.toast(player, "restrictions"); return InteractionResult.SUCCESS; @@ -96,7 +96,7 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase { return; if (isScreenChunkLoaded()) { - TileEntityScreen tes = getConnectedScreen(); + ScreenBlockEntity tes = getConnectedScreen(); if (tes != null) try { diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityRCtrl.java b/src/main/java/net/montoyo/wd/entity/RemoteControlBlockEntity.java similarity index 83% rename from src/main/java/net/montoyo/wd/entity/TileEntityRCtrl.java rename to src/main/java/net/montoyo/wd/entity/RemoteControlBlockEntity.java index 414c80c..bfc0c2a 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityRCtrl.java +++ b/src/main/java/net/montoyo/wd/entity/RemoteControlBlockEntity.java @@ -15,8 +15,8 @@ import net.montoyo.wd.data.SetURLData; import net.montoyo.wd.registry.TileRegistry; import net.montoyo.wd.utilities.Util; -public class TileEntityRCtrl extends TileEntityPeripheralBase { - public TileEntityRCtrl(BlockPos arg2, BlockState arg3) { +public class RemoteControlBlockEntity extends AbstractPeripheralBlockEntity { + public RemoteControlBlockEntity(BlockPos arg2, BlockState arg3) { super(TileRegistry.REMOTE_CONTROLLER.get(), arg2, arg3); } @@ -30,13 +30,13 @@ public class TileEntityRCtrl extends TileEntityPeripheralBase { return InteractionResult.SUCCESS; } - TileEntityScreen tes = getConnectedScreen(); + ScreenBlockEntity tes = getConnectedScreen(); if (tes == null) { Util.toast(player, "notLinked"); return InteractionResult.SUCCESS; } - TileEntityScreen.Screen scr = tes.getScreen(screenSide); + ScreenBlockEntity.Screen scr = tes.getScreen(screenSide); if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) { Util.toast(player, "restrictions"); return InteractionResult.SUCCESS; diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityScreen.java b/src/main/java/net/montoyo/wd/entity/ScreenBlockEntity.java similarity index 99% rename from src/main/java/net/montoyo/wd/entity/TileEntityScreen.java rename to src/main/java/net/montoyo/wd/entity/ScreenBlockEntity.java index 65cbfa4..77dd0f7 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityScreen.java +++ b/src/main/java/net/montoyo/wd/entity/ScreenBlockEntity.java @@ -53,8 +53,8 @@ import java.util.function.Consumer; import static net.montoyo.wd.block.BlockPeripheral.point; -public class TileEntityScreen extends BlockEntity { - public TileEntityScreen(BlockPos arg2, BlockState arg3) { +public class ScreenBlockEntity extends BlockEntity { + public ScreenBlockEntity(BlockPos arg2, BlockState arg3) { super(TileRegistry.SCREEN_BLOCK_ENTITY.get(), arg2, arg3); } @@ -792,7 +792,7 @@ public class TileEntityScreen extends BlockEntity { // TODO: what? lol String webUrl; try { - webUrl = TileEntityScreen.url(url); + webUrl = ScreenBlockEntity.url(url); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityServer.java b/src/main/java/net/montoyo/wd/entity/ServerBlockEntity.java similarity index 92% rename from src/main/java/net/montoyo/wd/entity/TileEntityServer.java rename to src/main/java/net/montoyo/wd/entity/ServerBlockEntity.java index c5db695..3479935 100644 --- a/src/main/java/net/montoyo/wd/entity/TileEntityServer.java +++ b/src/main/java/net/montoyo/wd/entity/ServerBlockEntity.java @@ -16,10 +16,10 @@ import net.montoyo.wd.registry.TileRegistry; import net.montoyo.wd.utilities.NameUUIDPair; import net.montoyo.wd.utilities.Util; -public class TileEntityServer extends BlockEntity { +public class ServerBlockEntity extends BlockEntity { private NameUUIDPair owner; - public TileEntityServer(BlockPos arg2, BlockState arg3) { + public ServerBlockEntity(BlockPos arg2, BlockState arg3) { super(TileRegistry.SERVER.get(), arg2, arg3); } diff --git a/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java b/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java index f1b05de..a989ab2 100644 --- a/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java +++ b/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java @@ -16,7 +16,7 @@ import net.montoyo.wd.client.ClientProxy; import net.montoyo.wd.config.ClientConfig; import net.montoyo.wd.controls.builtin.ClickControl; import net.montoyo.wd.core.DefaultUpgrade; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.registry.BlockRegistry; import net.montoyo.wd.net.WDNetworkRegistry; import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl; @@ -38,7 +38,7 @@ public class ItemLaserPointer extends Item implements WDItem { } //Laser pointer - private static TileEntityScreen pointedScreen; + private static ScreenBlockEntity pointedScreen; private static BlockSide pointedScreenSide; private static long lastPointPacket; @@ -57,11 +57,11 @@ public class ItemLaserPointer extends Item implements WDItem { BlockSide side = BlockSide.values()[result.getDirection().ordinal()]; Multiblock.findOrigin(mc.level, pos, side, null); - TileEntityScreen te = (TileEntityScreen) mc.level.getBlockEntity(pos.toBlock()); + ScreenBlockEntity te = (ScreenBlockEntity) 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); + ScreenBlockEntity.Screen scr = te.getScreen(side); if (scr.browser != null) { float hitX = ((float) result.getLocation().x) - (float) pos.x; @@ -81,7 +81,7 @@ public class ItemLaserPointer extends Item implements WDItem { deselectScreen(); } - private static void laserClick(TileEntityScreen tes, BlockSide side, TileEntityScreen.Screen scr, Vector2i hit) { + private static void laserClick(ScreenBlockEntity tes, BlockSide side, ScreenBlockEntity.Screen scr, Vector2i hit) { tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, hit, -1); if (pointedScreen == tes && pointedScreenSide == side) { long t = System.currentTimeMillis(); @@ -125,14 +125,14 @@ public class ItemLaserPointer extends Item implements WDItem { Vector2i tmp = new Vector2i(); BlockEntity be = mc.level.getBlockEntity(pos.toBlock()); - if (!(be instanceof TileEntityScreen)) return; + if (!(be instanceof ScreenBlockEntity)) return; //noinspection PatternVariableCanBeUsed - TileEntityScreen te = (TileEntityScreen) be; + ScreenBlockEntity te = (ScreenBlockEntity) be; if (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); + 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)) { diff --git a/src/main/java/net/montoyo/wd/item/ItemLinker.java b/src/main/java/net/montoyo/wd/item/ItemLinker.java index a933266..4654e32 100644 --- a/src/main/java/net/montoyo/wd/item/ItemLinker.java +++ b/src/main/java/net/montoyo/wd/item/ItemLinker.java @@ -17,7 +17,7 @@ import net.montoyo.wd.WebDisplays; import net.montoyo.wd.block.BlockScreen; import net.montoyo.wd.core.IPeripheral; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Multiblock; import net.montoyo.wd.utilities.Util; @@ -90,12 +90,12 @@ public class ItemLinker extends Item implements WDItem { Multiblock.findOrigin(context.getLevel(), pos, side, null); BlockEntity te = context.getLevel().getBlockEntity(pos.toBlock()); - if (te == null || !(te instanceof TileEntityScreen)) { + if (te == null || !(te instanceof ScreenBlockEntity)) { Util.toast(context.getPlayer(), "turnOn"); return InteractionResult.SUCCESS; } - TileEntityScreen.Screen scr = ((TileEntityScreen) te).getScreen(side); + ScreenBlockEntity.Screen scr = ((ScreenBlockEntity) te).getScreen(side); if (scr == null) Util.toast(context.getPlayer(), "turnOn"); else if ((scr.rightsFor(context.getPlayer()) & ScreenRights.MANAGE_UPGRADES) == 0) diff --git a/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java b/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java index 2601751..af14436 100644 --- a/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java +++ b/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java @@ -12,10 +12,9 @@ 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.WebDisplays; import net.montoyo.wd.block.BlockScreen; import net.montoyo.wd.config.CommonConfig; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.*; import org.jetbrains.annotations.NotNull; @@ -55,11 +54,11 @@ public class ItemOwnershipThief extends Item implements WDItem { return InteractionResult.SUCCESS; BlockEntity te = context.getLevel().getBlockEntity(bp); - if (te == null || !(te instanceof TileEntityScreen)) + if (te == null || !(te instanceof ScreenBlockEntity)) return InteractionResult.SUCCESS; - TileEntityScreen tes = (TileEntityScreen) te; - TileEntityScreen.Screen scr = tes.getScreen(side); + ScreenBlockEntity tes = (ScreenBlockEntity) te; + ScreenBlockEntity.Screen scr = tes.getScreen(side); if (scr == null) return InteractionResult.SUCCESS; @@ -79,12 +78,12 @@ public class ItemOwnershipThief extends Item implements WDItem { Multiblock.findOrigin(context.getLevel(), pos, side, null); BlockEntity te = context.getLevel().getBlockEntity(pos.toBlock()); - if (te == null || !(te instanceof TileEntityScreen)) { + if (te == null || !(te instanceof ScreenBlockEntity)) { Util.toast(context.getPlayer(), "turnOn"); return InteractionResult.SUCCESS; } - if (((TileEntityScreen) te).getScreen(side) == null) + if (((ScreenBlockEntity) te).getScreen(side) == null) Util.toast(context.getPlayer(), "turnOn"); else { CompoundTag tag = new CompoundTag(); diff --git a/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java b/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java index 83e5e4d..5771140 100644 --- a/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java +++ b/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java @@ -10,10 +10,9 @@ 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.WebDisplays; import net.montoyo.wd.block.BlockScreen; import net.montoyo.wd.data.ScreenConfigData; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Multiblock; import net.montoyo.wd.utilities.Util; @@ -42,12 +41,12 @@ public class ItemScreenConfigurator extends Item implements WDItem { Multiblock.findOrigin(context.getLevel(), origin, side, null); BlockEntity te = context.getLevel().getBlockEntity(origin.toBlock()); - if (te == null || !(te instanceof TileEntityScreen)) { + if (te == null || !(te instanceof ScreenBlockEntity)) { Util.toast(context.getPlayer(), "turnOn"); return InteractionResult.SUCCESS; } - TileEntityScreen.Screen scr = ((TileEntityScreen) te).getScreen(side); + ScreenBlockEntity.Screen scr = ((ScreenBlockEntity) te).getScreen(side); if (scr == null) Util.toast(context.getPlayer(), "turnOn"); else diff --git a/src/main/java/net/montoyo/wd/item/ItemUpgrade.java b/src/main/java/net/montoyo/wd/item/ItemUpgrade.java index d4721f9..291a7f8 100644 --- a/src/main/java/net/montoyo/wd/item/ItemUpgrade.java +++ b/src/main/java/net/montoyo/wd/item/ItemUpgrade.java @@ -7,10 +7,9 @@ package net.montoyo.wd.item; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.montoyo.wd.WebDisplays; import net.montoyo.wd.core.DefaultUpgrade; import net.montoyo.wd.core.IUpgrade; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.utilities.BlockSide; import org.jetbrains.annotations.NotNull; @@ -26,11 +25,11 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem { } @Override - public void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) { + public void onInstall(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) { } @Override - public boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) { + public boolean onRemove(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) { if (DefaultUpgrade.LASERMOUSE.matchesLaserMouse(is)) tes.clearLaserUser(screenSide); diff --git a/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageAddScreen.java b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageAddScreen.java index 80d65ab..755ce42 100644 --- a/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageAddScreen.java +++ b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageAddScreen.java @@ -10,7 +10,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.WebDisplays; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.net.Packet; import net.montoyo.wd.utilities.*; @@ -22,24 +22,24 @@ import static net.montoyo.wd.block.BlockScreen.hasTE; public class S2CMessageAddScreen extends Packet { private boolean clear; private Vector3i pos; - private TileEntityScreen.Screen[] screens; + private ScreenBlockEntity.Screen[] screens; - public S2CMessageAddScreen(TileEntityScreen tes) { + public S2CMessageAddScreen(ScreenBlockEntity tes) { clear = true; pos = new Vector3i(tes.getBlockPos()); - screens = new TileEntityScreen.Screen[tes.screenCount()]; + screens = new ScreenBlockEntity.Screen[tes.screenCount()]; for (int i = 0; i < tes.screenCount(); i++) screens[i] = tes.getScreen(i); } - public S2CMessageAddScreen(TileEntityScreen tes, TileEntityScreen.Screen... toSend) { + public S2CMessageAddScreen(ScreenBlockEntity tes, ScreenBlockEntity.Screen... toSend) { clear = false; pos = new Vector3i(tes.getBlockPos()); screens = toSend; } - public S2CMessageAddScreen(boolean clear, Vector3i pos, TileEntityScreen.Screen[] screens) { + public S2CMessageAddScreen(boolean clear, Vector3i pos, ScreenBlockEntity.Screen[] screens) { this.clear = clear; this.pos = pos; this.screens = screens; @@ -53,9 +53,9 @@ public class S2CMessageAddScreen extends Packet { int cnt = buf.readByte() & 7; - screens = new TileEntityScreen.Screen[cnt]; + screens = new ScreenBlockEntity.Screen[cnt]; for (int i = 0; i < cnt; i++) { - screens[i] = new TileEntityScreen.Screen(); + screens[i] = new ScreenBlockEntity.Screen(); screens[i].side = BlockSide.values()[buf.readByte()]; screens[i].size = new Vector2i(buf); screens[i].url = buf.readUtf(); @@ -76,7 +76,7 @@ public class S2CMessageAddScreen extends Packet { pos.writeTo(buf); buf.writeByte(screens.length); - for (TileEntityScreen.Screen scr : screens) { + for (ScreenBlockEntity.Screen scr : screens) { buf.writeByte(scr.side.ordinal()); scr.size.writeTo(buf); buf.writeUtf(scr.url); @@ -95,11 +95,11 @@ public class S2CMessageAddScreen extends Packet { ctx.enqueueWork(() -> { Level lvl = (Level) WebDisplays.PROXY.getWorld(ctx); BlockEntity te = lvl.getBlockEntity(pos.toBlock()); - if (!(te instanceof TileEntityScreen)) { + if (!(te instanceof ScreenBlockEntity)) { lvl.setBlockAndUpdate(pos.toBlock(), lvl.getBlockState(pos.toBlock()).setValue(hasTE, true)); te = lvl.getBlockEntity(pos.toBlock()); - if (!(te instanceof TileEntityScreen)) { + if (!(te instanceof ScreenBlockEntity)) { if (clear) Log.error("CMessageAddScreen: Can't add screen to invalid tile entity at %s", pos.toString()); @@ -107,17 +107,17 @@ public class S2CMessageAddScreen extends Packet { } } - TileEntityScreen tes = (TileEntityScreen) te; + ScreenBlockEntity tes = (ScreenBlockEntity) te; if (clear) tes.clear(); - for (TileEntityScreen.Screen entry : screens) { - TileEntityScreen.Screen scr = tes.addScreen(entry.side, entry.size, entry.resolution, null, false); + for (ScreenBlockEntity.Screen entry : screens) { + ScreenBlockEntity.Screen scr = tes.addScreen(entry.side, entry.size, entry.resolution, null, false); scr.rotation = entry.rotation; String webUrl; try { - webUrl = TileEntityScreen.url(entry.url); + webUrl = ScreenBlockEntity.url(entry.url); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageScreenUpdate.java b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageScreenUpdate.java index 05c7bf5..b4c2f88 100644 --- a/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageScreenUpdate.java +++ b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageScreenUpdate.java @@ -14,7 +14,7 @@ import net.montoyo.wd.WebDisplays; import net.montoyo.wd.controls.ScreenControl; import net.montoyo.wd.controls.ScreenControlRegistry; import net.montoyo.wd.controls.builtin.*; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.net.BufferUtils; import net.montoyo.wd.net.Packet; import net.montoyo.wd.utilities.*; @@ -39,49 +39,49 @@ public class S2CMessageScreenUpdate extends Packet { this.control = ScreenControlRegistry.parse(buf); } - public static S2CMessageScreenUpdate setURL(TileEntityScreen screen, BlockSide side, String weburl) { + public static S2CMessageScreenUpdate setURL(ScreenBlockEntity screen, BlockSide side, String weburl) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new SetURLControl(weburl, new Vector3i(screenUpdate.pos)); return screenUpdate; } - public static S2CMessageScreenUpdate setResolution(TileEntityScreen screen, BlockSide side, Vector2i res) { + public static S2CMessageScreenUpdate setResolution(ScreenBlockEntity screen, BlockSide side, Vector2i res) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new ScreenModifyControl(res); return screenUpdate; } - public static S2CMessageScreenUpdate rotation(TileEntityScreen screen, BlockSide side, Rotation rot) { + public static S2CMessageScreenUpdate rotation(ScreenBlockEntity screen, BlockSide side, Rotation rot) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new ScreenModifyControl(rot); return screenUpdate; } - public static S2CMessageScreenUpdate upgrade(TileEntityScreen screen, BlockSide side, boolean adding, ItemStack stack) { + public static S2CMessageScreenUpdate upgrade(ScreenBlockEntity screen, BlockSide side, boolean adding, ItemStack stack) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new ManageRightsAndUpdgradesControl(adding, stack); return screenUpdate; } - public static S2CMessageScreenUpdate click(TileEntityScreen screen, BlockSide side, ClickControl.ControlType mouseMove, Vector2i pos) { + public static S2CMessageScreenUpdate click(ScreenBlockEntity screen, BlockSide side, ClickControl.ControlType mouseMove, Vector2i pos) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new ClickControl(mouseMove, pos); return screenUpdate; } - public static S2CMessageScreenUpdate type(TileEntityScreen screen, BlockSide side, String text) { + public static S2CMessageScreenUpdate type(ScreenBlockEntity screen, BlockSide side, String text) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new KeyTypedControl(text, screenUpdate.pos); return screenUpdate; } - public static S2CMessageScreenUpdate autoVolume(TileEntityScreen screen, BlockSide side, boolean av) { + public static S2CMessageScreenUpdate autoVolume(ScreenBlockEntity screen, BlockSide side, boolean av) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new AutoVolumeControl(av); return screenUpdate; } - public static S2CMessageScreenUpdate owner(TileEntityScreen screen, BlockSide side, NameUUIDPair owner) { + public static S2CMessageScreenUpdate owner(ScreenBlockEntity screen, BlockSide side, NameUUIDPair owner) { S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side); screenUpdate.control = new OwnerControl(owner); return screenUpdate; @@ -107,7 +107,7 @@ public class S2CMessageScreenUpdate extends Packet { ctx.enqueueWork(() -> { Level level = (Level) WebDisplays.PROXY.getWorld(ctx); BlockEntity be = level.getBlockEntity(pos); - if (be instanceof TileEntityScreen tes) { + if (be instanceof ScreenBlockEntity tes) { control.handleClient(pos, side, tes, ctx); } }); diff --git a/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageRedstoneCtrl.java b/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageRedstoneCtrl.java index 0645c3b..ac9c073 100644 --- a/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageRedstoneCtrl.java +++ b/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageRedstoneCtrl.java @@ -12,8 +12,8 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.network.NetworkEvent; import net.montoyo.wd.core.ScreenRights; -import net.montoyo.wd.entity.TileEntityRedCtrl; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.RedstoneControlBlockEntity; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.net.Packet; import net.montoyo.wd.utilities.Util; import net.montoyo.wd.utilities.Vector3i; @@ -50,16 +50,16 @@ public class C2SMessageRedstoneCtrl extends Packet implements Runnable { return; BlockEntity te = world.getBlockEntity(blockPos); - if (te == null || !(te instanceof TileEntityRedCtrl)) + if (te == null || !(te instanceof RedstoneControlBlockEntity)) return; - TileEntityRedCtrl redCtrl = (TileEntityRedCtrl) te; + RedstoneControlBlockEntity redCtrl = (RedstoneControlBlockEntity) te; if (!redCtrl.isScreenChunkLoaded()) { Util.toast(player, "chunkUnloaded"); return; } - TileEntityScreen tes = redCtrl.getConnectedScreen(); + ScreenBlockEntity tes = redCtrl.getConnectedScreen(); if (tes == null) return; diff --git a/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageScreenCtrl.java b/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageScreenCtrl.java index 5ff83bd..9b224e4 100644 --- a/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageScreenCtrl.java +++ b/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageScreenCtrl.java @@ -17,7 +17,7 @@ import net.montoyo.wd.controls.ScreenControlRegistry; import net.montoyo.wd.controls.builtin.*; import net.montoyo.wd.core.JSServerRequest; import net.montoyo.wd.core.MissingPermissionException; -import net.montoyo.wd.entity.TileEntityScreen; +import net.montoyo.wd.entity.ScreenBlockEntity; import net.montoyo.wd.net.BufferUtils; import net.montoyo.wd.net.Packet; import net.montoyo.wd.utilities.*; @@ -40,13 +40,13 @@ public class C2SMessageScreenCtrl extends Packet { public C2SMessageScreenCtrl() { } - public C2SMessageScreenCtrl(TileEntityScreen screen, BlockSide side, ScreenControl control) { + public C2SMessageScreenCtrl(ScreenBlockEntity screen, BlockSide side, ScreenControl control) { this.pos = screen.getBlockPos(); this.side = side; this.control = control; } - protected static C2SMessageScreenCtrl base(TileEntityScreen screen, BlockSide side) { + protected static C2SMessageScreenCtrl base(ScreenBlockEntity screen, BlockSide side) { C2SMessageScreenCtrl packet = new C2SMessageScreenCtrl(); packet.pos = screen.getBlockPos(); packet.side = side; @@ -54,79 +54,79 @@ public class C2SMessageScreenCtrl extends Packet { } @Deprecated(forRemoval = true) - public static C2SMessageScreenCtrl setURL(TileEntityScreen tes, BlockSide side, String url, Vector3i remoteLocation) { + public static C2SMessageScreenCtrl setURL(ScreenBlockEntity tes, BlockSide side, String url, Vector3i remoteLocation) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new SetURLControl(url, remoteLocation); return ret; } @Deprecated(forRemoval = true) - public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, NameUUIDPair friend, boolean del) { + public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, NameUUIDPair friend, boolean del) { this(tes, side, new ModifyFriendListControl(friend, !del)); } @Deprecated(forRemoval = true) - public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, int fr, int or) { + public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, int fr, int or) { this(tes, side, new ManageRightsAndUpdgradesControl(fr, or)); } @Deprecated(forRemoval = true) - public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, ItemStack toRem) { + public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, ItemStack toRem) { this(tes, side, new ManageRightsAndUpdgradesControl(false, toRem)); } @Deprecated(forRemoval = true) - public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, Rotation rot) { + public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, Rotation rot) { this(tes, side, new ScreenModifyControl(rot)); } @Deprecated(forRemoval = true) - public static C2SMessageScreenCtrl vec2(TileEntityScreen tes, BlockSide side, int ctrl, Vector2i vec) { + public static C2SMessageScreenCtrl vec2(ScreenBlockEntity tes, BlockSide side, int ctrl, Vector2i vec) { throw new RuntimeException("Moved: look into ScreenControlRegistry"); } @Deprecated(forRemoval = true) - public static C2SMessageScreenCtrl resolution(TileEntityScreen tes, BlockSide side, Vector2i vec) { + public static C2SMessageScreenCtrl resolution(ScreenBlockEntity tes, BlockSide side, Vector2i vec) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new ScreenModifyControl(vec); return ret; } @Deprecated(forRemoval = true) - public static C2SMessageScreenCtrl type(TileEntityScreen tes, BlockSide side, String text, BlockPos soundPos) { + public static C2SMessageScreenCtrl type(ScreenBlockEntity tes, BlockSide side, String text, BlockPos soundPos) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new KeyTypedControl(text, soundPos); return ret; } - public static C2SMessageScreenCtrl laserMove(TileEntityScreen tes, BlockSide side, Vector2i vec) { + public static C2SMessageScreenCtrl laserMove(ScreenBlockEntity tes, BlockSide side, Vector2i vec) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new LaserControl(LaserControl.ControlType.MOVE, vec); return ret; } - public static C2SMessageScreenCtrl laserDown(TileEntityScreen tes, BlockSide side, Vector2i vec, int button) { + public static C2SMessageScreenCtrl laserDown(ScreenBlockEntity tes, BlockSide side, Vector2i vec, int button) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new LaserControl(LaserControl.ControlType.DOWN, vec, button); return ret; } @Deprecated(forRemoval = true) - public static C2SMessageScreenCtrl laserUp(TileEntityScreen tes, BlockSide side, int button) { + public static C2SMessageScreenCtrl laserUp(ScreenBlockEntity tes, BlockSide side, int button) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new LaserControl(LaserControl.ControlType.UP, null, button); return ret; } @Deprecated(forRemoval = true) - public static C2SMessageScreenCtrl jsRequest(TileEntityScreen tes, BlockSide side, int reqId, JSServerRequest reqType, Object... data) { + public static C2SMessageScreenCtrl jsRequest(ScreenBlockEntity tes, BlockSide side, int reqId, JSServerRequest reqType, Object... data) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new JSRequestControl(reqId, reqType, data); return ret; } @Deprecated(forRemoval = true) - public static C2SMessageScreenCtrl autoVol(TileEntityScreen tes, BlockSide side, boolean av) { + public static C2SMessageScreenCtrl autoVol(ScreenBlockEntity tes, BlockSide side, boolean av) { C2SMessageScreenCtrl ret = base(tes, side); ret.control = new AutoVolumeControl(av); return ret; @@ -150,7 +150,7 @@ public class C2SMessageScreenCtrl extends Packet { control.write(buf); } - public void checkPermission(ServerPlayer sender, TileEntityScreen scr, int right) throws MissingPermissionException { + public void checkPermission(ServerPlayer sender, ScreenBlockEntity scr, int right) throws MissingPermissionException { int prights = scr.getScreen(side).rightsFor(sender); if ((prights & right) == 0) throw new MissingPermissionException(right, sender); @@ -162,7 +162,7 @@ public class C2SMessageScreenCtrl extends Packet { try { Level level = (Level) WebDisplays.PROXY.getWorld(ctx); BlockEntity be = level.getBlockEntity(pos); - if (be instanceof TileEntityScreen tes) { + if (be instanceof ScreenBlockEntity tes) { control.handleServer(pos, side, tes, ctx, (perm) -> { try { checkPermission(ctx.getSender(), tes, perm); diff --git a/src/main/java/net/montoyo/wd/registry/TileRegistry.java b/src/main/java/net/montoyo/wd/registry/TileRegistry.java index 84b6b2f..18f0855 100644 --- a/src/main/java/net/montoyo/wd/registry/TileRegistry.java +++ b/src/main/java/net/montoyo/wd/registry/TileRegistry.java @@ -12,21 +12,21 @@ public class TileRegistry { .create(ForgeRegistries.BLOCK_ENTITY_TYPES, "webdisplays"); //Register tile entities - public static final RegistryObject> SCREEN_BLOCK_ENTITY = TILE_TYPES + public static final RegistryObject> SCREEN_BLOCK_ENTITY = TILE_TYPES .register("screen", () -> BlockEntityType.Builder - .of(TileEntityScreen::new, BlockRegistry.SCREEN_BLOCk.get()).build(null)); + .of(ScreenBlockEntity::new, BlockRegistry.SCREEN_BLOCk.get()).build(null)); public static final RegistryObject> KEYBOARD = TILE_TYPES.register("kb_left", () -> BlockEntityType.Builder - .of(TileEntityKeyboard::new, BlockRegistry.KEYBOARD_BLOCK.get()).build(null)); + .of(KeyboardBlockEntity::new, BlockRegistry.KEYBOARD_BLOCK.get()).build(null)); public static final RegistryObject> REMOTE_CONTROLLER = TILE_TYPES.register("rctrl", - () -> BlockEntityType.Builder.of(TileEntityRCtrl::new, BlockRegistry.REMOTE_CONTROLLER_BLOCK.get()).build(null)); //WITHOUT FACING (>= 3) + () -> BlockEntityType.Builder.of(RemoteControlBlockEntity::new, BlockRegistry.REMOTE_CONTROLLER_BLOCK.get()).build(null)); //WITHOUT FACING (>= 3) public static final RegistryObject> REDSTONE_CONTROLLER = TILE_TYPES.register("redctrl", - () -> BlockEntityType.Builder.of(TileEntityRedCtrl::new, BlockRegistry.REDSTONE_CONTROL_BLOCK.get()).build(null)); + () -> BlockEntityType.Builder.of(RedstoneControlBlockEntity::new, BlockRegistry.REDSTONE_CONTROL_BLOCK.get()).build(null)); public static final RegistryObject> SERVER = TILE_TYPES.register("server", - () -> BlockEntityType.Builder.of(TileEntityServer::new, BlockRegistry.SERVER_BLOCK.get()).build(null)); + () -> BlockEntityType.Builder.of(ServerBlockEntity::new, BlockRegistry.SERVER_BLOCK.get()).build(null)); public static void init(IEventBus bus) { TILE_TYPES.register(bus);