Fixed Some Stuff
This commit is contained in:
parent
87102aee13
commit
f3f67e76e5
|
|
@ -18,12 +18,18 @@ repositories {
|
||||||
// for more information about repositories.
|
// for more information about repositories.
|
||||||
maven { url "https://maven.shedaniel.me/" }
|
maven { url "https://maven.shedaniel.me/" }
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
|
maven {
|
||||||
|
url = "https://maven.parchmentmc.org"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// To change the versions see the gradle.properties file
|
// To change the versions see the gradle.properties file
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings loom.layered() {
|
||||||
|
officialMojangMappings()
|
||||||
|
parchment("org.parchmentmc.data:parchment-1.18.2:2022.05.02@zip")
|
||||||
|
}
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,10 @@
|
||||||
package net.montoyo.wd;
|
package net.montoyo.wd;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
import net.minecraftforge.fml.server.FMLServerHandler;
|
|
||||||
import net.montoyo.wd.utilities.Log;
|
import net.montoyo.wd.utilities.Log;
|
||||||
import net.montoyo.wd.core.HasAdvancement;
|
import net.montoyo.wd.core.HasAdvancement;
|
||||||
import net.montoyo.wd.core.JSServerRequest;
|
import net.montoyo.wd.core.JSServerRequest;
|
||||||
|
|
@ -33,7 +31,7 @@ public class SharedProxy {
|
||||||
public void postInit() {
|
public void postInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public World getWorld(int dim) {
|
public Level getWorld(int dim) {
|
||||||
if(dim == CURRENT_DIMENSION)
|
if(dim == CURRENT_DIMENSION)
|
||||||
throw new RuntimeException("Current dimension not available server side...");
|
throw new RuntimeException("Current dimension not available server side...");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,40 +5,10 @@
|
||||||
package net.montoyo.wd;
|
package net.montoyo.wd;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import net.minecraft.advancements.Advancement;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.minecraft.advancements.CriteriaTriggers;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.init.SoundEvents;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraftforge.client.event.ClientChatEvent;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import net.minecraftforge.common.config.Property;
|
|
||||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
|
||||||
import net.minecraftforge.event.ServerChatEvent;
|
|
||||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
|
||||||
import net.minecraftforge.fml.common.Loader;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.common.SidedProxy;
|
|
||||||
import net.minecraftforge.fml.common.event.*;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
import net.montoyo.wd.block.BlockKeyboardRight;
|
import net.montoyo.wd.block.BlockKeyboardRight;
|
||||||
import net.montoyo.wd.block.BlockPeripheral;
|
import net.montoyo.wd.block.BlockPeripheral;
|
||||||
import net.montoyo.wd.block.BlockScreen;
|
import net.montoyo.wd.block.BlockScreen;
|
||||||
|
|
@ -46,8 +16,8 @@ import net.montoyo.wd.core.*;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.TileEntityScreen;
|
||||||
import net.montoyo.wd.item.*;
|
import net.montoyo.wd.item.*;
|
||||||
import net.montoyo.wd.miniserv.server.Server;
|
import net.montoyo.wd.miniserv.server.Server;
|
||||||
import net.montoyo.wd.net.client.CMessageServerInfo;
|
|
||||||
import net.montoyo.wd.net.Messages;
|
import net.montoyo.wd.net.Messages;
|
||||||
|
import net.montoyo.wd.net.client.CMessageServerInfo;
|
||||||
import net.montoyo.wd.utilities.Log;
|
import net.montoyo.wd.utilities.Log;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
|
|
||||||
|
|
@ -57,18 +27,14 @@ import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Mod(modid = "webdisplays", version = WebDisplays.MOD_VERSION, dependencies = "required-after:mcef@[1.0,2.0);after:opencomputers;after:computercraft;")
|
public class WebDisplays implements ModInitializer {
|
||||||
public class WebDisplays {
|
|
||||||
|
|
||||||
public static final String MOD_VERSION = "1.1";
|
public static final String MOD_VERSION = "1.0.0";
|
||||||
|
|
||||||
@Mod.Instance(owner = "webdisplays")
|
|
||||||
public static WebDisplays INSTANCE;
|
public static WebDisplays INSTANCE;
|
||||||
|
|
||||||
@SidedProxy(serverSide = "net.montoyo.wd.SharedProxy", clientSide = "net.montoyo.wd.client.ClientProxy")
|
|
||||||
public static SharedProxy PROXY;
|
public static SharedProxy PROXY;
|
||||||
|
|
||||||
public static SimpleNetworkWrapper NET_HANDLER;
|
|
||||||
public static WDCreativeTab CREATIVE_TAB;
|
public static WDCreativeTab CREATIVE_TAB;
|
||||||
public static final ResourceLocation ADV_PAD_BREAK = new ResourceLocation("webdisplays", "webdisplays/pad_break");
|
public static final ResourceLocation ADV_PAD_BREAK = new ResourceLocation("webdisplays", "webdisplays/pad_break");
|
||||||
public static final String BLACKLIST_URL = "mod://webdisplays/blacklisted.html";
|
public static final String BLACKLIST_URL = "mod://webdisplays/blacklisted.html";
|
||||||
|
|
@ -104,109 +70,8 @@ public class WebDisplays {
|
||||||
public Criterion criterionLinkPeripheral;
|
public Criterion criterionLinkPeripheral;
|
||||||
public Criterion criterionKeyboardCat;
|
public Criterion criterionKeyboardCat;
|
||||||
|
|
||||||
//Config
|
@Override
|
||||||
public static final double PAD_RATIO = 59.0 / 30.0;
|
public void onInitialize() {
|
||||||
public String homePage;
|
|
||||||
public double padResX;
|
|
||||||
public double padResY;
|
|
||||||
private int lastPadId = 0;
|
|
||||||
public boolean doHardRecipe;
|
|
||||||
private boolean hasOC;
|
|
||||||
private boolean hasCC;
|
|
||||||
private String[] blacklist;
|
|
||||||
public boolean disableOwnershipThief;
|
|
||||||
public double unloadDistance2;
|
|
||||||
public double loadDistance2;
|
|
||||||
public int maxResX;
|
|
||||||
public int maxResY;
|
|
||||||
public int maxScreenX;
|
|
||||||
public int maxScreenY;
|
|
||||||
public int miniservPort;
|
|
||||||
public long miniservQuota;
|
|
||||||
public boolean enableSoundDistance;
|
|
||||||
public float ytVolume;
|
|
||||||
public float avDist100;
|
|
||||||
public float avDist0;
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
public void onPreInit(FMLPreInitializationEvent ev) {
|
|
||||||
//Load config
|
|
||||||
Configuration cfg = new Configuration(ev.getSuggestedConfigurationFile());
|
|
||||||
cfg.load();
|
|
||||||
|
|
||||||
//CAT: Main
|
|
||||||
Property blacklist = cfg.get("main", "blacklist", new String[0]);
|
|
||||||
Property padHeight = cfg.get("main", "padHeight", 480);
|
|
||||||
Property hardRecipe = cfg.get("main", "hardRecipes", true);
|
|
||||||
Property homePage = cfg.get("main", "homepage", "mod://webdisplays/main.html");
|
|
||||||
Property disableOT = cfg.get("main", "disableOwnershipThief", false);
|
|
||||||
Property maxResX = cfg.get("main", "maxResolutionX", 1920);
|
|
||||||
Property maxResY = cfg.get("main", "maxResolutionY", 1080);
|
|
||||||
Property miniservPort = cfg.get("main", "miniservPort", 25566);
|
|
||||||
Property miniservQuota = cfg.get("main", "miniservQuota", 1024); //It's stored as a string anyway
|
|
||||||
Property maxScreenX = cfg.get("main", "maxScreenSizeX", 16);
|
|
||||||
Property maxScreenY = cfg.get("main", "maxScreenSizeY", 16);
|
|
||||||
|
|
||||||
//CAT: Client options
|
|
||||||
Property loadDistance = cfg.get("client", "loadDistance", 30.0);
|
|
||||||
Property unloadDistance = cfg.get("client", "unloadDistance", 32.0);
|
|
||||||
|
|
||||||
//CAT: Auto volume config (client-side)
|
|
||||||
Property enableAutoVol = cfg.get("clientAutoVolume", "enableAutoVolume", true);
|
|
||||||
Property ytVolume = cfg.get("clientAutoVolume", "ytVolume", 100.0);
|
|
||||||
Property dist100 = cfg.get("clientAutoVolume", "dist100", 10.0);
|
|
||||||
Property dist0 = cfg.get("clientAutoVolume", "dist0", 30.0);
|
|
||||||
|
|
||||||
|
|
||||||
//Comments & shit
|
|
||||||
blacklist.setComment("An array of domain names you don't want to load.");
|
|
||||||
padHeight.setComment("The minePad Y resolution in pixels. padWidth = padHeight * " + PAD_RATIO);
|
|
||||||
hardRecipe.setComment("If true, breaking the minePad is required to craft upgrades.");
|
|
||||||
homePage.setComment("The URL that will be loaded each time you create a screen");
|
|
||||||
disableOT.setComment("If true, the ownership thief item will be disabled");
|
|
||||||
loadDistance.setComment("All screens outside this range will be unloaded");
|
|
||||||
unloadDistance.setComment("All unloaded screens inside this range will be loaded");
|
|
||||||
maxResX.setComment("Maximum horizontal screen resolution, in pixels");
|
|
||||||
maxResY.setComment("Maximum vertical screen resolution, in pixels");
|
|
||||||
miniservPort.setComment("The port used by miniserv. 0 to disable.");
|
|
||||||
miniservPort.setMaxValue(Short.MAX_VALUE);
|
|
||||||
miniservQuota.setComment("The amount of data that can be uploaded to miniserv, in KiB (so 1024 = 1 MiO)");
|
|
||||||
maxScreenX.setComment("Maximum screen width, in blocks. Resolution will be clamped by maxResolutionX.");
|
|
||||||
maxScreenY.setComment("Maximum screen height, in blocks. Resolution will be clamped by maxResolutionY.");
|
|
||||||
enableAutoVol.setComment("If true, the volume of YouTube videos will change depending on how far you are");
|
|
||||||
ytVolume.setComment("Volume for YouTube videos. This will have no effect if enableSoundDistance is set to false");
|
|
||||||
ytVolume.setMinValue(0.0);
|
|
||||||
ytVolume.setMaxValue(100.0);
|
|
||||||
dist100.setComment("Distance after which the sound starts dropping (in blocks)");
|
|
||||||
dist100.setMinValue(0.0);
|
|
||||||
dist0.setComment("Distance after which you can't hear anything (in blocks)");
|
|
||||||
dist0.setMinValue(0.0);
|
|
||||||
|
|
||||||
if(unloadDistance.getDouble() < loadDistance.getDouble() + 2.0)
|
|
||||||
unloadDistance.set(loadDistance.getDouble() + 2.0);
|
|
||||||
|
|
||||||
if(dist0.getDouble() < dist100.getDouble() + 0.1)
|
|
||||||
dist0.set(dist100.getDouble() + 0.1);
|
|
||||||
|
|
||||||
cfg.save();
|
|
||||||
|
|
||||||
this.blacklist = blacklist.getStringList();
|
|
||||||
doHardRecipe = hardRecipe.getBoolean();
|
|
||||||
this.homePage = homePage.getString();
|
|
||||||
disableOwnershipThief = disableOT.getBoolean();
|
|
||||||
unloadDistance2 = unloadDistance.getDouble() * unloadDistance.getDouble();
|
|
||||||
loadDistance2 = loadDistance.getDouble() * loadDistance.getDouble();
|
|
||||||
this.maxResX = maxResX.getInt();
|
|
||||||
this.maxResY = maxResY.getInt();
|
|
||||||
this.miniservPort = miniservPort.getInt();
|
|
||||||
this.miniservQuota = miniservQuota.getLong() * 1024L;
|
|
||||||
this.maxScreenX = maxScreenX.getInt();
|
|
||||||
this.maxScreenY = maxScreenY.getInt();
|
|
||||||
enableSoundDistance = enableAutoVol.getBoolean();
|
|
||||||
this.ytVolume = (float) ytVolume.getDouble();
|
|
||||||
avDist100 = (float) dist100.getDouble();
|
|
||||||
avDist0 = (float) dist0.getDouble();
|
|
||||||
|
|
||||||
CREATIVE_TAB = new WDCreativeTab();
|
CREATIVE_TAB = new WDCreativeTab();
|
||||||
|
|
||||||
//Criterions
|
//Criterions
|
||||||
|
|
@ -242,29 +107,16 @@ public class WebDisplays {
|
||||||
itemAdvIcon.setUnlocalizedName("webdisplays.advicon");
|
itemAdvIcon.setUnlocalizedName("webdisplays.advicon");
|
||||||
itemAdvIcon.setRegistryName("advicon");
|
itemAdvIcon.setRegistryName("advicon");
|
||||||
|
|
||||||
PROXY.preInit();
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
public void onInit(FMLInitializationEvent ev) {
|
|
||||||
//Register tile entities
|
|
||||||
GameRegistry.registerTileEntity(TileEntityScreen.class, new ResourceLocation("webdisplays", "screen"));
|
GameRegistry.registerTileEntity(TileEntityScreen.class, new ResourceLocation("webdisplays", "screen"));
|
||||||
for(DefaultPeripheral dp: DefaultPeripheral.values()) {
|
for(DefaultPeripheral dp: DefaultPeripheral.values()) {
|
||||||
if(dp.getTEClass() != null)
|
if(dp.getTEClass() != null)
|
||||||
GameRegistry.registerTileEntity(dp.getTEClass(), new ResourceLocation("webdisplays", dp.getName()));
|
GameRegistry.registerTileEntity(dp.getTEClass(), new ResourceLocation("webdisplays", dp.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Other things
|
|
||||||
CapabilityManager.INSTANCE.register(IWDDCapability.class, new WDDCapability.Storage(), new WDDCapability.Factory());
|
CapabilityManager.INSTANCE.register(IWDDCapability.class, new WDDCapability.Storage(), new WDDCapability.Factory());
|
||||||
PROXY.init();
|
|
||||||
NET_HANDLER = NetworkRegistry.INSTANCE.newSimpleChannel("webdisplays");
|
NET_HANDLER = NetworkRegistry.INSTANCE.newSimpleChannel("webdisplays");
|
||||||
Messages.registerAll(NET_HANDLER);
|
Messages.registerAll(NET_HANDLER);
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
|
||||||
PROXY.postInit();
|
|
||||||
hasOC = Loader.isModLoaded("opencomputers");
|
hasOC = Loader.isModLoaded("opencomputers");
|
||||||
hasCC = Loader.isModLoaded("computercraft");
|
hasCC = Loader.isModLoaded("computercraft");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
package net.montoyo.wd.client;
|
package net.montoyo.wd.client;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
import net.montoyo.mcef.api.IBrowser;
|
import net.montoyo.mcef.api.IBrowser;
|
||||||
import net.montoyo.mcef.api.IJSQueryCallback;
|
import net.montoyo.mcef.api.IJSQueryCallback;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
|
|
@ -24,7 +24,7 @@ import net.montoyo.wd.utilities.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public final class JSQueryDispatcher {
|
public final class JSQueryDispatcher {
|
||||||
|
|
||||||
private static final class QueryData {
|
private static final class QueryData {
|
||||||
|
|
@ -86,7 +86,7 @@ public final class JSQueryDispatcher {
|
||||||
private final ClientProxy.ScreenSidePair lookupResult = new ClientProxy.ScreenSidePair();
|
private final ClientProxy.ScreenSidePair lookupResult = new ClientProxy.ScreenSidePair();
|
||||||
private final HashMap<String, IScreenQueryHandler> handlers = new HashMap<>();
|
private final HashMap<String, IScreenQueryHandler> handlers = new HashMap<>();
|
||||||
private final ArrayList<ServerQuery> serverQueries = new ArrayList<>();
|
private final ArrayList<ServerQuery> serverQueries = new ArrayList<>();
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getInstance();
|
||||||
|
|
||||||
public JSQueryDispatcher(ClientProxy proxy) {
|
public JSQueryDispatcher(ClientProxy proxy) {
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
package net.montoyo.wd.client;
|
package net.montoyo.wd.client;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
import net.montoyo.wd.client.renderers.IModelBaker;
|
import net.montoyo.wd.client.renderers.IModelBaker;
|
||||||
|
|
||||||
public class ResourceModelPair {
|
public class ResourceModelPair {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd.client;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|
|
||||||
103
src/main/java/net/montoyo/wd/config/WDConfig.java
Normal file
103
src/main/java/net/montoyo/wd/config/WDConfig.java
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
package net.montoyo.wd.config;
|
||||||
|
|
||||||
|
public class WDConfig {
|
||||||
|
//Config
|
||||||
|
public static final double PAD_RATIO = 59.0 / 30.0;
|
||||||
|
public String homePage;
|
||||||
|
public double padResX;
|
||||||
|
public double padResY;
|
||||||
|
private int lastPadId = 0;
|
||||||
|
public boolean doHardRecipe;
|
||||||
|
private boolean hasOC;
|
||||||
|
private boolean hasCC;
|
||||||
|
private String[] blacklist;
|
||||||
|
public boolean disableOwnershipThief;
|
||||||
|
public double unloadDistance2;
|
||||||
|
public double loadDistance2;
|
||||||
|
public int maxResX;
|
||||||
|
public int maxResY;
|
||||||
|
public int maxScreenX;
|
||||||
|
public int maxScreenY;
|
||||||
|
public int miniservPort;
|
||||||
|
public long miniservQuota;
|
||||||
|
public boolean enableSoundDistance;
|
||||||
|
public float ytVolume;
|
||||||
|
public float avDist100;
|
||||||
|
public float avDist0;
|
||||||
|
//Load config
|
||||||
|
Configuration cfg = new Configuration(ev.getSuggestedConfigurationFile());
|
||||||
|
cfg.load();
|
||||||
|
|
||||||
|
//CAT: Main
|
||||||
|
Property blacklist = cfg.get("main", "blacklist", new String[0]);
|
||||||
|
Property padHeight = cfg.get("main", "padHeight", 480);
|
||||||
|
Property hardRecipe = cfg.get("main", "hardRecipes", true);
|
||||||
|
Property homePage = cfg.get("main", "homepage", "mod://webdisplays/main.html");
|
||||||
|
Property disableOT = cfg.get("main", "disableOwnershipThief", false);
|
||||||
|
Property maxResX = cfg.get("main", "maxResolutionX", 1920);
|
||||||
|
Property maxResY = cfg.get("main", "maxResolutionY", 1080);
|
||||||
|
Property miniservPort = cfg.get("main", "miniservPort", 25566);
|
||||||
|
Property miniservQuota = cfg.get("main", "miniservQuota", 1024); //It's stored as a string anyway
|
||||||
|
Property maxScreenX = cfg.get("main", "maxScreenSizeX", 16);
|
||||||
|
Property maxScreenY = cfg.get("main", "maxScreenSizeY", 16);
|
||||||
|
|
||||||
|
//CAT: Client options
|
||||||
|
Property loadDistance = cfg.get("client", "loadDistance", 30.0);
|
||||||
|
Property unloadDistance = cfg.get("client", "unloadDistance", 32.0);
|
||||||
|
|
||||||
|
//CAT: Auto volume config (client-side)
|
||||||
|
Property enableAutoVol = cfg.get("clientAutoVolume", "enableAutoVolume", true);
|
||||||
|
Property ytVolume = cfg.get("clientAutoVolume", "ytVolume", 100.0);
|
||||||
|
Property dist100 = cfg.get("clientAutoVolume", "dist100", 10.0);
|
||||||
|
Property dist0 = cfg.get("clientAutoVolume", "dist0", 30.0);
|
||||||
|
|
||||||
|
|
||||||
|
//Comments & shit
|
||||||
|
blacklist.setComment("An array of domain names you don't want to load.");
|
||||||
|
padHeight.setComment("The minePad Y resolution in pixels. padWidth = padHeight * " + PAD_RATIO);
|
||||||
|
hardRecipe.setComment("If true, breaking the minePad is required to craft upgrades.");
|
||||||
|
homePage.setComment("The URL that will be loaded each time you create a screen");
|
||||||
|
disableOT.setComment("If true, the ownership thief item will be disabled");
|
||||||
|
loadDistance.setComment("All screens outside this range will be unloaded");
|
||||||
|
unloadDistance.setComment("All unloaded screens inside this range will be loaded");
|
||||||
|
maxResX.setComment("Maximum horizontal screen resolution, in pixels");
|
||||||
|
maxResY.setComment("Maximum vertical screen resolution, in pixels");
|
||||||
|
miniservPort.setComment("The port used by miniserv. 0 to disable.");
|
||||||
|
miniservPort.setMaxValue(Short.MAX_VALUE);
|
||||||
|
miniservQuota.setComment("The amount of data that can be uploaded to miniserv, in KiB (so 1024 = 1 MiO)");
|
||||||
|
maxScreenX.setComment("Maximum screen width, in blocks. Resolution will be clamped by maxResolutionX.");
|
||||||
|
maxScreenY.setComment("Maximum screen height, in blocks. Resolution will be clamped by maxResolutionY.");
|
||||||
|
enableAutoVol.setComment("If true, the volume of YouTube videos will change depending on how far you are");
|
||||||
|
ytVolume.setComment("Volume for YouTube videos. This will have no effect if enableSoundDistance is set to false");
|
||||||
|
ytVolume.setMinValue(0.0);
|
||||||
|
ytVolume.setMaxValue(100.0);
|
||||||
|
dist100.setComment("Distance after which the sound starts dropping (in blocks)");
|
||||||
|
dist100.setMinValue(0.0);
|
||||||
|
dist0.setComment("Distance after which you can't hear anything (in blocks)");
|
||||||
|
dist0.setMinValue(0.0);
|
||||||
|
|
||||||
|
if(unloadDistance.getDouble() < loadDistance.getDouble() + 2.0)
|
||||||
|
unloadDistance.set(loadDistance.getDouble() + 2.0);
|
||||||
|
|
||||||
|
if(dist0.getDouble() < dist100.getDouble() + 0.1)
|
||||||
|
dist0.set(dist100.getDouble() + 0.1);
|
||||||
|
|
||||||
|
cfg.save();
|
||||||
|
|
||||||
|
this.blacklist = blacklist.getStringList();
|
||||||
|
doHardRecipe = hardRecipe.getBoolean();
|
||||||
|
this.homePage = homePage.getString();
|
||||||
|
disableOwnershipThief = disableOT.getBoolean();
|
||||||
|
unloadDistance2 = unloadDistance.getDouble() * unloadDistance.getDouble();
|
||||||
|
loadDistance2 = loadDistance.getDouble() * loadDistance.getDouble();
|
||||||
|
this.maxResX = maxResX.getInt();
|
||||||
|
this.maxResY = maxResY.getInt();
|
||||||
|
this.miniservPort = miniservPort.getInt();
|
||||||
|
this.miniservQuota = miniservQuota.getLong() * 1024L;
|
||||||
|
this.maxScreenX = maxScreenX.getInt();
|
||||||
|
this.maxScreenY = maxScreenY.getInt();
|
||||||
|
enableSoundDistance = enableAutoVol.getBoolean();
|
||||||
|
this.ytVolume = (float) ytVolume.getDouble();
|
||||||
|
avDist100 = (float) dist100.getDouble();
|
||||||
|
avDist0 = (float) dist0.getDouble();
|
||||||
|
}
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
package net.montoyo.wd.core;
|
package net.montoyo.wd.core;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public enum DefaultUpgrade {
|
public enum DefaultUpgrade {
|
||||||
|
|
||||||
LASER_MOUSE("lasermouse", "Laser_Sensor"),
|
LASER_MOUSE("lasermouse", "Laser_Sensor"),
|
||||||
|
|
@ -28,12 +30,11 @@ public enum DefaultUpgrade {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(ItemStack is) {
|
public boolean matches(ItemStack is) {
|
||||||
return is.getItem() == WebDisplays.INSTANCE.itemUpgrade && is.getMetadata() == ordinal();
|
return is.getItem() == WebDisplays.INSTANCE.itemUpgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getWikiName(int meta) {
|
/*public static String getWikiName(ItemStack itemStack) {
|
||||||
DefaultUpgrade[] values = values();
|
DefaultUpgrade[] values = values();
|
||||||
return (meta >= 0 && meta < values.length) ? values[meta].wikiName : null;
|
return !itemStack.isEmpty() ? values.wikiName : null;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
package net.montoyo.wd.core;
|
package net.montoyo.wd.core;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.TileEntityScreen;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
|
||||||
|
|
@ -14,8 +14,8 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
public interface IUpgrade {
|
public interface IUpgrade {
|
||||||
|
|
||||||
void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is);
|
void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is);
|
||||||
boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is); //Return true to prevent dropping
|
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
|
boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack); //myStack.getItem() is an instance of this class
|
||||||
String getJSName(@Nonnull ItemStack is); //modname:upgradename
|
String getJSName(@Nonnull ItemStack is); //modname:upgradename
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,14 @@
|
||||||
|
|
||||||
package net.montoyo.wd.item;
|
package net.montoyo.wd.item;
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.language.I18n;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.world.item.AirItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.core.DefaultUpgrade;
|
import net.montoyo.wd.core.DefaultUpgrade;
|
||||||
import net.montoyo.wd.core.IUpgrade;
|
import net.montoyo.wd.core.IUpgrade;
|
||||||
|
|
@ -20,7 +22,7 @@ import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
public class ItemUpgrade extends ItemMulti implements IUpgrade {
|
||||||
|
|
||||||
public ItemUpgrade() {
|
public ItemUpgrade() {
|
||||||
super(DefaultUpgrade.class);
|
super(DefaultUpgrade.class);
|
||||||
|
|
@ -30,12 +32,12 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is) {
|
public void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is) {
|
public boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
|
||||||
if(is.getMetadata() == DefaultUpgrade.LASER_MOUSE.ordinal())
|
if(DefaultUpgrade.LASER_MOUSE.matches(is))
|
||||||
tes.clearLaserUser(screenSide);
|
tes.clearLaserUser(screenSide);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -43,30 +45,21 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack) {
|
public boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack) {
|
||||||
return otherStack.getItem() == this && otherStack.getMetadata() == myStack.getMetadata();
|
return otherStack.getItem() == this && otherStack.getTag() == myStack.getTag();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
|
||||||
tt.add("" + ChatFormatting.ITALIC + I18n.format("item.webdisplays.upgrade.name"));
|
|
||||||
WDItem.addInformation(tt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getJSName(@Nonnull ItemStack is) {
|
public String getJSName(@Nonnull ItemStack is) {
|
||||||
int meta = is.getMetadata();
|
if(is.isEmpty())
|
||||||
DefaultUpgrade[] upgrades = DefaultUpgrade.values();
|
|
||||||
|
|
||||||
if(meta < 0 || meta >= upgrades.length)
|
|
||||||
return "webdisplays:wtf";
|
return "webdisplays:wtf";
|
||||||
else
|
else
|
||||||
return "webdisplays:" + upgrades[meta];
|
return "webdisplays:" + is;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
/*@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String getWikiName(@Nonnull ItemStack is) {
|
public String getWikiName(@Nonnull ItemStack is) {
|
||||||
return DefaultUpgrade.getWikiName(is.getMetadata());
|
return DefaultUpgrade.getWikiName(is.getItem().getName(is).toString());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
package net.montoyo.wd.item;
|
package net.montoyo.wd.item;
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.language.I18n;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
@ -20,7 +20,7 @@ public interface WDItem {
|
||||||
|
|
||||||
static void addInformation(@Nullable List<String> tt) {
|
static void addInformation(@Nullable List<String> tt) {
|
||||||
if(tt != null && WebDisplays.PROXY.isShiftDown())
|
if(tt != null && WebDisplays.PROXY.isShiftDown())
|
||||||
tt.add("" + ChatFormatting.GRAY + I18n.format("item.webdisplays.wiki"));
|
tt.add("" + ChatFormatting.GRAY + I18n.get("item.webdisplays.wiki"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class Client extends AbstractClient implements Runnable {
|
||||||
private volatile boolean connected;
|
private volatile boolean connected;
|
||||||
private final ByteBuffer readBuffer = ByteBuffer.allocateDirect(8192);
|
private final ByteBuffer readBuffer = ByteBuffer.allocateDirect(8192);
|
||||||
private volatile Thread thread;
|
private volatile Thread thread;
|
||||||
private final UUID clientUUID = Minecraft.getMinecraft().player.getGameProfile().getId();
|
private final UUID clientUUID = Minecraft.getInstance().player.getGameProfile().getId();
|
||||||
private final ArrayDeque<ClientTask> tasks = new ArrayDeque<>();
|
private final ArrayDeque<ClientTask> tasks = new ArrayDeque<>();
|
||||||
private ClientTask currentTask;
|
private ClientTask currentTask;
|
||||||
private volatile boolean authenticated;
|
private volatile boolean authenticated;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
package net.montoyo.wd.utilities;
|
package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
|
|
||||||
public final class AABB {
|
public final class AABB {
|
||||||
|
|
||||||
public final Vector3i start;
|
public final Vector3i start;
|
||||||
|
|
@ -33,7 +31,7 @@ public final class AABB {
|
||||||
end.z = Math.max(a.z, b.z);
|
end.z = Math.max(a.z, b.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AABB(AxisAlignedBB bb) {
|
public AABB(net.minecraft.world.phys.AABB bb) {
|
||||||
start = new Vector3i();
|
start = new Vector3i();
|
||||||
end = new Vector3i();
|
end = new Vector3i();
|
||||||
|
|
||||||
|
|
@ -70,8 +68,8 @@ public final class AABB {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBB toMc() {
|
public net.minecraft.world.phys.AABB toMc() {
|
||||||
return new AxisAlignedBB((double) start.x, (double) start.y, (double) start.z, (double) end.x, (double) end.y, (double) end.z);
|
return new net.minecraft.world.phys.AABB(start.x, start.y, start.z, end.x, end.y, end.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
package net.montoyo.wd.utilities;
|
package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.minecraft.world.ticks.WorldGenTickAccess;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
|
|
||||||
public abstract class Multiblock {
|
public abstract class Multiblock {
|
||||||
|
|
@ -39,7 +40,7 @@ public abstract class Multiblock {
|
||||||
public static final BlockOverride NULL_OVERRIDE = new BlockOverride(null, OverrideAction.NONE);
|
public static final BlockOverride NULL_OVERRIDE = new BlockOverride(null, OverrideAction.NONE);
|
||||||
|
|
||||||
//Modifies pos
|
//Modifies pos
|
||||||
public static void findOrigin(IBlockAccess world, Vector3i pos, BlockSide side, BlockOverride override)
|
public static void findOrigin(LevelAccessor world, Vector3i pos, BlockSide side, BlockOverride override)
|
||||||
{
|
{
|
||||||
if(override == null)
|
if(override == null)
|
||||||
override = NULL_OVERRIDE;
|
override = NULL_OVERRIDE;
|
||||||
|
|
@ -64,7 +65,7 @@ public abstract class Multiblock {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Origin stays constant
|
//Origin stays constant
|
||||||
public static Vector2i measure(IBlockAccess world, Vector3i origin, BlockSide side)
|
public static Vector2i measure(LevelAccessor world, Vector3i origin, BlockSide side)
|
||||||
{
|
{
|
||||||
Vector2i ret = new Vector2i();
|
Vector2i ret = new Vector2i();
|
||||||
Vector3i pos = origin.clone();
|
Vector3i pos = origin.clone();
|
||||||
|
|
@ -93,7 +94,7 @@ public abstract class Multiblock {
|
||||||
|
|
||||||
//Origin and size stays constant.
|
//Origin and size stays constant.
|
||||||
//Returns null if structure is okay, otherwise the erroring block pos.
|
//Returns null if structure is okay, otherwise the erroring block pos.
|
||||||
public static Vector3i check(IBlockAccess world, Vector3i origin, Vector2i size, BlockSide side)
|
public static Vector3i check(LevelAccessor world, Vector3i origin, Vector2i size, BlockSide side)
|
||||||
{
|
{
|
||||||
Vector3i pos = origin.clone();
|
Vector3i pos = origin.clone();
|
||||||
BlockPos.MutableBlockPos bp = new BlockPos.MutableBlockPos();
|
BlockPos.MutableBlockPos bp = new BlockPos.MutableBlockPos();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -30,8 +30,8 @@ public final class NameUUIDPair {
|
||||||
uuid = profile.getId();
|
uuid = profile.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NameUUIDPair(ByteBuf bb) {
|
public NameUUIDPair(FriendlyByteBuf bb) {
|
||||||
name = ByteBufUtils.readUTF8String(bb);
|
name = bb.readUtf();
|
||||||
|
|
||||||
long msb = bb.readLong();
|
long msb = bb.readLong();
|
||||||
long lsb = bb.readLong();
|
long lsb = bb.readLong();
|
||||||
|
|
@ -63,8 +63,8 @@ public final class NameUUIDPair {
|
||||||
return name.isEmpty() && uuid.getMostSignificantBits() == 0L && uuid.getLeastSignificantBits() == 0L;
|
return name.isEmpty() && uuid.getMostSignificantBits() == 0L && uuid.getLeastSignificantBits() == 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(ByteBuf bb) {
|
public void writeTo(FriendlyByteBuf bb) {
|
||||||
ByteBufUtils.writeUTF8String(bb, name);
|
bb.writeUtf(name);
|
||||||
bb.writeLong(uuid.getMostSignificantBits());
|
bb.writeLong(uuid.getMostSignificantBits());
|
||||||
bb.writeLong(uuid.getLeastSignificantBits());
|
bb.writeLong(uuid.getLeastSignificantBits());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
package net.montoyo.wd.utilities;
|
package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,15 @@
|
||||||
package net.montoyo.wd.utilities;
|
package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.util.text.*;
|
import net.minecraft.network.chat.FormattedText;
|
||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
import net.minecraft.network.chat.NbtComponent;
|
||||||
|
import net.minecraft.network.chat.Style;
|
||||||
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -18,7 +22,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
public abstract class Util {
|
public abstract class Util {
|
||||||
|
|
||||||
public static void serialize(ByteBuf bb, Object f) {
|
public static void serialize(FriendlyByteBuf bb, Object f) {
|
||||||
Class<?> cls = f.getClass();
|
Class<?> cls = f.getClass();
|
||||||
|
|
||||||
if(cls == Integer.class || cls == Integer.TYPE)
|
if(cls == Integer.class || cls == Integer.TYPE)
|
||||||
|
|
@ -30,7 +34,7 @@ public abstract class Util {
|
||||||
else if(cls == Boolean.class || cls == Boolean.TYPE)
|
else if(cls == Boolean.class || cls == Boolean.TYPE)
|
||||||
bb.writeBoolean((Boolean) f);
|
bb.writeBoolean((Boolean) f);
|
||||||
else if(cls == String.class)
|
else if(cls == String.class)
|
||||||
ByteBufUtils.writeUTF8String(bb, (String) f);
|
bb.writeUtf((String) f);
|
||||||
else if(cls == NameUUIDPair.class)
|
else if(cls == NameUUIDPair.class)
|
||||||
((NameUUIDPair) f).writeTo(bb);
|
((NameUUIDPair) f).writeTo(bb);
|
||||||
else if(cls.isEnum())
|
else if(cls.isEnum())
|
||||||
|
|
@ -57,7 +61,7 @@ public abstract class Util {
|
||||||
throw new RuntimeException(String.format("Cannot transmit class %s over network!", cls.getName()));
|
throw new RuntimeException(String.format("Cannot transmit class %s over network!", cls.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object unserialize(ByteBuf bb, Class cls) {
|
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();
|
return bb.readInt();
|
||||||
else if(cls == Float.class || cls == Float.TYPE)
|
else if(cls == Float.class || cls == Float.TYPE)
|
||||||
|
|
@ -67,7 +71,7 @@ public abstract class Util {
|
||||||
else if(cls == Boolean.class || cls == Boolean.TYPE)
|
else if(cls == Boolean.class || cls == Boolean.TYPE)
|
||||||
return bb.readBoolean();
|
return bb.readBoolean();
|
||||||
else if(cls == String.class)
|
else if(cls == String.class)
|
||||||
return ByteBufUtils.readUTF8String(bb);
|
return bb.readUtf();
|
||||||
else if(cls == NameUUIDPair.class)
|
else if(cls == NameUUIDPair.class)
|
||||||
return new NameUUIDPair(bb);
|
return new NameUUIDPair(bb);
|
||||||
else if(cls.isEnum())
|
else if(cls.isEnum())
|
||||||
|
|
@ -128,16 +132,15 @@ public abstract class Util {
|
||||||
return idx ^ (idx >> 16);
|
return idx ^ (idx >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toast(EntityPlayer player, String key, Object... data) {
|
public static void toast(Player player, String key, Object... data) {
|
||||||
toast(player, TextFormatting.RED, key, data);
|
toast(player, Style.EMPTY.withColor(0xff0000), key, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toast(EntityPlayer player, TextFormatting color, String key, Object... data) {
|
public static void toast(Player player, Style color, String key, Object... data) {
|
||||||
ITextComponent root = new TextComponentString("[WebDisplays] ");
|
NbtComponent root = (NbtComponent) FormattedText.of("[WebDisplays] ", color);
|
||||||
root.setStyle((new Style()).setColor(color));
|
root.append(new TranslatableComponent("webdisplays.message." + key, data));
|
||||||
root.appendSibling(new TextComponentTranslation("webdisplays.message." + key, data));
|
|
||||||
|
|
||||||
player.sendMessage(root);
|
player.sendMessage(root, player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void silentClose(Object obj) {
|
public static void silentClose(Object obj) {
|
||||||
|
|
@ -175,17 +178,17 @@ public abstract class Util {
|
||||||
return j.toString();
|
return j.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NBTTagCompound writeOwnerToNBT(NBTTagCompound tag, NameUUIDPair owner) {
|
public static CompoundTag writeOwnerToNBT(CompoundTag tag, NameUUIDPair owner) {
|
||||||
if(owner != null) {
|
if(owner != null) {
|
||||||
tag.setLong("OwnerMSB", owner.uuid.getMostSignificantBits());
|
tag.putLong("OwnerMSB", owner.uuid.getMostSignificantBits());
|
||||||
tag.setLong("OwnerLSB", owner.uuid.getLeastSignificantBits());
|
tag.putLong("OwnerLSB", owner.uuid.getLeastSignificantBits());
|
||||||
tag.setString("OwnerName", owner.name);
|
tag.putString("OwnerName", owner.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NameUUIDPair readOwnerFromNBT(NBTTagCompound tag) {
|
public static NameUUIDPair readOwnerFromNBT(CompoundTag tag) {
|
||||||
long msb = tag.getLong("OwnerMSB");
|
long msb = tag.getLong("OwnerMSB");
|
||||||
long lsb = tag.getLong("OwnerLSB");
|
long lsb = tag.getLong("OwnerLSB");
|
||||||
String str = tag.getString("OwnerName");
|
String str = tag.getString("OwnerName");
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
package net.montoyo.wd.utilities;
|
package net.montoyo.wd.utilities;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
public final class Vector3i {
|
public final class Vector3i {
|
||||||
|
|
||||||
|
|
@ -215,7 +215,7 @@ public final class Vector3i {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toBlock(BlockPos.MutableBlockPos bp) {
|
public void toBlock(BlockPos.MutableBlockPos bp) {
|
||||||
bp.setPos(x, y, z);
|
bp.set(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChunkLocalPos()
|
public int getChunkLocalPos()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user