Browse Source

server mod upload script, update to 1.14.4, dependency fix, bugfixes

Kajetan Johannes Hammerle 4 years ago
parent
commit
3e9e7f679a
31 changed files with 323 additions and 185 deletions
  1. 5 3
      build.gradle
  2. 0 20
      runClient.launch
  3. 0 17
      runServer.launch
  4. 32 0
      src/main/java/me/km/ClassLoaderUtils.java
  5. 1 1
      src/main/java/me/km/Client.java
  6. 2 6
      src/main/java/me/km/KajetansMod.java
  7. 1 1
      src/main/java/me/km/Server.java
  8. 1 0
      src/main/java/me/km/databank/DataBank.java
  9. 2 2
      src/main/java/me/km/entities/ModelHuman.java
  10. 2 2
      src/main/java/me/km/entities/RenderHuman.java
  11. 1 1
      src/main/java/me/km/events/CustomEventCaller.java
  12. 10 10
      src/main/java/me/km/items/ModelCylinder.java
  13. 10 10
      src/main/java/me/km/items/ModelHat.java
  14. 1 1
      src/main/java/me/km/networking/KeyManager.java
  15. 1 2
      src/main/java/me/km/overrides/ModCapeLayer.java
  16. 7 1
      src/main/java/me/km/overrides/ModEntityPlayerMP.java
  17. 7 6
      src/main/java/me/km/overrides/ModPlayerList.java
  18. 97 22
      src/main/java/me/km/permissions/ModCommandManager.java
  19. 7 2
      src/main/java/me/km/permissions/PermissionManager.java
  20. 1 1
      src/main/java/me/km/playerbank/PlayerManager.java
  21. 1 1
      src/main/java/me/km/plots/ProtectionEvents.java
  22. 0 1
      src/main/java/me/km/snuviscript/CommandScript.java
  23. 83 25
      src/main/java/me/km/snuviscript/MinecraftFunctions.java
  24. 1 2
      src/main/java/me/km/snuviscript/ScriptEvents.java
  25. 2 2
      src/main/java/me/km/snuviscript/ScriptVars.java
  26. 33 0
      src/main/java/me/km/utils/Mapper.java
  27. 2 23
      src/main/java/me/km/utils/Utils.java
  28. 1 1
      src/main/java/me/km/world/ModDimensionFactory.java
  29. 8 20
      src/main/java/me/km/world/WorldManager.java
  30. 2 2
      src/main/resources/META-INF/mods.toml
  31. 2 0
      uploadMod.sh

+ 5 - 3
build.gradle

@@ -20,7 +20,7 @@ archivesBaseName = 'km'
 sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
 
 minecraft {
-    mappings channel: 'snapshot', version: '20190621-1.14.2'
+    mappings channel: 'snapshot', version: '20190719-1.14.3'
 
     runs {
         client {
@@ -39,8 +39,10 @@ minecraft {
 }
 
 dependencies {
-    minecraft 'net.minecraftforge:forge:1.14.2-26.0.55'
+    minecraft 'net.minecraftforge:forge:1.14.4-28.0.91'
+    
     compile 'mysql:mysql-connector-java:5.1.42'
+    
     compile files('./libs/SnuviScriptRecoded.jar')
     compile files('./libs/kcm-1.0.jar')
-}
+}

+ 0 - 20
runClient.launch

@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
-  <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="KajetansMod"/>
-  <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.minecraftforge.userdev.LaunchTesting"/>
-  <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dforge.logging.console.level=warn -Dforge.logging.markers=SCAN,REGISTRIES,REGISTRYDUMP"/>
-  <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value=""/>
-  <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansMod/run"/>
-  <mapAttribute key="org.eclipse.debug.core.environmentVariables">
-    <mapEntry key="MOD_CLASSES" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansMod/bin/main:/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansMod/bin/main"/>
-    <mapEntry key="MCP_MAPPINGS" value="snapshot_20180921-1.13"/>
-    <mapEntry key="MCP_VERSION" value="20190213.203750"/>
-    <mapEntry key="FORGE_VERSION" value="25.0.219"/>
-    <mapEntry key="assetIndex" value="1.13.1"/>
-    <mapEntry key="assetDirectory" value="/home/kajetan/.gradle/caches/forge_gradle/assets"/>
-    <mapEntry key="nativesDirectory" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansMod/build/natives"/>
-    <mapEntry key="FORGE_GROUP" value="net.minecraftforge"/>
-    <mapEntry key="target" value="fmluserdevclient"/>
-    <mapEntry key="MC_VERSION" value="1.13.2"/>
-  </mapAttribute>
-</launchConfiguration>

+ 0 - 17
runServer.launch

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
-  <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="KajetansMod"/>
-  <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.minecraftforge.userdev.LaunchTesting"/>
-  <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dforge.logging.console.level=warn -Dforge.logging.markers=SCAN,REGISTRIES,REGISTRYDUMP"/>
-  <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value=""/>
-  <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansMod/run"/>
-  <mapAttribute key="org.eclipse.debug.core.environmentVariables">
-    <mapEntry key="MOD_CLASSES" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansMod/bin/main:/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansMod/bin/main"/>
-    <mapEntry key="MCP_MAPPINGS" value="snapshot_20180921-1.13"/>
-    <mapEntry key="MCP_VERSION" value="20190213.203750"/>
-    <mapEntry key="FORGE_VERSION" value="25.0.219"/>
-    <mapEntry key="FORGE_GROUP" value="net.minecraftforge"/>
-    <mapEntry key="target" value="fmluserdevserver"/>
-    <mapEntry key="MC_VERSION" value="1.13.2"/>
-  </mapAttribute>
-</launchConfiguration>

+ 32 - 0
src/main/java/me/km/ClassLoaderUtils.java

@@ -0,0 +1,32 @@
+package me.km;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class ClassLoaderUtils
+{
+    public static void loadDependencies()
+    {
+        URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
+        
+        try
+        {
+            Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
+            method.setAccessible(true);
+            method.invoke(sysloader, getURL("mods/libs/SnuviScriptRecoded.jar")); 
+            method.invoke(sysloader, getURL("mods/libs/mysql-connector-java.jar"));
+        }
+        catch(Throwable t)
+        {
+            t.printStackTrace();
+        }
+    }
+    
+    private static URL getURL(String s) throws MalformedURLException
+    {
+        return new File(s).toURI().toURL();
+    }
+}

+ 1 - 1
src/main/java/me/km/Client.java

@@ -40,7 +40,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
 import net.minecraftforge.common.MinecraftForge;
 import net.minecraftforge.event.entity.player.ItemTooltipEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.event.TickEvent;
 
 @OnlyIn(Dist.CLIENT)
 public class Client 

+ 2 - 6
src/main/java/me/km/KajetansMod.java

@@ -3,7 +3,6 @@ package me.km;
 import me.km.networking.ModPacketHandler;
 import me.km.world.ModWorldGeneration;
 import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fluids.FluidRegistry;
 import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
 import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
 import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
@@ -19,13 +18,10 @@ public class KajetansMod
 {    
     public static final String MODID = "km";
     
-    static
-    {
-        FluidRegistry.enableUniversalBucket();
-    }
-    
     public KajetansMod()
     {
+        ClassLoaderUtils.loadDependencies();
+        
         IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
         bus.addListener(this::init);
         bus.addListener(this::setupServer);

+ 1 - 1
src/main/java/me/km/Server.java

@@ -84,7 +84,7 @@ public class Server
         MinecraftForge.EVENT_BUS.register(scriptEvents);
         
         // command manager
-        commands = new ModCommandManager(true, perms, scriptEvents, scripts);
+        commands = new ModCommandManager(true, perms, scriptEvents, scripts, scheduler);
         ReflectionUtils.setCommandManager(server, commands);
         commands.registerCommand(new CommandGiveUp(scripts));
         commands.registerCommand(new CommandScript(scripts, server));  

+ 1 - 0
src/main/java/me/km/databank/DataBank.java

@@ -82,6 +82,7 @@ public class DataBank
             {
                 old.close();
             }
+            return ps;
         }
         catch(SQLException ex)
         {

+ 2 - 2
src/main/java/me/km/entities/ModelHuman.java

@@ -20,8 +20,8 @@ public class ModelHuman extends PlayerModel<EntityHuman>
         GlStateManager.translatef(0.0F, -1.5f * factor + 1.5f, 0.0F);
         GlStateManager.scalef(factor, factor, factor);
 
-        this.field_78116_c.render(scale);
-        this.field_78115_e.render(scale);
+        this.bipedHead.render(scale);
+        this.bipedBody.render(scale);
         this.bipedRightArm.render(scale);
         this.bipedLeftArm.render(scale);
         this.bipedRightLeg.render(scale);

+ 2 - 2
src/main/java/me/km/entities/RenderHuman.java

@@ -44,9 +44,9 @@ public class RenderHuman extends LivingRenderer<EntityHuman, ModelHuman>
         GlStateManager.setProfile(GlStateManager.Profile.PLAYER_SKIN);
         if(ent.isSlim())
         {
-            this.field_77045_g = alex;
+            this.entityModel = alex;
             super.doRender(ent, x, y, z, entityYaw, partialTicks);
-            this.field_77045_g = steve;
+            this.entityModel = steve;
         }
         else
         {

+ 1 - 1
src/main/java/me/km/events/CustomEventCaller.java

@@ -15,7 +15,7 @@ import net.minecraft.util.DamageSource;
 import net.minecraftforge.event.entity.living.LivingHurtEvent;
 import net.minecraftforge.eventbus.api.EventPriority;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.event.TickEvent;
 
 public class CustomEventCaller 
 {

+ 10 - 10
src/main/java/me/km/items/ModelCylinder.java

@@ -33,8 +33,8 @@ public class ModelCylinder extends BipedModel
         secHeadPart.mirror = true;
         setRotation(secHeadPart, 0, 0, 0);
          
-        field_78116_c.addChild(firstHeadPart);
-        field_78116_c.addChild(secHeadPart);
+        bipedHead.addChild(firstHeadPart);
+        bipedHead.addChild(secHeadPart);
     }
     
     @Override
@@ -44,13 +44,13 @@ public class ModelCylinder extends BipedModel
         if(entityIn instanceof ArmorStandEntity)
         {
             ArmorStandEntity ase = (ArmorStandEntity) entityIn;
-            this.field_78116_c.rotateAngleX = FACTOR * ase.getHeadRotation().getX();
-            this.field_78116_c.rotateAngleY = FACTOR * ase.getHeadRotation().getY();
-            this.field_78116_c.rotateAngleZ = FACTOR * ase.getHeadRotation().getZ();
-            this.field_78116_c.setRotationPoint(0.0F, 1.0F, 0.0F);
-            this.field_78115_e.rotateAngleX = FACTOR * ase.getBodyRotation().getX();
-            this.field_78115_e.rotateAngleY = FACTOR * ase.getBodyRotation().getY();
-            this.field_78115_e.rotateAngleZ = FACTOR * ase.getBodyRotation().getZ();
+            this.bipedHead.rotateAngleX = FACTOR * ase.getHeadRotation().getX();
+            this.bipedHead.rotateAngleY = FACTOR * ase.getHeadRotation().getY();
+            this.bipedHead.rotateAngleZ = FACTOR * ase.getHeadRotation().getZ();
+            this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F);
+            this.bipedBody.rotateAngleX = FACTOR * ase.getBodyRotation().getX();
+            this.bipedBody.rotateAngleY = FACTOR * ase.getBodyRotation().getY();
+            this.bipedBody.rotateAngleZ = FACTOR * ase.getBodyRotation().getZ();
             this.bipedLeftArm.rotateAngleX = FACTOR * ase.getLeftArmRotation().getX();
             this.bipedLeftArm.rotateAngleY = FACTOR * ase.getLeftArmRotation().getY();
             this.bipedLeftArm.rotateAngleZ = FACTOR * ase.getLeftArmRotation().getZ();
@@ -65,7 +65,7 @@ public class ModelCylinder extends BipedModel
             this.bipedRightLeg.rotateAngleY = FACTOR * ase.getRightLegRotation().getY();
             this.bipedRightLeg.rotateAngleZ = FACTOR * ase.getRightLegRotation().getZ();
             this.bipedRightLeg.setRotationPoint(-1.9F, 11.0F, 0.0F);
-            this.bipedHeadwear.func_217177_a(this.field_78116_c);
+            this.bipedHeadwear.copyModelAngles(this.bipedHead);
             return;
         }
         super.setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor);

+ 10 - 10
src/main/java/me/km/items/ModelHat.java

@@ -33,8 +33,8 @@ public class ModelHat extends BipedModel
         secHeadPart.mirror = true;
         setRotation(secHeadPart, 0, 0, 0);
          
-        field_78116_c.addChild(firstHeadPart);
-        field_78116_c.addChild(secHeadPart);
+        bipedHead.addChild(firstHeadPart);
+        bipedHead.addChild(secHeadPart);
     }
     
     @Override
@@ -44,13 +44,13 @@ public class ModelHat extends BipedModel
         if(entityIn instanceof ArmorStandEntity)
         {
             ArmorStandEntity ase = (ArmorStandEntity) entityIn;
-            this.field_78116_c.rotateAngleX = FACTOR * ase.getHeadRotation().getX();
-            this.field_78116_c.rotateAngleY = FACTOR * ase.getHeadRotation().getY();
-            this.field_78116_c.rotateAngleZ = FACTOR * ase.getHeadRotation().getZ();
-            this.field_78116_c.setRotationPoint(0.0F, 1.0F, 0.0F);
-            this.field_78115_e.rotateAngleX = FACTOR * ase.getBodyRotation().getX();
-            this.field_78115_e.rotateAngleY = FACTOR * ase.getBodyRotation().getY();
-            this.field_78115_e.rotateAngleZ = FACTOR * ase.getBodyRotation().getZ();
+            this.bipedHead.rotateAngleX = FACTOR * ase.getHeadRotation().getX();
+            this.bipedHead.rotateAngleY = FACTOR * ase.getHeadRotation().getY();
+            this.bipedHead.rotateAngleZ = FACTOR * ase.getHeadRotation().getZ();
+            this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F);
+            this.bipedBody.rotateAngleX = FACTOR * ase.getBodyRotation().getX();
+            this.bipedBody.rotateAngleY = FACTOR * ase.getBodyRotation().getY();
+            this.bipedBody.rotateAngleZ = FACTOR * ase.getBodyRotation().getZ();
             this.bipedLeftArm.rotateAngleX = FACTOR * ase.getLeftArmRotation().getX();
             this.bipedLeftArm.rotateAngleY = FACTOR * ase.getLeftArmRotation().getY();
             this.bipedLeftArm.rotateAngleZ = FACTOR * ase.getLeftArmRotation().getZ();
@@ -65,7 +65,7 @@ public class ModelHat extends BipedModel
             this.bipedRightLeg.rotateAngleY = FACTOR * ase.getRightLegRotation().getY();
             this.bipedRightLeg.rotateAngleZ = FACTOR * ase.getRightLegRotation().getZ();
             this.bipedRightLeg.setRotationPoint(-1.9F, 11.0F, 0.0F);
-            this.bipedHeadwear.func_217177_a(this.field_78116_c);
+            this.bipedHeadwear.copyModelAngles(this.bipedHead);
             return;
         }
         super.setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor);

+ 1 - 1
src/main/java/me/km/networking/KeyManager.java

@@ -2,7 +2,7 @@ package me.km.networking;
 
 import net.minecraft.client.settings.KeyBinding;
 import net.minecraftforge.fml.client.registry.ClientRegistry;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.event.TickEvent;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 import net.minecraftforge.eventbus.api.SubscribeEvent;

+ 1 - 2
src/main/java/me/km/overrides/ModCapeLayer.java

@@ -1,7 +1,6 @@
 package me.km.overrides;
 
 import com.mojang.blaze3d.platform.GlStateManager;
-import me.km.KajetansMod;
 import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
 import net.minecraft.client.renderer.entity.IEntityRenderer;
 import net.minecraft.client.renderer.entity.layers.CapeLayer;
@@ -60,7 +59,7 @@ public class ModCapeLayer extends CapeLayer
 
                 float f4 = MathHelper.lerp(p_212842_4_, entityIn.prevCameraYaw, entityIn.cameraYaw);
                 f1 = f1 + MathHelper.sin(MathHelper.lerp(p_212842_4_, entityIn.prevDistanceWalkedModified, entityIn.distanceWalkedModified) * 6.0F) * 32.0F * f4;
-                if(entityIn.func_213287_bg())
+                if(entityIn.shouldRenderSneaking())
                 {
                     f1 += 25.0F;
                 }

+ 7 - 1
src/main/java/me/km/overrides/ModEntityPlayerMP.java

@@ -9,7 +9,7 @@ import net.minecraft.server.MinecraftServer;
 import net.minecraft.server.management.PlayerInteractionManager;
 import net.minecraft.util.text.ITextComponent;
 import net.minecraft.util.text.StringTextComponent;
-import net.minecraft.world.ServerWorld;
+import net.minecraft.world.server.ServerWorld;
 
 public class ModEntityPlayerMP extends ServerPlayerEntity
 {
@@ -108,4 +108,10 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
         timedData.clear();
         data.clear();
     }
+
+    @Override
+    protected int getPermissionLevel()
+    {
+        return 4;
+    }
 }

+ 7 - 6
src/main/java/me/km/overrides/ModPlayerList.java

@@ -3,7 +3,6 @@ package me.km.overrides;
 import com.google.common.collect.Lists;
 import com.mojang.authlib.GameProfile;
 import io.netty.buffer.Unpooled;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -44,8 +43,9 @@ import net.minecraft.util.math.BlockPos;
 import net.minecraft.util.math.Vec3d;
 import net.minecraft.util.text.ITextComponent;
 import net.minecraft.util.text.TranslationTextComponent;
+import net.minecraft.world.GameRules;
 import net.minecraft.world.IWorld;
-import net.minecraft.world.ServerWorld;
+import net.minecraft.world.server.ServerWorld;
 import net.minecraft.world.dimension.DimensionType;
 import net.minecraft.world.storage.WorldInfo;
 import org.apache.logging.log4j.LogManager;
@@ -119,7 +119,8 @@ public class ModPlayerList extends DedicatedPlayerList
         setPlayerGameTypeBasedOnOther(p, null, sw);
         ServerPlayNetHandler spnh = new ServerPlayNetHandler(this.server, netManager, p);
         ModPacketHandler.syncDimensions(p);
-        spnh.sendPacket(new SJoinGamePacket(p.getEntityId(), p.interactionManager.getGameType(), wi.isHardcore(), sw.dimension.getType(), this.getMaxPlayers(), wi.getGenerator(), getViewDistance(), sw.getGameRules().getBoolean("reducedDebugInfo")));
+        net.minecraftforge.fml.network.NetworkHooks.sendMCRegistryPackets(netManager, "PLAY_TO_CLIENT");
+        spnh.sendPacket(new SJoinGamePacket(p.getEntityId(), p.interactionManager.getGameType(), wi.isHardcore(), sw.dimension.getType(), this.getMaxPlayers(), wi.getGenerator(), getViewDistance(), sw.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO)));
         spnh.sendPacket(new SCustomPayloadPlayPacket(SCustomPayloadPlayPacket.BRAND, (new PacketBuffer(Unpooled.buffer())).writeString(this.getServer().getServerModName())));
         spnh.sendPacket(new SServerDifficultyPacket(wi.getDifficulty(), wi.isDifficultyLocked()));
         spnh.sendPacket(new SPlayerAbilitiesPacket(p.abilities));
@@ -133,7 +134,7 @@ public class ModPlayerList extends DedicatedPlayerList
         this.server.refreshStatusNextTick();
 
         spnh.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
-        this.players.add(p);
+        this.addPlayer(p);
         this.uuidToPlayerMap.put(p.getUniqueID(), p);
         this.sendPacketToAllPlayers(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, p));
 
@@ -259,7 +260,7 @@ public class ModPlayerList extends DedicatedPlayerList
             dim = DimensionType.OVERWORLD;
         }
 
-        this.players.remove(pIn);
+        this.removePlayer(pIn);
         pIn.getServerWorld().removePlayer(pIn, true); // Forge: keep data until copyFrom called
         BlockPos blockpos = pIn.getBedLocation(dim);
         boolean flag = pIn.isSpawnForced(dim);
@@ -319,7 +320,7 @@ public class ModPlayerList extends DedicatedPlayerList
         this.sendWorldInfo(p, serverworld);
         this.updatePermissionLevel(p);
         serverworld.addRespawnedPlayer(p);
-        this.players.add(p);
+        this.addPlayer(p);
         this.uuidToPlayerMap.put(p.getUniqueID(), p);
         p.addSelfToInternalCraftingInventory();
         p.setHealth(p.getHealth());

+ 97 - 22
src/main/java/me/km/permissions/ModCommandManager.java

@@ -1,30 +1,54 @@
 package me.km.permissions;
 
+import com.google.common.collect.Maps;
+import com.mojang.brigadier.builder.ArgumentBuilder;
+import com.mojang.brigadier.builder.RequiredArgumentBuilder;
+import com.mojang.brigadier.tree.CommandNode;
+import com.mojang.brigadier.tree.RootCommandNode;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
-import me.km.Server;
+import java.util.Map;
+import me.hammerle.snuviscript.code.ISnuviScheduler;
 import me.km.events.CommandEvent;
 import me.km.snuviscript.ScriptEvents;
 import me.km.snuviscript.Scripts;
 import net.minecraft.command.CommandSource;
 import net.minecraft.command.Commands;
 import net.minecraft.command.ICommandSource;
+import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.command.arguments.SuggestionProviders;
 import net.minecraft.entity.Entity;
 import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.network.play.server.SCommandListPacket;
 
 public class ModCommandManager extends Commands
 {
-    private final HashSet<String> vanilla = new HashSet<>();
+    private final HashSet<String> otherCommands = new HashSet<>();
+    
     private final HashMap<String, Command> commands = new HashMap<>();
     private final PermissionManager perms;
     private final ScriptEvents events;
     private final Scripts scripts;
 
-    public ModCommandManager(boolean isDedicatedServer, PermissionManager perms, ScriptEvents events, Scripts scripts)
+    public ModCommandManager(boolean isDedicatedServer, PermissionManager perms, ScriptEvents events, Scripts scripts, ISnuviScheduler scheduler)
     {
         super(isDedicatedServer);
-        getDispatcher().getRoot().getChildren().forEach(c -> vanilla.add(c.getName()));
+        getDispatcher().getRoot().getChildren().forEach(c -> 
+        {
+            otherCommands.add(c.getName());
+        });
+        scheduler.scheduleTask(() -> 
+        {
+            getDispatcher().getRoot().getChildren().forEach(c -> 
+            {
+                if(otherCommands.add(c.getName()))
+                {
+                    perms.addOtherGroupPermission(c.getName());
+                }
+            }); 
+        });
         this.perms = perms;
         this.events = events;
         this.scripts = scripts;
@@ -103,20 +127,31 @@ public class ModCommandManager extends Commands
         return cs.getServer();
     }
     
+    private String lowerRawCommand(String raw)
+    {
+        int index = raw.indexOf(" ");
+        if(index == -1)
+        {
+            return raw.toLowerCase();
+        }
+        return raw.substring(0, index).toLowerCase() + raw.substring(index);
+    }
+    
     @Override
     public int handleCommand(CommandSource cs, String rawCommand)
-    {
+    { 
+        rawCommand = lowerRawCommand(rawCommand);
         String commandName = getCommandName(rawCommand);
         
         Command command = commands.get(commandName);
         if(command != null)
         {
-            if(perms.hasPermission(cs, commandName))
+            if(perms.hasPermission(cs, command.getName()))
             {
                 command.execute(getSource(cs), getArguments(rawCommand));
                 return 1;
             }
-            events.onMissingPermission(getSource(cs), commandName);
+            events.onMissingPermission(getSource(cs), command.getName());
             return 0;
         }
         
@@ -131,7 +166,7 @@ public class ModCommandManager extends Commands
             return 0;
         }
         
-        if(vanilla.contains(commandName))
+        if(otherCommands.contains(commandName))
         {
             if(perms.hasPermission(cs, commandName))
             {
@@ -155,18 +190,58 @@ public class ModCommandManager extends Commands
         return 0;
     }
 
-    //@Override
-    //public void sendCommandListPacket(EntityPlayerMP player)
-    //{
-    //    super.sendCommandListPacket(player);
-    //    LiteralCommandNode<ISuggestionProvider> test = new LiteralCommandNode<>(
-    //            "wusi", null, (c) -> true, null, null, false);
-    //    ArgumentCommandNode<ISuggestionProvider, String> a = 
-    //            new ArgumentCommandNode<>("ok", StringArgumentType.string(), null,
-    //        (c) -> true, null, null, false, null);
-    //    a.addChild(new ArgumentCommandNode<>("ok 2", StringArgumentType.string(), null,
-    //        (c) -> false, null, null, false, null));
-    //    test.addChild(a);
-    //    rootcommandnode.addChild(test);
-    //}
+    @Override
+    public void send(ServerPlayerEntity player)
+    {
+        Map<CommandNode<CommandSource>, CommandNode<ISuggestionProvider>> map = Maps.newHashMap();
+        RootCommandNode<ISuggestionProvider> rootcommandnode = new RootCommandNode<>();
+        map.put(getDispatcher().getRoot(), rootcommandnode);
+        this.commandSourceNodesToSuggestionNodes(getDispatcher().getRoot(), rootcommandnode, player.getCommandSource(), map);
+        player.connection.sendPacket(new SCommandListPacket(rootcommandnode));
+    }
+
+    private void commandSourceNodesToSuggestionNodes(CommandNode<CommandSource> node, CommandNode<ISuggestionProvider> suggestion, CommandSource source, Map<CommandNode<CommandSource>, CommandNode<ISuggestionProvider>> commandNodeToSuggestionNode)
+    {
+        for(CommandNode<CommandSource> commandnode : node.getChildren())
+        {
+            if(perms.hasPermission(source, commandnode.getName()))
+            //if(commandnode.canUse(source))
+            {
+                ArgumentBuilder<ISuggestionProvider, ?> argumentbuilder = (ArgumentBuilder) commandnode.createBuilder();
+                argumentbuilder.requires((p_197060_0_) ->
+                {
+                    return true;
+                });
+                if(argumentbuilder.getCommand() != null)
+                {
+                    argumentbuilder.executes((p_197053_0_) ->
+                    {
+                        return 0;
+                    });
+                }
+
+                if(argumentbuilder instanceof RequiredArgumentBuilder)
+                {
+                    RequiredArgumentBuilder<ISuggestionProvider, ?> requiredargumentbuilder = (RequiredArgumentBuilder) argumentbuilder;
+                    if(requiredargumentbuilder.getSuggestionsProvider() != null)
+                    {
+                        requiredargumentbuilder.suggests(SuggestionProviders.ensureKnown(requiredargumentbuilder.getSuggestionsProvider()));
+                    }
+                }
+
+                if(argumentbuilder.getRedirect() != null)
+                {
+                    argumentbuilder.redirect(commandNodeToSuggestionNode.get(argumentbuilder.getRedirect()));
+                }
+
+                CommandNode<ISuggestionProvider> commandnode1 = argumentbuilder.build();
+                commandNodeToSuggestionNode.put(commandnode, commandnode1);
+                suggestion.addChild(commandnode1);
+                if(!commandnode.getChildren().isEmpty())
+                {
+                    this.commandSourceNodesToSuggestionNodes(commandnode, commandnode1, source, commandNodeToSuggestionNode);
+                }
+            }
+        }
+    }
 }

+ 7 - 2
src/main/java/me/km/permissions/PermissionManager.java

@@ -14,7 +14,7 @@ public class PermissionManager
 {
     private final HashMap<UUID, ArrayList<Integer>> playerGroups = new HashMap<>();
     private final ArrayList<HashSet<String>> stringGroupPerms = new ArrayList<>();
-    private final HashSet<String> worldedit = new HashSet<>();
+    private final HashSet<String> otherGroup = new HashSet<>();
     private final boolean debug;
     
     public PermissionManager(boolean debug) 
@@ -33,7 +33,12 @@ public class PermissionManager
     private void addGroups()
     {
         stringGroupPerms.add(new HashSet<>());
-        stringGroupPerms.add(worldedit);
+        stringGroupPerms.add(otherGroup);
+    }
+    
+    public void addOtherGroupPermission(String perm)
+    {
+        otherGroup.add(perm);
     }
     
     // -------------------------------------------------------------------------

+ 1 - 1
src/main/java/me/km/playerbank/PlayerManager.java

@@ -4,7 +4,7 @@ import me.hammerle.snuviscript.code.ISnuviLogger;
 import me.km.overrides.ModEntityPlayerMP;
 import net.minecraftforge.eventbus.api.EventPriority;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.PlayerEvent;
+import net.minecraftforge.event.entity.player.PlayerEvent;
 
 public class PlayerManager
 {

+ 1 - 1
src/main/java/me/km/plots/ProtectionEvents.java

@@ -61,7 +61,7 @@ public class ProtectionEvents
     public void WitherDragonProtection(EntityJoinWorldEvent e)
     {
         EntityType type = e.getEntity().getType();
-        if(type == EntityType.WITHER && e.getWorld().getDimension().getType() != DimensionType.NETHER)
+        if(type == EntityType.WITHER && e.getWorld().getDimension().getType() != DimensionType.THE_NETHER)
         {
             e.setCanceled(true);
         }  

+ 0 - 1
src/main/java/me/km/snuviscript/CommandScript.java

@@ -36,7 +36,6 @@ public class CommandScript extends Command
         list.add("s");
         return list;
     }
-    
 
     @SuppressWarnings("unchecked")
     @Override

+ 83 - 25
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -120,7 +120,10 @@ import net.minecraft.util.Direction;
 import net.minecraft.util.NonNullList;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.SoundEvent;
+import net.minecraft.util.math.BlockRayTraceResult;
 import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.math.RayTraceContext;
+import net.minecraft.util.math.RayTraceResult;
 import net.minecraft.util.text.ITextComponent;
 import net.minecraft.util.text.StringTextComponent;
 import net.minecraft.util.text.Style;
@@ -128,9 +131,10 @@ import net.minecraft.util.text.TextFormatting;
 import net.minecraft.util.text.event.ClickEvent;
 import net.minecraft.util.text.event.HoverEvent;
 import net.minecraft.world.Difficulty;
+import net.minecraft.world.GameRules;
 import net.minecraft.world.GameType;
 import net.minecraft.world.IWorld;
-import net.minecraft.world.ServerWorld;
+import net.minecraft.world.server.ServerWorld;
 import net.minecraft.world.storage.WorldInfo;
 
 public class MinecraftFunctions
@@ -307,7 +311,6 @@ public class MinecraftFunctions
             ((PlayerEntity) in[0].get(sc)).getFoodStats().setFoodLevel(in[1].getInt(sc)); 
             return Void.TYPE; 
         });
-        ;
         sm.registerFunction("player.getsaturation", (sc, in) -> (double) ((PlayerEntity) in[0].get(sc)).getFoodStats().getSaturationLevel());
         sm.registerFunction("player.setsaturation", (sc, in) -> 
         { 
@@ -319,7 +322,7 @@ public class MinecraftFunctions
             Object o = in[0].get(sc);
             if(o instanceof PlayerEntity)
             {
-                return ((PlayerEntity) o).getName();
+                return ((PlayerEntity) o).getName().getFormattedText();
             }
             return server.getPlayerProfileCache().getProfileByUUID(getUUID(o.toString())).getName();
         });
@@ -332,7 +335,7 @@ public class MinecraftFunctions
             }
             return playerBank.getUUID(o.toString());
         });
-        sm.registerFunction("player.getid", (sc, in) -> getId(playerBank, in[0].get(sc)));
+        sm.registerFunction("player.getid", (sc, in) -> (double) getId(playerBank, in[0].get(sc)));
         sm.registerFunction("player.get", (sc, in) -> server.getPlayerList().getPlayerByUUID(getUUID(in[0].get(sc))));
         sm.registerFunction("player.getuuidfromid", (sc, in) -> playerBank.getUUIDfromID(in[0].getInt(sc)));
         sm.registerFunction("player.getnamefromid", (sc, in) -> playerBank.getNamefromID(in[0].getInt(sc)));
@@ -403,12 +406,37 @@ public class MinecraftFunctions
         });
         sm.registerFunction("player.gettarget", (sc, in) -> 
         { 
-            if(in.length > 2)
+            PlayerEntity p = (PlayerEntity) in[0].get(sc);
+            
+            double radius = in[1].getDouble(sc);
+            if(radius > 128.0)
+            {
+                radius = 128.0;
+            }
+            
+            RayTraceContext.BlockMode bm = RayTraceContext.BlockMode.OUTLINE;
+            if(in.length >= 3 && in[2].getBoolean(sc))
+            {
+                bm = RayTraceContext.BlockMode.COLLIDER;
+            }
+            RayTraceContext.FluidMode fm = RayTraceContext.FluidMode.NONE;
+            if(in.length >= 4 && in[3].getBoolean(sc))
             {
-                return new Location(((PlayerEntity) in[0].get(sc)).world, 
-                        Utils.getTargetBlock((PlayerEntity) in[0].get(sc), in[1].getInt(sc), in[2].getBoolean(sc), in[3].getBoolean(sc)));
+                fm = RayTraceContext.FluidMode.ANY;
             }
-            return new Location(((PlayerEntity) in[0].get(sc)).world, Utils.getTargetBlock((PlayerEntity) in[0].get(sc), in[1].getInt(sc), true, false));
+            
+            Vec3d start = p.getEyePosition(0.0f);
+            Vec3d unit = p.getLook(0.0f);
+            Vec3d end = start.add(unit.x * radius, unit.y * radius, unit.z * radius);
+            
+            BlockRayTraceResult result = p.world.rayTraceBlocks(new RayTraceContext(start, end, bm, fm, p));
+            
+            if(result.getType() == RayTraceResult.Type.BLOCK) 
+            {
+                return new Location(p.world, result.getPos());
+            }
+            
+            return new Location(p.world, end);
         });
                 
         sm.registerFunction("player.gettargetentity", (sc, in) -> Utils.getTargetedEntity((PlayerEntity) in[0].get(sc), in[1].getDouble(sc), getClass(in[2].getString(sc))));
@@ -559,12 +587,30 @@ public class MinecraftFunctions
         });  
         sm.registerFunction("world.setgamerule", (sc, in) -> 
         {                    
-            ((World) in[0].get(sc)).getGameRules().setOrCreateGameRule(in[1].getString(sc), in[2].getString(sc), server);
+            /*Object o = ((World) in[0].get(sc)).getGameRules().get(Mapper.getGameRule(in[1].getString(sc)));
+            if(o instanceof GameRules.BooleanValue)
+            {
+                ((GameRules.BooleanValue) o).set(in[2].getBoolean(sc), server);
+            }
+            if(o instanceof GameRules.IntegerValue)
+            {
+                ((GameRules.IntegerValue) o).set(in[2].getInt(sc), server);
+            }
+            ((World) in[0].get(sc)).getGameRules().setOrCreateGameRule(in[1].getString(sc), in[2].getString(sc), server);*/
             return Void.TYPE;
         });  
         sm.registerFunction("world.getgamerule", (sc, in) -> 
         {                    
-            return ((World) in[0].get(sc)).getGameRules().get(in[1].getString(sc)).getString();
+            Object o = ((World) in[0].get(sc)).getGameRules().get(Mapper.getGameRule(in[1].getString(sc)));
+            if(o instanceof GameRules.BooleanValue)
+            {
+                return ((GameRules.BooleanValue) o).get();
+            }
+            if(o instanceof GameRules.IntegerValue)
+            {
+                return (double) ((GameRules.IntegerValue) o).get();
+            }
+            return null;
         });  
         sm.registerFunction("world.setspawn", (sc, in) -> 
         {    
@@ -1191,7 +1237,7 @@ public class MinecraftFunctions
             ent.setCustomNameVisible(false);  
             return Void.TYPE; 
         }); 
-        sm.registerFunction("entity.getname", (sc, in) -> ((Entity) in[0].get(sc)).getDisplayName().getString()); 
+        sm.registerFunction("entity.getname", (sc, in) -> ((Entity) in[0].get(sc)).getDisplayName().getFormattedText()); 
         sm.registerFunction("entity.throw", (sc, in) -> 
         { 
             Entity ent = (Entity) in[0].get(sc);
@@ -2284,32 +2330,44 @@ public class MinecraftFunctions
             {
                 case "all":
                     PlayerList list = server.getPlayerList();
-                    scripts.getPlayerList(sc.getId()).forEach(uuid -> 
+                    if(list != null)
                     {
-                        ServerPlayerEntity p = list.getPlayerByUUID(uuid);
-                        if(p != null)
+                        scripts.getPlayerList(sc.getId()).forEach(uuid -> 
                         {
-                            c.accept(p);
-                        }
-                    });
+                            ServerPlayerEntity p = list.getPlayerByUUID(uuid);
+                            if(p != null)
+                            {
+                                c.accept(p);
+                            }
+                        });
+                    }
                     break;
                 case "online":
-                    server.getPlayerList().getPlayers().forEach(p -> c.accept(p));
+                    if(server.getPlayerList() != null)
+                    {
+                        server.getPlayerList().getPlayers().forEach(p -> c.accept(p));
+                    }   
                     break;
                 case "dev":
-                    server.getPlayerList().getPlayers().forEach(p -> 
+                    if(server.getPlayerList() != null)
                     {
-                        if(perms.hasPermission(p, "script.error"))
+                        server.getPlayerList().getPlayers().forEach(p -> 
                         {
-                            c.accept(p);
-                        }
-                    });
+                            if(perms.hasPermission(p, "script.error"))
+                            {
+                                c.accept(p);
+                            }
+                        });
+                    }
                     break;
                 case "server":
                     c.accept(server);
                     break;
                 default:
-                    c.accept(Utils.getPlayerByName(server, group.toString()));
+                    if(server.getPlayerList() != null)
+                    {
+                        c.accept(Utils.getPlayerByName(server, group.toString()));
+                    }
                     break;
             }
             return;
@@ -2431,4 +2489,4 @@ public class MinecraftFunctions
         w.addEntity(launch);
         return (T) launch;
     }
-}
+}

+ 1 - 2
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -14,7 +14,6 @@ import me.km.entities.EntityItemProjectile;
 import me.km.events.CommandEvent;
 import me.km.events.PlayerTabListNameEvent;
 import me.km.permissions.PermissionManager;
-import me.km.utils.ExplosionUtils;
 import me.km.utils.Location;
 import net.minecraft.command.ICommandSource;
 import net.minecraft.entity.Entity;
@@ -46,7 +45,7 @@ import net.minecraftforge.event.world.ExplosionEvent;
 import net.minecraftforge.eventbus.api.Event;
 import net.minecraftforge.eventbus.api.EventPriority;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.PlayerEvent;
+import net.minecraftforge.event.entity.player.PlayerEvent;
 
 public class ScriptEvents
 {              

+ 2 - 2
src/main/java/me/km/snuviscript/ScriptVars.java

@@ -23,7 +23,7 @@ public class ScriptVars
     public static void setPlayerVars(Script qd, PlayerEntity p)
     {
         qd.setVar("player", p);
-        qd.setVar("player_name", p == null ? null : p.getName());
+        qd.setVar("player_name", p == null ? null : p.getName().getFormattedText());
     }
     
     public static void setSecPlayer(Script qd, PlayerEntity p)
@@ -31,7 +31,7 @@ public class ScriptVars
         if(p != null)
         {
             qd.setVar("sec_player", p);
-            qd.setVar("sec_player_name", p.getName());
+            qd.setVar("sec_player_name", p.getName().getFormattedText());
         }
     }
 

+ 33 - 0
src/main/java/me/km/utils/Mapper.java

@@ -7,6 +7,7 @@ import net.minecraft.particles.IParticleData;
 import net.minecraft.potion.Effect;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.SoundEvent;
+import net.minecraft.world.GameRules;
 import net.minecraftforge.registries.ForgeRegistries;
 
 public class Mapper
@@ -40,4 +41,36 @@ public class Mapper
     {
         return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(name));
     }
+    
+    public static GameRules.RuleKey getGameRule(String name)
+    {
+        switch(name)
+        {
+            case "doFireTick": return GameRules.DO_FIRE_TICK;
+            case "mobGriefing": return GameRules.MOB_GRIEFING;
+            case "keepInventory": return GameRules.KEEP_INVENTORY;
+            case "doMobSpawning": return GameRules.DO_MOB_SPAWNING;
+            case "doMobLoot": return GameRules.DO_MOB_LOOT;
+            case "doTileDrops": return GameRules.DO_TILE_DROPS;
+            case "doEntityDrops": return GameRules.DO_ENTITY_DROPS;
+            case "commandBlockOutput": return GameRules.COMMAND_BLOCK_OUTPUT;
+            case "naturalRegeneration": return GameRules.NATURAL_REGENERATION;
+            case "doDaylightCycle": return GameRules.DO_DAYLIGHT_CYCLE;
+            case "logAdminCommands": return GameRules.LOG_ADMIN_COMMANDS;
+            case "showDeathMessages": return GameRules.SHOW_DEATH_MESSAGES;
+            case "randomTickSpeed": return GameRules.RANDOM_TICK_SPEED;
+            case "sendCommandFeedback": return GameRules.SEND_COMMAND_FEEDBACK;
+            case "reducedDebugInfo": return GameRules.REDUCED_DEBUG_INFO;
+            case "spectatorsGenerateChunks": return GameRules.SPECTATORS_GENERATE_CHUNKS;
+            case "spawnRadius": return GameRules.SPAWN_RADIUS;
+            case "disableElytraMovementCheck": return GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK;
+            case "maxEntityCramming": return GameRules.MAX_ENTITY_CRAMMING;
+            case "doWeatherCycle": return GameRules.DO_WEATHER_CYCLE;
+            case "doLimitedCrafting": return GameRules.DO_LIMITED_CRAFTING;
+            case "maxCommandChainLength": return GameRules.MAX_COMMAND_CHAIN_LENGTH;
+            case "announceAdvancements": return GameRules.ANNOUNCE_ADVANCEMENTS;
+            case "disableRaids": return GameRules.DISABLE_RAIDS;
+        }
+        return null;
+    }
 }

+ 2 - 23
src/main/java/me/km/utils/Utils.java

@@ -39,9 +39,9 @@ public class Utils
         else if(ent instanceof DamagingProjectileEntity)
         {
             DamagingProjectileEntity fire = (DamagingProjectileEntity) ent;
-            if(fire.field_70235_a instanceof PlayerEntity)
+            if(fire.shootingEntity instanceof PlayerEntity)
             {
-                return (PlayerEntity) fire.field_70235_a;
+                return (PlayerEntity) fire.shootingEntity;
             }
             return null;
         }
@@ -195,27 +195,6 @@ public class Utils
     // -------------------------------------------------------------------------
     // Player-Tools
     // -------------------------------------------------------------------------
-
-    public static BlockPos getTargetBlock(Entity ent, double range, boolean lastBlock, boolean fluid)
-    {
-        if(range > 128)
-        {
-            range = 128;
-        }
-        World w = ent.getEntityWorld().getWorld();
-        Vec3d start = ent.getEyePosition(1.0f);
-        Vec3d look = ent.getLookVec();
-        Vec3d end = start.add(look.x * range, look.y * range, look.z * range);   
-        RayTraceContext.BlockMode blockMode = lastBlock ? RayTraceContext.BlockMode.COLLIDER : RayTraceContext.BlockMode.OUTLINE;
-        RayTraceContext.FluidMode fluidMode = fluid ? RayTraceContext.FluidMode.ANY : RayTraceContext.FluidMode.NONE;
-        RayTraceResult ray = w.rayTraceBlocks(
-                new RayTraceContext(start, end, blockMode, fluidMode, ent));
-        if(ray == null || ray.getHitVec() == null)
-        {
-            return new BlockPos(end);
-        }
-        return new BlockPos(ray.getHitVec());  
-    }
     
     public static ServerPlayerEntity getPlayerByName(MinecraftServer server, String name)
     {

+ 1 - 1
src/main/java/me/km/world/ModOverworldDimension.java → src/main/java/me/km/world/ModDimensionFactory.java

@@ -7,7 +7,7 @@ import net.minecraft.world.dimension.DimensionType;
 import net.minecraft.world.dimension.OverworldDimension;
 import net.minecraftforge.common.ModDimension;
 
-public class ModOverworldDimension extends ModDimension
+public class ModDimensionFactory extends ModDimension
 {
     @Override
     public BiFunction<World, DimensionType, ? extends Dimension> getFactory()

+ 8 - 20
src/main/java/me/km/world/WorldManager.java

@@ -7,16 +7,16 @@ import me.km.utils.ReflectionUtils;
 import net.minecraft.server.MinecraftServer;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.world.IWorld;
-import net.minecraft.world.ServerWorld;
 import net.minecraft.world.dimension.DimensionType;
+import net.minecraft.world.server.ServerWorld;
 import net.minecraftforge.common.DimensionManager;
 import net.minecraftforge.common.ModDimension;
 import net.minecraftforge.registries.ClearableRegistry;
 
 public class WorldManager
 {
-    public static final ModDimension MOD_DIMENSION = new ModOverworldDimension().setRegistryName(KajetansMod.MODID, "mod_dimension");
-    
+    public static final ModDimension MOD_DIMENSION = new ModDimensionFactory().setRegistryName(KajetansMod.MODID, "mod_dimension");
+
     // -------------------------------------------------------------------------
     // unsafe stuff
     // -------------------------------------------------------------------------
@@ -31,7 +31,7 @@ public class WorldManager
         ClearableRegistry<DimensionType> reg = (ClearableRegistry<DimensionType>) DimensionManager.getRegistry();
         reg.clear();
         reg.register(DimensionType.OVERWORLD.getId() + 1, new ResourceLocation("minecraft", "overworld"), DimensionType.OVERWORLD);
-        reg.register(DimensionType.NETHER.getId() + 1, new ResourceLocation("minecraft", "the_nether"), DimensionType.NETHER);
+        reg.register(DimensionType.THE_NETHER.getId() + 1, new ResourceLocation("minecraft", "the_nether"), DimensionType.THE_NETHER);
         reg.register(DimensionType.THE_END.getId() + 1, new ResourceLocation("minecraft", "the_end"), DimensionType.THE_END);
     }
     
@@ -113,11 +113,6 @@ public class WorldManager
     // normal stuff
     // -------------------------------------------------------------------------
     
-    private static ServerWorld getOverworld(MinecraftServer server)
-    {
-        return server.getWorld(DimensionType.OVERWORLD);
-    }
-    
     public static String getName(IWorld ws)
     {
         if(ws == null)
@@ -125,23 +120,14 @@ public class WorldManager
             return "null";
         }
         DimensionType type = ws.getDimension().getType();
-        if(type == DimensionType.NETHER)
-        {
-            return ws.getWorldInfo().getWorldName() + "_nether";
-        }
-        else if(type == DimensionType.THE_END)
-        {
-            return ws.getWorldInfo().getWorldName() + "_end";
-        }
         ResourceLocation rl = getRegistry(type);
         return rl == null ? "null" : rl.getPath();
     }
 
     public static ServerWorld get(MinecraftServer server, String name)
     {
-        ServerWorld w = getOverworld(server);
         String domain;
-        if(w.getWorldInfo().getWorldName().startsWith(name))
+        if(name.equals("overworld") || name.equals("the_nether") || name.equals("the_end"))
         {
             domain = "minecraft";
         }
@@ -149,6 +135,7 @@ public class WorldManager
         {
             domain = KajetansMod.MODID;
         }
+        ResourceLocation rl = new ResourceLocation(domain, name);
         DimensionType type = getType(new ResourceLocation(domain, name));
         if(type == null)
         {
@@ -164,7 +151,8 @@ public class WorldManager
         {
             return false;
         }
-        DimensionManager.registerDimension(rl, MOD_DIMENSION, null, true);
+        DimensionType dt = DimensionManager.registerDimension(rl, MOD_DIMENSION, null, true);
+        DimensionManager.keepLoaded(dt, true);
         return true;
     }
     

+ 2 - 2
src/main/resources/META-INF/mods.toml

@@ -1,8 +1,8 @@
 modLoader="javafml"
-loaderVersion="[26,)"
+loaderVersion="[28,)"
 [[mods]]
 modId="km"
-version="0.0.36"
+version="0.0.38"
 displayName="Kajetans Mod"
 credits="kajetanjohannes"
 authors="kajetanjohannes"

+ 2 - 0
uploadMod.sh

@@ -0,0 +1,2 @@
+./gradlew build
+scp build/libs/km-1.0.jar alpaga:../minecraft/server/mods