diff --git a/LICENSE b/LICENSE
index b2669d7..49e4784 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1 +1,21 @@
-This mod and its source code is now in public domain. Feel free to do whatever you want with it; make forks, distribute it... whatever I would appreciate it, of course, if you credited me 😊 Thank you!
+MIT License
+
+Copyright (c) 2023 CinemaMod Group
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index e19d6e3..acd5ec4 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,25 @@
-# CinemaMod WebDisplays
-This is a fork of the WebDisplays mod from 1.12, updated to work in newer versions, and with some bug fixes and reworking.
-
-Cinemamod WebDisplays also uses CinemaMod's [MCEF](https://github.com/CinemaMod/mcef) and [JCEF](https://github.com/CinemaMod/java-cef), which should allow for WD to be a bit more seamless than [Chromium's JCEF](https://github.com/chromiumembedded/java-cef) would allow for.
-
# WebDisplays
-WebDisplays adds a screen block, which allows you to browse the internet in minecraft.
+WebDisplays is a mod for creating and interacting with web browsers in Minecraft. You can create screens in your world and browse the internet.
-### Wiki
-* A Wiki which details all blocks/items can be found on [montoyo's website](https://montoyo.net/wdwiki/). However, a lot of stuff has changed since that wiki was written.
+WebDisplays was originally written by montoyo. It is currently maintained by CinemaMod Group.
+
+Discussion: https://discord.gg/rNrh5kW8Ty
+
+## Install
+Download WebDisplays from either:
+- CurseForge: https://legacy.curseforge.com/minecraft/mc-mods/webdisplays
+- Modrinth: TODO
+
+**WebDisplays Requires MCEF!** You must install MCEF in order for WebDisplays to work.
+
+Download MCEF from either:
+- CurseForge: https://legacy.curseforge.com/minecraft/mc-mods/mcef
+- Modrinth: https://modrinth.com/mod/mcef
+
+
+
+
+## Wiki
+[Outdated Wiki from the original creator](https://montoyo.net/wdwiki/index.php?title=Main_Page)
+
+[Outdated Getting Started](https://montoyo.net/wdwiki/index.php?title=Screen)
diff --git a/build.gradle b/build.gradle
index d28a328..10bc6d6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -79,7 +79,6 @@ repositories{
name = "cursemaven"
url = "https://www.cursemaven.com"
}
- flatDir { dirs 'libs' }
maven { url 'https://mcef-download.cinemamod.com/repositories/releases/' }
}
@@ -101,7 +100,7 @@ dependencies {
jar {
manifest {
attributes([
- "Specification-Title": "Webdisplays",
+ "Specification-Title": "WebDisplays",
"Specification-Vendor": "CinemaMod Group",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
diff --git a/gradle.properties b/gradle.properties
index b6708a3..959d7a1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,17 +1,5 @@
# Done to increase the memory available to gradle.
-org.gradle.jvmargs=-Xmx3G
-loom.platform=forge
-
-# Fabric Properties
-# check these on https://fabricmc.net/develop
-minecraft_version=1.19.2
-yarn_mappings=1.19.2+build.28
-loader_version=0.14.14
-
-# Mod Properties
-mod_version = 1.3.3
-maven_group = net.montoyo.wd
-archives_base_name = webdisplays
-
-# Dependencies
-forge_version=1.19.2-43.2.6
+org.gradle.jvmargs = -Xmx3G
+mod_version = 2.0.1-1.20.1
+maven_group = com.cinemamod
+archives_base_name = webdisplays
\ No newline at end of file
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/libs/mcef-2.x.jar b/libs/mcef-2.x.jar
deleted file mode 100644
index f4316ec..0000000
Binary files a/libs/mcef-2.x.jar and /dev/null differ
diff --git a/src/main/java/net/montoyo/wd/SharedProxy.java b/src/main/java/net/montoyo/wd/SharedProxy.java
index 899f91a..408a4c7 100644
--- a/src/main/java/net/montoyo/wd/SharedProxy.java
+++ b/src/main/java/net/montoyo/wd/SharedProxy.java
@@ -14,14 +14,18 @@ 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 net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import javax.annotation.Nonnull;
import java.util.UUID;
@@ -58,7 +62,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/WebDisplays.java b/src/main/java/net/montoyo/wd/WebDisplays.java
index d9be126..564a8c0 100644
--- a/src/main/java/net/montoyo/wd/WebDisplays.java
+++ b/src/main/java/net/montoyo/wd/WebDisplays.java
@@ -43,16 +43,16 @@ import net.montoyo.wd.config.ClientConfig;
import net.montoyo.wd.config.CommonConfig;
import net.montoyo.wd.controls.ScreenControlRegistry;
import net.montoyo.wd.core.*;
-import net.montoyo.wd.init.BlockInit;
-import net.montoyo.wd.init.ItemInit;
-import net.montoyo.wd.init.TabInit;
-import net.montoyo.wd.init.TileInit;
+import net.montoyo.wd.registry.BlockRegistry;
+import net.montoyo.wd.registry.ItemRegistry;
+import net.montoyo.wd.registry.WDTabs;
+import net.montoyo.wd.registry.TileRegistry;
import net.montoyo.wd.miniserv.server.Server;
import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.net.client_bound.S2CMessageServerInfo;
import net.montoyo.wd.utilities.DistSafety;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
import java.io.*;
import java.net.MalformedURLException;
@@ -133,10 +133,10 @@ public class WebDisplays {
WDNetworkRegistry.init();
SOUNDS.register(bus);
onRegisterSounds();
- TabInit.init(bus);
- BlockInit.init(bus);
- ItemInit.init(bus);
- TileInit.init(bus);
+ WDTabs.init(bus);
+ BlockRegistry.init(bus);
+ ItemRegistry.init(bus);
+ TileRegistry.init(bus);
PROXY.preInit();
@@ -256,7 +256,7 @@ public class WebDisplays {
if(!ev.getEntity().level().isClientSide) {
ItemStack is = ev.getEntity().getItem();
- if(is.getItem() == ItemInit.MINEPAD.get()) {
+ if(is.getItem() == ItemRegistry.MINEPAD.get()) {
CompoundTag tag = is.getTag();
if(tag == null) {
@@ -274,7 +274,7 @@ public class WebDisplays {
@SubscribeEvent
public void onPlayerCraft(PlayerEvent.ItemCraftedEvent ev) {
- if(CommonConfig.hardRecipes && ItemInit.isCompCraftItem(ev.getCrafting().getItem()) && (CraftComponent.EXTCARD.makeItemStack().is(ev.getCrafting().getItem()))) {
+ if(CommonConfig.hardRecipes && ItemRegistry.isCompCraftItem(ev.getCrafting().getItem()) && (CraftComponent.EXTCARD.makeItemStack().is(ev.getCrafting().getItem()))) {
if((ev.getEntity() instanceof ServerPlayer && !hasPlayerAdvancement((ServerPlayer) ev.getEntity(), ADV_PAD_BREAK)) || PROXY.hasClientPlayerAdvancement(ADV_PAD_BREAK) != HasAdvancement.YES) {
ev.getCrafting().setDamageValue(CraftComponent.BADEXTCARD.ordinal());
diff --git a/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java b/src/main/java/net/montoyo/wd/block/KeyboardBlockLeft.java
similarity index 84%
rename from src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java
rename to src/main/java/net/montoyo/wd/block/KeyboardBlockLeft.java
index 8f5be72..65cb7bc 100644
--- a/src/main/java/net/montoyo/wd/block/BlockKeyboardLeft.java
+++ b/src/main/java/net/montoyo/wd/block/KeyboardBlockLeft.java
@@ -26,14 +26,13 @@ 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;
import org.jetbrains.annotations.NotNull;
-public class BlockKeyboardLeft extends BlockPeripheral {
-
+public class KeyboardBlockLeft extends PeripheralBlock {
public static final EnumProperty TYPE = EnumProperty.create("type", DefaultPeripheral.class);
public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST);
// public static final DirectionProperty HALF = DirectionProperty.create("facing", Direction.EAST, Direction.WEST);
@@ -47,25 +46,25 @@ public class BlockKeyboardLeft extends BlockPeripheral {
private static final Property>[] properties = new Property>[] {TYPE, FACING};
- public BlockKeyboardLeft() {
+ public KeyboardBlockLeft() {
super(DefaultPeripheral.KEYBOARD);
}
// TODO: make non static (for extensibility purposes)
- public static TileEntityKeyboard getTileEntity(BlockState state, Level world, BlockPos pos) {
- if (state.getBlock() instanceof BlockKeyboardLeft) {
+ public static KeyboardBlockEntity getTileEntity(BlockState state, Level world, BlockPos pos) {
+ if (state.getBlock() instanceof KeyboardBlockLeft) {
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()));
+ BlockPos relative = pos.relative(KeyboardBlockLeft.mapDirection(state.getValue(FACING).getOpposite()));
BlockState ns = world.getBlockState(relative);
- if (ns.getBlock() instanceof BlockPeripheral) {
+ if (ns.getBlock() instanceof PeripheralBlock) {
BlockEntity te = world.getBlockEntity(relative); // TODO: check?
- if (te instanceof TileEntityKeyboard)
- return (TileEntityKeyboard) te;
+ if (te instanceof KeyboardBlockEntity)
+ return (KeyboardBlockEntity) te;
}
return null;
@@ -90,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 = KeyboardBlockLeft.getTileEntity(state, world, pos);
if (tek != null)
tek.simulateCat(entity);
@@ -102,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 = KeyboardBlockLeft.getTileEntity(state, level, pos);
if (tek != null)
return tek.onRightClick(player, hand);
@@ -120,10 +119,10 @@ public class BlockKeyboardLeft extends BlockPeripheral {
}
private static void removeRightPiece(BlockState state, Level world, BlockPos pos) {
- BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING)));
+ BlockPos relative = pos.relative(KeyboardBlockLeft.mapDirection(state.getValue(FACING)));
BlockState ns = world.getBlockState(relative);
- if (ns.getBlock() instanceof BlockKeyboardRight)
+ if (ns.getBlock() instanceof KeyboardBlockRight)
world.setBlock(relative, Blocks.AIR.defaultBlockState(), 3);
}
diff --git a/src/main/java/net/montoyo/wd/block/BlockKeyboardRight.java b/src/main/java/net/montoyo/wd/block/KeyboardBlockRight.java
similarity index 84%
rename from src/main/java/net/montoyo/wd/block/BlockKeyboardRight.java
rename to src/main/java/net/montoyo/wd/block/KeyboardBlockRight.java
index b27f8b5..169ed62 100644
--- a/src/main/java/net/montoyo/wd/block/BlockKeyboardRight.java
+++ b/src/main/java/net/montoyo/wd/block/KeyboardBlockRight.java
@@ -23,32 +23,31 @@ 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;
-import net.montoyo.wd.utilities.BlockSide;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.math.Vector3i;
import org.jetbrains.annotations.NotNull;
-import static net.montoyo.wd.block.BlockKeyboardLeft.KEYBOARD_AABBS;
-import static net.montoyo.wd.block.BlockPeripheral.point;
+import static net.montoyo.wd.block.KeyboardBlockLeft.KEYBOARD_AABBS;
+import static net.montoyo.wd.block.PeripheralBlock.point;
// TODO: merge into KeyboardLeft
-public class BlockKeyboardRight extends Block implements IPeripheral {
-
+public class KeyboardBlockRight extends Block implements IPeripheral {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
- public BlockKeyboardRight() {
+ public KeyboardBlockRight() {
super(Properties.copy(Blocks.STONE)
.strength(1.5f, 10.f));
}
private static void removeLeftPiece(BlockState state, Level world, BlockPos pos) {
- BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING).getOpposite()));
+ BlockPos relative = pos.relative(KeyboardBlockLeft.mapDirection(state.getValue(FACING).getOpposite()));
BlockState ns = world.getBlockState(relative);
- if (ns.getBlock() instanceof BlockKeyboardLeft)
+ if (ns.getBlock() instanceof KeyboardBlockLeft)
world.setBlock(relative, Blocks.AIR.defaultBlockState(), 3);
}
@@ -83,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 = KeyboardBlockLeft.getTileEntity(state, world, pos);
return keyboard != null && keyboard.connect(world, pos, state, scrPos, scrSide);
}
@@ -91,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 = KeyboardBlockLeft.getTileEntity(state, world, pos);
if (tek != null)
tek.simulateCat(entity);
@@ -103,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 = KeyboardBlockLeft.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/PeripheralBlock.java
similarity index 77%
rename from src/main/java/net/montoyo/wd/block/BlockPeripheral.java
rename to src/main/java/net/montoyo/wd/block/PeripheralBlock.java
index bb5b638..40c25f3 100644
--- a/src/main/java/net/montoyo/wd/block/BlockPeripheral.java
+++ b/src/main/java/net/montoyo/wd/block/PeripheralBlock.java
@@ -28,19 +28,19 @@ 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;
import net.montoyo.wd.utilities.Log;
import org.jetbrains.annotations.Nullable;
-public class BlockPeripheral extends WDBlockContainer {
+public class PeripheralBlock extends WDContainerBlock {
DefaultPeripheral type;
- public BlockPeripheral(DefaultPeripheral type) {
+ public PeripheralBlock(DefaultPeripheral type) {
super(BlockBehaviour.Properties.copy(Blocks.STONE).strength(1.5f, 10.f));
this.type = type;
}
@@ -49,12 +49,12 @@ public class BlockPeripheral extends WDBlockContainer {
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
BlockEntityType.BlockEntitySupplier extends BlockEntity> cls = type.getTEClass();
- if(cls == null)
+ if (cls == null)
return null;
try {
return cls.create(pos, state);
- } catch(Throwable t) {
+ } catch (Throwable t) {
Log.errorEx("Couldn't instantiate peripheral TileEntity:", t);
}
@@ -68,18 +68,18 @@ public class BlockPeripheral extends WDBlockContainer {
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
- if(player.isShiftKeyDown())
+ if (player.isShiftKeyDown())
return InteractionResult.FAIL;
- if(player.getItemInHand(hand).getItem() instanceof ItemLinker)
+ if (player.getItemInHand(hand).getItem() instanceof ItemLinker)
return InteractionResult.FAIL;
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;
@@ -92,16 +92,16 @@ public class BlockPeripheral extends WDBlockContainer {
@Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
- if(world.isClientSide)
+ if (world.isClientSide)
return;
- if(placer instanceof Player) {
+ 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,13 +113,13 @@ 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
public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) {
- if(!world.isClientSide) {
+ if (!world.isClientSide) {
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(world, pos)), new S2CMessageCloseGui(pos));
}
super.playerDestroy(world, player, pos, state, blockEntity, tool);
@@ -133,7 +133,7 @@ public class BlockPeripheral extends WDBlockContainer {
public static PacketDistributor.TargetPoint point(Player exclude, Level world, BlockPos bp) {
return new PacketDistributor.TargetPoint((ServerPlayer) exclude, bp.getX(), bp.getY(), bp.getZ(), 64.0, world.dimension());
}
-
+
public static PacketDistributor.TargetPoint point(Level world, BlockPos bp) {
return new PacketDistributor.TargetPoint(bp.getX(), bp.getY(), bp.getZ(), 64.0, world.dimension());
}
diff --git a/src/main/java/net/montoyo/wd/block/BlockScreen.java b/src/main/java/net/montoyo/wd/block/ScreenBlock.java
similarity index 79%
rename from src/main/java/net/montoyo/wd/block/BlockScreen.java
rename to src/main/java/net/montoyo/wd/block/ScreenBlock.java
index 071378a..34950bb 100644
--- a/src/main/java/net/montoyo/wd/block/BlockScreen.java
+++ b/src/main/java/net/montoyo/wd/block/ScreenBlock.java
@@ -13,10 +13,8 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
-import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
@@ -35,53 +33,31 @@ import net.montoyo.wd.core.IUpgrade;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.SetURLData;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
-import net.montoyo.wd.init.BlockInit;
+import net.montoyo.wd.entity.ScreenBlockEntity;
import net.montoyo.wd.item.ItemLaserPointer;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3f;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.serialization.Util;
import org.jetbrains.annotations.NotNull;
-public class BlockScreen extends BaseEntityBlock {
-
+public class ScreenBlock extends BaseEntityBlock {
public static final BooleanProperty hasTE = BooleanProperty.create("haste");
public static final BooleanProperty emitting = BooleanProperty.create("emitting");
private static final Property>[] properties = new Property>[]{hasTE, emitting};
- public BlockScreen(Properties properties) {
+ public ScreenBlock(Properties properties) {
super(properties.strength(1.5f, 10.f));
this.registerDefaultState(this.defaultBlockState().setValue(hasTE, false).setValue(emitting, false));
}
- @Override
- protected void createBlockStateDefinition(StateDefinition.Builder builder) {
- builder.add(properties);
- }
-
- @Override
- public RenderShape getRenderShape(BlockState state) {
- return RenderShape.MODEL;
- }
-
- public static boolean isntScreenBlock(Level world, Vector3i pos) {
- return world.getBlockState(pos.toBlock()).getBlock() != BlockInit.blockScreen.get();
- }
-
- @org.jetbrains.annotations.Nullable
- @Override
- public BlockState getStateForPlacement(BlockPlaceContext context) {
- return super.getStateForPlacement(context);
- }
-
- @Override
- public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos currentPos, BlockPos neighborPos) {
- return super.updateShape(state, direction, neighborState, level, currentPos, neighborPos);
- }
-
@Override
public void onRemove(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) {
// TODO: make this also get called on client?
if (p_60518_.getBlock() == p_60515_.getBlock()) return;
-
+
for (BlockSide value : BlockSide.values()) {
Vector3i vec = new Vector3i(p_60517_.getX(), p_60517_.getY(), p_60517_.getZ());
Multiblock.findOrigin(p_60516_, vec, value, null);
@@ -108,7 +84,7 @@ public class BlockScreen extends BaseEntityBlock {
return InteractionResult.FAIL;
else if (heldItem.getItem() instanceof ItemLaserPointer)
return InteractionResult.FAIL; // laser pointer already handles stuff
-
+
// handling the off hand leads to double clicking
if (!isUpgrade && hand == InteractionHand.OFF_HAND)
return InteractionResult.FAIL;
@@ -122,13 +98,13 @@ 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) {
ScreenData scr = te.getScreen(side);
if (sneaking) { //Right Click
- if((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0)
+ if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0)
Util.toast(player, "restrictions");
else
(new SetURLData(pos, scr.side, scr.url)).sendTo((ServerPlayer) player);
@@ -160,11 +136,11 @@ public class BlockScreen extends BaseEntityBlock {
}
Vector2i tmp = new Vector2i();
-
+
float hitX = ((float) hit.getLocation().x) - (float) te.getBlockPos().getX();
float hitY = ((float) hit.getLocation().y) - (float) te.getBlockPos().getY();
float hitZ = ((float) hit.getLocation().z) - (float) te.getBlockPos().getZ();
-
+
if (hit2pixels(side, hit.getBlockPos(), new Vector3i(hit.getBlockPos()), scr, hitX, hitY, hitZ, tmp))
te.click(side, tmp);
return InteractionResult.CONSUME;
@@ -198,7 +174,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;
}
@@ -208,13 +184,13 @@ public class BlockScreen extends BaseEntityBlock {
@Override
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos source,
- boolean isMoving){
+ boolean isMoving) {
if (block != this && !world.isClientSide && !state.getValue(emitting)) {
for (BlockSide side : BlockSide.values()) {
Vector3i vec = new Vector3i(pos);
Multiblock.findOrigin(world, vec, side, null);
- TileEntityScreen tes = (TileEntityScreen) world.getBlockEntity(vec.toBlock());
+ 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();
@@ -227,72 +203,59 @@ public class BlockScreen extends BaseEntityBlock {
public static boolean hit2pixels(BlockSide side, BlockPos bpos, Vector3i pos, ScreenData scr, float hitX, float hitY, float hitZ, Vector2i dst) {
if(side.right.x < 0)
hitX -= 1.f;
-
+
if(side.right.z < 0 || side == BlockSide.TOP || side == BlockSide.BOTTOM)
hitZ -= 1.f;
-
- Vector3f rel = new Vector3f(bpos.getX(), bpos.getY(), bpos.getZ());
- rel.sub((float) pos.x, (float) pos.y, (float) pos.z);
- rel.add(hitX, hitY, hitZ);
-
+
+ Vector3f rel = new Vector3f(hitX, hitY, hitZ);
+
float cx = rel.dot(side.right.toFloat()) - 2.f / 16.f;
float cy = rel.dot(side.up.toFloat()) - 2.f / 16.f;
float sw = ((float) scr.size.x) - 4.f / 16.f;
float sh = ((float) scr.size.y) - 4.f / 16.f;
-
+
cx /= sw;
cy /= sh;
-
- if(cx >= 0.f && cx <= 1.0 && cy >= 0.f && cy <= 1.f) {
- if(side != BlockSide.BOTTOM)
+
+ if (cx >= 0.f && cx <= 1.0 && cy >= 0.f && cy <= 1.f) {
+ if (side != BlockSide.BOTTOM)
cy = 1.f - cy;
-
- switch(scr.rotation) {
+
+ switch (scr.rotation) {
case ROT_90:
cy = 1.0f - cy;
break;
-
+
case ROT_180:
cx = 1.0f - cx;
cy = 1.0f - cy;
break;
-
+
case ROT_270:
cx = 1.0f - cx;
break;
-
- default:
- break;
}
-
+
cx *= (float) scr.resolution.x;
cy *= (float) scr.resolution.y;
-
- if(scr.rotation.isVertical) {
+
+ if (scr.rotation.isVertical) {
dst.x = (int) cy;
dst.y = (int) cx;
} else {
dst.x = (int) cx;
dst.y = (int) cy;
}
-
+
return true;
}
-
- return false;
- }
- @org.jetbrains.annotations.Nullable
- @Override
- public BlockEntity newBlockEntity (BlockPos pos, BlockState state){
- if (!state.getValue(hasTE))
- return null;
- return new TileEntityScreen(pos, state);
+ return false;
}
/************************************************* DESTRUCTION HANDLING *************************************************/
- private void onDestroy (Level world, BlockPos pos, Player ply){
+ private void onDestroy(Level world, BlockPos pos, Player ply) {
if (!world.isClientSide) {
Vector3i bp = new Vector3i(pos);
Multiblock.BlockOverride override = new Multiblock.BlockOverride(bp, Multiblock.OverrideAction.SIMULATE);
@@ -302,28 +265,28 @@ public class BlockScreen extends BaseEntityBlock {
}
}
- private void destroySide (Level world, Vector3i pos, BlockSide side, Multiblock.BlockOverride override, Player
- source){
+ private void destroySide(Level world, Vector3i pos, BlockSide side, Multiblock.BlockOverride override, Player
+ source) {
Multiblock.findOrigin(world, pos, side, override);
BlockPos bp = pos.toBlock();
BlockEntity te = world.getBlockEntity(bp);
- 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.
}
}
@Override
- public boolean onDestroyedByPlayer (BlockState state, Level level, BlockPos pos, Player player,
- boolean willHarvest, FluidState fluid){
+ public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player,
+ boolean willHarvest, FluidState fluid) {
onDestroy(level, pos, player);
return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid);
}
@Override
- public void setPlacedBy (Level world, @NotNull BlockPos pos, @NotNull BlockState
- state, @org.jetbrains.annotations.Nullable LivingEntity whoDidThisShit, @NotNull ItemStack stack){
+ public void setPlacedBy(Level world, @NotNull BlockPos pos, @NotNull BlockState
+ state, @org.jetbrains.annotations.Nullable LivingEntity whoDidThisShit, @NotNull ItemStack stack) {
if (world.isClientSide)
return;
@@ -338,25 +301,42 @@ public class BlockScreen extends BaseEntityBlock {
neighbors[5] = new Vector3i(pos.getX(), pos.getY(), pos.getZ() - 1);
for (Vector3i neighbor : neighbors) {
- if (world.getBlockState(neighbor.toBlock()).getBlock() instanceof BlockScreen) {
+ if (world.getBlockState(neighbor.toBlock()).getBlock() instanceof ScreenBlock) {
for (BlockSide bs : BlockSide.values())
destroySide(world, neighbor.clone(), bs, override, (whoDidThisShit instanceof Player) ? ((Player) whoDidThisShit) : null);
}
}
}
+ /************************************************* STUFF THAT'S UNLIKELY TO BE TOUCHED BUT NEEDS TO BE HERE *************************************************/
+
@Override
- public @NotNull PushReaction getPistonPushReaction (BlockState state){
+ public @NotNull PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.IGNORE;
}
@Override
- public int getSignal (BlockState state, BlockGetter level, BlockPos pos, Direction direction){
+ public int getSignal(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return state.getValue(emitting) ? 15 : 0;
}
@Override
- public boolean isSignalSource (BlockState state){
+ public boolean isSignalSource(BlockState state) {
return state.getValue(emitting);
}
+
+ @Override
+ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
+ return state.getValue(hasTE) ? new ScreenBlockEntity(pos, state) : null;
+ }
+
+ @Override
+ public RenderShape getRenderShape(BlockState state) {
+ return RenderShape.MODEL;
+ }
+
+ @Override
+ protected void createBlockStateDefinition(StateDefinition.Builder builder) {
+ builder.add(properties);
+ }
}
diff --git a/src/main/java/net/montoyo/wd/block/WDBlockContainer.java b/src/main/java/net/montoyo/wd/block/WDContainerBlock.java
similarity index 74%
rename from src/main/java/net/montoyo/wd/block/WDBlockContainer.java
rename to src/main/java/net/montoyo/wd/block/WDContainerBlock.java
index c62659f..6c7dc55 100644
--- a/src/main/java/net/montoyo/wd/block/WDBlockContainer.java
+++ b/src/main/java/net/montoyo/wd/block/WDContainerBlock.java
@@ -7,11 +7,11 @@ package net.montoyo.wd.block;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.BaseEntityBlock;
-public abstract class WDBlockContainer extends BaseEntityBlock {
+public abstract class WDContainerBlock extends BaseEntityBlock {
protected static BlockItem itemBlock;
- public WDBlockContainer(Properties arg) {
+ public WDContainerBlock(Properties arg) {
super(arg);
}
diff --git a/src/main/java/net/montoyo/wd/block/item/KeyboardItem.java b/src/main/java/net/montoyo/wd/block/item/KeyboardItem.java
index 381c500..ad776e0 100644
--- a/src/main/java/net/montoyo/wd/block/item/KeyboardItem.java
+++ b/src/main/java/net/montoyo/wd/block/item/KeyboardItem.java
@@ -7,48 +7,48 @@ import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
-import net.montoyo.wd.block.BlockKeyboardLeft;
-import net.montoyo.wd.init.BlockInit;
+import net.montoyo.wd.block.KeyboardBlockLeft;
+import net.montoyo.wd.registry.BlockRegistry;
public class KeyboardItem extends BlockItem {
- public KeyboardItem(Block arg, Properties arg2) {
- super(arg, arg2);
- }
-
- @Override
- protected boolean placeBlock(BlockPlaceContext arg, BlockState arg2) {
- Direction facing = arg.getHorizontalDirection();
- arg2 = arg2.setValue(BlockKeyboardLeft.FACING, facing);
-
- Direction d = BlockKeyboardLeft.mapDirection(facing);
-
- if (isValid(arg.getClickedPos(), arg.getLevel(), arg2, d)) {
- Block kbRight = BlockInit.blockKbRight.get();
- BlockState rightState = kbRight.defaultBlockState();
-
- rightState = rightState.setValue(BlockKeyboardLeft.FACING, facing);
- if (!arg.getLevel().setBlock(
- arg.getClickedPos().relative(d),
- rightState,
- 11
- )) return false;
- return arg.getLevel().setBlock(arg.getClickedPos(), arg2, 11);// 161
- } else if (isValid(arg.getClickedPos().relative(d.getOpposite(), 2), arg.getLevel(), arg2, d)) {
- Block kbRight = BlockInit.blockKbRight.get();
- BlockState rightState = kbRight.defaultBlockState();
-
- rightState = rightState.setValue(BlockKeyboardLeft.FACING, facing);
- if (!arg.getLevel().setBlock(
- arg.getClickedPos(),
- rightState,
- 11
- )) return false;
- return arg.getLevel().setBlock(arg.getClickedPos().relative(d.getOpposite()), arg2, 11);// 161
- }
- return false;
- }
-
- private boolean isValid(BlockPos pos, Level level, BlockState state, Direction d) {
- return level.getBlockState(pos.relative(d)).isAir();
- }
+ public KeyboardItem(Block arg, Properties arg2) {
+ super(arg, arg2);
+ }
+
+ @Override
+ protected boolean placeBlock(BlockPlaceContext arg, BlockState arg2) {
+ Direction facing = arg.getHorizontalDirection();
+ arg2 = arg2.setValue(KeyboardBlockLeft.FACING, facing);
+
+ Direction d = KeyboardBlockLeft.mapDirection(facing);
+
+ if (isValid(arg.getClickedPos(), arg.getLevel(), arg2, d)) {
+ Block kbRight = BlockRegistry.blockKbRight.get();
+ BlockState rightState = kbRight.defaultBlockState();
+
+ rightState = rightState.setValue(KeyboardBlockLeft.FACING, facing);
+ if (!arg.getLevel().setBlock(
+ arg.getClickedPos().relative(d),
+ rightState,
+ 11
+ )) return false;
+ return arg.getLevel().setBlock(arg.getClickedPos(), arg2, 11);// 161
+ } else if (isValid(arg.getClickedPos().relative(d.getOpposite(), 2), arg.getLevel(), arg2, d)) {
+ Block kbRight = BlockRegistry.blockKbRight.get();
+ BlockState rightState = kbRight.defaultBlockState();
+
+ rightState = rightState.setValue(KeyboardBlockLeft.FACING, facing);
+ if (!arg.getLevel().setBlock(
+ arg.getClickedPos(),
+ rightState,
+ 11
+ )) return false;
+ return arg.getLevel().setBlock(arg.getClickedPos().relative(d.getOpposite()), arg2, 11);// 161
+ }
+ return false;
+ }
+
+ private boolean isValid(BlockPos pos, Level level, BlockState state, Direction d) {
+ return level.getBlockState(pos.relative(d)).isAir();
+ }
}
diff --git a/src/main/java/net/montoyo/wd/client/ClientProxy.java b/src/main/java/net/montoyo/wd/client/ClientProxy.java
index 50837b9..36acce6 100644
--- a/src/main/java/net/montoyo/wd/client/ClientProxy.java
+++ b/src/main/java/net/montoyo/wd/client/ClientProxy.java
@@ -10,13 +10,11 @@ import com.mojang.authlib.GameProfile;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
-import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
@@ -24,8 +22,6 @@ import net.minecraft.client.multiplayer.ClientAdvancements;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
-import net.minecraft.client.renderer.texture.TextureAtlas;
-import net.minecraft.client.resources.model.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
@@ -62,20 +58,18 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.network.NetworkEvent;
import net.montoyo.wd.SharedProxy;
import net.montoyo.wd.WebDisplays;
-import net.montoyo.wd.block.BlockScreen;
+import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.client.gui.*;
import net.montoyo.wd.client.gui.loading.GuiLoader;
import net.montoyo.wd.client.js.WDRouter;
import net.montoyo.wd.client.renderers.*;
-import net.montoyo.wd.config.ClientConfig;
import net.montoyo.wd.core.HasAdvancement;
-import net.montoyo.wd.core.JSServerRequest;
import net.montoyo.wd.data.GuiData;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
-import net.montoyo.wd.init.BlockInit;
-import net.montoyo.wd.init.ItemInit;
-import net.montoyo.wd.init.TileInit;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.registry.BlockRegistry;
+import net.montoyo.wd.registry.ItemRegistry;
+import net.montoyo.wd.registry.TileRegistry;
import net.montoyo.wd.item.ItemLaserPointer;
import net.montoyo.wd.item.ItemMinePad2;
import net.montoyo.wd.item.WDItem;
@@ -83,6 +77,11 @@ import net.montoyo.wd.miniserv.client.Client;
import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.net.server_bound.C2SMessageMinepadUrl;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import org.cef.CefSettings;
import org.cef.browser.CefBrowser;
import org.cef.browser.CefFrame;
@@ -91,7 +90,6 @@ import org.cef.callback.CefQueryCallback;
import org.cef.handler.CefDisplayHandler;
import org.cef.handler.CefMessageRouterHandlerAdapter;
import org.cef.misc.CefCursorType;
-import org.cef.network.CefRequest;
import org.joml.Vector3d;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -155,7 +153,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
BlockPos bpos = result.getBlockPos();
- if (result.getType() != HitResult.Type.BLOCK || mc.level.getBlockState(bpos).getBlock() != BlockInit.blockScreen.get()) {
+ if (result.getType() != HitResult.Type.BLOCK || mc.level.getBlockState(bpos).getBlock() != BlockRegistry.SCREEN_BLOCk.get()) {
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
poseStack.blit(new ResourceLocation(
@@ -203,7 +201,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);
}
@@ -236,7 +234,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
@@ -247,7 +245,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
/**************************************** INHERITED METHODS ****************************************/
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
- BlockEntityRenderers.register(TileInit.SCREEN_BLOCK_ENTITY.get(), new ScreenRenderer.ScreenRendererProvider());
+ BlockEntityRenderers.register(TileRegistry.SCREEN_BLOCK_ENTITY.get(), new ScreenRenderer.ScreenRendererProvider());
}
@SubscribeEvent
@@ -327,7 +325,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) {
@@ -548,7 +546,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
}
}
- for (TileEntityScreen tes : screenTracking)
+ for (ScreenBlockEntity tes : screenTracking)
tes.updateClientSideURL(browser, url);
}
}
@@ -658,7 +656,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;
@@ -787,10 +785,10 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
Item item = ev.getItemStack().getItem();
IItemRenderer renderer;
- if (ItemInit.MINEPAD.isPresent() && ItemInit.LASER_POINTER.isPresent()) {
- if (item == ItemInit.MINEPAD.get())
+ if (ItemRegistry.MINEPAD.isPresent() && ItemRegistry.LASER_POINTER.isPresent()) {
+ if (item == ItemRegistry.MINEPAD.get())
renderer = minePadRenderer;
- else if (item == ItemInit.LASER_POINTER.get())
+ else if (item == ItemRegistry.LASER_POINTER.get())
renderer = laserPointerRenderer;
else
return;
@@ -830,8 +828,8 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
for (int i = 0; i < cnt; i++) {
ItemStack item = inv.get(i);
- if (ItemInit.MINEPAD.isPresent()) {
- if (item.getItem() == ItemInit.MINEPAD.get()) {
+ if (ItemRegistry.MINEPAD.isPresent()) {
+ if (item.getItem() == ItemRegistry.MINEPAD.get()) {
CompoundTag tag = item.getTag();
if (tag != null && tag.contains("PadID"))
@@ -863,13 +861,13 @@ 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++) {
ScreenData scr = tes.getScreen(i);
@@ -912,7 +910,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
public static void onDrawSelection(RenderHighlightEvent event) {
if (event.getTarget() instanceof BlockHitResult bhr) {
BlockState state = Minecraft.getInstance().level.getBlockState(bhr.getBlockPos());
- if (state.getBlock() instanceof BlockScreen screen) {
+ if (state.getBlock() instanceof ScreenBlock screen) {
Vector3i vec = new Vector3i(bhr.getBlockPos().getX(), bhr.getBlockPos().getY(), bhr.getBlockPos().getZ());
BlockSide side = BlockSide.fromInt(bhr.getDirection().ordinal());
Multiblock.findOrigin(
@@ -924,7 +922,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/WDScheme.java b/src/main/java/net/montoyo/wd/client/WDScheme.java
index 40caf0f..1956eed 100644
--- a/src/main/java/net/montoyo/wd/client/WDScheme.java
+++ b/src/main/java/net/montoyo/wd/client/WDScheme.java
@@ -8,7 +8,7 @@ import net.montoyo.wd.miniserv.Constants;
import net.montoyo.wd.miniserv.client.Client;
import net.montoyo.wd.miniserv.client.ClientTaskGetFile;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
import org.cef.callback.CefCallback;
import org.cef.handler.CefResourceHandler;
import org.cef.misc.IntRef;
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 aca4c5f..973042b 100644
--- a/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java
+++ b/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java
@@ -23,13 +23,13 @@ import net.montoyo.wd.client.gui.controls.Label;
import net.montoyo.wd.client.gui.loading.FillControl;
import net.montoyo.wd.client.js.WDRouter;
import net.montoyo.wd.entity.ScreenData;
-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;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.TypeData;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.TypeData;
+import net.montoyo.wd.utilities.serialization.Util;
import org.cef.browser.CefBrowser;
import org.cef.browser.CefFrame;
import org.cef.browser.CefMessageRouter;
@@ -53,7 +53,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;
@@ -69,7 +69,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/GuiMinePad.java b/src/main/java/net/montoyo/wd/client/gui/GuiMinePad.java
index f67dcb2..0e9ef15 100644
--- a/src/main/java/net/montoyo/wd/client/gui/GuiMinePad.java
+++ b/src/main/java/net/montoyo/wd/client/gui/GuiMinePad.java
@@ -4,7 +4,6 @@
package net.montoyo.wd.client.gui;
-import com.cinemamod.mcef.MCEF;
import com.cinemamod.mcef.MCEFBrowser;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
@@ -16,8 +15,7 @@ import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.client.ClientProxy;
-import net.montoyo.wd.utilities.BlockSide;
-import org.cef.browser.CefBrowserOsr;
+import net.montoyo.wd.utilities.data.BlockSide;
import org.cef.misc.CefCursorType;
import org.lwjgl.glfw.GLFW;
diff --git a/src/main/java/net/montoyo/wd/client/gui/GuiRedstoneCtrl.java b/src/main/java/net/montoyo/wd/client/gui/GuiRedstoneCtrl.java
index 55cbe99..6275e3b 100644
--- a/src/main/java/net/montoyo/wd/client/gui/GuiRedstoneCtrl.java
+++ b/src/main/java/net/montoyo/wd/client/gui/GuiRedstoneCtrl.java
@@ -7,16 +7,11 @@ package net.montoyo.wd.client.gui;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
-import net.montoyo.wd.WebDisplays;
-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.net.WDNetworkRegistry;
-import net.montoyo.wd.net.server_bound.C2SMessageRedstoneCtrl;
-import net.montoyo.wd.utilities.BlockSide;
-import net.montoyo.wd.utilities.Util;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.math.Vector3i;
import javax.annotation.Nullable;
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 1aca969..48f2032 100644
--- a/src/main/java/net/montoyo/wd/client/gui/GuiScreenConfig.java
+++ b/src/main/java/net/montoyo/wd/client/gui/GuiScreenConfig.java
@@ -16,11 +16,15 @@ 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.ScreenData;
-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;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import org.lwjgl.glfw.GLFW;
import javax.annotation.Nullable;
@@ -31,7 +35,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;
@@ -120,7 +124,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;
diff --git a/src/main/java/net/montoyo/wd/client/gui/GuiServer.java b/src/main/java/net/montoyo/wd/client/gui/GuiServer.java
index 4a2e71c..dcbba35 100644
--- a/src/main/java/net/montoyo/wd/client/gui/GuiServer.java
+++ b/src/main/java/net/montoyo/wd/client/gui/GuiServer.java
@@ -23,9 +23,11 @@ import net.montoyo.wd.miniserv.Constants;
import net.montoyo.wd.miniserv.client.*;
import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
+import net.montoyo.wd.utilities.serialization.Util;
import org.lwjgl.glfw.GLFW;
-import org.lwjgl.opengl.GL;
-import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
import javax.swing.filechooser.FileSystemView;
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..c83ef41 100644
--- a/src/main/java/net/montoyo/wd/client/gui/GuiSetURL2.java
+++ b/src/main/java/net/montoyo/wd/client/gui/GuiSetURL2.java
@@ -15,14 +15,14 @@ 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;
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
-import net.montoyo.wd.utilities.BlockSide;
-import net.montoyo.wd.utilities.Util;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.serialization.Util;
+import net.montoyo.wd.utilities.math.Vector3i;
import java.io.IOException;
import java.util.Map;
@@ -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/gui/WDScreen.java b/src/main/java/net/montoyo/wd/client/gui/WDScreen.java
index 1a1740e..ee86c72 100644
--- a/src/main/java/net/montoyo/wd/client/gui/WDScreen.java
+++ b/src/main/java/net/montoyo/wd/client/gui/WDScreen.java
@@ -8,7 +8,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
@@ -27,6 +26,10 @@ import net.montoyo.wd.client.gui.loading.JsonOWrapper;
import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.net.server_bound.C2SMessageACQuery;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.data.Bounds;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import javax.annotation.Nullable;
import java.io.IOException;
diff --git a/src/main/java/net/montoyo/wd/client/gui/controls/Control.java b/src/main/java/net/montoyo/wd/client/gui/controls/Control.java
index 1d973a1..c32ade0 100644
--- a/src/main/java/net/montoyo/wd/client/gui/controls/Control.java
+++ b/src/main/java/net/montoyo/wd/client/gui/controls/Control.java
@@ -14,20 +14,18 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
-import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.montoyo.wd.client.gui.WDScreen;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
-import net.montoyo.wd.utilities.Bounds;
+import net.montoyo.wd.utilities.data.Bounds;
import org.joml.Matrix4f;
import java.util.Arrays;
import static com.mojang.math.Axis.XP;
-import static org.lwjgl.opengl.GL11.*;
@OnlyIn(Dist.CLIENT)
public abstract class Control {
diff --git a/src/main/java/net/montoyo/wd/client/gui/controls/ControlGroup.java b/src/main/java/net/montoyo/wd/client/gui/controls/ControlGroup.java
index ce32abf..1f2460c 100644
--- a/src/main/java/net/montoyo/wd/client/gui/controls/ControlGroup.java
+++ b/src/main/java/net/montoyo/wd/client/gui/controls/ControlGroup.java
@@ -7,18 +7,14 @@ package net.montoyo.wd.client.gui.controls;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
-import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
-import net.montoyo.wd.utilities.Bounds;
-import org.lwjgl.opengl.GL11;
+import net.montoyo.wd.utilities.data.Bounds;
import java.util.Arrays;
-import static org.lwjgl.opengl.GL11.*;
-
public class ControlGroup extends Container {
private int width;
diff --git a/src/main/java/net/montoyo/wd/client/gui/controls/YTButton.java b/src/main/java/net/montoyo/wd/client/gui/controls/YTButton.java
index 4852f2a..3d22159 100644
--- a/src/main/java/net/montoyo/wd/client/gui/controls/YTButton.java
+++ b/src/main/java/net/montoyo/wd/client/gui/controls/YTButton.java
@@ -6,7 +6,7 @@ package net.montoyo.wd.client.gui.controls;
import net.minecraft.network.chat.Component;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
import net.montoyo.wd.utilities.VideoType;
import java.net.MalformedURLException;
diff --git a/src/main/java/net/montoyo/wd/client/renderers/LaserPointerRenderer.java b/src/main/java/net/montoyo/wd/client/renderers/LaserPointerRenderer.java
index 244720c..3b9af81 100644
--- a/src/main/java/net/montoyo/wd/client/renderers/LaserPointerRenderer.java
+++ b/src/main/java/net/montoyo/wd/client/renderers/LaserPointerRenderer.java
@@ -16,10 +16,9 @@ import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.montoyo.wd.client.ClientProxy;
-import net.montoyo.wd.init.ItemInit;
+import net.montoyo.wd.registry.ItemRegistry;
import net.montoyo.wd.item.ItemLaserPointer;
import org.joml.Matrix4f;
-import org.lwjgl.opengl.GL11;
import static com.mojang.math.Axis.*;
@@ -40,7 +39,7 @@ public final class LaserPointerRenderer implements IItemRenderer {
ClientProxy.mouseOn ||
ItemLaserPointer.isOn()
) &&
- mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.LASER_POINTER.get()) &&
+ mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemRegistry.LASER_POINTER.get()) &&
(mc.hitResult == null || mc.hitResult.getType() == HitResult.Type.BLOCK || mc.hitResult.getType() == HitResult.Type.MISS);
}
diff --git a/src/main/java/net/montoyo/wd/client/renderers/ScreenBaker.java b/src/main/java/net/montoyo/wd/client/renderers/ScreenBaker.java
index 4a01654..5fa644a 100644
--- a/src/main/java/net/montoyo/wd/client/renderers/ScreenBaker.java
+++ b/src/main/java/net/montoyo/wd/client/renderers/ScreenBaker.java
@@ -19,9 +19,9 @@ import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.client.model.data.ModelProperty;
-import net.montoyo.wd.utilities.BlockSide;
-import net.montoyo.wd.utilities.Vector3f;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.math.Vector3f;
+import net.montoyo.wd.utilities.math.Vector3i;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
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 75e08a0..14cf7bf 100644
--- a/src/main/java/net/montoyo/wd/client/renderers/ScreenRenderer.java
+++ b/src/main/java/net/montoyo/wd/client/renderers/ScreenRenderer.java
@@ -12,21 +12,20 @@ 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.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
-import net.montoyo.wd.utilities.Vector3f;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.math.Vector3f;
+import net.montoyo.wd.utilities.math.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();
}
}
@@ -36,7 +35,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;
diff --git a/src/main/java/net/montoyo/wd/controls/ScreenControl.java b/src/main/java/net/montoyo/wd/controls/ScreenControl.java
index a1c2410..ada2821 100644
--- a/src/main/java/net/montoyo/wd/controls/ScreenControl.java
+++ b/src/main/java/net/montoyo/wd/controls/ScreenControl.java
@@ -8,8 +8,8 @@ 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.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
import java.util.Objects;
import java.util.function.Function;
@@ -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..11d82ed 100644
--- a/src/main/java/net/montoyo/wd/controls/ScreenControlRegistry.java
+++ b/src/main/java/net/montoyo/wd/controls/ScreenControlRegistry.java
@@ -8,8 +8,8 @@ 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.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Log;
import java.lang.reflect.Method;
@@ -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..35c9f3a 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/AutoVolumeControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/AutoVolumeControl.java
@@ -9,8 +9,8 @@ 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.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.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..68e1ee4 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/ClickControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/ClickControl.java
@@ -8,9 +8,9 @@ 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.Vector2i;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.math.Vector2i;
import java.util.function.Function;
@@ -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..b394a5f 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.Log;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
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..42390d0 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/KeyTypedControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/KeyTypedControl.java
@@ -9,8 +9,8 @@ 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.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.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..ac8c25a 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/LaserControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/LaserControl.java
@@ -9,9 +9,9 @@ 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.Vector2i;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.math.Vector2i;
import java.util.function.Function;
@@ -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 ced1a30..512c65a 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/ManageRightsAndUpdgradesControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/ManageRightsAndUpdgradesControl.java
@@ -12,8 +12,8 @@ import net.montoyo.wd.controls.ScreenControl;
import net.montoyo.wd.core.MissingPermissionException;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
-import net.montoyo.wd.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
import java.util.function.Function;
@@ -80,7 +80,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 -> {
@@ -103,7 +103,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 -> {
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..5926975 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/ModifyFriendListControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/ModifyFriendListControl.java
@@ -10,9 +10,9 @@ 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.NameUUIDPair;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import java.util.function.Function;
@@ -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..ab81be4 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/OwnerControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/OwnerControl.java
@@ -8,9 +8,9 @@ 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.NameUUIDPair;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import java.util.function.Function;
@@ -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..ed10ee6 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/ScreenModifyControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/ScreenModifyControl.java
@@ -9,10 +9,10 @@ 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.Rotation;
-import net.montoyo.wd.utilities.Vector2i;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.math.Vector2i;
import java.util.function.Function;
@@ -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..04618dd 100644
--- a/src/main/java/net/montoyo/wd/controls/builtin/SetURLControl.java
+++ b/src/main/java/net/montoyo/wd/controls/builtin/SetURLControl.java
@@ -9,9 +9,9 @@ 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.math.Vector3i;
import java.util.function.Function;
@@ -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..3c442ec 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.utilities.BlockSide;
-import net.montoyo.wd.utilities.NameUUIDPair;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
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/AdvancementIcon.java b/src/main/java/net/montoyo/wd/core/AdvancementIcon.java
deleted file mode 100644
index b81790f..0000000
--- a/src/main/java/net/montoyo/wd/core/AdvancementIcon.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2018 BARBOTIN Nicolas
- */
-
-package net.montoyo.wd.core;
-
-public enum AdvancementIcon {
-
- WEB_DISPLAYS("wd"),
- BROKEN_PAD("brokenpad"),
- PIGEON("pigeon");
-
- private final String name;
-
- AdvancementIcon(String n) {
- name = n;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
-}
diff --git a/src/main/java/net/montoyo/wd/core/CCArguments.java b/src/main/java/net/montoyo/wd/core/CCArguments.java
index caab3ae..3dbaf91 100644
--- a/src/main/java/net/montoyo/wd/core/CCArguments.java
+++ b/src/main/java/net/montoyo/wd/core/CCArguments.java
@@ -7,6 +7,7 @@ package net.montoyo.wd.core;
import java.util.List;
import java.util.Map;
+// TODO: bring this back when SSR is implemented
public class CCArguments implements IComputerArgs {
private final Object[] args;
diff --git a/src/main/java/net/montoyo/wd/core/CraftComponent.java b/src/main/java/net/montoyo/wd/core/CraftComponent.java
index 53544a8..0481856 100644
--- a/src/main/java/net/montoyo/wd/core/CraftComponent.java
+++ b/src/main/java/net/montoyo/wd/core/CraftComponent.java
@@ -5,7 +5,7 @@
package net.montoyo.wd.core;
import net.minecraft.world.item.ItemStack;
-import net.montoyo.wd.init.ItemInit;
+import net.montoyo.wd.registry.ItemRegistry;
public enum CraftComponent {
STONEKEY("stonekey", "StoneKey"),
@@ -32,6 +32,6 @@ public enum CraftComponent {
}
public ItemStack makeItemStack() {
- return new ItemStack(ItemInit.getComputerCraftItem(ordinal()).get(), 1);
+ return new ItemStack(ItemRegistry.getComputerCraftItem(ordinal()).get(), 1);
}
}
diff --git a/src/main/java/net/montoyo/wd/core/Criterion.java b/src/main/java/net/montoyo/wd/core/Criterion.java
index 475aba6..3482c95 100644
--- a/src/main/java/net/montoyo/wd/core/Criterion.java
+++ b/src/main/java/net/montoyo/wd/core/Criterion.java
@@ -20,9 +20,7 @@ import java.util.Arrays;
import java.util.HashMap;
public class Criterion implements CriterionTrigger {
-
public static class Instance extends AbstractCriterionTriggerInstance {
-
public Instance(ResourceLocation id, ContextAwarePredicate arg2) {
super(id, arg2);
}
@@ -67,10 +65,9 @@ public class Criterion implements CriterionTrigger {
public void trigger(PlayerAdvancements ply) {
ArrayList> listeners = map.get(ply);
- if(listeners != null) {
+ if (listeners != null) {
Listener[] copy = listeners.toArray(new Listener[0]); //We need to make a copy, otherwise we get a ConcurrentModificationException
Arrays.stream(copy).forEach(l -> l.run(ply));
}
}
-
}
diff --git a/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java b/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java
index 89b9f5c..bf7e3b2 100644
--- a/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java
+++ b/src/main/java/net/montoyo/wd/core/DefaultPeripheral.java
@@ -8,23 +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.init.BlockInit;
+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, BlockInit.blockKeyBoard), //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 ,BlockInit.blockRControl), //WITHOUT FACING (>= 3)
- REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl::new ,BlockInit.blockRedControl),
- SERVER("server", "Server", TileEntityServer::new, BlockInit.blockServer);
+ 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/HasAdvancement.java b/src/main/java/net/montoyo/wd/core/HasAdvancement.java
index 1e458e2..9aa7f7d 100644
--- a/src/main/java/net/montoyo/wd/core/HasAdvancement.java
+++ b/src/main/java/net/montoyo/wd/core/HasAdvancement.java
@@ -5,9 +5,7 @@
package net.montoyo.wd.core;
public enum HasAdvancement {
-
DONT_KNOW,
YES,
NO
-
}
diff --git a/src/main/java/net/montoyo/wd/core/IComputerArgs.java b/src/main/java/net/montoyo/wd/core/IComputerArgs.java
index 366e549..a4248d4 100644
--- a/src/main/java/net/montoyo/wd/core/IComputerArgs.java
+++ b/src/main/java/net/montoyo/wd/core/IComputerArgs.java
@@ -7,10 +7,8 @@ package net.montoyo.wd.core;
import java.util.Map;
public interface IComputerArgs {
-
String checkString(int i);
int checkInteger(int i);
Map checkTable(int i);
int count();
-
}
diff --git a/src/main/java/net/montoyo/wd/core/IPeripheral.java b/src/main/java/net/montoyo/wd/core/IPeripheral.java
index f412d50..fc06351 100644
--- a/src/main/java/net/montoyo/wd/core/IPeripheral.java
+++ b/src/main/java/net/montoyo/wd/core/IPeripheral.java
@@ -7,11 +7,9 @@ package net.montoyo.wd.core;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
-import net.montoyo.wd.utilities.BlockSide;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.math.Vector3i;
public interface IPeripheral {
-
boolean connect(Level world, BlockPos blockPos, BlockState blockState, Vector3i screenPos, BlockSide screenSide);
-
}
diff --git a/src/main/java/net/montoyo/wd/core/IScreenQueryHandler.java b/src/main/java/net/montoyo/wd/core/IScreenQueryHandler.java
index f9b5617..f18dc7a 100644
--- a/src/main/java/net/montoyo/wd/core/IScreenQueryHandler.java
+++ b/src/main/java/net/montoyo/wd/core/IScreenQueryHandler.java
@@ -6,14 +6,12 @@
//
//import net.montoyo.mcef.api.IJSQueryCallback;
//import net.montoyo.wd.entity.TileEntityScreen;
-//import net.montoyo.wd.utilities.BlockSide;
+//import net.montoyo.wd.utilities.orientation.BlockSide;
//
//import javax.annotation.Nonnull;
//
//public interface IScreenQueryHandler {
-//
// //args is an array of Doubles or Strings
// //The screen DOES exist, so scr.getScreen(side) is never null
// void handleQuery(@Nonnull IJSQueryCallback cb, @Nonnull TileEntityScreen scr, @Nonnull BlockSide side, @Nonnull Object[] args);
-//
//}
diff --git a/src/main/java/net/montoyo/wd/core/IUpgrade.java b/src/main/java/net/montoyo/wd/core/IUpgrade.java
index f2b8523..3524400 100644
--- a/src/main/java/net/montoyo/wd/core/IUpgrade.java
+++ b/src/main/java/net/montoyo/wd/core/IUpgrade.java
@@ -6,17 +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.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.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/core/IWDDCapability.java b/src/main/java/net/montoyo/wd/core/IWDDCapability.java
index de2a75e..1cc5750 100644
--- a/src/main/java/net/montoyo/wd/core/IWDDCapability.java
+++ b/src/main/java/net/montoyo/wd/core/IWDDCapability.java
@@ -5,9 +5,7 @@
package net.montoyo.wd.core;
public interface IWDDCapability {
-
boolean isFirstRun();
void clearFirstRun();
void cloneTo(IWDDCapability dst);
-
}
diff --git a/src/main/java/net/montoyo/wd/core/JSServerRequest.java b/src/main/java/net/montoyo/wd/core/JSServerRequest.java
index e017be3..7ef36e7 100644
--- a/src/main/java/net/montoyo/wd/core/JSServerRequest.java
+++ b/src/main/java/net/montoyo/wd/core/JSServerRequest.java
@@ -5,10 +5,9 @@
package net.montoyo.wd.core;
import net.minecraft.network.FriendlyByteBuf;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
public enum JSServerRequest {
-
CLEAR_REDSTONE,
SET_REDSTONE_AT(Integer.class, Integer.class, Boolean.class);
@@ -50,5 +49,4 @@ public enum JSServerRequest {
return ret;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/core/MissingPermissionException.java b/src/main/java/net/montoyo/wd/core/MissingPermissionException.java
index be08eb5..48a9932 100644
--- a/src/main/java/net/montoyo/wd/core/MissingPermissionException.java
+++ b/src/main/java/net/montoyo/wd/core/MissingPermissionException.java
@@ -7,7 +7,6 @@ package net.montoyo.wd.core;
import net.minecraft.server.level.ServerPlayer;
public class MissingPermissionException extends Exception {
-
private final int permission;
private final ServerPlayer player;
@@ -24,5 +23,4 @@ public class MissingPermissionException extends Exception {
public ServerPlayer getPlayer() {
return player;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/core/OCArguments.java b/src/main/java/net/montoyo/wd/core/OCArguments.java
index b14370c..954cc15 100644
--- a/src/main/java/net/montoyo/wd/core/OCArguments.java
+++ b/src/main/java/net/montoyo/wd/core/OCArguments.java
@@ -10,7 +10,6 @@ import java.util.Optional;
@Optional.Interface(iface = "net.montoyo.wd.core.IComputerArgs", modid = "opencomputers")
public class OCArguments implements IComputerArgs {
-
//Keep this as an "Object" so that it doesn't crash if OC is absent
private final Object args;
@@ -41,5 +40,4 @@ public class OCArguments implements IComputerArgs {
public int count() {
return ((Arguments) args).count();
}
-
} */
diff --git a/src/main/java/net/montoyo/wd/core/ScreenRights.java b/src/main/java/net/montoyo/wd/core/ScreenRights.java
index 41f7759..e67e67d 100644
--- a/src/main/java/net/montoyo/wd/core/ScreenRights.java
+++ b/src/main/java/net/montoyo/wd/core/ScreenRights.java
@@ -5,9 +5,10 @@
package net.montoyo.wd.core;
public abstract class ScreenRights {
-
public static final int CHANGE_URL = 1; //Change URL AND run JavaScript
- /** use {@link ScreenRights#INTERACT instead} */
+ /**
+ * use {@link ScreenRights#INTERACT instead}
+ */
@Deprecated(forRemoval = true)
public static final int CLICK = 2; //Click AND type
public static final int INTERACT = 2; //Click AND type
@@ -21,5 +22,4 @@ public abstract class ScreenRights {
public static final int NONE = 0;
public static final int ALL = 0xFF;
public static final int DEFAULTS = CHANGE_URL | INTERACT | MANAGE_UPGRADES | MODIFY_SCREEN;
-
}
diff --git a/src/main/java/net/montoyo/wd/core/WDDCapability.java b/src/main/java/net/montoyo/wd/core/WDDCapability.java
index f049827..9f7faef 100644
--- a/src/main/java/net/montoyo/wd/core/WDDCapability.java
+++ b/src/main/java/net/montoyo/wd/core/WDDCapability.java
@@ -18,14 +18,11 @@ import javax.annotation.Nonnull;
import java.util.concurrent.Callable;
public class WDDCapability implements IWDDCapability {
-
public static class Factory implements Callable {
-
@Override
public IWDDCapability call() {
return new WDDCapability();
}
-
}
public static class Provider implements ICapabilitySerializable {
@@ -38,7 +35,7 @@ public class WDDCapability implements IWDDCapability {
@NotNull
@Override
public LazyOptional getCapability(@NotNull Capability capability, @org.jetbrains.annotations.Nullable Direction arg) {
- return cap == capability ? INSTANCE.cast() : LazyOptional.empty();
+ return cap == capability ? INSTANCE.cast() : LazyOptional.empty();
}
@Override
@@ -78,8 +75,7 @@ public class WDDCapability implements IWDDCapability {
@Override
public void cloneTo(IWDDCapability dst) {
- if(!isFirstRun())
+ if (!isFirstRun())
dst.clearFirstRun();
}
-
}
diff --git a/src/main/java/net/montoyo/wd/data/GuiData.java b/src/main/java/net/montoyo/wd/data/GuiData.java
index 57d0473..8d5828a 100644
--- a/src/main/java/net/montoyo/wd/data/GuiData.java
+++ b/src/main/java/net/montoyo/wd/data/GuiData.java
@@ -18,53 +18,54 @@ import java.util.HashMap;
import java.util.function.Supplier;
public abstract class GuiData {
- public static GuiData read(String name, FriendlyByteBuf buf) {
- GuiType type = dataTable.get(name);
- GuiData data = type.create();
- data.deserialize(buf);
- return data;
- }
-
- protected static class GuiType {
- Class extends GuiData> clazz;
- Supplier constructor;
-
- public GuiType(Class extends GuiData> clazz, Supplier constructor) {
- this.clazz = clazz;
- this.constructor = constructor;
- }
-
- public GuiData create() {
- return constructor.get();
- }
- }
-
- private static final HashMap dataTable = new HashMap<>();
-
- static {
- dataTable.put("SetURL", new GuiType(SetURLData.class, SetURLData::new));
- dataTable.put("ScreenConfig", new GuiType(ScreenConfigData.class, ScreenConfigData::new));
- dataTable.put("Keyboard", new GuiType(KeyboardData.class, KeyboardData::new));
- dataTable.put("RedstoneCtrl", new GuiType(RedstoneCtrlData.class, RedstoneCtrlData::new));
- dataTable.put("Server", new GuiType(ServerData.class, ServerData::new));
- }
-
- public static Class extends GuiData> classOf(String name) {
- return dataTable.get(name).clazz;
- }
-
- public GuiData() {
- }
+ public static GuiData read(String name, FriendlyByteBuf buf) {
+ GuiType type = dataTable.get(name);
+ GuiData data = type.create();
+ data.deserialize(buf);
+ return data;
+ }
- @OnlyIn(Dist.CLIENT)
- public abstract Screen createGui(Screen old, Level world);
-
- public abstract String getName();
-
- public void sendTo(ServerPlayer player) {
- WDNetworkRegistry.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new S2CMessageOpenGui(this));
- }
+ protected static class GuiType {
+ Class extends GuiData> clazz;
+ Supplier constructor;
+
+ public GuiType(Class extends GuiData> clazz, Supplier constructor) {
+ this.clazz = clazz;
+ this.constructor = constructor;
+ }
+
+ public GuiData create() {
+ return constructor.get();
+ }
+ }
+
+ private static final HashMap dataTable = new HashMap<>();
+
+ static {
+ dataTable.put("SetURL", new GuiType(SetURLData.class, SetURLData::new));
+ dataTable.put("ScreenConfig", new GuiType(ScreenConfigData.class, ScreenConfigData::new));
+ dataTable.put("Keyboard", new GuiType(KeyboardData.class, KeyboardData::new));
+ dataTable.put("RedstoneCtrl", new GuiType(RedstoneCtrlData.class, RedstoneCtrlData::new));
+ dataTable.put("Server", new GuiType(ServerData.class, ServerData::new));
+ }
+
+ public static Class extends GuiData> classOf(String name) {
+ return dataTable.get(name).clazz;
+ }
+
+ public GuiData() {
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ public abstract Screen createGui(Screen old, Level world);
+
+ public abstract String getName();
+
+ public void sendTo(ServerPlayer player) {
+ WDNetworkRegistry.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new S2CMessageOpenGui(this));
+ }
public abstract void serialize(FriendlyByteBuf buf);
+
public abstract void deserialize(FriendlyByteBuf buf);
}
diff --git a/src/main/java/net/montoyo/wd/data/KeyboardData.java b/src/main/java/net/montoyo/wd/data/KeyboardData.java
index 969b136..bcfda4e 100644
--- a/src/main/java/net/montoyo/wd/data/KeyboardData.java
+++ b/src/main/java/net/montoyo/wd/data/KeyboardData.java
@@ -12,23 +12,22 @@ 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.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.math.Vector3i;
public class KeyboardData extends GuiData {
-
public Vector3i pos;
public BlockSide side;
public int kbX;
public int kbY;
public int kbZ;
-
+
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();
@@ -40,19 +39,19 @@ 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
public String getName() {
return "Keyboard";
}
-
+
@Override
public void serialize(FriendlyByteBuf buf) {
buf.writeInt(pos.x);
diff --git a/src/main/java/net/montoyo/wd/data/RedstoneCtrlData.java b/src/main/java/net/montoyo/wd/data/RedstoneCtrlData.java
index f9ee152..d6f41f7 100644
--- a/src/main/java/net/montoyo/wd/data/RedstoneCtrlData.java
+++ b/src/main/java/net/montoyo/wd/data/RedstoneCtrlData.java
@@ -13,19 +13,18 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.montoyo.wd.client.gui.GuiRedstoneCtrl;
import net.montoyo.wd.net.BufferUtils;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.math.Vector3i;
public class RedstoneCtrlData extends GuiData {
-
public ResourceLocation dimension;
public Vector3i pos;
public String risingEdgeURL;
public String fallingEdgeURL;
-
+
public RedstoneCtrlData() {
super();
}
-
+
public RedstoneCtrlData(ResourceLocation d, BlockPos p, String r, String f) {
dimension = d;
pos = new Vector3i(p);
@@ -43,7 +42,7 @@ public class RedstoneCtrlData extends GuiData {
public String getName() {
return "RedstoneCtrl";
}
-
+
@Override
public void serialize(FriendlyByteBuf buf) {
buf.writeUtf(dimension.toString());
@@ -51,7 +50,7 @@ public class RedstoneCtrlData extends GuiData {
buf.writeUtf(risingEdgeURL);
buf.writeUtf(fallingEdgeURL);
}
-
+
@Override
public void deserialize(FriendlyByteBuf buf) {
dimension = new ResourceLocation(buf.readUtf());
diff --git a/src/main/java/net/montoyo/wd/data/ScreenConfigData.java b/src/main/java/net/montoyo/wd/data/ScreenConfigData.java
index a558e6d..9e2f6ef 100644
--- a/src/main/java/net/montoyo/wd/data/ScreenConfigData.java
+++ b/src/main/java/net/montoyo/wd/data/ScreenConfigData.java
@@ -14,26 +14,25 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.network.PacketDistributor;
import net.montoyo.wd.client.gui.GuiScreenConfig;
import net.montoyo.wd.entity.ScreenData;
-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;
-import net.montoyo.wd.utilities.BlockSide;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.NameUUIDPair;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
+import net.montoyo.wd.utilities.math.Vector3i;
public class ScreenConfigData extends GuiData {
-
- public boolean onlyUpdate;
- public Vector3i pos;
- public BlockSide side;
- public NameUUIDPair[] friends;
- public int friendRights;
- public int otherRights;
-
- public ScreenConfigData() {
- }
+ public boolean onlyUpdate;
+ public Vector3i pos;
+ public BlockSide side;
+ public NameUUIDPair[] friends;
+ public int friendRights;
+ public int otherRights;
+
+ public ScreenConfigData() {
+ }
public ScreenConfigData(Vector3i pos, BlockSide side, ScreenData scr) {
this.pos = pos;
diff --git a/src/main/java/net/montoyo/wd/data/ServerData.java b/src/main/java/net/montoyo/wd/data/ServerData.java
index d0e37d6..28a9da7 100644
--- a/src/main/java/net/montoyo/wd/data/ServerData.java
+++ b/src/main/java/net/montoyo/wd/data/ServerData.java
@@ -12,17 +12,16 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.montoyo.wd.client.gui.GuiServer;
import net.montoyo.wd.net.BufferUtils;
-import net.montoyo.wd.utilities.NameUUIDPair;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
+import net.montoyo.wd.utilities.math.Vector3i;
public class ServerData extends GuiData {
-
public Vector3i pos;
public NameUUIDPair owner;
-
+
public ServerData() {
}
-
+
public ServerData(BlockPos bp, NameUUIDPair owner) {
pos = new Vector3i(bp);
this.owner = owner;
@@ -38,13 +37,13 @@ public class ServerData extends GuiData {
public String getName() {
return "Server";
}
-
+
@Override
public void serialize(FriendlyByteBuf buf) {
BufferUtils.writeVec3i(buf, pos);
owner.writeTo(buf);
}
-
+
@Override
public void deserialize(FriendlyByteBuf buf) {
pos = BufferUtils.readVec3i(buf);
diff --git a/src/main/java/net/montoyo/wd/data/SetURLData.java b/src/main/java/net/montoyo/wd/data/SetURLData.java
index f1b8e5f..97f2e12 100644
--- a/src/main/java/net/montoyo/wd/data/SetURLData.java
+++ b/src/main/java/net/montoyo/wd/data/SetURLData.java
@@ -12,23 +12,22 @@ 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.data.BlockSide;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.math.Vector3i;
public class SetURLData extends GuiData {
-
public Vector3i pos;
public BlockSide side;
public String url;
public boolean isRemote;
public Vector3i remoteLocation;
-
+
public SetURLData() {
}
-
+
public SetURLData(Vector3i pos, BlockSide side, String url) {
this.pos = pos;
this.side = side;
@@ -50,19 +49,19 @@ 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
public String getName() {
return "SetURL";
}
-
+
@Override
public void serialize(FriendlyByteBuf buf) {
BufferUtils.writeVec3i(buf, pos);
@@ -71,7 +70,7 @@ public class SetURLData extends GuiData {
buf.writeBoolean(isRemote);
if (isRemote) BufferUtils.writeVec3i(buf, remoteLocation);
}
-
+
@Override
public void deserialize(FriendlyByteBuf buf) {
pos = BufferUtils.readVec3i(buf);
diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityInterfaceBase.java b/src/main/java/net/montoyo/wd/entity/AbstractInterfaceBlockEntity.java
similarity index 90%
rename from src/main/java/net/montoyo/wd/entity/TileEntityInterfaceBase.java
rename to src/main/java/net/montoyo/wd/entity/AbstractInterfaceBlockEntity.java
index 726ca46..7ccd1b8 100644
--- a/src/main/java/net/montoyo/wd/entity/TileEntityInterfaceBase.java
+++ b/src/main/java/net/montoyo/wd/entity/AbstractInterfaceBlockEntity.java
@@ -13,7 +13,11 @@ import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.core.IComputerArgs;
import net.montoyo.wd.core.IUpgrade;
import net.montoyo.wd.core.ScreenRights;
-import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
+import net.montoyo.wd.utilities.serialization.TypeData;
+import net.montoyo.wd.utilities.serialization.Util;
import java.io.IOException;
import java.lang.annotation.ElementType;
@@ -23,9 +27,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);
}
@@ -108,7 +111,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
@@ -119,7 +122,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
@@ -128,7 +131,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;
@@ -140,7 +143,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;
@@ -152,7 +155,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;
@@ -162,7 +165,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;
@@ -206,7 +209,7 @@ 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");
@@ -245,7 +248,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");
@@ -326,7 +329,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");
@@ -346,7 +349,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");
@@ -369,7 +372,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");
@@ -384,7 +387,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");
@@ -406,5 +409,4 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
return null;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java b/src/main/java/net/montoyo/wd/entity/AbstractPeripheralBlockEntity.java
similarity index 78%
rename from src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java
rename to src/main/java/net/montoyo/wd/entity/AbstractPeripheralBlockEntity.java
index 1c54927..d3f3ab1 100644
--- a/src/main/java/net/montoyo/wd/entity/TileEntityPeripheralBase.java
+++ b/src/main/java/net/montoyo/wd/entity/AbstractPeripheralBlockEntity.java
@@ -16,29 +16,28 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import net.montoyo.wd.core.IPeripheral;
-import net.montoyo.wd.utilities.BlockSide;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.math.Vector3i;
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);
}
-
+
// TODO
@Override
public void load(CompoundTag tag) {
super.load(tag);
-
- if(tag.contains("WDScreen", 10)) {
+
+ if (tag.contains("WDScreen", 10)) {
CompoundTag scr = tag.getCompound("WDScreen");
screenPos = new Vector3i(scr.getInt("X"), scr.getInt("Y"), scr.getInt("Z"));
screenSide = BlockSide.values()[scr.getByte("Side")];
@@ -47,28 +46,28 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP
screenSide = null;
}
}
-
+
@Override
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
-
- if(screenPos != null && screenSide != null) {
+
+ if (screenPos != null && screenSide != null) {
CompoundTag scr = new CompoundTag();
scr.putInt("X", screenPos.x);
scr.putInt("Y", screenPos.y);
scr.putInt("Z", screenPos.z);
scr.putByte("Side", (byte) screenSide.ordinal());
-
+
tag.put("WDScreen", scr);
}
}
-
+
// this is not used for loading from disk, so I'm marking it final
@Override
public final void deserializeNBT(CompoundTag tag) {
super.deserializeNBT(tag);
}
-
+
// this is not used for writing to disk, so I'm marking it final
@Override
@Nonnull
@@ -79,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 == null || !(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;
}
@@ -108,31 +107,31 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP
}
@Nullable
- public TileEntityScreen getConnectedScreen() {
- if(screenPos == null || screenSide == null)
+ public ScreenBlockEntity getConnectedScreen() {
+ if (screenPos == null || screenSide == null)
return null;
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
- if(te == null || !(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() {
- if(screenPos == null || screenSide == null)
+ public ScreenBlockEntity getConnectedScreenEx() {
+ if (screenPos == null || screenSide == null)
return null;
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
- if(te == null || !(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 3153c53..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,18 +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");
@@ -79,5 +79,4 @@ public class TileEntityCCInterface extends TileEntityInterfaceBase implements IP
public boolean equals(@Nullable IPeripheral periph) {
return periph == this;
}
-
}*/
diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityKeyboard.java b/src/main/java/net/montoyo/wd/entity/KeyboardBlockEntity.java
similarity index 83%
rename from src/main/java/net/montoyo/wd/entity/TileEntityKeyboard.java
rename to src/main/java/net/montoyo/wd/entity/KeyboardBlockEntity.java
index 284ab17..722dc52 100644
--- a/src/main/java/net/montoyo/wd/entity/TileEntityKeyboard.java
+++ b/src/main/java/net/montoyo/wd/entity/KeyboardBlockEntity.java
@@ -15,15 +15,14 @@ import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.KeyboardData;
-import net.montoyo.wd.init.TileInit;
-import net.montoyo.wd.utilities.Util;
-
-public class TileEntityKeyboard extends TileEntityPeripheralBase {
+import net.montoyo.wd.registry.TileRegistry;
+import net.montoyo.wd.utilities.serialization.Util;
+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) {
- super(TileInit.KEYBOARD.get(), arg2, arg3);
+ public KeyboardBlockEntity(BlockPos arg2, BlockState arg3) {
+ super(TileRegistry.KEYBOARD.get(), arg2, arg3);
}
@Override
@@ -36,7 +35,7 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase {
return InteractionResult.SUCCESS;
}
- TileEntityScreen tes = getConnectedScreen();
+ ScreenBlockEntity tes = getConnectedScreen();
if(tes == null) {
Util.toast(player, "notLinked");
return InteractionResult.SUCCESS;
@@ -56,7 +55,7 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase {
if(!isScreenChunkLoaded())
return;
- TileEntityScreen tes = getConnectedScreen();
+ ScreenBlockEntity tes = getConnectedScreen();
if(tes != null) {
ScreenData scr = tes.getScreen(screenSide);
@@ -72,10 +71,9 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase {
tes.type(screenSide, "t" + rnd, getBlockPos());
Player owner = level.getPlayerByUUID(scr.owner.uuid);
- if(owner != null && owner instanceof ServerPlayer && ent instanceof Ocelot)
+ if(owner instanceof ServerPlayer && ent instanceof Ocelot)
WebDisplays.INSTANCE.criterionKeyboardCat.trigger(((ServerPlayer) owner).getAdvancements());
}
}
}
-
}
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 80%
rename from src/main/java/net/montoyo/wd/entity/TileEntityRedCtrl.java
rename to src/main/java/net/montoyo/wd/entity/RedstoneControlBlockEntity.java
index 74dabae..029486f 100644
--- a/src/main/java/net/montoyo/wd/entity/TileEntityRedCtrl.java
+++ b/src/main/java/net/montoyo/wd/entity/RedstoneControlBlockEntity.java
@@ -14,30 +14,29 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.RedstoneCtrlData;
-import net.montoyo.wd.init.TileInit;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.registry.TileRegistry;
+import net.montoyo.wd.utilities.serialization.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) {
- super(TileInit.REDSTONE_CONTROLLER.get(), arg2, arg3);
+ public RedstoneControlBlockEntity(BlockPos arg2, BlockState arg3) {
+ super(TileRegistry.REDSTONE_CONTROLLER.get(), arg2, arg3);
}
-
+
@Override
public void load(CompoundTag tag) {
super.load(tag);
-
+
risingEdgeURL = tag.getString("RisingEdgeURL");
fallingEdgeURL = tag.getString("FallingEdgeURL");
state = tag.getBoolean("Powered");
}
-
+
@Override
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
@@ -45,19 +44,19 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
tag.putString("FallingEdgeURL", fallingEdgeURL);
tag.putBoolean("Powered", state);
}
-
+
@Override
public InteractionResult onRightClick(Player player, InteractionHand hand) {
- if(level.isClientSide)
+ if (level.isClientSide)
return InteractionResult.SUCCESS;
- if(!isScreenChunkLoaded()) {
+ if (!isScreenChunkLoaded()) {
Util.toast(player, "chunkUnloaded");
return InteractionResult.SUCCESS;
}
- TileEntityScreen tes = getConnectedScreen();
- if(tes == null) {
+ ScreenBlockEntity tes = getConnectedScreen();
+ if (tes == null) {
Util.toast(player, "notLinked");
return InteractionResult.SUCCESS;
}
@@ -76,10 +75,10 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
public void onNeighborChange(Block neighborType, BlockPos neighborPos) {
boolean hasPower = (level.hasNeighborSignal(getBlockPos()) || level.hasNeighborSignal(getBlockPos().above())); //Same as dispenser
- if(hasPower != state) {
+ if (hasPower != state) {
state = hasPower;
- if(state) //Rising edge
+ if (state) //Rising edge
changeURL(risingEdgeURL);
else //Falling edge
changeURL(fallingEdgeURL);
@@ -93,11 +92,11 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
}
private void changeURL(String url) {
- if(level.isClientSide || url.isEmpty())
+ if (level.isClientSide || url.isEmpty())
return;
- if(isScreenChunkLoaded()) {
- TileEntityScreen tes = getConnectedScreen();
+ if (isScreenChunkLoaded()) {
+ 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 71%
rename from src/main/java/net/montoyo/wd/entity/TileEntityRCtrl.java
rename to src/main/java/net/montoyo/wd/entity/RemoteControlBlockEntity.java
index 114a7c6..d90299f 100644
--- a/src/main/java/net/montoyo/wd/entity/TileEntityRCtrl.java
+++ b/src/main/java/net/montoyo/wd/entity/RemoteControlBlockEntity.java
@@ -12,26 +12,26 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.SetURLData;
-import net.montoyo.wd.init.TileInit;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.registry.TileRegistry;
+import net.montoyo.wd.utilities.serialization.Util;
-public class TileEntityRCtrl extends TileEntityPeripheralBase {
- public TileEntityRCtrl(BlockPos arg2, BlockState arg3) {
- super(TileInit.REMOTE_CONTROLLER.get(), arg2, arg3);
+public class RemoteControlBlockEntity extends AbstractPeripheralBlockEntity {
+ public RemoteControlBlockEntity(BlockPos arg2, BlockState arg3) {
+ super(TileRegistry.REMOTE_CONTROLLER.get(), arg2, arg3);
}
@Override
public InteractionResult onRightClick(Player player, InteractionHand hand) {
- if(level.isClientSide)
+ if (level.isClientSide)
return InteractionResult.SUCCESS;
- if(!isScreenChunkLoaded()) {
+ if (!isScreenChunkLoaded()) {
Util.toast(player, "chunkUnloaded");
return InteractionResult.SUCCESS;
}
- TileEntityScreen tes = getConnectedScreen();
- if(tes == null) {
+ ScreenBlockEntity tes = getConnectedScreen();
+ if (tes == null) {
Util.toast(player, "notLinked");
return InteractionResult.SUCCESS;
}
@@ -45,5 +45,4 @@ public class TileEntityRCtrl extends TileEntityPeripheralBase {
(new SetURLData(screenPos, screenSide, scr.url, getBlockPos())).sendTo((ServerPlayer) player);
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 95%
rename from src/main/java/net/montoyo/wd/entity/TileEntityScreen.java
rename to src/main/java/net/montoyo/wd/entity/ScreenBlockEntity.java
index 5a09e36..60c5a4d 100644
--- a/src/main/java/net/montoyo/wd/entity/TileEntityScreen.java
+++ b/src/main/java/net/montoyo/wd/entity/ScreenBlockEntity.java
@@ -25,43 +25,45 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraftforge.network.PacketDistributor;
import net.montoyo.wd.WebDisplays;
-import net.montoyo.wd.block.BlockScreen;
+import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.client.ClientProxy;
import net.montoyo.wd.config.CommonConfig;
import net.montoyo.wd.controls.builtin.ClickControl;
import net.montoyo.wd.core.DefaultUpgrade;
import net.montoyo.wd.core.IUpgrade;
-import net.montoyo.wd.core.JSServerRequest;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.ScreenConfigData;
-import net.montoyo.wd.init.BlockInit;
-import net.montoyo.wd.init.ItemInit;
-import net.montoyo.wd.init.TileInit;
+import net.montoyo.wd.registry.BlockRegistry;
+import net.montoyo.wd.registry.ItemRegistry;
+import net.montoyo.wd.registry.TileRegistry;
import net.montoyo.wd.miniserv.SyncPlugin;
import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.net.client_bound.S2CMessageAddScreen;
-import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
-import net.montoyo.wd.net.client_bound.S2CMessageJSResponse;
import net.montoyo.wd.net.client_bound.S2CMessageScreenUpdate;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.MutableAABB;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3f;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
+import net.montoyo.wd.utilities.serialization.TypeData;
import org.cef.browser.CefBrowser;
-import org.lwjgl.opengl.GL11;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.function.Consumer;
-import static net.montoyo.wd.block.BlockPeripheral.point;
+import static net.montoyo.wd.block.PeripheralBlock.point;
-public class TileEntityScreen extends BlockEntity {
-
- public TileEntityScreen(BlockPos arg2, BlockState arg3) {
- super(TileInit.SCREEN_BLOCK_ENTITY.get(), arg2, arg3);
+public class ScreenBlockEntity extends BlockEntity {
+ public ScreenBlockEntity(BlockPos arg2, BlockState arg3) {
+ super(TileRegistry.SCREEN_BLOCK_ENTITY.get(), arg2, arg3);
}
public void forEachScreenBlocks(BlockSide side, Consumer func) {
@@ -70,6 +72,7 @@ public class TileEntityScreen extends BlockEntity {
if (scr != null) {
ScreenIterator it = new ScreenIterator(getBlockPos(), side, scr.size);
+ // TODO: cache chunk
while (it.hasNext())
func.accept(it.next());
}
@@ -95,6 +98,7 @@ public class TileEntityScreen extends BlockEntity {
scr.browser = null;
}
}
+ screens.clear();
loaded = false;
}
@@ -107,6 +111,14 @@ public class TileEntityScreen extends BlockEntity {
if (list.isEmpty())
return;
+ // very important to close these
+ for (Screen screen : screens) {
+ if (screen.browser != null) {
+ screen.browser.close(true);
+ screen.browser = null;
+ }
+ }
+
screens.clear();
for (int i = 0; i < list.size(); i++)
screens.add(ScreenData.deserialize(list.getCompound(i)));
@@ -221,17 +233,18 @@ public class TileEntityScreen extends BlockEntity {
}
public void clear() {
+ // very important that these get closed
+ for (Screen screen : screens)
+ if (screen.browser != null) {
+ screen.browser.close(true);
+ screen.browser = null;
+ }
screens.clear();
if (!level.isClientSide)
setChanged();
}
- public void requestData(ServerPlayer ep) {
- if (!level.isClientSide)
- WDNetworkRegistry.INSTANCE.send(PacketDistributor.PLAYER.with(() -> ep), new S2CMessageAddScreen(this));
- }
-
public static String url(String url) throws IOException {
System.out.println("URL received: " + url);
if (!(WebDisplays.PROXY instanceof ClientProxy)) {
@@ -268,6 +281,7 @@ public class TileEntityScreen extends BlockEntity {
}
}
+ // TODO: is there a reason this is unused?
public void removeScreen(BlockSide side) {
int idx = -1;
for (int i = 0; i < screens.size(); i++) {
@@ -294,7 +308,7 @@ public class TileEntityScreen extends BlockEntity {
if (!level.isClientSide) {
if (screens.isEmpty()) //No more screens: remove tile entity
- level.setBlockAndUpdate(getBlockPos(), BlockInit.blockScreen.get().defaultBlockState().setValue(BlockScreen.hasTE, false));
+ level.setBlockAndUpdate(getBlockPos(), BlockRegistry.SCREEN_BLOCk.get().defaultBlockState().setValue(ScreenBlock.hasTE, false));
else
setChanged();
}
@@ -330,7 +344,7 @@ public class TileEntityScreen extends BlockEntity {
private static Player getLaserUser(ScreenData scr) {
if (scr.laserUser != null) {
- if (scr.laserUser.isRemoved() || !scr.laserUser.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.LASER_POINTER.get()))
+ if (scr.laserUser.isRemoved() || !scr.laserUser.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemRegistry.LASER_POINTER.get()))
scr.laserUser = null;
}
@@ -362,13 +376,6 @@ public class TileEntityScreen extends BlockEntity {
WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(level, getBlockPos())), S2CMessageScreenUpdate.click(this, side, ClickControl.ControlType.CLICK, vec));
}
- void clickUnsafe(BlockSide side, ClickControl.ControlType action, int x, int y) {
- if (level.isClientSide) {
- Vector2i vec = (action == ClickControl.ControlType.UP) ? null : new Vector2i(x, y);
- WDNetworkRegistry.INSTANCE.send(PacketDistributor.NEAR.with(() -> point(level, getBlockPos())), S2CMessageScreenUpdate.click(this, side, action, vec));
- }
- }
-
public void handleMouseEvent(BlockSide side, ClickControl.ControlType event, @Nullable Vector2i vec, int button) {
if (button > 1) return; // buttons above 1 crash the game
@@ -609,9 +616,10 @@ public class TileEntityScreen extends BlockEntity {
public void updateClientSideURL(CefBrowser target, String url) {
for (ScreenData scr : screens) {
if (scr.browser == target) {
+ // TODO: what? lol
String webUrl;
try {
- webUrl = TileEntityScreen.url(url);
+ webUrl = ScreenBlockEntity.url(url);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -1073,5 +1081,4 @@ public class TileEntityScreen extends BlockEntity {
//
// return oldState.getValue(BlockScreen.hasTE) != newState.getValue(BlockScreen.hasTE);
// }
-
}
diff --git a/src/main/java/net/montoyo/wd/entity/TileEntityServer.java b/src/main/java/net/montoyo/wd/entity/ServerBlockEntity.java
similarity index 69%
rename from src/main/java/net/montoyo/wd/entity/TileEntityServer.java
rename to src/main/java/net/montoyo/wd/entity/ServerBlockEntity.java
index b33115c..834ff1a 100644
--- a/src/main/java/net/montoyo/wd/entity/TileEntityServer.java
+++ b/src/main/java/net/montoyo/wd/entity/ServerBlockEntity.java
@@ -12,16 +12,15 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.data.ServerData;
-import net.montoyo.wd.init.TileInit;
-import net.montoyo.wd.utilities.NameUUIDPair;
-import net.montoyo.wd.utilities.Util;
-
-public class TileEntityServer extends BlockEntity {
+import net.montoyo.wd.registry.TileRegistry;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
+import net.montoyo.wd.utilities.serialization.Util;
+public class ServerBlockEntity extends BlockEntity {
private NameUUIDPair owner;
- public TileEntityServer(BlockPos arg2, BlockState arg3) {
- super(TileInit.SERVER.get(), arg2, arg3);
+ public ServerBlockEntity(BlockPos arg2, BlockState arg3) {
+ super(TileRegistry.SERVER.get(), arg2, arg3);
}
@Override
@@ -29,7 +28,7 @@ public class TileEntityServer extends BlockEntity {
super.load(tag);
owner = Util.readOwnerFromNBT(tag);
}
-
+
@Override
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
@@ -42,13 +41,12 @@ public class TileEntityServer extends BlockEntity {
}
public void onPlayerRightClick(Player ply) {
- if(level.isClientSide)
+ if (level.isClientSide)
return;
- if( WebDisplays.INSTANCE.miniservPort == 0)
+ if (WebDisplays.INSTANCE.miniservPort == 0)
Util.toast(ply, "noMiniserv");
- else if(owner != null && ply instanceof ServerPlayer)
+ else if (owner != null && ply instanceof ServerPlayer)
(new ServerData(getBlockPos(), owner)).sendTo((ServerPlayer) ply);
}
-
}
diff --git a/src/main/java/net/montoyo/wd/init/BlockInit.java b/src/main/java/net/montoyo/wd/init/BlockInit.java
deleted file mode 100644
index 9ed24f9..0000000
--- a/src/main/java/net/montoyo/wd/init/BlockInit.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.montoyo.wd.init;
-
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.Blocks;
-import net.minecraft.world.level.block.state.BlockBehaviour;
-import net.minecraftforge.eventbus.api.IEventBus;
-import net.minecraftforge.registries.DeferredRegister;
-import net.minecraftforge.registries.ForgeRegistries;
-import net.minecraftforge.registries.RegistryObject;
-import net.montoyo.wd.block.BlockKeyboardLeft;
-import net.montoyo.wd.block.BlockKeyboardRight;
-import net.montoyo.wd.block.BlockPeripheral;
-import net.montoyo.wd.block.BlockScreen;
-import net.montoyo.wd.core.DefaultPeripheral;
-
-public class BlockInit {
-
- public static void init(IEventBus bus) {
- BLOCKS.register(bus);
- }
-
- public static DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "webdisplays");
-
- public static final RegistryObject blockScreen = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.copy(Blocks.STONE)));
-
- public static final RegistryObject blockKeyBoard = BlockInit.BLOCKS.register("kb_left", BlockKeyboardLeft::new);
- public static final RegistryObject blockKbRight = BLOCKS.register("kb_right", BlockKeyboardRight::new);
-
- public static final RegistryObject blockRedControl = BlockInit.BLOCKS.register("redctrl", () -> new BlockPeripheral(DefaultPeripheral.REDSTONE_CONTROLLER));
- public static final RegistryObject blockRControl = BlockInit.BLOCKS.register("rctrl", () -> new BlockPeripheral(DefaultPeripheral.REMOTE_CONTROLLER));
- public static final RegistryObject blockServer = BlockInit.BLOCKS.register("server", () -> new BlockPeripheral(DefaultPeripheral.SERVER));
-}
diff --git a/src/main/java/net/montoyo/wd/init/TileInit.java b/src/main/java/net/montoyo/wd/init/TileInit.java
deleted file mode 100644
index 167d4ae..0000000
--- a/src/main/java/net/montoyo/wd/init/TileInit.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package net.montoyo.wd.init;
-
-import net.minecraft.world.level.ClipContext;
-import net.minecraft.world.level.block.entity.BlockEntityType;
-import net.minecraftforge.eventbus.api.IEventBus;
-import net.minecraftforge.registries.DeferredRegister;
-import net.minecraftforge.registries.ForgeRegistries;
-import net.minecraftforge.registries.RegistryObject;
-import net.montoyo.wd.core.DefaultPeripheral;
-import net.montoyo.wd.entity.*;
-
-import java.util.Locale;
-
-public class TileInit {
-
- public static final DeferredRegister> TILE_TYPES = DeferredRegister
- .create(ForgeRegistries.BLOCK_ENTITY_TYPES, "webdisplays");
-
- //Register tile entities
- public static final RegistryObject> SCREEN_BLOCK_ENTITY = TILE_TYPES
- .register("screen", () -> BlockEntityType.Builder
- .of(TileEntityScreen::new, BlockInit.blockScreen.get()).build(null));
-
- public static final RegistryObject> KEYBOARD = TILE_TYPES.register("kb_left", () -> BlockEntityType.Builder
- .of(TileEntityKeyboard::new, BlockInit.blockKeyBoard.get()).build(null));
-
- public static final RegistryObject> REMOTE_CONTROLLER = TILE_TYPES.register("rctrl",
- () -> BlockEntityType.Builder.of(TileEntityRCtrl::new, BlockInit.blockRControl.get()).build(null)); //WITHOUT FACING (>= 3)
-
- public static final RegistryObject> REDSTONE_CONTROLLER = TILE_TYPES.register("redctrl",
- () -> BlockEntityType.Builder.of(TileEntityRedCtrl::new, BlockInit.blockRedControl.get()).build(null));
-
- public static final RegistryObject> SERVER = TILE_TYPES.register("server" ,
- () -> BlockEntityType.Builder.of(TileEntityServer::new, BlockInit.blockServer.get()).build(null));
-
- public static void init(IEventBus bus) {
- TILE_TYPES.register(bus);
- }
-}
diff --git a/src/main/java/net/montoyo/wd/item/ItemCraftComponent.java b/src/main/java/net/montoyo/wd/item/ItemCraftComponent.java
index 367193e..5214932 100644
--- a/src/main/java/net/montoyo/wd/item/ItemCraftComponent.java
+++ b/src/main/java/net/montoyo/wd/item/ItemCraftComponent.java
@@ -10,7 +10,6 @@ import net.montoyo.wd.core.CraftComponent;
import org.jetbrains.annotations.NotNull;
public class ItemCraftComponent extends ItemMulti implements WDItem {
-
public ItemCraftComponent(Properties properties) {
super(CraftComponent.class, properties
// .tab(WebDisplays.CREATIVE_TAB)
diff --git a/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java b/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java
index 8c1765e..acec927 100644
--- a/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java
+++ b/src/main/java/net/montoyo/wd/item/ItemLaserPointer.java
@@ -11,21 +11,20 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
-import net.montoyo.wd.WebDisplays;
-import net.montoyo.wd.block.BlockScreen;
+import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.client.ClientProxy;
import net.montoyo.wd.config.ClientConfig;
import net.montoyo.wd.controls.builtin.ClickControl;
import net.montoyo.wd.core.DefaultUpgrade;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
-import net.montoyo.wd.init.BlockInit;
+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;
-import net.montoyo.wd.utilities.BlockSide;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Multiblock;
-import net.montoyo.wd.utilities.Vector2i;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -40,7 +39,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;
@@ -54,12 +53,12 @@ public class ItemLaserPointer extends Item implements WDItem {
BlockPos bpos = result.getBlockPos();
- if (result.getType() == HitResult.Type.BLOCK && mc.level.getBlockState(bpos).getBlock() == BlockInit.blockScreen.get()) {
+ if (result.getType() == HitResult.Type.BLOCK && mc.level.getBlockState(bpos).getBlock() == BlockRegistry.SCREEN_BLOCk.get()) {
Vector3i pos = new Vector3i(result.getBlockPos());
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
Multiblock.findOrigin(mc.level, pos, side, null);
- TileEntityScreen te = (TileEntityScreen) mc.level.getBlockEntity(pos.toBlock());
+ 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...
@@ -71,7 +70,7 @@ public class ItemLaserPointer extends Item implements WDItem {
float hitZ = ((float) result.getLocation().z) - (float) pos.z;
Vector2i tmp = new Vector2i();
- if (BlockScreen.hit2pixels(side, bpos, new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
+ if (ScreenBlock.hit2pixels(side, bpos, new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
laserClick(te, side, scr, tmp);
}
}
@@ -127,17 +126,17 @@ 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...
ScreenData scr = te.getScreen(side);
if (scr.browser != null) {
- if (BlockScreen.hit2pixels(side, result.getBlockPos(), new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
+ if (ScreenBlock.hit2pixels(side, result.getBlockPos(), new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
te.handleMouseEvent(side, ClickControl.ControlType.MOVE, tmp, -1);
te.handleMouseEvent(side, press ? ClickControl.ControlType.DOWN : ClickControl.ControlType.UP, tmp, button);
diff --git a/src/main/java/net/montoyo/wd/item/ItemLinker.java b/src/main/java/net/montoyo/wd/item/ItemLinker.java
index ee56b86..322b2b6 100644
--- a/src/main/java/net/montoyo/wd/item/ItemLinker.java
+++ b/src/main/java/net/montoyo/wd/item/ItemLinker.java
@@ -14,47 +14,46 @@ import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.WebDisplays;
-import net.montoyo.wd.block.BlockScreen;
+import net.montoyo.wd.block.ScreenBlock;
import net.montoyo.wd.core.IPeripheral;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
-import net.montoyo.wd.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Multiblock;
-import net.montoyo.wd.utilities.Util;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.serialization.Util;
+import net.montoyo.wd.utilities.math.Vector3i;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ItemLinker extends Item implements WDItem {
-
public ItemLinker(Properties properties) {
super(properties
- .stacksTo(1)
+ .stacksTo(1)
// .tab(WebDisplays.CREATIVE_TAB)
);
}
@Override
public InteractionResult useOn(UseOnContext context) {
- if(context.getLevel().isClientSide())
+ if (context.getLevel().isClientSide())
return InteractionResult.SUCCESS;
ItemStack stack = context.getPlayer().getItemInHand(context.getHand());
CompoundTag tag = stack.getTag();
- if(tag != null) {
- if(tag.contains("ScreenX") && tag.contains("ScreenY") && tag.contains("ScreenZ") && tag.contains("ScreenSide")) {
+ if (tag != null) {
+ if (tag.contains("ScreenX") && tag.contains("ScreenY") && tag.contains("ScreenZ") && tag.contains("ScreenSide")) {
BlockState state = context.getLevel().getBlockState(context.getClickedPos());
IPeripheral target;
- if(state.getBlock() instanceof IPeripheral)
+ if (state.getBlock() instanceof IPeripheral)
target = (IPeripheral) state.getBlock();
else {
BlockEntity te = context.getLevel().getBlockEntity(context.getClickedPos());
- if(te == null || !(te instanceof IPeripheral)) {
- if(context.getPlayer().isShiftKeyDown()) {
+ if (te == null || !(te instanceof IPeripheral)) {
+ if (context.getPlayer().isShiftKeyDown()) {
Util.toast(context.getPlayer(), ChatFormatting.GOLD, "linkAbort");
stack.setTag(null);
} else
@@ -69,10 +68,10 @@ public class ItemLinker extends Item implements WDItem {
Vector3i tePos = new Vector3i(tag.getInt("ScreenX"), tag.getInt("ScreenY"), tag.getInt("ScreenZ"));
BlockSide scrSide = BlockSide.values()[tag.getByte("ScreenSide")];
- if(target.connect(context.getLevel(), context.getClickedPos(), state, tePos, scrSide)) {
+ if (target.connect(context.getLevel(), context.getClickedPos(), state, tePos, scrSide)) {
Util.toast(context.getPlayer(), ChatFormatting.AQUA, "linked");
- if(context.getPlayer() instanceof ServerPlayer)
+ if (context.getPlayer() instanceof ServerPlayer)
WebDisplays.INSTANCE.criterionLinkPeripheral.trigger(((ServerPlayer) context.getPlayer()).getAdvancements());
} else
Util.toast(context.getPlayer(), "linkError");
@@ -82,7 +81,7 @@ public class ItemLinker extends Item implements WDItem {
}
}
- if(!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof BlockScreen)) {
+ if (!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof ScreenBlock)) {
Util.toast(context.getPlayer(), "notAScreen");
return InteractionResult.SUCCESS;
}
@@ -92,7 +91,7 @@ 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;
}
@@ -100,7 +99,7 @@ public class ItemLinker extends Item implements WDItem {
ScreenData scr = ((TileEntityScreen) te).getScreen(side);
if(scr == null)
Util.toast(context.getPlayer(), "turnOn");
- else if((scr.rightsFor(context.getPlayer()) & ScreenRights.MANAGE_UPGRADES) == 0)
+ else if ((scr.rightsFor(context.getPlayer()) & ScreenRights.MANAGE_UPGRADES) == 0)
Util.toast(context.getPlayer(), "restrictions");
else {
tag = new CompoundTag();
@@ -121,5 +120,4 @@ public class ItemLinker extends Item implements WDItem {
public String getWikiName(@Nonnull ItemStack is) {
return is.getItem().getName(is).getString();
}
-
}
diff --git a/src/main/java/net/montoyo/wd/item/ItemMinePad2.java b/src/main/java/net/montoyo/wd/item/ItemMinePad2.java
index 8bf0caf..354a064 100644
--- a/src/main/java/net/montoyo/wd/item/ItemMinePad2.java
+++ b/src/main/java/net/montoyo/wd/item/ItemMinePad2.java
@@ -28,90 +28,88 @@ import javax.annotation.Nullable;
import java.util.UUID;
public class ItemMinePad2 extends Item implements WDItem {
-
- public ItemMinePad2(Properties properties) {
- super(properties
- .stacksTo(1)
- .defaultDurability(0)
+ public ItemMinePad2(Properties properties) {
+ super(properties
+ .stacksTo(1)
+ .defaultDurability(0)
// .tab(WebDisplays.CREATIVE_TAB)
- );
- }
-
- private static String getURL(ItemStack is) {
- if (is.getTag() == null || !is.getTag().contains("PadURL"))
- return CommonConfig.Browser.homepage;
- else
- return is.getTag().getString("PadURL");
- }
-
- @Override
- @Nonnull
- public InteractionResultHolder use(Level world, Player ply, @Nonnull InteractionHand hand) {
- ItemStack is = ply.getItemInHand(hand);
- boolean ok;
-
- if (ply.isShiftKeyDown()) {
- if (world.isClientSide)
- WebDisplays.PROXY.displaySetPadURLGui(is, getURL(is));
-
- ok = true;
- } else if (is.getTag() != null && is.getTag().contains("PadID")) {
- if (world.isClientSide)
- WebDisplays.PROXY.openMinePadGui(is.getTag().getUUID("PadID"));
-
- ok = true;
- } else {
- UUID uuid = UUID.randomUUID();
- String url = getURL(is);
- WDNetworkRegistry.INSTANCE.sendToServer(new C2SMessageMinepadUrl(uuid, url));
- is.getOrCreateTag().putUUID("PadID", uuid);
-
- ok = true;
- }
-
- return new InteractionResultHolder<>(ok ? InteractionResult.SUCCESS : InteractionResult.PASS, is);
- }
-
-
- @Override
- public boolean onEntityItemUpdate(ItemStack stack, ItemEntity ent) {
- if (ent.onGround() && !ent.level().isClientSide) {
- CompoundTag tag = ent.getItem().getTag();
-
- if (tag != null && tag.contains("ThrowHeight")) {
- //Delete it, it touched the ground
- double height = tag.getDouble("ThrowHeight");
- UUID thrower = null;
-
- if (tag.contains("ThrowerMSB") && tag.contains("ThrowerLSB"))
- thrower = new UUID(tag.getLong("ThrowerMSB"), tag.getLong("ThrowerLSB"));
-
- if (tag.contains("PadID") || tag.contains("PadURL")) {
- tag.remove("ThrowerMSB");
- tag.remove("ThrowerLSB");
- tag.remove("ThrowHeight");
- } else //We can delete the whole tag
- ent.getItem().setTag(null);
-
- if (thrower != null && height - ent.getBlockY() >= 20.0) {
- ent.level().playSound(null, ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), SoundEvents.GLASS_BREAK, SoundSource.BLOCKS, 4.0f, 1.0f);
- ent.level().addFreshEntity(new ItemEntity(ent.level(), ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), CraftComponent.EXTCARD.makeItemStack()));
- ent.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
-
- Player ply = ent.level().getPlayerByUUID(thrower);
- if (ply != null && ply instanceof ServerPlayer)
- WebDisplays.INSTANCE.criterionPadBreak.trigger(((ServerPlayer) ply).getAdvancements());
- }
- }
- }
-
- return false;
- }
-
- @Nullable
- @Override
- public String getWikiName(@Nonnull ItemStack is) {
- return is.getItem().getName(is).getString();
- }
-
+ );
+ }
+
+ private static String getURL(ItemStack is) {
+ if (is.getTag() == null || !is.getTag().contains("PadURL"))
+ return CommonConfig.Browser.homepage;
+ else
+ return is.getTag().getString("PadURL");
+ }
+
+ @Override
+ @Nonnull
+ public InteractionResultHolder use(Level world, Player ply, @Nonnull InteractionHand hand) {
+ ItemStack is = ply.getItemInHand(hand);
+ boolean ok;
+
+ if (ply.isShiftKeyDown()) {
+ if (world.isClientSide)
+ WebDisplays.PROXY.displaySetPadURLGui(is, getURL(is));
+
+ ok = true;
+ } else if (is.getTag() != null && is.getTag().contains("PadID")) {
+ if (world.isClientSide)
+ WebDisplays.PROXY.openMinePadGui(is.getTag().getUUID("PadID"));
+
+ ok = true;
+ } else {
+ UUID uuid = UUID.randomUUID();
+ String url = getURL(is);
+ WDNetworkRegistry.INSTANCE.sendToServer(new C2SMessageMinepadUrl(uuid, url));
+ is.getOrCreateTag().putUUID("PadID", uuid);
+
+ ok = true;
+ }
+
+ return new InteractionResultHolder<>(ok ? InteractionResult.SUCCESS : InteractionResult.PASS, is);
+ }
+
+
+ @Override
+ public boolean onEntityItemUpdate(ItemStack stack, ItemEntity ent) {
+ if (ent.onGround() && !ent.level().isClientSide) {
+ CompoundTag tag = ent.getItem().getTag();
+
+ if (tag != null && tag.contains("ThrowHeight")) {
+ //Delete it, it touched the ground
+ double height = tag.getDouble("ThrowHeight");
+ UUID thrower = null;
+
+ if (tag.contains("ThrowerMSB") && tag.contains("ThrowerLSB"))
+ thrower = new UUID(tag.getLong("ThrowerMSB"), tag.getLong("ThrowerLSB"));
+
+ if (tag.contains("PadID") || tag.contains("PadURL")) {
+ tag.remove("ThrowerMSB");
+ tag.remove("ThrowerLSB");
+ tag.remove("ThrowHeight");
+ } else //We can delete the whole tag
+ ent.getItem().setTag(null);
+
+ if (thrower != null && height - ent.getBlockY() >= 20.0) {
+ ent.level().playSound(null, ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), SoundEvents.GLASS_BREAK, SoundSource.BLOCKS, 4.0f, 1.0f);
+ ent.level().addFreshEntity(new ItemEntity(ent.level(), ent.getBlockX(), ent.getBlockY(), ent.getBlockZ(), CraftComponent.EXTCARD.makeItemStack()));
+ ent.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
+
+ Player ply = ent.level().getPlayerByUUID(thrower);
+ if (ply != null && ply instanceof ServerPlayer)
+ WebDisplays.INSTANCE.criterionPadBreak.trigger(((ServerPlayer) ply).getAdvancements());
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Nullable
+ @Override
+ public String getWikiName(@Nonnull ItemStack is) {
+ return is.getItem().getName(is).getString();
+ }
}
diff --git a/src/main/java/net/montoyo/wd/item/ItemMulti.java b/src/main/java/net/montoyo/wd/item/ItemMulti.java
index 47731ea..7ab05b9 100644
--- a/src/main/java/net/montoyo/wd/item/ItemMulti.java
+++ b/src/main/java/net/montoyo/wd/item/ItemMulti.java
@@ -9,7 +9,6 @@ import net.minecraft.world.item.Item;
import java.util.BitSet;
public class ItemMulti extends Item {
-
protected final Enum[] values;
protected final BitSet creativeTabItems;
diff --git a/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java b/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java
index 4a2126e..41221c1 100644
--- a/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java
+++ b/src/main/java/net/montoyo/wd/item/ItemOwnershipThief.java
@@ -12,52 +12,53 @@ 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.block.ScreenBlock;
import net.montoyo.wd.config.CommonConfig;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
+import net.montoyo.wd.entity.ScreenBlockEntity;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.serialization.Util;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ItemOwnershipThief extends Item implements WDItem {
-
public ItemOwnershipThief(Properties properties) {
super(properties
- .stacksTo(1)
+ .stacksTo(1)
// .tab(WebDisplays.CREATIVE_TAB)
);
}
@Override
public @NotNull InteractionResult useOn(UseOnContext context) {
- if(context.getPlayer().isShiftKeyDown())
+ if (context.getPlayer().isShiftKeyDown())
return InteractionResult.PASS;
- if(context.getLevel().isClientSide)
+ if (context.getLevel().isClientSide)
return InteractionResult.SUCCESS;
- if(CommonConfig.disableOwnershipThief) {
+ if (CommonConfig.disableOwnershipThief) {
Util.toast(context.getPlayer(), "otDisabled");
return InteractionResult.SUCCESS;
}
ItemStack stack = context.getPlayer().getItemInHand(context.getHand());
- if(stack.hasTag()) {
+ if (stack.hasTag()) {
CompoundTag tag = stack.getTag();
- if(tag.contains("PosX") && tag.contains("PosY") && tag.contains("PosZ") && tag.contains("Side")) {
+ if (tag.contains("PosX") && tag.contains("PosY") && tag.contains("PosZ") && tag.contains("Side")) {
BlockPos bp = new BlockPos(tag.getInt("PosX"), tag.getInt("PosY"), tag.getInt("PosZ"));
BlockSide side = BlockSide.values()[tag.getByte("Side")];
- if(!(context.getLevel().getBlockState(bp).getBlock() instanceof BlockScreen))
+ if (!(context.getLevel().getBlockState(bp).getBlock() instanceof ScreenBlock))
return InteractionResult.SUCCESS;
BlockEntity te = context.getLevel().getBlockEntity(bp);
- if(te == null || !(te instanceof TileEntityScreen))
+ if (te == null || !(te instanceof ScreenBlockEntity))
return InteractionResult.SUCCESS;
TileEntityScreen tes = (TileEntityScreen) te;
@@ -73,7 +74,7 @@ public class ItemOwnershipThief extends Item implements WDItem {
}
}
- if(!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof BlockScreen))
+ if (!(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof ScreenBlock))
return InteractionResult.SUCCESS;
Vector3i pos = new Vector3i(context.getClickedPos());
@@ -81,12 +82,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();
@@ -108,5 +109,4 @@ public class ItemOwnershipThief extends Item implements WDItem {
public String getWikiName(@Nonnull ItemStack is) {
return "Ownership_Thief";
}
-
}
diff --git a/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java b/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java
index 424a46a..1c323dc 100644
--- a/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java
+++ b/src/main/java/net/montoyo/wd/item/ItemScreenConfigurator.java
@@ -10,32 +10,30 @@ 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.block.ScreenBlock;
import net.montoyo.wd.data.ScreenConfigData;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
-import net.montoyo.wd.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
import net.montoyo.wd.utilities.Multiblock;
-import net.montoyo.wd.utilities.Util;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.serialization.Util;
+import net.montoyo.wd.utilities.math.Vector3i;
import org.jetbrains.annotations.NotNull;
public class ItemScreenConfigurator extends Item implements WDItem {
-
public ItemScreenConfigurator(Properties properties) {
super(properties
- .stacksTo(1)
+ .stacksTo(1)
// .tab(WebDisplays.CREATIVE_TAB)
);
}
@Override
public InteractionResult useOn(UseOnContext context) {
- if(context.getPlayer().isShiftKeyDown() || !(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof BlockScreen))
+ if (context.getPlayer().isShiftKeyDown() || !(context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof ScreenBlock))
return InteractionResult.PASS;
- if(context.getLevel().isClientSide)
+ if (context.getLevel().isClientSide)
return InteractionResult.SUCCESS;
Vector3i origin = new Vector3i(context.getClickedPos());
@@ -44,7 +42,7 @@ 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;
}
diff --git a/src/main/java/net/montoyo/wd/item/ItemUpgrade.java b/src/main/java/net/montoyo/wd/item/ItemUpgrade.java
index 6212636..29147c6 100644
--- a/src/main/java/net/montoyo/wd/item/ItemUpgrade.java
+++ b/src/main/java/net/montoyo/wd/item/ItemUpgrade.java
@@ -7,11 +7,10 @@ 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.utilities.BlockSide;
+import net.montoyo.wd.entity.ScreenBlockEntity;
+import net.montoyo.wd.utilities.data.BlockSide;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
@@ -19,19 +18,19 @@ import javax.annotation.Nullable;
public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
public final DefaultUpgrade type;
-
+
public ItemUpgrade(DefaultUpgrade type) {
super(DefaultUpgrade.class, new Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/);
this.type = type;
}
@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) {
- if(DefaultUpgrade.LASERMOUSE.matchesLaserMouse(is))
+ public boolean onRemove(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
+ if (DefaultUpgrade.LASERMOUSE.matchesLaserMouse(is))
tes.clearLaserUser(screenSide);
return false;
diff --git a/src/main/java/net/montoyo/wd/item/WDItem.java b/src/main/java/net/montoyo/wd/item/WDItem.java
index d514fa2..1c832c2 100644
--- a/src/main/java/net/montoyo/wd/item/WDItem.java
+++ b/src/main/java/net/montoyo/wd/item/WDItem.java
@@ -14,10 +14,9 @@ import javax.annotation.Nullable;
import java.util.List;
public interface WDItem {
-
static void addInformation(@Nullable List tt) {
- if(tt != null && WebDisplays.PROXY.isShiftDown())
- tt.add("" + ChatFormatting.GRAY + I18n.get("item.webdisplays.wiki"));
+ if (tt != null && WebDisplays.PROXY.isShiftDown())
+ tt.add(ChatFormatting.GRAY + I18n.get("item.webdisplays.wiki"));
}
String getWikiName(@Nonnull ItemStack is);
diff --git a/src/main/java/net/montoyo/wd/miniserv/client/Client.java b/src/main/java/net/montoyo/wd/miniserv/client/Client.java
index 021d175..fb2669e 100644
--- a/src/main/java/net/montoyo/wd/miniserv/client/Client.java
+++ b/src/main/java/net/montoyo/wd/miniserv/client/Client.java
@@ -9,7 +9,7 @@ import net.minecraft.world.entity.player.Player;
import net.montoyo.wd.miniserv.*;
import net.montoyo.wd.net.server_bound.C2SMessageMiniservConnect;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
diff --git a/src/main/java/net/montoyo/wd/miniserv/client/ClientTaskUploadFile.java b/src/main/java/net/montoyo/wd/miniserv/client/ClientTaskUploadFile.java
index c214e07..e2f026d 100644
--- a/src/main/java/net/montoyo/wd/miniserv/client/ClientTaskUploadFile.java
+++ b/src/main/java/net/montoyo/wd/miniserv/client/ClientTaskUploadFile.java
@@ -8,7 +8,7 @@ import net.montoyo.wd.miniserv.Constants;
import net.montoyo.wd.miniserv.OutgoingPacket;
import net.montoyo.wd.miniserv.PacketID;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
import java.io.File;
import java.io.FileInputStream;
diff --git a/src/main/java/net/montoyo/wd/miniserv/server/Server.java b/src/main/java/net/montoyo/wd/miniserv/server/Server.java
index 7a2a95f..9a3e4d0 100644
--- a/src/main/java/net/montoyo/wd/miniserv/server/Server.java
+++ b/src/main/java/net/montoyo/wd/miniserv/server/Server.java
@@ -6,7 +6,7 @@ package net.montoyo.wd.miniserv.server;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
import java.io.File;
import java.io.IOException;
diff --git a/src/main/java/net/montoyo/wd/miniserv/server/ServerClient.java b/src/main/java/net/montoyo/wd/miniserv/server/ServerClient.java
index b4de508..ca27c27 100644
--- a/src/main/java/net/montoyo/wd/miniserv/server/ServerClient.java
+++ b/src/main/java/net/montoyo/wd/miniserv/server/ServerClient.java
@@ -6,7 +6,7 @@ package net.montoyo.wd.miniserv.server;
import net.montoyo.wd.miniserv.*;
import net.montoyo.wd.utilities.Log;
-import net.montoyo.wd.utilities.Util;
+import net.montoyo.wd.utilities.serialization.Util;
import java.io.*;
import java.nio.channels.ClosedChannelException;
diff --git a/src/main/java/net/montoyo/wd/mixins/MouseHandlerMixin.java b/src/main/java/net/montoyo/wd/mixins/MouseHandlerMixin.java
index 7138dc6..7fadaf7 100644
--- a/src/main/java/net/montoyo/wd/mixins/MouseHandlerMixin.java
+++ b/src/main/java/net/montoyo/wd/mixins/MouseHandlerMixin.java
@@ -4,7 +4,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.MouseHandler;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.phys.HitResult;
-import net.montoyo.wd.init.ItemInit;
+import net.montoyo.wd.registry.ItemRegistry;
import net.montoyo.wd.item.ItemLaserPointer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -15,21 +15,23 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MouseHandler.class)
public class MouseHandlerMixin {
- @Shadow @Final private Minecraft minecraft;
-
- @Inject(at = @At("HEAD"), method = "onPress", cancellable = true)
- public void prePress(long p_91531_, int p_91532_, int p_91533_, int p_91534_, CallbackInfo ci) {
- boolean flag = p_91533_ == 1;
-
- if (Minecraft.getInstance().screen == null) {
- if (
- minecraft.player != null && minecraft.level != null &&
- minecraft.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.LASER_POINTER.get()) &&
- (minecraft.hitResult == null || minecraft.hitResult.getType() == HitResult.Type.BLOCK || minecraft.hitResult.getType() == HitResult.Type.MISS)
- ) {
- ItemLaserPointer.press(flag, p_91532_);
- ci.cancel();
- }
- }
- }
+ @Shadow
+ @Final
+ private Minecraft minecraft;
+
+ @Inject(at = @At("HEAD"), method = "onPress", cancellable = true)
+ public void prePress(long p_91531_, int p_91532_, int p_91533_, int p_91534_, CallbackInfo ci) {
+ boolean flag = p_91533_ == 1;
+
+ if (Minecraft.getInstance().screen == null) {
+ if (
+ minecraft.player != null && minecraft.level != null &&
+ minecraft.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemRegistry.LASER_POINTER.get()) &&
+ (minecraft.hitResult == null || minecraft.hitResult.getType() == HitResult.Type.BLOCK || minecraft.hitResult.getType() == HitResult.Type.MISS)
+ ) {
+ ItemLaserPointer.press(flag, p_91532_);
+ ci.cancel();
+ }
+ }
+ }
}
diff --git a/src/main/java/net/montoyo/wd/mixins/OverlayMixin.java b/src/main/java/net/montoyo/wd/mixins/OverlayMixin.java
index 84cb49e..0b7ae78 100644
--- a/src/main/java/net/montoyo/wd/mixins/OverlayMixin.java
+++ b/src/main/java/net/montoyo/wd/mixins/OverlayMixin.java
@@ -14,19 +14,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Gui.class)
public class OverlayMixin {
- @Shadow
- @Final
- protected Minecraft minecraft;
-
- @Shadow
- protected int screenWidth;
-
- @Shadow
- protected int screenHeight;
-
- @Inject(at = @At("HEAD"), method = "renderCrosshair", cancellable = true)
- public void preDrawCrosshair(GuiGraphics pGuiGraphics, CallbackInfo ci) {
+ @Shadow
+ @Final
+ protected Minecraft minecraft;
+
+ @Shadow
+ protected int screenWidth;
+
+ @Shadow
+ protected int screenHeight;
+
+ @Inject(at = @At("HEAD"), method = "renderCrosshair", cancellable = true)
+ public void preDrawCrosshair(GuiGraphics pGuiGraphics, CallbackInfo ci) {
// ClientProxy.renderCrosshair(minecraft.options, screenWidth, screenHeight, ((Gui) (Object) this).getBlitOffset(), poseStack, ci);
- ClientProxy.renderCrosshair(minecraft.options, screenWidth, screenHeight, 0, pGuiGraphics, ci);
- }
+ ClientProxy.renderCrosshair(minecraft.options, screenWidth, screenHeight, 0, pGuiGraphics, ci);
+ }
}
diff --git a/src/main/java/net/montoyo/wd/net/BufferUtils.java b/src/main/java/net/montoyo/wd/net/BufferUtils.java
index cb10fe0..db68a37 100644
--- a/src/main/java/net/montoyo/wd/net/BufferUtils.java
+++ b/src/main/java/net/montoyo/wd/net/BufferUtils.java
@@ -1,7 +1,7 @@
package net.montoyo.wd.net;
import net.minecraft.network.FriendlyByteBuf;
-import net.montoyo.wd.utilities.Vector3i;
+import net.montoyo.wd.utilities.math.Vector3i;
import java.util.Arrays;
import java.util.function.Consumer;
diff --git a/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageACResult.java b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageACResult.java
index e54f152..d6c406f 100644
--- a/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageACResult.java
+++ b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageACResult.java
@@ -8,7 +8,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.network.NetworkEvent;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.net.Packet;
-import net.montoyo.wd.utilities.NameUUIDPair;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
public class S2CMessageACResult extends Packet {
private static NameUUIDPair[] result;
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 b6e0681..b974b20 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
@@ -11,21 +11,26 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.network.NetworkEvent;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.entity.ScreenData;
-import net.montoyo.wd.entity.TileEntityScreen;
+import net.montoyo.wd.entity.ScreenBlockEntity;
import net.montoyo.wd.net.Packet;
import net.montoyo.wd.utilities.*;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import java.io.IOException;
import java.util.ArrayList;
-import static net.montoyo.wd.block.BlockScreen.hasTE;
+import static net.montoyo.wd.block.ScreenBlock.hasTE;
public class S2CMessageAddScreen extends Packet {
private boolean clear;
private Vector3i pos;
private ScreenData[] screens;
- public S2CMessageAddScreen(TileEntityScreen tes) {
+ public S2CMessageAddScreen(ScreenBlockEntity tes) {
clear = true;
pos = new Vector3i(tes.getBlockPos());
screens = new ScreenData[tes.screenCount()];
@@ -96,11 +101,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());
@@ -108,7 +113,7 @@ public class S2CMessageAddScreen extends Packet {
}
}
- TileEntityScreen tes = (TileEntityScreen) te;
+ ScreenBlockEntity tes = (ScreenBlockEntity) te;
if (clear)
tes.clear();
@@ -118,7 +123,7 @@ public class S2CMessageAddScreen extends Packet {
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/S2CMessageCloseGui.java b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageCloseGui.java
index 761b541..9d253c2 100644
--- a/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageCloseGui.java
+++ b/src/main/java/net/montoyo/wd/net/client_bound/S2CMessageCloseGui.java
@@ -9,7 +9,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.network.NetworkEvent;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.net.Packet;
-import net.montoyo.wd.utilities.BlockSide;
+import net.montoyo.wd.utilities.data.BlockSide;
import java.util.Arrays;
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..e1317bc 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,10 +14,14 @@ 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.*;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
// TODO: use registry based approach
public class S2CMessageScreenUpdate extends Packet {
@@ -39,49 +43,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 +111,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/C2SMessageACQuery.java b/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageACQuery.java
index 082ec6e..7041176 100644
--- a/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageACQuery.java
+++ b/src/main/java/net/montoyo/wd/net/server_bound/C2SMessageACQuery.java
@@ -13,7 +13,7 @@ import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.net.Packet;
import net.montoyo.wd.net.WDNetworkRegistry;
import net.montoyo.wd.net.client_bound.S2CMessageACResult;
-import net.montoyo.wd.utilities.NameUUIDPair;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
import java.util.Arrays;
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..1143120 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,11 +12,11 @@ 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;
+import net.montoyo.wd.utilities.serialization.Util;
+import net.montoyo.wd.utilities.math.Vector3i;
public class C2SMessageRedstoneCtrl extends Packet implements Runnable {
private Player player;
@@ -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..1c9001c 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,10 +17,14 @@ 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.*;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
+import net.montoyo.wd.utilities.data.Rotation;
+import net.montoyo.wd.utilities.serialization.NameUUIDPair;
// TODO: this is a mess; a registry based approach would likely be more readable
public class C2SMessageScreenCtrl extends Packet {
@@ -40,13 +44,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 +58,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 +154,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 +166,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/BlockRegistry.java b/src/main/java/net/montoyo/wd/registry/BlockRegistry.java
new file mode 100644
index 0000000..b0cf12d
--- /dev/null
+++ b/src/main/java/net/montoyo/wd/registry/BlockRegistry.java
@@ -0,0 +1,31 @@
+package net.montoyo.wd.registry;
+
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.state.BlockBehaviour;
+import net.minecraftforge.eventbus.api.IEventBus;
+import net.minecraftforge.registries.DeferredRegister;
+import net.minecraftforge.registries.ForgeRegistries;
+import net.minecraftforge.registries.RegistryObject;
+import net.montoyo.wd.block.KeyboardBlockLeft;
+import net.montoyo.wd.block.KeyboardBlockRight;
+import net.montoyo.wd.block.PeripheralBlock;
+import net.montoyo.wd.block.ScreenBlock;
+import net.montoyo.wd.core.DefaultPeripheral;
+
+public class BlockRegistry {
+ public static void init(IEventBus bus) {
+ BLOCKS.register(bus);
+ }
+
+ public static DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "webdisplays");
+
+ public static final RegistryObject SCREEN_BLOCk = BLOCKS.register("screen", () -> new ScreenBlock(BlockBehaviour.Properties.copy(Blocks.STONE)));
+
+ public static final RegistryObject KEYBOARD_BLOCK = BlockRegistry.BLOCKS.register("kb_left", KeyboardBlockLeft::new);
+ public static final RegistryObject blockKbRight = BLOCKS.register("kb_right", KeyboardBlockRight::new);
+
+ public static final RegistryObject REDSTONE_CONTROL_BLOCK = BlockRegistry.BLOCKS.register("redctrl", () -> new PeripheralBlock(DefaultPeripheral.REDSTONE_CONTROLLER));
+ public static final RegistryObject REMOTE_CONTROLLER_BLOCK = BlockRegistry.BLOCKS.register("rctrl", () -> new PeripheralBlock(DefaultPeripheral.REMOTE_CONTROLLER));
+ public static final RegistryObject SERVER_BLOCK = BlockRegistry.BLOCKS.register("server", () -> new PeripheralBlock(DefaultPeripheral.SERVER));
+}
diff --git a/src/main/java/net/montoyo/wd/init/ItemInit.java b/src/main/java/net/montoyo/wd/registry/ItemRegistry.java
similarity index 80%
rename from src/main/java/net/montoyo/wd/init/ItemInit.java
rename to src/main/java/net/montoyo/wd/registry/ItemRegistry.java
index f4b9a7f..4b2aecc 100644
--- a/src/main/java/net/montoyo/wd/init/ItemInit.java
+++ b/src/main/java/net/montoyo/wd/registry/ItemRegistry.java
@@ -1,4 +1,4 @@
-package net.montoyo.wd.init;
+package net.montoyo.wd.registry;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
@@ -6,7 +6,6 @@ import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
-import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.block.item.KeyboardItem;
import net.montoyo.wd.core.CraftComponent;
import net.montoyo.wd.core.DefaultUpgrade;
@@ -15,11 +14,11 @@ import net.montoyo.wd.item.*;
import java.util.Locale;
@SuppressWarnings({"unchecked", "unused"})
-public class ItemInit{
+public class ItemRegistry {
public static void init(IEventBus bus) {
ITEMS.register(bus);
}
-
+
public static final DeferredRegister- ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "webdisplays");
protected static final RegistryObject
- [] COMP_CRAFT_ITEMS = new RegistryObject[CraftComponent.values().length];
@@ -31,13 +30,13 @@ public class ItemInit{
public static final RegistryObject
- MINEPAD = ITEMS.register("minepad", () -> new ItemMinePad2(new Item.Properties()));
public static final RegistryObject
- LASER_POINTER = ITEMS.register("laserpointer", () -> new ItemLaserPointer(new Item.Properties()));
- static {
+ static {
DefaultUpgrade[] defaultUpgrades = DefaultUpgrade.values();
for (int i = 0; i < defaultUpgrades.length; i++) {
DefaultUpgrade upgrade = defaultUpgrades[i];
UPGRADE_ITEMS[i] = ITEMS.register("upgrade_" + upgrade.name().toLowerCase(Locale.ROOT), () -> new ItemUpgrade(upgrade));
}
-
+
CraftComponent[] components = CraftComponent.values();
for (int i = 0; i < components.length; i++) {
CraftComponent cc = components[i];
@@ -45,29 +44,29 @@ public class ItemInit{
}
}
- public static final RegistryObject
- SCREEN = ITEMS.register("screen", () -> new BlockItem(BlockInit.blockScreen.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
+ public static final RegistryObject
- SCREEN = ITEMS.register("screen", () -> new BlockItem(BlockRegistry.SCREEN_BLOCk.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
+
+ public static final RegistryObject
- KEYBOARD = ITEMS.register("keyboard", () -> new KeyboardItem(BlockRegistry.KEYBOARD_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
+ public static final RegistryObject
- REDSTONE_CONTROLLER = ITEMS.register("redctrl", () -> new BlockItem(BlockRegistry.REDSTONE_CONTROL_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
+ public static final RegistryObject
- REMOTE_CONTROLLER = ITEMS.register("rctrl", () -> new BlockItem(BlockRegistry.REMOTE_CONTROLLER_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
+ public static final RegistryObject
- SERVER = ITEMS.register("server", () -> new BlockItem(BlockRegistry.SERVER_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
- public static final RegistryObject
- KEYBOARD = ITEMS.register("keyboard", () -> new KeyboardItem(BlockInit.blockKeyBoard.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
- public static final RegistryObject
- REDSTONE_CONTROLLER = ITEMS.register("redctrl", () -> new BlockItem(BlockInit.blockRedControl.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
- public static final RegistryObject
- REMOTE_CONTROLLER = ITEMS.register("rctrl", () -> new BlockItem(BlockInit.blockRControl.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
- public static final RegistryObject
- SERVER = ITEMS.register("server", () -> new BlockItem(BlockInit.blockServer.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
-
public static RegistryObject
- getComputerCraftItem(int index) {
return COMP_CRAFT_ITEMS[index];
}
-
+
public static RegistryObject
- getUpgradeItem(int index) {
return UPGRADE_ITEMS[index];
}
-
+
public static int countCompCraftItems() {
return COMP_CRAFT_ITEMS.length;
}
-
+
public static int countUpgrades() {
return UPGRADE_ITEMS.length;
}
-
+
public static boolean isCompCraftItem(Item item) {
for (RegistryObject
- itemRegistryObject : COMP_CRAFT_ITEMS)
if (item == itemRegistryObject.get())
diff --git a/src/main/java/net/montoyo/wd/registry/TileRegistry.java b/src/main/java/net/montoyo/wd/registry/TileRegistry.java
new file mode 100644
index 0000000..18f0855
--- /dev/null
+++ b/src/main/java/net/montoyo/wd/registry/TileRegistry.java
@@ -0,0 +1,34 @@
+package net.montoyo.wd.registry;
+
+import net.minecraft.world.level.block.entity.BlockEntityType;
+import net.minecraftforge.eventbus.api.IEventBus;
+import net.minecraftforge.registries.DeferredRegister;
+import net.minecraftforge.registries.ForgeRegistries;
+import net.minecraftforge.registries.RegistryObject;
+import net.montoyo.wd.entity.*;
+
+public class TileRegistry {
+ public static final DeferredRegister> TILE_TYPES = DeferredRegister
+ .create(ForgeRegistries.BLOCK_ENTITY_TYPES, "webdisplays");
+
+ //Register tile entities
+ public static final RegistryObject> SCREEN_BLOCK_ENTITY = TILE_TYPES
+ .register("screen", () -> BlockEntityType.Builder
+ .of(ScreenBlockEntity::new, BlockRegistry.SCREEN_BLOCk.get()).build(null));
+
+ public static final RegistryObject> KEYBOARD = TILE_TYPES.register("kb_left", () -> BlockEntityType.Builder
+ .of(KeyboardBlockEntity::new, BlockRegistry.KEYBOARD_BLOCK.get()).build(null));
+
+ public static final RegistryObject> REMOTE_CONTROLLER = TILE_TYPES.register("rctrl",
+ () -> 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(RedstoneControlBlockEntity::new, BlockRegistry.REDSTONE_CONTROL_BLOCK.get()).build(null));
+
+ public static final RegistryObject> SERVER = TILE_TYPES.register("server",
+ () -> BlockEntityType.Builder.of(ServerBlockEntity::new, BlockRegistry.SERVER_BLOCK.get()).build(null));
+
+ public static void init(IEventBus bus) {
+ TILE_TYPES.register(bus);
+ }
+}
diff --git a/src/main/java/net/montoyo/wd/init/TabInit.java b/src/main/java/net/montoyo/wd/registry/WDTabs.java
similarity index 55%
rename from src/main/java/net/montoyo/wd/init/TabInit.java
rename to src/main/java/net/montoyo/wd/registry/WDTabs.java
index e8286e7..5b06446 100644
--- a/src/main/java/net/montoyo/wd/init/TabInit.java
+++ b/src/main/java/net/montoyo/wd/registry/WDTabs.java
@@ -2,7 +2,7 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.init;
+package net.montoyo.wd.registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
@@ -11,38 +11,37 @@ import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
-import net.montoyo.wd.init.ItemInit;
-public class TabInit {
+public class WDTabs {
public static final DeferredRegister TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, "webdisplays");
public static final RegistryObject EXAMPLE_TAB = TABS.register("main", () -> CreativeModeTab.builder()
// Set name of tab to display
.title(Component.translatable("itemGroup.webdisplays"))
// Set icon of creative tab
- .icon(() -> new ItemStack(ItemInit.SCREEN.get()))
+ .icon(() -> new ItemStack(ItemRegistry.SCREEN.get()))
// Add default items to tab
.displayItems((params, output) -> {
// core items
- output.accept(ItemInit.SCREEN.get());
- output.accept(ItemInit.KEYBOARD.get());
- output.accept(ItemInit.LINKER.get());
+ output.accept(ItemRegistry.SCREEN.get());
+ output.accept(ItemRegistry.KEYBOARD.get());
+ output.accept(ItemRegistry.LINKER.get());
// remote control
- output.accept(ItemInit.REMOTE_CONTROLLER.get());
+ output.accept(ItemRegistry.REMOTE_CONTROLLER.get());
// redstone stuff
- output.accept(ItemInit.REDSTONE_CONTROLLER.get());
+ output.accept(ItemRegistry.REDSTONE_CONTROLLER.get());
// admin tools
- output.accept(ItemInit.OWNERSHIP_THEIF.get());
+ output.accept(ItemRegistry.OWNERSHIP_THEIF.get());
// tool items
- output.accept(ItemInit.SERVER.get());
- output.accept(ItemInit.CONFIGURATOR.get());
- output.accept(ItemInit.MINEPAD.get());
- output.accept(ItemInit.LASER_POINTER.get());
+ output.accept(ItemRegistry.SERVER.get());
+ output.accept(ItemRegistry.CONFIGURATOR.get());
+ output.accept(ItemRegistry.MINEPAD.get());
+ output.accept(ItemRegistry.LASER_POINTER.get());
// upgrades
- for (int i = 0; i < ItemInit.countUpgrades(); i++) output.accept(ItemInit.getUpgradeItem(i).get());
+ for (int i = 0; i < ItemRegistry.countUpgrades(); i++) output.accept(ItemRegistry.getUpgradeItem(i).get());
// cc
- for (int i = 0; i < ItemInit.countCompCraftItems(); i++) output.accept(ItemInit.getComputerCraftItem(i).get());
+ for (int i = 0; i < ItemRegistry.countCompCraftItems(); i++) output.accept(ItemRegistry.getComputerCraftItem(i).get());
})
.build()
);
diff --git a/src/main/java/net/montoyo/wd/utilities/BlockSide.java b/src/main/java/net/montoyo/wd/utilities/BlockSide.java
deleted file mode 100644
index 90b602b..0000000
--- a/src/main/java/net/montoyo/wd/utilities/BlockSide.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2018 BARBOTIN Nicolas
- */
-
-package net.montoyo.wd.utilities;
-
-public enum BlockSide {
-
- BOTTOM(new Vector3i( 0, 0, -1), new Vector3i( 1, 0, 0), new Vector3i( 0, -1, 0)),
- TOP (new Vector3i( 0, 0, -1), new Vector3i( 1, 0, 0), new Vector3i( 0, 1, 0)),
- NORTH (new Vector3i( 0, 1, 0), new Vector3i(-1, 0, 0), new Vector3i( 0, 0, -1)),
- SOUTH (new Vector3i( 0, 1, 0), new Vector3i( 1, 0, 0), new Vector3i( 0, 0, 1)),
- WEST (new Vector3i( 0, 1, 0), new Vector3i( 0, 0, 1), new Vector3i(-1, 0, 0)),
- EAST (new Vector3i( 0, 1, 0), new Vector3i( 0, 0, -1), new Vector3i( 1, 0, 0));
-
- public final Vector3i up;
- public final Vector3i right;
- public final Vector3i forward;
- public final Vector3i down;
- public final Vector3i left;
- public final Vector3i backward;
-
- BlockSide(Vector3i u, Vector3i r, Vector3i f) {
- up = u;
- right = r;
- forward = f;
- down = u.clone().neg();
- left = r.clone().neg();
- backward = f.clone().neg();
- }
-
- public BlockSide reverse()
- {
- int side = ordinal();
- int div = side / 2;
- int rest = 1 - side % 2;
-
- return values()[div * 2 + rest];
- }
-
- public static int reverse(int side) {
- int div = side / 2;
- int rest = 1 - side % 2;
-
- return div * 2 + rest;
- }
-
- public static BlockSide fromInt(int s) {
- BlockSide[] values = values();
- return (s < 0 || s >= values.length) ? null : values[s];
- }
-
-}
diff --git a/src/main/java/net/montoyo/wd/utilities/DistSafety.java b/src/main/java/net/montoyo/wd/utilities/DistSafety.java
index 3bd4064..8309a2f 100644
--- a/src/main/java/net/montoyo/wd/utilities/DistSafety.java
+++ b/src/main/java/net/montoyo/wd/utilities/DistSafety.java
@@ -7,10 +7,10 @@ public class DistSafety {
public static ClientProxy createProxy() {
return new ClientProxy();
}
-
- public static boolean isConnected() {
- if (Minecraft.getInstance().getConnection() == null) return false;
- if (Minecraft.getInstance().getConnection().getConnection().isConnecting()) return false;
- return Minecraft.getInstance().getConnection().getConnection().isConnected();
- }
+
+ public static boolean isConnected() {
+ if (Minecraft.getInstance().getConnection() == null) return false;
+ if (Minecraft.getInstance().getConnection().getConnection().isConnecting()) return false;
+ return Minecraft.getInstance().getConnection().getConnection().isConnected();
+ }
}
diff --git a/src/main/java/net/montoyo/wd/utilities/Log.java b/src/main/java/net/montoyo/wd/utilities/Log.java
index 82b56d6..fc1003f 100644
--- a/src/main/java/net/montoyo/wd/utilities/Log.java
+++ b/src/main/java/net/montoyo/wd/utilities/Log.java
@@ -8,29 +8,27 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
public abstract class Log {
-
- public static void info(String what, Object ... data) {
+ public static void info(String what, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.INFO, String.format(what, data));
}
- public static void warning(String what, Object ... data) {
+ public static void warning(String what, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.WARN, String.format(what, data));
}
- public static void error(String what, Object ... data) {
+ public static void error(String what, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.ERROR, String.format(what, data));
}
- public static void infoEx(String what, Throwable e, Object ... data) {
+ public static void infoEx(String what, Throwable e, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.INFO, String.format(what, data), e);
}
- public static void warningEx(String what, Throwable e, Object ... data) {
+ public static void warningEx(String what, Throwable e, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.WARN, String.format(what, data), e);
}
- public static void errorEx(String what, Throwable e, Object ... data) {
+ public static void errorEx(String what, Throwable e, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.ERROR, String.format(what, data), e);
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/Multiblock.java b/src/main/java/net/montoyo/wd/utilities/Multiblock.java
index 550d8e2..8bef699 100644
--- a/src/main/java/net/montoyo/wd/utilities/Multiblock.java
+++ b/src/main/java/net/montoyo/wd/utilities/Multiblock.java
@@ -6,11 +6,12 @@ package net.montoyo.wd.utilities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;
-import net.montoyo.wd.WebDisplays;
-import net.montoyo.wd.init.BlockInit;
+import net.montoyo.wd.registry.BlockRegistry;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
public abstract class Multiblock {
-
public enum OverrideAction {
NONE,
SIMULATE,
@@ -27,9 +28,9 @@ public abstract class Multiblock {
}
public boolean apply(Vector3i bp, boolean originalResult) {
- if(action == OverrideAction.NONE || !bp.equals(pos))
+ if (action == OverrideAction.NONE || !bp.equals(pos))
return originalResult;
- else if(action == OverrideAction.SIMULATE)
+ else if (action == OverrideAction.SIMULATE)
return true;
else //action == OverrideAction.IGNORE
return false;
@@ -40,9 +41,8 @@ public abstract class Multiblock {
public static final BlockOverride NULL_OVERRIDE = new BlockOverride(null, OverrideAction.NONE);
//Modifies pos
- public static void findOrigin(LevelAccessor world, Vector3i pos, BlockSide side, BlockOverride override)
- {
- if(override == null)
+ public static void findOrigin(LevelAccessor world, Vector3i pos, BlockSide side, BlockOverride override) {
+ if (override == null)
override = NULL_OVERRIDE;
BlockPos.MutableBlockPos bp = new BlockPos.MutableBlockPos();
@@ -51,7 +51,7 @@ public abstract class Multiblock {
do {
pos.add(side.left);
pos.toBlock(bp);
- } while(override.apply(pos, world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get()));
+ } while (override.apply(pos, world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get()));
pos.add(side.right);
@@ -59,14 +59,13 @@ public abstract class Multiblock {
do {
pos.add(side.down);
pos.toBlock(bp);
- } while(override.apply(pos, world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get()));
+ } while (override.apply(pos, world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get()));
pos.add(side.up);
}
//Origin stays constant
- public static Vector2i measure(LevelAccessor world, Vector3i origin, BlockSide side)
- {
+ public static Vector2i measure(LevelAccessor world, Vector3i origin, BlockSide side) {
Vector2i ret = new Vector2i();
Vector3i pos = origin.clone();
@@ -78,7 +77,7 @@ public abstract class Multiblock {
pos.add(side.up);
pos.toBlock(bp);
ret.y++;
- } while(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get());
+ } while (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get());
pos.add(side.down);
@@ -87,33 +86,32 @@ public abstract class Multiblock {
pos.add(side.right);
pos.toBlock(bp);
ret.x++;
- } while(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get());
+ } while (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get());
return ret;
}
//Origin and size stays constant.
//Returns null if structure is okay, otherwise the erroring block pos.
- public static Vector3i check(LevelAccessor world, Vector3i origin, Vector2i size, BlockSide side)
- {
+ public static Vector3i check(LevelAccessor world, Vector3i origin, Vector2i size, BlockSide side) {
Vector3i pos = origin.clone();
BlockPos.MutableBlockPos bp = new BlockPos.MutableBlockPos();
//Check inner
- for(int y = 0; y < size.y; y++) {
- for(int x = 0; x < size.x; x++) {
+ for (int y = 0; y < size.y; y++) {
+ for (int x = 0; x < size.x; x++) {
pos.toBlock(bp);
- if(!(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get()))
+ if (!(world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get()))
return pos; //Hole
pos.add(side.forward);
pos.toBlock(bp);
- if(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get())
+ if (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get())
return pos; //Back should be empty
pos.addMul(side.backward, 2);
pos.toBlock(bp);
- if(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get())
+ if (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get())
return pos; //Front should be empty
pos.add(side.forward);
@@ -128,9 +126,9 @@ public abstract class Multiblock {
pos.set(origin);
pos.add(side.left);
- for(int y = 0; y < size.y; y++) {
+ for (int y = 0; y < size.y; y++) {
pos.toBlock(bp);
- if(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get())
+ if (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get())
return pos; //Left edge should be empty
pos.add(side.up);
@@ -140,9 +138,9 @@ public abstract class Multiblock {
pos.set(origin);
pos.addMul(side.right, size.x);
- for(int y = 0; y < size.y; y++) {
+ for (int y = 0; y < size.y; y++) {
pos.toBlock(bp);
- if(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get())
+ if (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get())
return pos; //Left edge should be empty
pos.add(side.up);
@@ -152,9 +150,9 @@ public abstract class Multiblock {
pos.set(origin);
pos.add(side.down);
- for(int x = 0; x < size.x; x++) {
+ for (int x = 0; x < size.x; x++) {
pos.toBlock(bp);
- if(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get())
+ if (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get())
return pos; //Left edge should be empty
pos.add(side.right);
@@ -164,9 +162,9 @@ public abstract class Multiblock {
pos.set(origin);
pos.addMul(side.up, size.y);
- for(int x = 0; x < size.x; x++) {
+ for (int x = 0; x < size.x; x++) {
pos.toBlock(bp);
- if(world.getBlockState(bp).getBlock() == BlockInit.blockScreen.get())
+ if (world.getBlockState(bp).getBlock() == BlockRegistry.SCREEN_BLOCk.get())
return pos; //Left edge should be empty
pos.add(side.right);
@@ -175,5 +173,4 @@ public abstract class Multiblock {
//All good.
return null;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/MutableAABB.java b/src/main/java/net/montoyo/wd/utilities/MutableAABB.java
deleted file mode 100644
index b3acb7a..0000000
--- a/src/main/java/net/montoyo/wd/utilities/MutableAABB.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2018 BARBOTIN Nicolas
- */
-
-package net.montoyo.wd.utilities;
-
-import net.minecraft.world.phys.AABB;
-
-public final class MutableAABB extends AABB {
- public MutableAABB() {
- super(0, 0, 0, 0, 0, 0);
- }
-
- public MutableAABB(Vector3i pos) {
- super(pos.x, pos.y, pos.z, pos.x, pos.y, pos.z);
- }
-
- public MutableAABB(Vector3i a, Vector3i b) {
- super(a.x, a.y, a.z, b.x, b.y, b.z);
- }
-
- public MutableAABB(net.minecraft.world.phys.AABB bb) {
- super(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
- }
-
- public MutableAABB(double x1, double y1, double z1, double x2, double y2, double z2) {
- super(x1, y1, z1, x2, y2, z2);
- }
-
- public MutableAABB expand(Vector3i vec) {
- if (vec.x > maxX)
- maxX = vec.x;
- else if (vec.x < minX)
- minX = vec.x;
-
- if (vec.y > maxY)
- maxY = vec.y;
- else if (vec.y < minY)
- minY = vec.y;
-
- if (vec.z > maxZ)
- maxZ = vec.z;
- else if (vec.z < minZ)
- minZ = vec.z;
-
- return this;
- }
-
- @Override
- public AABB move(double x, double y, double z) {
- minX += x;
- minY += y;
- minZ += z;
- maxX += x;
- maxY += y;
- maxZ += z;
- return this;
- }
-
- public net.minecraft.world.phys.AABB toMc() {
- return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
- }
-
- public void setAndCheck(double x1, double y1, double z1, double x2, double y2, double z2) {
- minX = Math.min(x1, x2);
- minY = Math.min(y1, y2);
- minZ = Math.min(z1, z2);
-
- maxX = Math.max(x1, x2);
- maxY = Math.max(y1, y2);
- maxZ = Math.max(z1, z2);
- }
-
- public void expand(double x1, double y1, double z1, double x2, double y2, double z2) {
- minX = Math.min(minX, Math.min(x1, x2));
- minY = Math.min(minY, Math.min(y1, y2));
- minZ = Math.min(minZ, Math.min(z1, z2));
-
- maxX = Math.max(maxX, Math.max(x1, x2));
- maxY = Math.max(maxY, Math.max(y1, y2));
- maxZ = Math.max(maxZ, Math.max(z1, z2));
- }
-}
diff --git a/src/main/java/net/montoyo/wd/utilities/NibbleArray.java b/src/main/java/net/montoyo/wd/utilities/NibbleArray.java
index b66d9b3..000f3a3 100644
--- a/src/main/java/net/montoyo/wd/utilities/NibbleArray.java
+++ b/src/main/java/net/montoyo/wd/utilities/NibbleArray.java
@@ -5,11 +5,10 @@
package net.montoyo.wd.utilities;
public final class NibbleArray {
-
private final byte[] data;
public NibbleArray(int count) {
- if((count & 1) != 0)
+ if ((count & 1) != 0)
count++;
data = new byte[count >> 1];
@@ -19,17 +18,17 @@ public final class NibbleArray {
data = d;
}
- public final int get(int idx) {
- if((idx & 1) == 0)
+ public int get(int idx) {
+ if ((idx & 1) == 0)
return (data[idx >> 1] >> 4) & 0x0F; //MSB
else
return data[idx >> 1] & 0x0F; //LSB
}
- public final void set(int idx, int val) {
+ public void set(int idx, int val) {
val &= 0x0F;
- if((idx & 1) == 0) {
+ if ((idx & 1) == 0) {
idx >>= 1;
data[idx] = (byte) ((data[idx] & 0x0F) | (val << 4)); //MSB
} else {
@@ -43,5 +42,4 @@ public final class NibbleArray {
System.arraycopy(data, 0, ret, 0, data.length);
return ret;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/ScreenIterator.java b/src/main/java/net/montoyo/wd/utilities/ScreenIterator.java
index 698209c..b26d77b 100644
--- a/src/main/java/net/montoyo/wd/utilities/ScreenIterator.java
+++ b/src/main/java/net/montoyo/wd/utilities/ScreenIterator.java
@@ -5,13 +5,14 @@
package net.montoyo.wd.utilities;
import net.minecraft.core.BlockPos;
+import net.montoyo.wd.utilities.math.Vector2i;
+import net.montoyo.wd.utilities.math.Vector3i;
+import net.montoyo.wd.utilities.data.BlockSide;
import java.util.Iterator;
public final class ScreenIterator implements Iterator {
-
- private final Vector3i vec1;
- private final Vector3i vec2;
+ private final Vector3i from, to;
private final BlockSide side;
private final Vector2i size;
private final BlockPos.MutableBlockPos blockPos;
@@ -20,31 +21,31 @@ public final class ScreenIterator implements Iterator {
private boolean hasNext = true;
public ScreenIterator(BlockPos pos, BlockSide side, Vector2i size) {
- vec1 = new Vector3i(pos);
- vec2 = vec1.clone();
+ from = new Vector3i(pos);
+ to = from.clone();
this.side = side;
this.size = size;
blockPos = new BlockPos.MutableBlockPos();
}
@Override
- public final boolean hasNext() {
+ public boolean hasNext() {
return hasNext;
}
@Override
- public final BlockPos next() {
- vec2.toBlock(blockPos);
+ public BlockPos next() {
+ to.toBlock(blockPos);
- if(++x >= size.x) {
- if(++y >= size.y)
+ if (++x >= size.x) {
+ if (++y >= size.y)
hasNext = false;
else {
x = 0;
- vec2.set(vec1.add(side.up));
+ to.set(from.add(side.up));
}
} else
- vec2.add(side.right);
+ to.add(side.right);
return blockPos;
}
@@ -60,5 +61,4 @@ public final class ScreenIterator implements Iterator {
public int getIndex() {
return y * size.x + x;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/VideoType.java b/src/main/java/net/montoyo/wd/utilities/VideoType.java
index aaaa719..8219384 100644
--- a/src/main/java/net/montoyo/wd/utilities/VideoType.java
+++ b/src/main/java/net/montoyo/wd/utilities/VideoType.java
@@ -10,130 +10,128 @@ import java.net.MalformedURLException;
import java.net.URL;
public enum VideoType {
-
- YOUTUBE(
- "document.getElementById(\"movie_player\").",
- new Function("setVolume(", ")"),
- new Function("getCurrentTime(", ")"),
- new Function("seekTo(", ")")
- ),
- YOUTUBE_EMBED(
- "document.getElementsByClassName(\"html5-video-player\")[0].",
- new Function("setVolume(", ")"),
- new Function("getCurrentTime(", ")"),
- new Function("seekTo(", ")")
- );
-
- private final String base;
- private final Function volume;
- private final Function getTime;
- private final Function setTime;
- private final int volumeCap;
-
- VideoType(
- String base,
- Function volume,
- Function getTime,
- Function setTime
- ) {
- this.base = base;
- this.volume = volume;
- this.getTime = getTime;
- this.setTime = setTime;
- // lol, what?
- volumeCap = volume.prefix.length() + 5 + volume.suffix.length();
- }
-
+ YOUTUBE(
+ "document.getElementById(\"movie_player\").",
+ new Function("setVolume(", ")"),
+ new Function("getCurrentTime(", ")"),
+ new Function("seekTo(", ")")
+ ),
+ YOUTUBE_EMBED(
+ "document.getElementsByClassName(\"html5-video-player\")[0].",
+ new Function("setVolume(", ")"),
+ new Function("getCurrentTime(", ")"),
+ new Function("seekTo(", ")")
+ );
+
+ private final String base;
+ private final Function volume;
+ private final Function getTime;
+ private final Function setTime;
+ private final int volumeCap;
+
+ VideoType(
+ String base,
+ Function volume,
+ Function getTime,
+ Function setTime
+ ) {
+ this.base = base;
+ this.volume = volume;
+ this.getTime = getTime;
+ this.setTime = setTime;
+ // lol, what?
+ volumeCap = volume.prefix.length() + 5 + volume.suffix.length();
+ }
+
// public static void registerQueries(JSQueryDispatcher jsQueryDispatcher) {
// // TODO: register GetTime query
// }
-
+
protected static class Function {
- String prefix, suffix;
-
- public Function(String prefix, String suffix) {
- this.prefix = prefix;
- this.suffix = suffix;
- }
-
- public String apply() {
- return prefix + suffix;
- }
-
- public String apply(String arg) {
- return prefix + arg + suffix;
- }
- }
-
- @Nullable
- public static VideoType getTypeFromURL(@Nonnull URL url) {
- String loHost = url.getHost().toLowerCase();
- if (loHost.equals("youtu.be"))
- return url.getPath().length() > 1 ? YOUTUBE : null;
- else if (!loHost.equals("www.youtube.com") && !loHost.equals("youtube.com"))
- return null;
-
- String loPath = url.getPath().toLowerCase();
- if (loPath.equals("/watch")) {
- if (url.getQuery() != null && (url.getQuery().startsWith("v=") || url.getQuery().contains("&v=")))
- return YOUTUBE;
- } else if (loPath.startsWith("/embed/"))
- return loPath.length() > 7 ? YOUTUBE_EMBED : null;
-
- return null;
- }
-
- @Nullable
- public static VideoType getTypeFromURL(@Nonnull String url) {
- try {
- return getTypeFromURL(new URL(url));
- } catch (MalformedURLException ex) {
- return null;
- }
- }
-
- @Nonnull
- public String getVideoIDFromURL(@Nonnull URL url) {
- if (this == YOUTUBE) {
- if (url.getHost().equalsIgnoreCase("youtu.be"))
- return url.getPath().substring(1);
-
- String args[] = url.getQuery().split("&");
- for (String arg : args) {
- if (arg.startsWith("v="))
- return arg.substring(2);
- }
- } else if (this == YOUTUBE_EMBED)
- return url.getPath().substring(7);
-
- return "";
- }
-
- @Nonnull
- public String getURLFromID(@Nonnull String vid, boolean autoplay) {
- String format;
- if (this == YOUTUBE)
- format = autoplay ? "https://www.youtube.com/watch?v=%s&autoplay=1" : "https://www.youtube.com/watch?v=%s";
- else if (this == YOUTUBE_EMBED)
- format = autoplay ? "https://www.youtube.com/embed/%s?autoplay=1" : "https://www.youtube.com/embed/%s";
- else
- return "";
-
- return String.format(format, vid);
- }
-
- // TODO: timestamp stuff
- @Nonnull
- public String getVolumeJSQuery(int volInt, int volFrac) {
- return volume.apply(volInt + "." + volFrac);
- }
-
- public String getTimeStampQuery() {
- return getTime.apply();
- }
-
- public String setTimeStampQuery(float ts) {
- return setTime.apply(String.valueOf(ts));
- }
-
+ String prefix, suffix;
+
+ public Function(String prefix, String suffix) {
+ this.prefix = prefix;
+ this.suffix = suffix;
+ }
+
+ public String apply() {
+ return prefix + suffix;
+ }
+
+ public String apply(String arg) {
+ return prefix + arg + suffix;
+ }
+ }
+
+ @Nullable
+ public static VideoType getTypeFromURL(@Nonnull URL url) {
+ String loHost = url.getHost().toLowerCase();
+ if (loHost.equals("youtu.be"))
+ return url.getPath().length() > 1 ? YOUTUBE : null;
+ else if (!loHost.equals("www.youtube.com") && !loHost.equals("youtube.com"))
+ return null;
+
+ String loPath = url.getPath().toLowerCase();
+ if (loPath.equals("/watch")) {
+ if (url.getQuery() != null && (url.getQuery().startsWith("v=") || url.getQuery().contains("&v=")))
+ return YOUTUBE;
+ } else if (loPath.startsWith("/embed/"))
+ return loPath.length() > 7 ? YOUTUBE_EMBED : null;
+
+ return null;
+ }
+
+ @Nullable
+ public static VideoType getTypeFromURL(@Nonnull String url) {
+ try {
+ return getTypeFromURL(new URL(url));
+ } catch (MalformedURLException ex) {
+ return null;
+ }
+ }
+
+ @Nonnull
+ public String getVideoIDFromURL(@Nonnull URL url) {
+ if (this == YOUTUBE) {
+ if (url.getHost().equalsIgnoreCase("youtu.be"))
+ return url.getPath().substring(1);
+
+ String args[] = url.getQuery().split("&");
+ for (String arg : args) {
+ if (arg.startsWith("v="))
+ return arg.substring(2);
+ }
+ } else if (this == YOUTUBE_EMBED)
+ return url.getPath().substring(7);
+
+ return "";
+ }
+
+ @Nonnull
+ public String getURLFromID(@Nonnull String vid, boolean autoplay) {
+ String format;
+ if (this == YOUTUBE)
+ format = autoplay ? "https://www.youtube.com/watch?v=%s&autoplay=1" : "https://www.youtube.com/watch?v=%s";
+ else if (this == YOUTUBE_EMBED)
+ format = autoplay ? "https://www.youtube.com/embed/%s?autoplay=1" : "https://www.youtube.com/embed/%s";
+ else
+ return "";
+
+ return String.format(format, vid);
+ }
+
+ // TODO: timestamp stuff
+ @Nonnull
+ public String getVolumeJSQuery(int volInt, int volFrac) {
+ return volume.apply(volInt + "." + volFrac);
+ }
+
+ public String getTimeStampQuery() {
+ return getTime.apply();
+ }
+
+ public String setTimeStampQuery(float ts) {
+ return setTime.apply(String.valueOf(ts));
+ }
}
diff --git a/src/main/java/net/montoyo/wd/utilities/data/BlockSide.java b/src/main/java/net/montoyo/wd/utilities/data/BlockSide.java
new file mode 100644
index 0000000..cc8088f
--- /dev/null
+++ b/src/main/java/net/montoyo/wd/utilities/data/BlockSide.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 BARBOTIN Nicolas
+ */
+
+package net.montoyo.wd.utilities.data;
+
+import net.montoyo.wd.utilities.math.Vector3i;
+
+public enum BlockSide {
+ BOTTOM(new Vector3i(0, 0, -1), new Vector3i(1, 0, 0), new Vector3i(0, -1, 0)),
+ TOP(new Vector3i(0, 0, -1), new Vector3i(1, 0, 0), new Vector3i(0, 1, 0)),
+ NORTH(new Vector3i(0, 1, 0), new Vector3i(-1, 0, 0), new Vector3i(0, 0, -1)),
+ SOUTH(new Vector3i(0, 1, 0), new Vector3i(1, 0, 0), new Vector3i(0, 0, 1)),
+ WEST(new Vector3i(0, 1, 0), new Vector3i(0, 0, 1), new Vector3i(-1, 0, 0)),
+ EAST(new Vector3i(0, 1, 0), new Vector3i(0, 0, -1), new Vector3i(1, 0, 0));
+
+ public final Vector3i up, down;
+ public final Vector3i left, right;
+ public final Vector3i forward, backward;
+
+ // mostly used for click coordinate calculations
+ public final Vector3i horizontal, vertical;
+
+ BlockSide(Vector3i u, Vector3i r, Vector3i f) {
+ up = u;
+ right = r;
+ forward = f;
+ down = u.clone().neg();
+ left = r.clone().neg();
+ backward = f.clone().neg();
+
+ horizontal = new Vector3i(Math.abs(r.x), Math.abs(r.y), Math.abs(r.z));
+ vertical = new Vector3i(Math.abs(u.x), Math.abs(u.y), Math.abs(u.z));
+ }
+
+ public BlockSide reverse() {
+ int side = ordinal();
+ int div = side / 2;
+ int rest = 1 - side % 2;
+
+ return values()[div * 2 + rest];
+ }
+
+ public static int reverse(int side) {
+ int div = side / 2;
+ int rest = 1 - side % 2;
+
+ return div * 2 + rest;
+ }
+
+ public static BlockSide fromInt(int s) {
+ BlockSide[] values = values();
+ return (s < 0 || s >= values.length) ? null : values[s];
+ }
+}
diff --git a/src/main/java/net/montoyo/wd/utilities/Bounds.java b/src/main/java/net/montoyo/wd/utilities/data/Bounds.java
similarity index 92%
rename from src/main/java/net/montoyo/wd/utilities/Bounds.java
rename to src/main/java/net/montoyo/wd/utilities/data/Bounds.java
index f7e3b2d..ef8a792 100644
--- a/src/main/java/net/montoyo/wd/utilities/Bounds.java
+++ b/src/main/java/net/montoyo/wd/utilities/data/Bounds.java
@@ -2,10 +2,9 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.data;
public final class Bounds {
-
public final int minX;
public final int minY;
public final int maxX;
@@ -25,5 +24,4 @@ public final class Bounds {
public final int getHeight() {
return maxY - minY;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/Rotation.java b/src/main/java/net/montoyo/wd/utilities/data/Rotation.java
similarity index 92%
rename from src/main/java/net/montoyo/wd/utilities/Rotation.java
rename to src/main/java/net/montoyo/wd/utilities/data/Rotation.java
index e098254..8f65730 100644
--- a/src/main/java/net/montoyo/wd/utilities/Rotation.java
+++ b/src/main/java/net/montoyo/wd/utilities/data/Rotation.java
@@ -2,10 +2,9 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.data;
public enum Rotation {
-
ROT_0(0.0f, false),
ROT_90(90.0f, true),
ROT_180(180.0f, false),
@@ -24,5 +23,4 @@ public enum Rotation {
public int getAngleAsInt() {
return (int) angle;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/math/MutableAABB.java b/src/main/java/net/montoyo/wd/utilities/math/MutableAABB.java
new file mode 100644
index 0000000..55328cd
--- /dev/null
+++ b/src/main/java/net/montoyo/wd/utilities/math/MutableAABB.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 BARBOTIN Nicolas
+ */
+
+package net.montoyo.wd.utilities.math;
+
+import net.minecraft.world.phys.AABB;
+
+public final class MutableAABB extends AABB {
+ public MutableAABB() {
+ super(0, 0, 0, 0, 0, 0);
+ }
+
+ public MutableAABB(Vector3i pos) {
+ super(pos.x, pos.y, pos.z, pos.x, pos.y, pos.z);
+ }
+
+ public MutableAABB(Vector3i a, Vector3i b) {
+ super(a.x, a.y, a.z, b.x, b.y, b.z);
+ }
+
+ public MutableAABB(net.minecraft.world.phys.AABB bb) {
+ super(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
+ }
+
+ public MutableAABB(double x1, double y1, double z1, double x2, double y2, double z2) {
+ super(x1, y1, z1, x2, y2, z2);
+ }
+
+ public MutableAABB expand(Vector3i vec) {
+ if (vec.x > maxX)
+ maxX = vec.x;
+ else if (vec.x < minX)
+ minX = vec.x;
+
+ if (vec.y > maxY)
+ maxY = vec.y;
+ else if (vec.y < minY)
+ minY = vec.y;
+
+ if (vec.z > maxZ)
+ maxZ = vec.z;
+ else if (vec.z < minZ)
+ minZ = vec.z;
+
+ return this;
+ }
+
+ @Override
+ public AABB move(double x, double y, double z) {
+ minX += x;
+ minY += y;
+ minZ += z;
+ maxX += x;
+ maxY += y;
+ maxZ += z;
+ return this;
+ }
+
+ public net.minecraft.world.phys.AABB toMc() {
+ return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
+ }
+
+ public void setAndCheck(double x1, double y1, double z1, double x2, double y2, double z2) {
+ minX = Math.min(x1, x2);
+ minY = Math.min(y1, y2);
+ minZ = Math.min(z1, z2);
+
+ maxX = Math.max(x1, x2);
+ maxY = Math.max(y1, y2);
+ maxZ = Math.max(z1, z2);
+ }
+
+ public void expand(double x1, double y1, double z1, double x2, double y2, double z2) {
+ minX = Math.min(minX, Math.min(x1, x2));
+ minY = Math.min(minY, Math.min(y1, y2));
+ minZ = Math.min(minZ, Math.min(z1, z2));
+
+ maxX = Math.max(maxX, Math.max(x1, x2));
+ maxY = Math.max(maxY, Math.max(y1, y2));
+ maxZ = Math.max(maxZ, Math.max(z1, z2));
+ }
+}
diff --git a/src/main/java/net/montoyo/wd/utilities/Vector2i.java b/src/main/java/net/montoyo/wd/utilities/math/Vector2i.java
similarity index 63%
rename from src/main/java/net/montoyo/wd/utilities/Vector2i.java
rename to src/main/java/net/montoyo/wd/utilities/math/Vector2i.java
index 1cf0a78..1614863 100644
--- a/src/main/java/net/montoyo/wd/utilities/Vector2i.java
+++ b/src/main/java/net/montoyo/wd/utilities/math/Vector2i.java
@@ -2,43 +2,36 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.math;
import io.netty.buffer.ByteBuf;
public final class Vector2i {
-
public int x;
public int y;
- public Vector2i()
- {
+ public Vector2i() {
x = 0;
y = 0;
}
- public Vector2i(int val)
- {
+ public Vector2i(int val) {
x = val;
y = val;
}
- public Vector2i(int x, int y)
- {
+ public Vector2i(int x, int y) {
this.x = x;
this.y = y;
}
- public Vector2i(ByteBuf bb)
- {
+ public Vector2i(ByteBuf bb) {
x = bb.readInt();
y = bb.readInt();
}
- public void writeTo(ByteBuf bb)
- {
+ public void writeTo(ByteBuf bb) {
bb.writeInt(x);
bb.writeInt(y);
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/Vector3f.java b/src/main/java/net/montoyo/wd/utilities/math/Vector3f.java
similarity index 97%
rename from src/main/java/net/montoyo/wd/utilities/Vector3f.java
rename to src/main/java/net/montoyo/wd/utilities/math/Vector3f.java
index a31ffd2..938a96f 100644
--- a/src/main/java/net/montoyo/wd/utilities/Vector3f.java
+++ b/src/main/java/net/montoyo/wd/utilities/math/Vector3f.java
@@ -2,10 +2,9 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.math;
public final class Vector3f {
-
public float x;
public float y;
public float z;
@@ -40,7 +39,7 @@ public final class Vector3f {
@Override
public boolean equals(Object o) {
- if(o instanceof Vector3f) {
+ if (o instanceof Vector3f) {
Vector3f src = (Vector3f) o;
return (src.x == x && src.y == y && src.z == z);
@@ -182,5 +181,4 @@ public final class Vector3f {
return this;
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/Vector3i.java b/src/main/java/net/montoyo/wd/utilities/math/Vector3i.java
similarity index 90%
rename from src/main/java/net/montoyo/wd/utilities/Vector3i.java
rename to src/main/java/net/montoyo/wd/utilities/math/Vector3i.java
index d9823b7..92037da 100644
--- a/src/main/java/net/montoyo/wd/utilities/Vector3i.java
+++ b/src/main/java/net/montoyo/wd/utilities/math/Vector3i.java
@@ -2,13 +2,12 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.math;
import io.netty.buffer.ByteBuf;
import net.minecraft.core.BlockPos;
public final class Vector3i {
-
public int x;
public int y;
public int z;
@@ -55,7 +54,7 @@ public final class Vector3i {
@Override
public boolean equals(Object o) {
- if(o instanceof Vector3i) {
+ if (o instanceof Vector3i) {
Vector3i src = (Vector3i) o;
return (src.x == x && src.y == y && src.z == z);
@@ -155,48 +154,42 @@ public final class Vector3i {
return this;
}
- public Vector3i set(int x, int y, int z)
- {
+ public Vector3i set(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
- public Vector3i set(double x, double y, double z)
- {
+ public Vector3i set(double x, double y, double z) {
this.x = (int) x;
this.y = (int) y;
this.z = (int) z;
return this;
}
- public Vector3i set(float x, float y, float z)
- {
+ public Vector3i set(float x, float y, float z) {
this.x = (int) x;
this.y = (int) y;
this.z = (int) z;
return this;
}
- public Vector3i set(int val)
- {
+ public Vector3i set(int val) {
x = val;
y = val;
z = val;
return this;
}
- public Vector3i set(Vector3i val)
- {
+ public Vector3i set(Vector3i val) {
x = val.x;
y = val.y;
z = val.z;
return this;
}
- public Vector3i set(Vector3f vec)
- {
+ public Vector3i set(Vector3f vec) {
this.x = (int) vec.x;
this.y = (int) vec.y;
this.z = (int) vec.z;
@@ -210,6 +203,7 @@ public final class Vector3i {
public Vector3f toFloat() {
return new Vector3f((float) x, (float) y, (float) z);
}
+
public BlockPos toBlock() {
return new BlockPos(x, y, z);
}
@@ -218,8 +212,7 @@ public final class Vector3i {
bp.set(x, y, z);
}
- public int getChunkLocalPos()
- {
+ public int getChunkLocalPos() {
int lx = x & 15;
int ly = y & 255;
int lz = z & 15;
@@ -232,5 +225,4 @@ public final class Vector3i {
bb.writeInt(y);
bb.writeInt(z);
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/DontSerialize.java b/src/main/java/net/montoyo/wd/utilities/serialization/DontSerialize.java
similarity index 86%
rename from src/main/java/net/montoyo/wd/utilities/DontSerialize.java
rename to src/main/java/net/montoyo/wd/utilities/serialization/DontSerialize.java
index 6191c80..ec66310 100644
--- a/src/main/java/net/montoyo/wd/utilities/DontSerialize.java
+++ b/src/main/java/net/montoyo/wd/utilities/serialization/DontSerialize.java
@@ -2,7 +2,7 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.serialization;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/src/main/java/net/montoyo/wd/utilities/NameUUIDPair.java b/src/main/java/net/montoyo/wd/utilities/serialization/NameUUIDPair.java
similarity index 91%
rename from src/main/java/net/montoyo/wd/utilities/NameUUIDPair.java
rename to src/main/java/net/montoyo/wd/utilities/serialization/NameUUIDPair.java
index 0533841..9686ab6 100644
--- a/src/main/java/net/montoyo/wd/utilities/NameUUIDPair.java
+++ b/src/main/java/net/montoyo/wd/utilities/serialization/NameUUIDPair.java
@@ -2,16 +2,14 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.serialization;
import com.mojang.authlib.GameProfile;
-import io.netty.buffer.ByteBuf;
import net.minecraft.network.FriendlyByteBuf;
import java.util.UUID;
public final class NameUUIDPair {
-
public final String name;
public final UUID uuid;
@@ -48,7 +46,7 @@ public final class NameUUIDPair {
@Override
public boolean equals(Object obj) {
- if(obj == null || !(obj instanceof NameUUIDPair))
+ if (obj == null || !(obj instanceof NameUUIDPair))
return false;
return ((NameUUIDPair) obj).uuid.equals(uuid);
@@ -68,5 +66,4 @@ public final class NameUUIDPair {
bb.writeLong(uuid.getMostSignificantBits());
bb.writeLong(uuid.getLeastSignificantBits());
}
-
}
diff --git a/src/main/java/net/montoyo/wd/utilities/TypeData.java b/src/main/java/net/montoyo/wd/utilities/serialization/TypeData.java
similarity index 95%
rename from src/main/java/net/montoyo/wd/utilities/TypeData.java
rename to src/main/java/net/montoyo/wd/utilities/serialization/TypeData.java
index cdf5f74..212439d 100644
--- a/src/main/java/net/montoyo/wd/utilities/TypeData.java
+++ b/src/main/java/net/montoyo/wd/utilities/serialization/TypeData.java
@@ -2,7 +2,7 @@
* Copyright (C) 2019 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.serialization;
import com.google.gson.annotations.SerializedName;
diff --git a/src/main/java/net/montoyo/wd/utilities/Util.java b/src/main/java/net/montoyo/wd/utilities/serialization/Util.java
similarity index 74%
rename from src/main/java/net/montoyo/wd/utilities/Util.java
rename to src/main/java/net/montoyo/wd/utilities/serialization/Util.java
index 32583a5..6db86e8 100644
--- a/src/main/java/net/montoyo/wd/utilities/Util.java
+++ b/src/main/java/net/montoyo/wd/utilities/serialization/Util.java
@@ -2,7 +2,7 @@
* Copyright (C) 2018 BARBOTIN Nicolas
*/
-package net.montoyo.wd.utilities;
+package net.montoyo.wd.utilities.serialization;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
@@ -19,41 +19,40 @@ import java.util.StringJoiner;
import java.util.UUID;
public abstract class Util {
-
@Deprecated(forRemoval = true)
public static void serialize(FriendlyByteBuf bb, Object f) {
Class> cls = f.getClass();
- if(cls == Integer.class || cls == Integer.TYPE)
+ if (cls == Integer.class || cls == Integer.TYPE)
bb.writeInt((Integer) f);
- else if(cls == Float.class || cls == Float.TYPE)
+ else if (cls == Float.class || cls == Float.TYPE)
bb.writeFloat((Float) f);
- else if(cls == Double.class || cls == Double.TYPE)
+ else if (cls == Double.class || cls == Double.TYPE)
bb.writeDouble((Double) f);
- else if(cls == Boolean.class || cls == Boolean.TYPE)
+ else if (cls == Boolean.class || cls == Boolean.TYPE)
bb.writeBoolean((Boolean) f);
- else if(cls == String.class)
+ else if (cls == String.class)
bb.writeUtf((String) f);
- else if(cls == NameUUIDPair.class)
+ else if (cls == NameUUIDPair.class)
((NameUUIDPair) f).writeTo(bb);
- else if(cls.isEnum())
+ else if (cls.isEnum())
bb.writeByte(((Enum>) f).ordinal());
- else if(cls.isArray()) {
+ else if (cls.isArray()) {
Object[] ray = (Object[]) f;
bb.writeInt(ray.length);
- for(Object o : ray)
+ for (Object o : ray)
serialize(bb, o);
} else if (cls == ResourceLocation.class) {
bb.writeUtf(f.toString());
- } else if(!cls.isPrimitive()) {
+ } else if (!cls.isPrimitive()) {
Field[] fields = cls.getFields();
- for(Field ff : fields) {
+ for (Field ff : fields) {
try {
- if(ff.getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(ff.getModifiers()))
+ if (ff.getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(ff.getModifiers()))
serialize(bb, ff.get(f));
- } catch(IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Caught IllegalAccessException for %s.%s", cls.getName(), ff.getName()));
}
@@ -61,51 +60,51 @@ public abstract class Util {
} else
throw new RuntimeException(String.format("Cannot transmit class %s over network!", cls.getName()));
}
-
+
@Deprecated(forRemoval = true)
public static Object unserialize(FriendlyByteBuf bb, Class cls) {
- if(cls == Integer.class || cls == Integer.TYPE)
+ if (cls == Integer.class || cls == Integer.TYPE)
return bb.readInt();
- else if(cls == Float.class || cls == Float.TYPE)
+ else if (cls == Float.class || cls == Float.TYPE)
return bb.readFloat();
- else if(cls == Double.class || cls == Double.TYPE)
+ else if (cls == Double.class || cls == Double.TYPE)
return bb.readDouble();
- else if(cls == Boolean.class || cls == Boolean.TYPE)
+ else if (cls == Boolean.class || cls == Boolean.TYPE)
return bb.readBoolean();
- else if(cls == String.class)
+ else if (cls == String.class)
return bb.readUtf();
- else if(cls == NameUUIDPair.class)
+ else if (cls == NameUUIDPair.class)
return new NameUUIDPair(bb);
- else if(cls.isEnum())
+ else if (cls.isEnum())
return cls.getEnumConstants()[bb.readByte()];
- else if(cls.isArray()) {
+ else if (cls.isArray()) {
Object[] ray = new Object[bb.readInt()];
- for(int i = 0; i < ray.length; i++)
+ for (int i = 0; i < ray.length; i++)
ray[i] = unserialize(bb, cls.getComponentType());
return Arrays.copyOf(ray, ray.length, cls);
- } else if(cls == ResourceLocation.class) {
+ } else if (cls == ResourceLocation.class) {
return new ResourceLocation(bb.readUtf());
- } else if(!cls.isPrimitive()) {
+ } else if (!cls.isPrimitive()) {
Object ret;
Field[] fields = cls.getFields();
try {
ret = cls.newInstance();
- } catch(InstantiationException e) {
+ } catch (InstantiationException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Caught InstantiationException for class %s", cls.getName()));
- } catch(IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Caught IllegalAccessException for class %s", cls.getName()));
}
- for(Field ff : fields) {
+ for (Field ff : fields) {
try {
- if(ff.getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(ff.getModifiers()))
+ if (ff.getAnnotation(DontSerialize.class) == null && !Modifier.isStatic(ff.getModifiers()))
ff.set(ret, unserialize(bb, ff.getType()));
- } catch(IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
throw new RuntimeException(String.format("Caught IllegalAccessException for %s.%s", cls.getName(), ff.getName()));
}
}
@@ -117,12 +116,12 @@ public abstract class Util {
public static String addSlashes(String str) {
String out = "";
- for(int i = 0; i < str.length(); i++) {
+ for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
- if(c == '\\')
+ if (c == '\\')
out += "\\\\";
- else if(c == '\"')
+ else if (c == '\"')
out += "\\\"";
else
out += c;
@@ -150,7 +149,8 @@ public abstract class Util {
public static void silentClose(Object obj) {
try {
obj.getClass().getMethod("close").invoke(obj);
- } catch(Throwable t) {}
+ } catch (Throwable t) {
+ }
}
public static String addProtocol(String str) {
@@ -161,13 +161,13 @@ public abstract class Util {
return fname.isEmpty() || fname.length() > 64 || fname.charAt(0) == '.' || fname.indexOf('/') >= 0 || fname.indexOf('\\') >= 0;
}
- public static final String[] SIZES = { "bytes", "KiB", "MiB", "GiB", "TiB" };
+ public static final String[] SIZES = {"bytes", "KiB", "MiB", "GiB", "TiB"};
public static String sizeString(long l) {
double d = (double) l;
int size = 0;
- while(l >= 1024L && size + 1 < SIZES.length) {
+ while (l >= 1024L && size + 1 < SIZES.length) {
d /= 1024.0;
l /= 1024L;
size++;
@@ -183,7 +183,7 @@ public abstract class Util {
}
public static CompoundTag writeOwnerToNBT(CompoundTag tag, NameUUIDPair owner) {
- if(owner != null) {
+ if (owner != null) {
tag.putLong("OwnerMSB", owner.uuid.getMostSignificantBits());
tag.putLong("OwnerLSB", owner.uuid.getLeastSignificantBits());
tag.putString("OwnerName", owner.name);
@@ -199,5 +199,4 @@ public abstract class Util {
return new NameUUIDPair(str, new UUID(msb, lsb));
}
-
}
diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml
index 29a061b..fac3519 100644
--- a/src/main/resources/META-INF/mods.toml
+++ b/src/main/resources/META-INF/mods.toml
@@ -2,7 +2,7 @@ modLoader="javafml" #mandatory
loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
-license="Public Domain"
+license="MIT"
issueTrackerURL="" #optional
@@ -10,17 +10,17 @@ issueTrackerURL="" #optional
modId="webdisplays" #mandatory
-version="1.3.3" #mandatory
+version="2.0.1-1.20.1" #mandatory
displayName="WebDisplays" #mandatory
-displayURL="https://github.com/Mysticpasta1/webdisplays" #optional
+displayURL="https://github.com/CinemaMod/webdisplays" #optional
logoFile= "" #optional
credits="" #optional
-authors="Mysticpasta1, WaterPicker, Montoyo, GiantLuigi4" #optional
+authors="GiantLuigi4, ds58, Mysticpasta1, montoyo, WaterPicker" #optional
description='''
'''
@@ -42,6 +42,6 @@ side="BOTH"
[[dependencies.webdisplays]]
modId="mcef"
mandatory=true
-versionRange="[1.20.1-2.4.17, )"
+versionRange="[2.0.0+1.20.1, )"
ordering="NONE"
side="BOTH"