fixed some stuff for forge
This commit is contained in:
parent
4eeb61d328
commit
d35c9c23a6
25
build.gradle
25
build.gradle
|
|
@ -1,5 +1,6 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '0.12-SNAPSHOT'
|
||||
id 'dev.architectury.loom' version '0.12.0-SNAPSHOT'
|
||||
id 'io.github.juuxel.loom-quiltflower' version '1.6.0'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
|
@ -18,17 +19,21 @@ repositories {
|
|||
// for more information about repositories.
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven {
|
||||
url = "https://maven.parchmentmc.org"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// To change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
mappings loom.layered() {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-1.18.2:2022.05.02@zip")
|
||||
}
|
||||
forge "net.minecraftforge:forge:${project.forge_version}"
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
modImplementation "com.github.Mysticpasta1:mcef-fabric:master-SNAPSHOT"
|
||||
modImplementation "com.github.Mysticpasta1:mcef-forge:master-SNAPSHOT"
|
||||
modApi("me.shedaniel.cloth:cloth-config-fabric:6.2.62") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
}
|
||||
|
|
@ -38,6 +43,14 @@ dependencies {
|
|||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||
}
|
||||
|
||||
loom {
|
||||
forge {
|
||||
mixinConfigs = [
|
||||
"webdisplays.mixins.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
loom.platform=forge
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
|
|
@ -13,4 +14,4 @@ maven_group = net.montoyo.wd
|
|||
archives_base_name = webdisplays
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.56.1+1.18.2
|
||||
forge_version=1.18.2-40.1.52
|
||||
|
|
|
|||
|
|
@ -1,8 +1,21 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
pluginManagement {
|
||||
repositories {
|
||||
//jcenter() // jcenter will be stopped in 2022
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
maven { url "https://files.minecraftforge.net/maven/" }
|
||||
maven {
|
||||
name = 'Cotton'
|
||||
url = 'https://server.bbkr.space/artifactory/libs-release/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
|
|
|||
|
|
@ -5,12 +5,9 @@
|
|||
package net.montoyo.wd;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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.core.HasAdvancement;
|
||||
import net.montoyo.wd.core.JSServerRequest;
|
||||
|
|
|
|||
|
|
@ -5,40 +5,34 @@
|
|||
package net.montoyo.wd;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
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.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
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.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
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.minecraftforge.network.NetworkRegistry;
|
||||
import net.montoyo.mcef.easy_forge_compat.Configuration;
|
||||
import net.montoyo.wd.block.BlockKeyboardRight;
|
||||
import net.montoyo.wd.block.BlockPeripheral;
|
||||
import net.montoyo.wd.block.BlockScreen;
|
||||
|
|
@ -46,8 +40,8 @@ import net.montoyo.wd.core.*;
|
|||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.item.*;
|
||||
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.client.CMessageServerInfo;
|
||||
import net.montoyo.wd.utilities.Log;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
|
||||
|
|
@ -57,15 +51,13 @@ import java.net.URL;
|
|||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mod(modid = "webdisplays", version = WebDisplays.MOD_VERSION, dependencies = "required-after:mcef@[1.0,2.0);after:opencomputers;after:computercraft;")
|
||||
@Mod("webdisplays")
|
||||
public class WebDisplays {
|
||||
|
||||
public static final String MOD_VERSION = "1.1";
|
||||
|
||||
@Mod.Instance(owner = "webdisplays")
|
||||
public static WebDisplays INSTANCE;
|
||||
|
||||
@SidedProxy(serverSide = "net.montoyo.wd.SharedProxy", clientSide = "net.montoyo.wd.client.ClientProxy")
|
||||
public static SharedProxy PROXY;
|
||||
|
||||
public static SimpleNetworkWrapper NET_HANDLER;
|
||||
|
|
@ -128,10 +120,8 @@ public class WebDisplays {
|
|||
public float avDist100;
|
||||
public float avDist0;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onPreInit(FMLPreInitializationEvent ev) {
|
||||
//Load config
|
||||
Configuration cfg = new Configuration(ev.getSuggestedConfigurationFile());
|
||||
public WebDisplays() {
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.load();
|
||||
|
||||
//CAT: Main
|
||||
|
|
@ -238,16 +228,12 @@ public class WebDisplays {
|
|||
itemLaserPointer = new ItemLaserPointer();
|
||||
itemCraftComp = new ItemCraftComponent();
|
||||
|
||||
itemAdvIcon = new ItemMulti(AdvancementIcon.class);
|
||||
itemAdvIcon.setUnlocalizedName("webdisplays.advicon");
|
||||
itemAdvIcon = new ItemMulti(AdvancementIcon.class, new Item.Properties());
|
||||
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"));
|
||||
for(DefaultPeripheral dp: DefaultPeripheral.values()) {
|
||||
|
|
@ -260,13 +246,10 @@ public class WebDisplays {
|
|||
PROXY.init();
|
||||
NET_HANDLER = NetworkRegistry.INSTANCE.newSimpleChannel("webdisplays");
|
||||
Messages.registerAll(NET_HANDLER);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
||||
PROXY.postInit();
|
||||
hasOC = Loader.isModLoaded("opencomputers");
|
||||
hasCC = Loader.isModLoaded("computercraft");
|
||||
hasOC = ModList.get().isLoaded("opencomputers");
|
||||
hasCC = ModList.get().isLoaded("computercraft");
|
||||
|
||||
if(hasCC) {
|
||||
try {
|
||||
|
|
@ -302,7 +285,7 @@ public class WebDisplays {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onWorldLoad(WorldEvent.Load ev) {
|
||||
if(ev.getWorld().isRemote || ev.getWorld().provider.getDimension() != 0)
|
||||
if(ev.getWorld().isClientSide() || ev.getWorld().provider.getDimension() != 0)
|
||||
return;
|
||||
|
||||
File worldDir = ev.getWorld().getSaveHandler().getWorldDirectory();
|
||||
|
|
@ -337,7 +320,7 @@ public class WebDisplays {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onWorldSave(WorldEvent.Save ev) {
|
||||
if(ev.getWorld().isRemote || ev.getWorld().provider.getDimension() != 0)
|
||||
if(ev.getWorld().isClientSide() || ev.getWorld().provider.getDimension() != 0)
|
||||
return;
|
||||
|
||||
File f = new File(ev.getWorld().getSaveHandler().getWorldDirectory(), "wd_next.txt");
|
||||
|
|
@ -367,40 +350,40 @@ public class WebDisplays {
|
|||
UUID thrower = ev.getPlayer().getGameProfile().getId();
|
||||
tag.setLong("ThrowerMSB", thrower.getMostSignificantBits());
|
||||
tag.setLong("ThrowerLSB", thrower.getLeastSignificantBits());
|
||||
tag.setDouble("ThrowHeight", ev.getPlayer().posY + ev.getPlayer().getEyeHeight());
|
||||
tag.setDouble("ThrowHeight", ev.getPlayer().getY() + ev.getPlayer().getEyeHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerCraft(PlayerEvent.ItemCraftedEvent ev) {
|
||||
if(doHardRecipe && ev.crafting.getItem() == itemCraftComp && ev.crafting.getMetadata() == CraftComponent.EXTENSION_CARD.ordinal()) {
|
||||
if((ev.player instanceof EntityPlayerMP && !hasPlayerAdvancement((EntityPlayerMP) ev.player, ADV_PAD_BREAK)) || PROXY.hasClientPlayerAdvancement(ADV_PAD_BREAK) != HasAdvancement.YES) {
|
||||
ev.crafting.setItemDamage(CraftComponent.BAD_EXTENSION_CARD.ordinal());
|
||||
if(doHardRecipe && ev.getCrafting().getItem() == itemCraftComp && ev.getCrafting().is(CraftComponent.EXTENSION_CARD.makeItemStack()) {
|
||||
if((ev.getCrafting() instanceof ServerPlayer && !hasPlayerAdvancement((ServerPlayer) ev.getPlayer(), ADV_PAD_BREAK)) || PROXY.hasClientPlayerAdvancement(ADV_PAD_BREAK) != HasAdvancement.YES) {
|
||||
ev.getCrafting().setDamageValue(CraftComponent.BAD_EXTENSION_CARD.ordinal());
|
||||
|
||||
if(!ev.player.world.isRemote)
|
||||
ev.player.world.playSound(null, ev.player.posX, ev.player.posY, ev.player.posZ, SoundEvents.ENTITY_ITEM_BREAK, SoundCategory.MASTER, 1.0f, 1.0f);
|
||||
if(!ev.getPlayer().getLevel().isClientSide)
|
||||
ev.getPlayer().getLevel().playSound(null, ev.getPlayer().getX(), ev.getPlayer().getY(), ev.getPlayer().getZ(), SoundEvents.ENTITY_ITEM_BREAK, SoundSource.MASTER, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onServerStop(FMLServerStoppingEvent ev) {
|
||||
@SubscribeEvent
|
||||
public static void onServerStop(ServerStoppingEvent ev) {
|
||||
Server.getInstance().stopServer();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLogIn(PlayerEvent.PlayerLoggedInEvent ev) {
|
||||
if(!ev.player.world.isRemote && ev.player instanceof EntityPlayerMP) {
|
||||
WebDisplays.NET_HANDLER.sendTo(new CMessageServerInfo(miniservPort), (EntityPlayerMP) ev.player);
|
||||
IWDDCapability cap = ev.player.getCapability(WDDCapability.INSTANCE, null);
|
||||
if(!ev.getPlayer().getLevel().isClientSide && ev.getPlayer() instanceof ServerPlayer) {
|
||||
WebDisplays.NET_HANDLER.sendTo(new CMessageServerInfo(miniservPort), (ServerPlayer) ev.getPlayer());
|
||||
IWDDCapability cap = ev.getPlayer().getCapability(WDDCapability.INSTANCE, null);
|
||||
|
||||
if(cap == null)
|
||||
Log.warning("Player %s (%s) has null IWDDCapability!", ev.player.getName(), ev.player.getGameProfile().getId().toString());
|
||||
Log.warning("Player %s (%s) has null IWDDCapability!", ev.getPlayer().getName(), ev.getPlayer().getGameProfile().getId().toString());
|
||||
else if(cap.isFirstRun()) {
|
||||
Util.toast(ev.player, TextFormatting.LIGHT_PURPLE, "welcome1");
|
||||
Util.toast(ev.player, TextFormatting.LIGHT_PURPLE, "welcome2");
|
||||
Util.toast(ev.player, TextFormatting.LIGHT_PURPLE, "welcome3");
|
||||
Util.toast(ev.getPlayer(), ChatFormatting.LIGHT_PURPLE, "welcome1");
|
||||
Util.toast(ev.getPlayer(), ChatFormatting.LIGHT_PURPLE, "welcome2");
|
||||
Util.toast(ev.getPlayer(), ChatFormatting.LIGHT_PURPLE, "welcome3");
|
||||
|
||||
cap.clearFirstRun();
|
||||
}
|
||||
|
|
@ -409,20 +392,20 @@ public class WebDisplays {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onLogOut(PlayerEvent.PlayerLoggedOutEvent ev) {
|
||||
if(!ev.player.world.isRemote)
|
||||
Server.getInstance().getClientManager().revokeClientKey(ev.player.getGameProfile().getId());
|
||||
if(!ev.getPlayer().getLevel().isClientSide)
|
||||
Server.getInstance().getClientManager().revokeClientKey(ev.getPlayer().getGameProfile().getId());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void attachEntityCaps(AttachCapabilitiesEvent<Entity> ev) {
|
||||
if(ev.getObject() instanceof EntityPlayer)
|
||||
if(ev.getObject() instanceof Player)
|
||||
ev.addCapability(CAPABILITY, new WDDCapability.Provider());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone ev) {
|
||||
IWDDCapability src = ev.getOriginal().getCapability(WDDCapability.INSTANCE, null);
|
||||
IWDDCapability dst = ev.getEntityPlayer().getCapability(WDDCapability.INSTANCE, null);
|
||||
IWDDCapability dst = ev.getPlayer().getCapability(WDDCapability.INSTANCE, null);
|
||||
|
||||
if(src == null) {
|
||||
Log.error("src is null");
|
||||
|
|
@ -449,8 +432,8 @@ public class WebDisplays {
|
|||
}
|
||||
|
||||
if(sb.toString().equals("ironic he could save others from death but not himself")) {
|
||||
EntityPlayer ply = ev.getPlayer();
|
||||
ply.world.playSound(null, ply.posX, ply.posY, ply.posZ, soundIronic, SoundCategory.PLAYERS, 1.0f, 1.0f);
|
||||
Player ply = ev.getPlayer();
|
||||
ply.getLevel().playSound(null, ply.getX(), ply.getY(), ply.getZ(), soundIronic, SoundSource.PLAYERS, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -460,13 +443,13 @@ public class WebDisplays {
|
|||
PROXY.renderRecipes();
|
||||
}
|
||||
|
||||
private boolean hasPlayerAdvancement(EntityPlayerMP ply, ResourceLocation rl) {
|
||||
private boolean hasPlayerAdvancement(ServerPlayer ply, ResourceLocation rl) {
|
||||
MinecraftServer server = PROXY.getServer();
|
||||
if(server == null)
|
||||
return false;
|
||||
|
||||
Advancement adv = server.getAdvancementManager().getAdvancement(rl);
|
||||
return adv != null && ply.getAdvancements().getProgress(adv).isDone();
|
||||
Advancement adv = server.getAdvancements().getAdvancement(rl);
|
||||
return adv != null && ply.getAdvancements().getOrStartProgress(adv).isDone();
|
||||
}
|
||||
|
||||
public static int getNextAvailablePadID() {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,10 @@
|
|||
package net.montoyo.wd.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.montoyo.mcef.api.IBrowser;
|
||||
import net.montoyo.mcef.api.IJSQueryCallback;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
|
@ -24,7 +23,7 @@ import net.montoyo.wd.utilities.*;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class JSQueryDispatcher {
|
||||
|
||||
private static final class QueryData {
|
||||
|
|
@ -86,7 +85,7 @@ public final class JSQueryDispatcher {
|
|||
private final ClientProxy.ScreenSidePair lookupResult = new ClientProxy.ScreenSidePair();
|
||||
private final HashMap<String, IScreenQueryHandler> handlers = new HashMap<>();
|
||||
private final ArrayList<ServerQuery> serverQueries = new ArrayList<>();
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
public JSQueryDispatcher(ClientProxy proxy) {
|
||||
this.proxy = proxy;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.client;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.montoyo.wd.client.renderers.IModelBaker;
|
||||
|
||||
public class ResourceModelPair {
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
/*
|
||||
package net.montoyo.wd.client;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class StaticStateMapper extends StateMapperBase {
|
||||
public class StaticStateMapper {
|
||||
|
||||
private final ModelResourceLocation resLoc;
|
||||
|
||||
|
|
@ -20,8 +20,8 @@ public class StaticStateMapper extends StateMapperBase {
|
|||
|
||||
@Override
|
||||
@Nonnull
|
||||
protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState state) {
|
||||
protected ModelResourceLocation getModelResourceLocation(@Nonnull BlockState state) {
|
||||
return resLoc;
|
||||
}
|
||||
|
||||
}
|
||||
} */
|
||||
|
|
|
|||
|
|
@ -4,13 +4,10 @@
|
|||
|
||||
package net.montoyo.wd.client.renderers;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.ClientProxy;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
|
|
@ -19,7 +16,7 @@ import net.montoyo.wd.utilities.Vector3i;
|
|||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class ScreenRenderer extends TileEntitySpecialRenderer<TileEntityScreen> {
|
||||
public class ScreenRenderer extends BlockEntityRenderers<TileEntityScreen> {
|
||||
|
||||
private final Vector3f mid = new Vector3f();
|
||||
private final Vector3i tmpi = new Vector3i();
|
||||
|
|
@ -31,8 +28,6 @@ public class ScreenRenderer extends TileEntitySpecialRenderer<TileEntityScreen>
|
|||
return;
|
||||
|
||||
//Disable lighting
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
setLightmapDisabled(true);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_BLEND);
|
||||
|
|
@ -123,7 +118,7 @@ public class ScreenRenderer extends TileEntitySpecialRenderer<TileEntityScreen>
|
|||
glColor4f(1.f, 1.f, 1.f, 1.f); glTexCoord2f(1.f, 0.f); glVertex3f( sw, sh, 0.505f);
|
||||
glColor4f(1.f, 1.f, 1.f, 1.f); glTexCoord2f(0.f, 0.f); glVertex3f(-sw, sh, 0.505f);
|
||||
glEnd();
|
||||
GlStateManager.bindTexture(0); //Minecraft does shit with mah texture otherwise...
|
||||
RenderSystem.bindTexture(0); //Minecraft does shit with mah texture otherwise...
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
@ -136,12 +131,10 @@ public class ScreenRenderer extends TileEntitySpecialRenderer<TileEntityScreen>
|
|||
*/
|
||||
|
||||
//Re-enable lighting
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
setLightmapDisabled(false);
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
public void renderAABB(AxisAlignedBB bb) {
|
||||
public void renderAABB(AABB bb) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
|
@ -149,46 +142,47 @@ public class ScreenRenderer extends TileEntitySpecialRenderer<TileEntityScreen>
|
|||
glColor4f(0.f, 0.5f, 1.f, 0.75f);
|
||||
glDepthMask(false);
|
||||
|
||||
Tessellator t = Tessellator.getInstance();
|
||||
BufferBuilder vb = t.getBuffer();
|
||||
vb.begin(GL_QUADS, DefaultVertexFormats.POSITION);
|
||||
Tesselator t = new Tesselator();
|
||||
BufferBuilder vb = t.getBuilder();
|
||||
VertexBuffer tb = new VertexBuffer();
|
||||
vb.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
|
||||
|
||||
//Bottom
|
||||
vb.pos(bb.minX, bb.minY, bb.minZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.minY, bb.minZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.minX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.minY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.minY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.minY, bb.maxZ).endVertex();
|
||||
|
||||
//Top
|
||||
vb.pos(bb.minX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.minX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.maxY, bb.maxZ).endVertex();
|
||||
|
||||
//Left
|
||||
vb.pos(bb.minX, bb.minY, bb.minZ).endVertex();
|
||||
vb.pos(bb.minX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.minX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.minX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.minY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.maxY, bb.minZ).endVertex();
|
||||
|
||||
//Right
|
||||
vb.pos(bb.maxX, bb.minY, bb.minZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.minY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.maxY, bb.minZ).endVertex();
|
||||
|
||||
//Front
|
||||
vb.pos(bb.minX, bb.minY, bb.minZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.minY, bb.minZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.pos(bb.minX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.minY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.minY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.maxY, bb.minZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.maxY, bb.minZ).endVertex();
|
||||
|
||||
//Back
|
||||
vb.pos(bb.minX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.maxX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.pos(bb.minX, bb.maxY, bb.maxZ).endVertex();
|
||||
t.draw();
|
||||
vb.vertex(bb.minX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.minY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.maxX, bb.maxY, bb.maxZ).endVertex();
|
||||
vb.vertex(bb.minX, bb.maxY, bb.maxZ).endVertex();
|
||||
tb.draw();
|
||||
|
||||
glDepthMask(true);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
|
|
|||
|
|
@ -4,14 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
/*
|
||||
import net.montoyo.wd.entity.TileEntityCCInterface;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
@ -37,3 +30,4 @@ public class CCPeripheralProvider implements IPeripheralProvider {
|
|||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
package net.montoyo.wd.core;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
||||
public enum CraftComponent {
|
||||
|
|
@ -32,13 +34,8 @@ public enum CraftComponent {
|
|||
return name;
|
||||
}
|
||||
|
||||
public static String getWikiName(int meta) {
|
||||
CraftComponent[] values = values();
|
||||
return (meta >= 0 && meta < values.length) ? values[meta].wikiName : null;
|
||||
}
|
||||
|
||||
public ItemStack makeItemStack() {
|
||||
return new ItemStack(WebDisplays.INSTANCE.itemCraftComp, 1, ordinal());
|
||||
public ItemStack makeItemStack(CompoundTag compoundTag) {
|
||||
return new ItemStack(WebDisplays.INSTANCE.itemCraftComp, 1, compoundTag);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,26 +4,27 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.AbstractCriterionInstance;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.advancements.CriterionTrigger;
|
||||
import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance;
|
||||
import net.minecraft.advancements.critereon.DeserializationContext;
|
||||
import net.minecraft.advancements.critereon.EntityPredicate;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Criterion implements ICriterionTrigger<Criterion.Instance> {
|
||||
public class Criterion implements CriterionTrigger<Criterion.Instance> {
|
||||
|
||||
public static class Instance extends AbstractCriterionInstance {
|
||||
public static class Instance extends AbstractCriterionTriggerInstance {
|
||||
|
||||
public Instance(ResourceLocation id) {
|
||||
super(id);
|
||||
public Instance(ResourceLocation id, EntityPredicate.Composite arg2) {
|
||||
super(id, arg2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final ResourceLocation id;
|
||||
|
|
@ -40,12 +41,12 @@ public class Criterion implements ICriterionTrigger<Criterion.Instance> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addListener(@Nonnull PlayerAdvancements adv, @Nonnull Listener<Instance> l) {
|
||||
public void addPlayerListener(PlayerAdvancements adv, Listener<Instance> l) {
|
||||
map.computeIfAbsent(adv, k -> new ArrayList<>()).add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(@Nonnull PlayerAdvancements adv, @Nonnull Listener<Instance> l) {
|
||||
public void removePlayerListener(PlayerAdvancements adv, Listener<Instance> l) {
|
||||
map.computeIfPresent(adv, (k, v) -> {
|
||||
v.remove(l);
|
||||
return v.isEmpty() ? null : v;
|
||||
|
|
@ -53,14 +54,13 @@ public class Criterion implements ICriterionTrigger<Criterion.Instance> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeAllListeners(@Nonnull PlayerAdvancements adv) {
|
||||
public void removePlayerListeners(PlayerAdvancements adv) {
|
||||
map.remove(adv);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext ctx) {
|
||||
return new Instance(id);
|
||||
public @NotNull Instance createInstance(JsonObject json, DeserializationContext context) {
|
||||
return new Instance(id, EntityPredicate.Composite.fromJson(json, "instance", context));
|
||||
}
|
||||
|
||||
public void trigger(PlayerAdvancements ply) {
|
||||
|
|
@ -68,7 +68,7 @@ public class Criterion implements ICriterionTrigger<Criterion.Instance> {
|
|||
|
||||
if(listeners != null) {
|
||||
Listener[] copy = listeners.toArray(new Listener[0]); //We need to make a copy, otherwise we get a ConcurrentModificationException
|
||||
Arrays.stream(copy).forEach(l -> l.grantCriterion(ply));
|
||||
Arrays.stream(copy).forEach(l -> l.run(ply));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,10 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.montoyo.wd.entity.*;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum DefaultPeripheral implements IStringSerializable {
|
||||
public enum DefaultPeripheral {
|
||||
|
||||
KEYBOARD("keyboard", "Keyboard", TileEntityKeyboard.class), //WITH FACING (< 3)
|
||||
CC_INTERFACE("ccinterface", "ComputerCraft_Interface", TileEntityCCInterface.class),
|
||||
|
|
@ -21,9 +18,9 @@ public enum DefaultPeripheral implements IStringSerializable {
|
|||
|
||||
private final String name;
|
||||
private final String wikiName;
|
||||
private final Class<? extends TileEntity> teClass;
|
||||
private final Class<? extends BlockEntity> teClass;
|
||||
|
||||
DefaultPeripheral(String name, String wname, Class<? extends TileEntity> te) {
|
||||
DefaultPeripheral(String name, String wname, Class<? extends BlockEntity> te) {
|
||||
this.name = name;
|
||||
wikiName = wname;
|
||||
teClass = te;
|
||||
|
|
@ -36,13 +33,7 @@ public enum DefaultPeripheral implements IStringSerializable {
|
|||
return values()[meta & 3]; //With facing
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Class<? extends TileEntity> getTEClass() {
|
||||
public Class<? extends BlockEntity> getTEClass() {
|
||||
return teClass;
|
||||
}
|
||||
|
||||
|
|
@ -60,8 +51,4 @@ public enum DefaultPeripheral implements IStringSerializable {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public String getWikiName() {
|
||||
return wikiName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
||||
public enum DefaultUpgrade {
|
||||
|
|
@ -28,12 +28,6 @@ public enum DefaultUpgrade {
|
|||
}
|
||||
|
||||
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) {
|
||||
DefaultUpgrade[] values = values();
|
||||
return (meta >= 0 && meta < values.length) ? values[meta].wikiName : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
public interface IPeripheral {
|
||||
|
||||
boolean connect(World world, BlockPos blockPos, IBlockState blockState, Vector3i screenPos, BlockSide screenSide);
|
||||
boolean connect(Level world, BlockPos blockPos, BlockState blockState, Vector3i screenPos, BlockSide screenSide);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
|
||||
|
|
@ -14,8 +14,8 @@ import javax.annotation.Nullable;
|
|||
|
||||
public interface IUpgrade {
|
||||
|
||||
void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is);
|
||||
boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is); //Return true to prevent dropping
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
|
||||
public enum JSServerRequest {
|
||||
|
|
@ -23,7 +23,7 @@ public enum JSServerRequest {
|
|||
return (id >= 0 && id < values.length) ? values[id] : null;
|
||||
}
|
||||
|
||||
public boolean serialize(ByteBuf buf, Object[] data) {
|
||||
public boolean serialize(FriendlyByteBuf buf, Object[] data) {
|
||||
if(data.length != requestTypes.length)
|
||||
return false;
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ public enum JSServerRequest {
|
|||
return true;
|
||||
}
|
||||
|
||||
public Object[] deserialize(ByteBuf buf) {
|
||||
public Object[] deserialize(FriendlyByteBuf buf) {
|
||||
Object[] ret = new Object[requestTypes.length];
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class MissingPermissionException extends Exception {
|
||||
|
||||
private final int permission;
|
||||
private final EntityPlayerMP player;
|
||||
private final ServerPlayer player;
|
||||
|
||||
public MissingPermissionException(int p, EntityPlayerMP ply) {
|
||||
public MissingPermissionException(int p, ServerPlayer ply) {
|
||||
super("Player " + ply.getName() + " is missing permission " + p);
|
||||
permission = p;
|
||||
player = ply;
|
||||
|
|
@ -21,7 +21,7 @@ public class MissingPermissionException extends Exception {
|
|||
return permission;
|
||||
}
|
||||
|
||||
public EntityPlayerMP getPlayer() {
|
||||
public ServerPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
*/
|
||||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
/*
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Optional.Interface(iface = "net.montoyo.wd.core.IComputerArgs", modid = "opencomputers")
|
||||
public class OCArguments implements IComputerArgs {
|
||||
|
|
@ -43,4 +42,4 @@ public class OCArguments implements IComputerArgs {
|
|||
return ((Arguments) args).count();
|
||||
}
|
||||
|
||||
}
|
||||
} */
|
||||
|
|
|
|||
|
|
@ -6,20 +6,20 @@ package net.montoyo.wd.core;
|
|||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class WDCreativeTab extends CreativeTabs {
|
||||
public class WDCreativeTab extends CreativeModeTab {
|
||||
|
||||
public WDCreativeTab() {
|
||||
super("webdisplays");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getTabIconItem() {
|
||||
return new ItemStack(WebDisplays.INSTANCE.blockScreen);
|
||||
public ItemStack makeIcon() {
|
||||
return WebDisplays.INSTANCE.blockScreen.getItem();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
package net.montoyo.wd.data;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.net.client.CMessageOpenGui;
|
||||
|
||||
|
|
@ -29,11 +29,11 @@ public abstract class GuiData {
|
|||
return dataTable.get(name);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract GuiScreen createGui(GuiScreen old, World world);
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract Screen createGui(Screen old, Level world);
|
||||
public abstract String getName();
|
||||
|
||||
public void sendTo(EntityPlayerMP player) {
|
||||
public void sendTo(ServerPlayer player) {
|
||||
WebDisplays.NET_HANDLER.sendTo(new CMessageOpenGui(this), player);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,16 @@
|
|||
package net.montoyo.wd.data;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.montoyo.wd.client.gui.GuiKeyboard;
|
||||
|
|
@ -35,10 +42,10 @@ public class KeyboardData extends GuiData {
|
|||
kbZ = kbPos.getZ();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public GuiScreen createGui(GuiScreen old, World world) {
|
||||
TileEntity te = world.getTileEntity(pos.toBlock());
|
||||
public Screen createGui(Screen old, Level world) {
|
||||
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
||||
if(te == null || !(te instanceof TileEntityScreen)) {
|
||||
Log.error("TileEntity at %s is not a screen; can't open keyboard!", pos.toString());
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
package net.montoyo.wd.data;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.montoyo.wd.client.gui.GuiRedstoneCtrl;
|
||||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ public class RedstoneCtrlData extends GuiData {
|
|||
fallingEdgeURL = f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public GuiScreen createGui(GuiScreen old, World world) {
|
||||
public Screen createGui(Screen old, Level world) {
|
||||
return new GuiRedstoneCtrl(dimension, pos, risingEdgeURL, fallingEdgeURL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
package net.montoyo.wd.data;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.gui.GuiScreenConfig;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
|
|
@ -40,9 +40,9 @@ public class ScreenConfigData extends GuiData {
|
|||
onlyUpdate = false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public GuiScreen createGui(GuiScreen old, World world) {
|
||||
public Screen createGui(Screen old, Level world) {
|
||||
if(old != null && old instanceof GuiScreenConfig) {
|
||||
GuiScreenConfig gsc = (GuiScreenConfig) old;
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ public class ScreenConfigData extends GuiData {
|
|||
if(onlyUpdate)
|
||||
return null;
|
||||
|
||||
TileEntity te = world.getTileEntity(pos.toBlock());
|
||||
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
||||
if(te == null || !(te instanceof TileEntityScreen)) {
|
||||
Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString());
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,13 @@
|
|||
package net.montoyo.wd.data;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.montoyo.wd.client.gui.GuiServer;
|
||||
|
|
@ -26,9 +31,9 @@ public class ServerData extends GuiData {
|
|||
this.owner = owner;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public GuiScreen createGui(GuiScreen old, World world) {
|
||||
public Screen createGui(Screen old, Level world) {
|
||||
return new GuiServer(pos, owner);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
package net.montoyo.wd.data;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.montoyo.wd.client.gui.GuiSetURL2;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
|
|
@ -43,10 +43,11 @@ public class SetURLData extends GuiData {
|
|||
remoteLocation = new Vector3i(rl);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public GuiScreen createGui(GuiScreen old, World world) {
|
||||
TileEntity te = world.getTileEntity(pos.toBlock());
|
||||
public Screen createGui(Screen old, Level world) {
|
||||
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
||||
if(te == null || !(te instanceof TileEntityScreen)) {
|
||||
Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString());
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,8 @@
|
|||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.BitSet;
|
||||
|
||||
public class ItemMulti extends Item {
|
||||
|
|
@ -17,34 +13,12 @@ public class ItemMulti extends Item {
|
|||
protected final Enum[] values;
|
||||
protected final BitSet creativeTabItems;
|
||||
|
||||
public ItemMulti(Class<? extends Enum> cls) {
|
||||
public ItemMulti(Class<? extends Enum> cls, Properties properties) {
|
||||
super(properties);
|
||||
values = cls.getEnumConstants();
|
||||
creativeTabItems = new BitSet(values.length);
|
||||
creativeTabItems.set(0, values.length);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int meta = stack.getMetadata();
|
||||
String ret = getUnlocalizedName();
|
||||
|
||||
if(meta >= 0 && meta < values.length)
|
||||
return ret + '.' + values[meta];
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> items) {
|
||||
if(isInCreativeTab(tab)) {
|
||||
for(int i = 0; i < values.length; i++) {
|
||||
if(creativeTabItems.get(i))
|
||||
items.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
setDamage(this.getDefaultInstance(),0);
|
||||
}
|
||||
|
||||
public Enum[] getEnumValues() {
|
||||
|
|
|
|||
|
|
@ -4,17 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.block.BlockScreen;
|
||||
import net.montoyo.wd.data.ScreenConfigData;
|
||||
|
|
@ -25,8 +15,6 @@ import net.montoyo.wd.utilities.Util;
|
|||
import net.montoyo.wd.utilities.Vector3i;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemScreenConfigurator extends Item implements WDItem {
|
||||
|
||||
|
|
@ -66,15 +54,4 @@ public class ItemScreenConfigurator extends Item implements WDItem {
|
|||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
||||
WDItem.addInformation(tt);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return "Screen_Configurator";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,8 @@
|
|||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.montoyo.wd.core.DefaultUpgrade;
|
||||
import net.montoyo.wd.core.IUpgrade;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
|
|
@ -18,24 +13,22 @@ import net.montoyo.wd.utilities.BlockSide;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
||||
|
||||
public ItemUpgrade() {
|
||||
super(DefaultUpgrade.class);
|
||||
setUnlocalizedName("webdisplays.upgrade");
|
||||
super(DefaultUpgrade.class, new Properties());
|
||||
setRegistryName("upgrade");
|
||||
setCreativeTab(WebDisplays.CREATIVE_TAB);
|
||||
//TODO set creative tab to WebDisplays.CREATIVE_TAB
|
||||
}
|
||||
|
||||
@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
|
||||
public boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is) {
|
||||
if(is.getMetadata() == DefaultUpgrade.LASER_MOUSE.ordinal())
|
||||
public boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
|
||||
if(DefaultUpgrade.LASER_MOUSE.matches(is))
|
||||
tes.clearLaserUser(screenSide);
|
||||
|
||||
return false;
|
||||
|
|
@ -43,30 +36,17 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
|||
|
||||
@Override
|
||||
public boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack) {
|
||||
return otherStack.getItem() == this && otherStack.getMetadata() == myStack.getMetadata();
|
||||
}
|
||||
|
||||
@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);
|
||||
return otherStack.getItem() == this && otherStack == myStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJSName(@Nonnull ItemStack is) {
|
||||
int meta = is.getMetadata();
|
||||
ItemStack meta = is;
|
||||
DefaultUpgrade[] upgrades = DefaultUpgrade.values();
|
||||
|
||||
if(meta < 0 || meta >= upgrades.length)
|
||||
if(meta.isEmpty())
|
||||
return "webdisplays:wtf";
|
||||
else
|
||||
return "webdisplays:" + upgrades[meta];
|
||||
return "webdisplays:" + is;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWikiName(@Nonnull ItemStack is) {
|
||||
return DefaultUpgrade.getWikiName(is.getMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,23 +4,18 @@
|
|||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public interface WDItem {
|
||||
|
||||
@Nullable
|
||||
String getWikiName(@Nonnull ItemStack is);
|
||||
|
||||
static void addInformation(@Nullable List<String> tt) {
|
||||
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 final ByteBuffer readBuffer = ByteBuffer.allocateDirect(8192);
|
||||
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 ClientTask currentTask;
|
||||
private volatile boolean authenticated;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
package net.montoyo.wd.utilities;
|
||||
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
public final class AABB {
|
||||
|
||||
public final Vector3i start;
|
||||
|
|
@ -33,7 +31,7 @@ public final class AABB {
|
|||
end.z = Math.max(a.z, b.z);
|
||||
}
|
||||
|
||||
public AABB(AxisAlignedBB bb) {
|
||||
public AABB(net.minecraft.world.phys.AABB bb) {
|
||||
start = new Vector3i();
|
||||
end = new Vector3i();
|
||||
|
||||
|
|
@ -70,8 +68,8 @@ public final class AABB {
|
|||
return this;
|
||||
}
|
||||
|
||||
public AxisAlignedBB toMc() {
|
||||
return new AxisAlignedBB((double) start.x, (double) start.y, (double) start.z, (double) end.x, (double) end.y, (double) end.z);
|
||||
public net.minecraft.world.phys.AABB toMc() {
|
||||
return new net.minecraft.world.phys.AABB(start.x, start.y, start.z, end.x, end.y, end.z);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
package net.montoyo.wd.utilities;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
||||
public abstract class Multiblock {
|
||||
|
|
@ -39,7 +39,7 @@ public abstract class Multiblock {
|
|||
public static final BlockOverride NULL_OVERRIDE = new BlockOverride(null, OverrideAction.NONE);
|
||||
|
||||
//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)
|
||||
override = NULL_OVERRIDE;
|
||||
|
|
@ -64,7 +64,7 @@ public abstract class Multiblock {
|
|||
}
|
||||
|
||||
//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();
|
||||
Vector3i pos = origin.clone();
|
||||
|
|
@ -93,7 +93,7 @@ public abstract class Multiblock {
|
|||
|
||||
//Origin and size stays constant.
|
||||
//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();
|
||||
BlockPos.MutableBlockPos bp = new BlockPos.MutableBlockPos();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package net.montoyo.wd.utilities;
|
|||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -30,8 +30,8 @@ public final class NameUUIDPair {
|
|||
uuid = profile.getId();
|
||||
}
|
||||
|
||||
public NameUUIDPair(ByteBuf bb) {
|
||||
name = ByteBufUtils.readUTF8String(bb);
|
||||
public NameUUIDPair(FriendlyByteBuf bb) {
|
||||
name = bb.readUtf();
|
||||
|
||||
long msb = bb.readLong();
|
||||
long lsb = bb.readLong();
|
||||
|
|
@ -63,8 +63,8 @@ public final class NameUUIDPair {
|
|||
return name.isEmpty() && uuid.getMostSignificantBits() == 0L && uuid.getLeastSignificantBits() == 0L;
|
||||
}
|
||||
|
||||
public void writeTo(ByteBuf bb) {
|
||||
ByteBufUtils.writeUTF8String(bb, name);
|
||||
public void writeTo(FriendlyByteBuf bb) {
|
||||
bb.writeUtf(name);
|
||||
bb.writeLong(uuid.getMostSignificantBits());
|
||||
bb.writeLong(uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package net.montoyo.wd.utilities;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
|
||||
package net.montoyo.wd.utilities;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.NbtComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
|
@ -18,7 +20,7 @@ import java.util.UUID;
|
|||
|
||||
public abstract class Util {
|
||||
|
||||
public static void serialize(ByteBuf bb, Object f) {
|
||||
public static void serialize(FriendlyByteBuf bb, Object f) {
|
||||
Class<?> cls = f.getClass();
|
||||
|
||||
if(cls == Integer.class || cls == Integer.TYPE)
|
||||
|
|
@ -30,7 +32,7 @@ public abstract class Util {
|
|||
else if(cls == Boolean.class || cls == Boolean.TYPE)
|
||||
bb.writeBoolean((Boolean) f);
|
||||
else if(cls == String.class)
|
||||
ByteBufUtils.writeUTF8String(bb, (String) f);
|
||||
bb.writeUtf((String) f);
|
||||
else if(cls == NameUUIDPair.class)
|
||||
((NameUUIDPair) f).writeTo(bb);
|
||||
else if(cls.isEnum())
|
||||
|
|
@ -57,7 +59,7 @@ public abstract class Util {
|
|||
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)
|
||||
return bb.readInt();
|
||||
else if(cls == Float.class || cls == Float.TYPE)
|
||||
|
|
@ -67,7 +69,7 @@ public abstract class Util {
|
|||
else if(cls == Boolean.class || cls == Boolean.TYPE)
|
||||
return bb.readBoolean();
|
||||
else if(cls == String.class)
|
||||
return ByteBufUtils.readUTF8String(bb);
|
||||
return bb.readUtf();
|
||||
else if(cls == NameUUIDPair.class)
|
||||
return new NameUUIDPair(bb);
|
||||
else if(cls.isEnum())
|
||||
|
|
@ -128,16 +130,16 @@ public abstract class Util {
|
|||
return idx ^ (idx >> 16);
|
||||
}
|
||||
|
||||
public static void toast(EntityPlayer player, String key, Object... data) {
|
||||
toast(player, TextFormatting.RED, key, data);
|
||||
public static void toast(Player player, String key, Object... data) {
|
||||
toast(player, ChatFormatting.RED, key, data);
|
||||
}
|
||||
|
||||
public static void toast(EntityPlayer player, TextFormatting color, String key, Object... data) {
|
||||
ITextComponent root = new TextComponentString("[WebDisplays] ");
|
||||
root.setStyle((new Style()).setColor(color));
|
||||
root.appendSibling(new TextComponentTranslation("webdisplays.message." + key, data));
|
||||
public static void toast(Player player, ChatFormatting color, String key, Object... data) {
|
||||
NbtComponent root = (NbtComponent) FormattedText.of("[WebDisplays] ");
|
||||
root.withStyle(color);
|
||||
root.append(new TranslatableComponent("webdisplays.message." + key, data));
|
||||
|
||||
player.sendMessage(root);
|
||||
player.sendMessage(root, player.getUUID());
|
||||
}
|
||||
|
||||
public static void silentClose(Object obj) {
|
||||
|
|
@ -175,17 +177,17 @@ public abstract class Util {
|
|||
return j.toString();
|
||||
}
|
||||
|
||||
public static NBTTagCompound writeOwnerToNBT(NBTTagCompound tag, NameUUIDPair owner) {
|
||||
public static CompoundTag writeOwnerToNBT(CompoundTag tag, NameUUIDPair owner) {
|
||||
if(owner != null) {
|
||||
tag.setLong("OwnerMSB", owner.uuid.getMostSignificantBits());
|
||||
tag.setLong("OwnerLSB", owner.uuid.getLeastSignificantBits());
|
||||
tag.setString("OwnerName", owner.name);
|
||||
tag.putLong("OwnerMSB", owner.uuid.getMostSignificantBits());
|
||||
tag.putLong("OwnerLSB", owner.uuid.getLeastSignificantBits());
|
||||
tag.putString("OwnerName", owner.name);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static NameUUIDPair readOwnerFromNBT(NBTTagCompound tag) {
|
||||
public static NameUUIDPair readOwnerFromNBT(CompoundTag tag) {
|
||||
long msb = tag.getLong("OwnerMSB");
|
||||
long lsb = tag.getLong("OwnerLSB");
|
||||
String str = tag.getString("OwnerName");
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
package net.montoyo.wd.utilities;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public final class Vector3i {
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ public final class Vector3i {
|
|||
}
|
||||
|
||||
public void toBlock(BlockPos.MutableBlockPos bp) {
|
||||
bp.setPos(x, y, z);
|
||||
bp.set(x, y, z);
|
||||
}
|
||||
|
||||
public int getChunkLocalPos()
|
||||
|
|
|
|||
47
src/main/resources/META-INF/mods.toml
Normal file
47
src/main/resources/META-INF/mods.toml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
modLoader="javafml" #mandatory
|
||||
|
||||
loaderVersion="[40,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
|
||||
license="BSD-3-Clause"
|
||||
|
||||
issueTrackerURL="" #optional
|
||||
|
||||
[[mods]] #mandatory
|
||||
|
||||
modId="webdisplays" #mandatory
|
||||
|
||||
version="1.0.0" #mandatory
|
||||
|
||||
displayName="MCEF" #mandatory
|
||||
|
||||
displayURL="https://github.com/Mysticpasta1/webdisplays" #optional
|
||||
|
||||
logoFile= "" #optional
|
||||
|
||||
credits="" #optional
|
||||
|
||||
authors="Mysticpasta1, WaterPicker, Montoyo" #optional
|
||||
|
||||
description='''
|
||||
'''
|
||||
|
||||
[[dependencies.webdisplays]] #optional
|
||||
modId="forge" #mandatory
|
||||
mandatory=true #mandatory
|
||||
versionRange="[40,)" #mandatory
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.webdisplays]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.18.2,1.19)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.webdisplays]]
|
||||
modId="forgecef"
|
||||
mandatory=true
|
||||
versionRange="[1.0.0, )"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
]
|
||||
},
|
||||
"mixins": [
|
||||
"modid.mixins.json"
|
||||
"webdisplays.mixin.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user