This commit is contained in:
GiantLuigi4 2023-11-10 23:50:06 -05:00
parent aa8c545089
commit a9d9dcfecf
68 changed files with 828 additions and 999 deletions

View File

@ -42,10 +42,10 @@ 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;
@ -130,10 +130,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();
@ -253,7 +253,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) {
@ -271,7 +271,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());

View File

@ -33,7 +33,6 @@ import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
import org.jetbrains.annotations.NotNull;
public class BlockKeyboardLeft extends BlockPeripheral {
public static final EnumProperty<DefaultPeripheral> TYPE = EnumProperty.create("type", DefaultPeripheral.class);
public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST);
// public static final DirectionProperty HALF = DirectionProperty.create("facing", Direction.EAST, Direction.WEST);

View File

@ -36,7 +36,6 @@ import static net.montoyo.wd.block.BlockPeripheral.point;
// TODO: merge into KeyboardLeft
public class BlockKeyboardRight extends Block implements IPeripheral {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public BlockKeyboardRight() {

View File

@ -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,13 +33,11 @@ import net.montoyo.wd.core.IUpgrade;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.SetURLData;
import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.init.BlockInit;
import net.montoyo.wd.item.ItemLaserPointer;
import net.montoyo.wd.utilities.*;
import org.jetbrains.annotations.NotNull;
public class BlockScreen 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};
@ -51,42 +47,6 @@ public class BlockScreen extends BaseEntityBlock {
this.registerDefaultState(this.defaultBlockState().setValue(hasTE, false).setValue(emitting, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> 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);
}
public int getMetaFromState(BlockState state) {
int ret = 0;
if (state.getValue(hasTE))
ret |= 1;
if (state.getValue(emitting))
ret |= 2;
return ret;
}
@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?
@ -235,23 +195,15 @@ public class BlockScreen extends BaseEntityBlock {
}
public static boolean hit2pixels(BlockSide side, BlockPos bpos, Vector3i pos, TileEntityScreen.Screen scr, float hitX, float hitY, float hitZ, Vector2i dst) {
if(side.right.x < 0)
hitX -= 1.f;
Vector3f rel = new Vector3f(hitX, hitY, hitZ);
if(side.right.z < 0 || side == BlockSide.TOP || side == BlockSide.BOTTOM)
hitZ -= 1.f;
// how these dot products come in is beyond me
float cx = rel.dot(side.horizontal.toFloat()) - 2.f / 16.f;
float cy = rel.dot(side.vertical.toFloat()) - 2.f / 16.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);
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;
// scale coordinate to be in the size mcef expects (0 -> 1)
cx /= ((float) scr.size.x) - 4.f / 16.f;
cy /= ((float) scr.size.y) - 4.f / 16.f;
if (cx >= 0.f && cx <= 1.0 && cy >= 0.f && cy <= 1.f) {
if (side != BlockSide.BOTTOM)
@ -270,9 +222,6 @@ public class BlockScreen extends BaseEntityBlock {
case ROT_270:
cx = 1.0f - cx;
break;
default:
break;
}
cx *= (float) scr.resolution.x;
@ -292,17 +241,6 @@ public class BlockScreen extends BaseEntityBlock {
return false;
}
@org.jetbrains.annotations.Nullable
@Override
public BlockEntity newBlockEntity (BlockPos pos, BlockState state){
int meta = getMetaFromState(state);
if ((meta & 1) == 0)
return null;
return ((meta & 1) == 0) ? null : new TileEntityScreen(pos, state);
}
/************************************************* DESTRUCTION HANDLING *************************************************/
private void onDestroy(Level world, BlockPos pos, Player ply) {
@ -358,6 +296,8 @@ public class BlockScreen extends BaseEntityBlock {
}
}
/************************************************* STUFF THAT'S UNLIKELY TO BE TOUCHED BUT NEEDS TO BE HERE *************************************************/
@Override
public @NotNull PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.IGNORE;
@ -372,4 +312,19 @@ public class BlockScreen extends BaseEntityBlock {
public boolean isSignalSource(BlockState state) {
return state.getValue(emitting);
}
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return state.getValue(hasTE) ? new TileEntityScreen(pos, state) : null;
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(properties);
}
}

View File

@ -8,7 +8,7 @@ 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.registry.BlockRegistry;
public class KeyboardItem extends BlockItem {
public KeyboardItem(Block arg, Properties arg2) {
@ -23,7 +23,7 @@ public class KeyboardItem extends BlockItem {
Direction d = BlockKeyboardLeft.mapDirection(facing);
if (isValid(arg.getClickedPos(), arg.getLevel(), arg2, d)) {
Block kbRight = BlockInit.blockKbRight.get();
Block kbRight = BlockRegistry.blockKbRight.get();
BlockState rightState = kbRight.defaultBlockState();
rightState = rightState.setValue(BlockKeyboardLeft.FACING, facing);
@ -34,7 +34,7 @@ public class KeyboardItem extends BlockItem {
)) 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();
Block kbRight = BlockRegistry.blockKbRight.get();
BlockState rightState = kbRight.defaultBlockState();
rightState = rightState.setValue(BlockKeyboardLeft.FACING, facing);

View File

@ -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;
@ -66,14 +62,12 @@ import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.client.gui.*;
import net.montoyo.wd.client.gui.loading.GuiLoader;
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.TileEntityScreen;
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.item.ItemLaserPointer;
import net.montoyo.wd.item.ItemMinePad2;
import net.montoyo.wd.item.WDItem;
@ -86,7 +80,6 @@ import org.cef.browser.CefBrowser;
import org.cef.browser.CefFrame;
import org.cef.handler.CefDisplayHandler;
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;
@ -150,7 +143,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(
@ -242,7 +235,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
@ -780,10 +773,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;
@ -823,8 +816,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"))

View File

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

View File

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

View File

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

View File

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

View File

@ -20,9 +20,7 @@ import java.util.Arrays;
import java.util.HashMap;
public class Criterion implements CriterionTrigger<Criterion.Instance> {
public static class Instance extends AbstractCriterionTriggerInstance {
public Instance(ResourceLocation id, ContextAwarePredicate arg2) {
super(id, arg2);
}
@ -72,5 +70,4 @@ public class Criterion implements CriterionTrigger<Criterion.Instance> {
Arrays.stream(copy).forEach(l -> l.run(ply));
}
}
}

View File

@ -12,19 +12,18 @@ 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.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", TileEntityKeyboard::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", TileEntityRCtrl::new , BlockRegistry.REMOTE_CONTROLLER_BLOCK), //WITHOUT FACING (>= 3)
REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl::new , BlockRegistry.REDSTONE_CONTROL_BLOCK),
SERVER("server", "Server", TileEntityServer::new, BlockRegistry.SERVER_BLOCK);
private final String name;
private final String wikiName;

View File

@ -5,9 +5,7 @@
package net.montoyo.wd.core;
public enum HasAdvancement {
DONT_KNOW,
YES,
NO
}

View File

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

View File

@ -11,7 +11,5 @@ import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Vector3i;
public interface IPeripheral {
boolean connect(Level world, BlockPos blockPos, BlockState blockState, Vector3i screenPos, BlockSide screenSide);
}

View File

@ -11,9 +11,7 @@
//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);
//
//}

View File

@ -13,10 +13,8 @@ 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
boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack); //myStack.getItem() is an instance of this class
String getJSName(@Nonnull ItemStack is); //modname:upgradename
}

View File

@ -5,9 +5,7 @@
package net.montoyo.wd.core;
public interface IWDDCapability {
boolean isFirstRun();
void clearFirstRun();
void cloneTo(IWDDCapability dst);
}

View File

@ -8,7 +8,6 @@ import net.minecraft.network.FriendlyByteBuf;
import net.montoyo.wd.utilities.Util;
public enum JSServerRequest {
CLEAR_REDSTONE,
SET_REDSTONE_AT(Integer.class, Integer.class, Boolean.class);
@ -50,5 +49,4 @@ public enum JSServerRequest {
return ret;
}
}

View File

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

View File

@ -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();
}
} */

View File

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

View File

@ -18,14 +18,11 @@ import javax.annotation.Nonnull;
import java.util.concurrent.Callable;
public class WDDCapability implements IWDDCapability {
public static class Factory implements Callable<IWDDCapability> {
@Override
public IWDDCapability call() {
return new WDDCapability();
}
}
public static class Provider implements ICapabilitySerializable<CompoundTag> {
@ -81,5 +78,4 @@ public class WDDCapability implements IWDDCapability {
if (!isFirstRun())
dst.clearFirstRun();
}
}

View File

@ -66,5 +66,6 @@ public abstract class GuiData {
}
public abstract void serialize(FriendlyByteBuf buf);
public abstract void deserialize(FriendlyByteBuf buf);
}

View File

@ -18,7 +18,6 @@ import net.montoyo.wd.utilities.Log;
import net.montoyo.wd.utilities.Vector3i;
public class KeyboardData extends GuiData {
public Vector3i pos;
public BlockSide side;
public int kbX;

View File

@ -16,7 +16,6 @@ import net.montoyo.wd.net.BufferUtils;
import net.montoyo.wd.utilities.Vector3i;
public class RedstoneCtrlData extends GuiData {
public ResourceLocation dimension;
public Vector3i pos;
public String risingEdgeURL;

View File

@ -23,7 +23,6 @@ import net.montoyo.wd.utilities.NameUUIDPair;
import net.montoyo.wd.utilities.Vector3i;
public class ScreenConfigData extends GuiData {
public boolean onlyUpdate;
public Vector3i pos;
public BlockSide side;

View File

@ -16,7 +16,6 @@ import net.montoyo.wd.utilities.NameUUIDPair;
import net.montoyo.wd.utilities.Vector3i;
public class ServerData extends GuiData {
public Vector3i pos;
public NameUUIDPair owner;

View File

@ -19,7 +19,6 @@ import net.montoyo.wd.utilities.Log;
import net.montoyo.wd.utilities.Vector3i;
public class SetURLData extends GuiData {
public Vector3i pos;
public BlockSide side;
public String url;

View File

@ -20,7 +20,6 @@ import java.util.ArrayList;
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "computercraft")
public class TileEntityCCInterface extends TileEntityInterfaceBase implements IPeripheral {
private static final String[] METHOD_NAMES;
private static final Method[] METHODS;
@ -79,5 +78,4 @@ public class TileEntityCCInterface extends TileEntityInterfaceBase implements IP
public boolean equals(@Nullable IPeripheral periph) {
return periph == this;
}
}*/

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Map;
public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
public TileEntityInterfaceBase(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
super(arg, arg2, arg3);
}
@ -406,5 +405,4 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
return null;
}
}

View File

@ -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.registry.TileRegistry;
import net.montoyo.wd.utilities.Util;
public class TileEntityKeyboard extends TileEntityPeripheralBase {
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);
super(TileRegistry.KEYBOARD.get(), arg2, arg3);
}
@Override
@ -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());
}
}
}
}

View File

@ -25,7 +25,6 @@ import javax.annotation.Nullable;
import java.util.Objects;
public abstract class TileEntityPeripheralBase extends BlockEntity implements IPeripheral {
protected Vector3i screenPos;
protected BlockSide screenSide;
@ -79,7 +78,7 @@ 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 TileEntityScreen)) {
Log.error("TileEntityPeripheralBase.connect(): Tile entity at %s is not a screen!", pos.toString());
return false;
}
@ -113,7 +112,7 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP
return null;
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
if(te == null || !(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null) {
if (!(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null) {
screenPos = null;
screenSide = null;
setChanged();
@ -129,7 +128,7 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP
return null;
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
if(te == null || !(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null)
if (!(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null)
return null;
return (TileEntityScreen) te;

View File

@ -12,12 +12,12 @@ 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.registry.TileRegistry;
import net.montoyo.wd.utilities.Util;
public class TileEntityRCtrl extends TileEntityPeripheralBase {
public TileEntityRCtrl(BlockPos arg2, BlockState arg3) {
super(TileInit.REMOTE_CONTROLLER.get(), arg2, arg3);
super(TileRegistry.REMOTE_CONTROLLER.get(), arg2, arg3);
}
@Override
@ -45,5 +45,4 @@ public class TileEntityRCtrl extends TileEntityPeripheralBase {
(new SetURLData(screenPos, screenSide, scr.url, getBlockPos())).sendTo((ServerPlayer) player);
return InteractionResult.SUCCESS;
}
}

View File

@ -14,19 +14,18 @@ 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.registry.TileRegistry;
import net.montoyo.wd.utilities.Util;
import java.io.IOException;
public class TileEntityRedCtrl extends TileEntityPeripheralBase {
private String risingEdgeURL = "";
private String fallingEdgeURL = "";
private boolean state = false;
public TileEntityRedCtrl(BlockPos arg2, BlockState arg3) {
super(TileInit.REDSTONE_CONTROLLER.get(), arg2, arg3);
super(TileRegistry.REDSTONE_CONTROLLER.get(), arg2, arg3);
}
@Override

View File

@ -31,27 +31,22 @@ 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 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;
@ -59,9 +54,8 @@ import java.util.function.Consumer;
import static net.montoyo.wd.block.BlockPeripheral.point;
public class TileEntityScreen extends BlockEntity {
public TileEntityScreen(BlockPos arg2, BlockState arg3) {
super(TileInit.SCREEN_BLOCK_ENTITY.get(), arg2, arg3);
super(TileRegistry.SCREEN_BLOCK_ENTITY.get(), arg2, arg3);
}
public static class Screen {
@ -277,6 +271,7 @@ public class TileEntityScreen extends BlockEntity {
scr.browser = null;
}
}
screens.clear();
loaded = false;
}
@ -289,6 +284,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(Screen.deserialize(list.getCompound(i)));
@ -403,17 +406,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)) {
@ -450,6 +454,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++) {
@ -476,7 +481,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(BlockScreen.hasTE, false));
else
setChanged();
}
@ -512,7 +517,7 @@ public class TileEntityScreen extends BlockEntity {
private static Player getLaserUser(Screen 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;
}
@ -544,13 +549,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
@ -791,6 +789,7 @@ public class TileEntityScreen extends BlockEntity {
public void updateClientSideURL(CefBrowser target, String url) {
for (Screen scr : screens) {
if (scr.browser == target) {
// TODO: what? lol
String webUrl;
try {
webUrl = TileEntityScreen.url(url);
@ -1255,5 +1254,4 @@ public class TileEntityScreen extends BlockEntity {
//
// return oldState.getValue(BlockScreen.hasTE) != newState.getValue(BlockScreen.hasTE);
// }
}

View File

@ -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.registry.TileRegistry;
import net.montoyo.wd.utilities.NameUUIDPair;
import net.montoyo.wd.utilities.Util;
public class TileEntityServer extends BlockEntity {
private NameUUIDPair owner;
public TileEntityServer(BlockPos arg2, BlockState arg3) {
super(TileInit.SERVER.get(), arg2, arg3);
super(TileRegistry.SERVER.get(), arg2, arg3);
}
@Override
@ -50,5 +49,4 @@ public class TileEntityServer extends BlockEntity {
else if (owner != null && ply instanceof ServerPlayer)
(new ServerData(getBlockPos(), owner)).sendTo((ServerPlayer) ply);
}
}

View File

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

View File

@ -11,14 +11,13 @@ 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.client.ClientProxy;
import net.montoyo.wd.config.ClientConfig;
import net.montoyo.wd.controls.builtin.ClickControl;
import net.montoyo.wd.core.DefaultUpgrade;
import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.init.BlockInit;
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;
@ -53,7 +52,7 @@ 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()];

View File

@ -27,7 +27,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ItemLinker extends Item implements WDItem {
public ItemLinker(Properties properties) {
super(properties
.stacksTo(1)
@ -120,5 +119,4 @@ public class ItemLinker extends Item implements WDItem {
public String getWikiName(@Nonnull ItemStack is) {
return is.getItem().getName(is).getString();
}
}

View File

@ -28,7 +28,6 @@ import javax.annotation.Nullable;
import java.util.UUID;
public class ItemMinePad2 extends Item implements WDItem {
public ItemMinePad2(Properties properties) {
super(properties
.stacksTo(1)
@ -113,5 +112,4 @@ public class ItemMinePad2 extends Item implements WDItem {
public String getWikiName(@Nonnull ItemStack is) {
return is.getItem().getName(is).getString();
}
}

View File

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

View File

@ -23,7 +23,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ItemOwnershipThief extends Item implements WDItem {
public ItemOwnershipThief(Properties properties) {
super(properties
.stacksTo(1)
@ -107,5 +106,4 @@ public class ItemOwnershipThief extends Item implements WDItem {
public String getWikiName(@Nonnull ItemStack is) {
return "Ownership_Thief";
}
}

View File

@ -21,7 +21,6 @@ import net.montoyo.wd.utilities.Vector3i;
import org.jetbrains.annotations.NotNull;
public class ItemScreenConfigurator extends Item implements WDItem {
public ItemScreenConfigurator(Properties properties) {
super(properties
.stacksTo(1)

View File

@ -14,10 +14,9 @@ import javax.annotation.Nullable;
import java.util.List;
public interface WDItem {
static void addInformation(@Nullable List<String> tt) {
if (tt != null && WebDisplays.PROXY.isShiftDown())
tt.add("" + ChatFormatting.GRAY + I18n.get("item.webdisplays.wiki"));
tt.add(ChatFormatting.GRAY + I18n.get("item.webdisplays.wiki"));
}
String getWikiName(@Nonnull ItemStack is);

View File

@ -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,7 +15,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MouseHandler.class)
public class MouseHandlerMixin {
@Shadow @Final private Minecraft minecraft;
@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) {
@ -24,7 +26,7 @@ public class MouseHandlerMixin {
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.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_);

View File

@ -1,4 +1,4 @@
package net.montoyo.wd.init;
package net.montoyo.wd.registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
@ -13,20 +13,19 @@ import net.montoyo.wd.block.BlockPeripheral;
import net.montoyo.wd.block.BlockScreen;
import net.montoyo.wd.core.DefaultPeripheral;
public class BlockInit {
public class BlockRegistry {
public static void init(IEventBus bus) {
BLOCKS.register(bus);
}
public static DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "webdisplays");
public static final RegistryObject<BlockScreen> blockScreen = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.copy(Blocks.STONE)));
public static final RegistryObject<BlockScreen> SCREEN_BLOCk = BLOCKS.register("screen", () -> new BlockScreen(BlockBehaviour.Properties.copy(Blocks.STONE)));
public static final RegistryObject<BlockKeyboardLeft> blockKeyBoard = BlockInit.BLOCKS.register("kb_left", BlockKeyboardLeft::new);
public static final RegistryObject<BlockKeyboardLeft> KEYBOARD_BLOCK = BlockRegistry.BLOCKS.register("kb_left", BlockKeyboardLeft::new);
public static final RegistryObject<BlockKeyboardRight> blockKbRight = BLOCKS.register("kb_right", BlockKeyboardRight::new);
public static final RegistryObject<BlockPeripheral> blockRedControl = BlockInit.BLOCKS.register("redctrl", () -> new BlockPeripheral(DefaultPeripheral.REDSTONE_CONTROLLER));
public static final RegistryObject<BlockPeripheral> blockRControl = BlockInit.BLOCKS.register("rctrl", () -> new BlockPeripheral(DefaultPeripheral.REMOTE_CONTROLLER));
public static final RegistryObject<BlockPeripheral> blockServer = BlockInit.BLOCKS.register("server", () -> new BlockPeripheral(DefaultPeripheral.SERVER));
public static final RegistryObject<BlockPeripheral> REDSTONE_CONTROL_BLOCK = BlockRegistry.BLOCKS.register("redctrl", () -> new BlockPeripheral(DefaultPeripheral.REDSTONE_CONTROLLER));
public static final RegistryObject<BlockPeripheral> REMOTE_CONTROLLER_BLOCK = BlockRegistry.BLOCKS.register("rctrl", () -> new BlockPeripheral(DefaultPeripheral.REMOTE_CONTROLLER));
public static final RegistryObject<BlockPeripheral> SERVER_BLOCK = BlockRegistry.BLOCKS.register("server", () -> new BlockPeripheral(DefaultPeripheral.SERVER));
}

View File

@ -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,7 +14,7 @@ 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);
}
@ -45,12 +44,12 @@ public class ItemInit{
}
}
public static final RegistryObject<Item> SCREEN = ITEMS.register("screen", () -> new BlockItem(BlockInit.blockScreen.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> SCREEN = ITEMS.register("screen", () -> new BlockItem(BlockRegistry.SCREEN_BLOCk.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> KEYBOARD = ITEMS.register("keyboard", () -> new KeyboardItem(BlockInit.blockKeyBoard.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> REDSTONE_CONTROLLER = ITEMS.register("redctrl", () -> new BlockItem(BlockInit.blockRedControl.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> REMOTE_CONTROLLER = ITEMS.register("rctrl", () -> new BlockItem(BlockInit.blockRControl.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> SERVER = ITEMS.register("server", () -> new BlockItem(BlockInit.blockServer.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> KEYBOARD = ITEMS.register("keyboard", () -> new KeyboardItem(BlockRegistry.KEYBOARD_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> REDSTONE_CONTROLLER = ITEMS.register("redctrl", () -> new BlockItem(BlockRegistry.REDSTONE_CONTROL_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> REMOTE_CONTROLLER = ITEMS.register("rctrl", () -> new BlockItem(BlockRegistry.REMOTE_CONTROLLER_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static final RegistryObject<Item> SERVER = ITEMS.register("server", () -> new BlockItem(BlockRegistry.SERVER_BLOCK.get(), new Item.Properties()/*.tab(WebDisplays.CREATIVE_TAB)*/));
public static RegistryObject<Item> getComputerCraftItem(int index) {
return COMP_CRAFT_ITEMS[index];

View File

@ -1,37 +1,32 @@
package net.montoyo.wd.init;
package net.montoyo.wd.registry;
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 class TileRegistry {
public static final DeferredRegister<BlockEntityType<?>> TILE_TYPES = DeferredRegister
.create(ForgeRegistries.BLOCK_ENTITY_TYPES, "webdisplays");
//Register tile entities
public static final RegistryObject<BlockEntityType<TileEntityScreen>> SCREEN_BLOCK_ENTITY = TILE_TYPES
.register("screen", () -> BlockEntityType.Builder
.of(TileEntityScreen::new, BlockInit.blockScreen.get()).build(null));
.of(TileEntityScreen::new, BlockRegistry.SCREEN_BLOCk.get()).build(null));
public static final RegistryObject<BlockEntityType<?>> KEYBOARD = TILE_TYPES.register("kb_left", () -> BlockEntityType.Builder
.of(TileEntityKeyboard::new, BlockInit.blockKeyBoard.get()).build(null));
.of(TileEntityKeyboard::new, BlockRegistry.KEYBOARD_BLOCK.get()).build(null));
public static final RegistryObject<BlockEntityType<?>> REMOTE_CONTROLLER = TILE_TYPES.register("rctrl",
() -> BlockEntityType.Builder.of(TileEntityRCtrl::new, BlockInit.blockRControl.get()).build(null)); //WITHOUT FACING (>= 3)
() -> BlockEntityType.Builder.of(TileEntityRCtrl::new, BlockRegistry.REMOTE_CONTROLLER_BLOCK.get()).build(null)); //WITHOUT FACING (>= 3)
public static final RegistryObject<BlockEntityType<?>> REDSTONE_CONTROLLER = TILE_TYPES.register("redctrl",
() -> BlockEntityType.Builder.of(TileEntityRedCtrl::new, BlockInit.blockRedControl.get()).build(null));
() -> BlockEntityType.Builder.of(TileEntityRedCtrl::new, BlockRegistry.REDSTONE_CONTROL_BLOCK.get()).build(null));
public static final RegistryObject<BlockEntityType<?>> SERVER = TILE_TYPES.register("server",
() -> BlockEntityType.Builder.of(TileEntityServer::new, BlockInit.blockServer.get()).build(null));
() -> BlockEntityType.Builder.of(TileEntityServer::new, BlockRegistry.SERVER_BLOCK.get()).build(null));
public static void init(IEventBus bus) {
TILE_TYPES.register(bus);

View File

@ -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<CreativeModeTab> TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, "webdisplays");
public static final RegistryObject<CreativeModeTab> 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()
);

View File

@ -5,7 +5,6 @@
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)),
@ -13,12 +12,12 @@ public enum BlockSide {
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;
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;
@ -27,10 +26,12 @@ public enum BlockSide {
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()
{
public BlockSide reverse() {
int side = ordinal();
int div = side / 2;
int rest = 1 - side % 2;
@ -49,5 +50,4 @@ public enum BlockSide {
BlockSide[] values = values();
return (s < 0 || s >= values.length) ? null : values[s];
}
}

View File

@ -5,7 +5,6 @@
package net.montoyo.wd.utilities;
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;
}
}

View File

@ -8,7 +8,6 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
public abstract class Log {
public static void info(String what, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.INFO, String.format(what, data));
}
@ -32,5 +31,4 @@ public abstract class Log {
public static void errorEx(String what, Throwable e, Object... data) {
LogManager.getLogger("WebDisplays").log(Level.ERROR, String.format(what, data), e);
}
}

View File

@ -6,8 +6,7 @@ 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;
public abstract class Multiblock {
@ -51,7 +50,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,7 +58,7 @@ 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);
}
@ -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,7 +86,7 @@ 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;
}
@ -103,17 +102,17 @@ public abstract class Multiblock {
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);
@ -130,7 +129,7 @@ public abstract class Multiblock {
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);
@ -142,7 +141,7 @@ public abstract class Multiblock {
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);
@ -154,7 +153,7 @@ public abstract class Multiblock {
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);
@ -166,7 +165,7 @@ public abstract class Multiblock {
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);

View File

@ -11,7 +11,6 @@ import net.minecraft.network.FriendlyByteBuf;
import java.util.UUID;
public final class NameUUIDPair {
public final String name;
public final UUID uuid;
@ -68,5 +67,4 @@ public final class NameUUIDPair {
bb.writeLong(uuid.getMostSignificantBits());
bb.writeLong(uuid.getLeastSignificantBits());
}
}

View File

@ -5,7 +5,6 @@
package net.montoyo.wd.utilities;
public final class NibbleArray {
private final byte[] data;
public NibbleArray(int count) {
@ -43,5 +42,4 @@ public final class NibbleArray {
System.arraycopy(data, 0, ret, 0, data.length);
return ret;
}
}

View File

@ -5,7 +5,6 @@
package net.montoyo.wd.utilities;
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;
}
}

View File

@ -9,7 +9,6 @@ import net.minecraft.core.BlockPos;
import java.util.Iterator;
public final class ScreenIterator implements Iterator<BlockPos> {
private final Vector3i vec1;
private final Vector3i vec2;
private final BlockSide side;
@ -60,5 +59,4 @@ public final class ScreenIterator implements Iterator<BlockPos> {
public int getIndex() {
return y * size.x + x;
}
}

View File

@ -19,7 +19,6 @@ 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();
@ -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) {
@ -199,5 +199,4 @@ public abstract class Util {
return new NameUUIDPair(str, new UUID(msb, lsb));
}
}

View File

@ -7,38 +7,31 @@ package net.montoyo.wd.utilities;
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);
}
}

View File

@ -5,7 +5,6 @@
package net.montoyo.wd.utilities;
public final class Vector3f {
public float x;
public float y;
public float z;
@ -182,5 +181,4 @@ public final class Vector3f {
return this;
}
}

View File

@ -8,7 +8,6 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.core.BlockPos;
public final class Vector3i {
public int x;
public int y;
public int 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);
}
}

View File

@ -10,7 +10,6 @@ import java.net.MalformedURLException;
import java.net.URL;
public enum VideoType {
YOUTUBE(
"document.getElementById(\"movie_player\").",
new Function("setVolume(", ")"),
@ -135,5 +134,4 @@ public enum VideoType {
public String setTimeStampQuery(float ts) {
return setTime.apply(String.valueOf(ts));
}
}