Quellcode durchsuchen

added block mappings, compound tag hasUniqueId -> contains, bugfixes,
missing snuvi script commands, dimension stuff, mod player list

Kajetan Johannes Hammerle vor 5 Jahren
Ursprung
Commit
9f76d017d8

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

@@ -73,7 +73,7 @@ public class ClientEvents
         if(item instanceof ArmorItem)
         {
             CompoundNBT com = stack.getTag();
-            if(com != null && com.hasUniqueId("magic"))
+            if(com != null && com.contains("magic"))
             {
                 int magic = com.getInt("magic");
                 if(magic != 0)

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

@@ -30,7 +30,7 @@ public class DamageUtils
         for(ItemStack stack : liv.getArmorInventoryList())
         {
             CompoundNBT com = stack.getTag();
-            if(com != null && com.hasUniqueId("magic"))
+            if(com != null && com.contains("magic"))
             {
                 level += com.getInt("magic");
             }

+ 18 - 1
src/main/java/me/km/ObjectRegistry.java

@@ -31,10 +31,27 @@ public class ObjectRegistry
         e.getMappings().stream()
                 .forEach((missing) -> 
                 {
-                    if(missing.key.toString().contains("cauldron"))
+                    String key = missing.key.toString();
+                    if(key.contains("cauldron"))
                     {
                         missing.remap(ModBlocks.cookingPotCopper);   
                     }
+                    else if(key.contains("campfire"))
+                    {
+                        missing.remap(Blocks.CAMPFIRE);   
+                    }
+                    else if(key.contains("spikes"))
+                    {
+                        missing.remap(ModBlocks.spikesCopper);   
+                    }
+                    else if(key.contains("campfire"))
+                    {
+                        missing.remap(Blocks.CAMPFIRE);   
+                    }
+                    else if(key.contains("barrel"))
+                    {
+                        missing.remap(Blocks.BARREL);   
+                    }
                     else
                     {
                         missing.remap(Blocks.STONE);   

+ 2 - 1
src/main/java/me/km/blocks/BlockSpikes.java

@@ -4,6 +4,7 @@ import net.minecraft.block.Block;
 import net.minecraft.block.BlockState;
 import net.minecraft.block.Blocks;
 import net.minecraft.entity.Entity;
+import net.minecraft.entity.LivingEntity;
 import net.minecraft.util.BlockRenderLayer;
 import net.minecraft.util.DamageSource;
 import net.minecraft.util.Direction;
@@ -40,7 +41,7 @@ public class BlockSpikes extends Block
     @Override
     public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity ent)
     {
-        if(!ent.isSneaking())
+        if(!ent.isSneaking() && ent instanceof LivingEntity)
         {
             ent.attackEntityFrom(DamageSource.CACTUS, 1.0F);
         }

+ 3 - 8
src/main/java/me/km/blocks/cookingpot/BlockCookingPot.java

@@ -58,13 +58,8 @@ public class BlockCookingPot extends CauldronBlock implements ITileEntityProvide
             if(te instanceof TileEntityCookingPot)
             {
                 TileEntityCookingPot cauldron = (TileEntityCookingPot) te;
-                boolean b = false;
-                if(cauldron.hasDefaultColor())
-                {
-                    b = super.onBlockActivated(state, w, pos, p, hand, hit);
-                }
                 ItemStack stack = p.getHeldItem(hand);
-                if(stack.isEmpty() || b)
+                if(stack.isEmpty())
                 {
                     return true;
                 }
@@ -100,10 +95,10 @@ public class BlockCookingPot extends CauldronBlock implements ITileEntityProvide
                     {
                         stack.shrink(1);
                     }
+                    return true;
                 }
-                return true;
             }
-            return true;
+            return super.onBlockActivated(state, w, pos, p, hand, hit);
         }
     }
 

+ 1 - 1
src/main/java/me/km/blocks/cookingpot/CookingPotColorMixer.java

@@ -73,7 +73,7 @@ public class CookingPotColorMixer
     private Color getItemColor(ItemStack stack)
     {
         Item item = stack.getItem();
-        if(item == Item.getItemFromBlock(Blocks.PUMPKIN)) { return PUMPKIN; }
+        if(item == Items.PUMPKIN) { return PUMPKIN; }
         else if(item == Items.APPLE) { return APPLE; }
         else if(item == Items.GOLDEN_APPLE) { return APPLE_GOLDEN; }
         else if(item == Items.BEETROOT_SEEDS) { return BEETROOT_SEEDS; }

+ 1 - 1
src/main/java/me/km/blocks/cookingpot/TileEntityCookingPot.java

@@ -55,7 +55,7 @@ public class TileEntityCookingPot extends TileEntity
     
     private void readItems(CompoundNBT com)
     {
-        if(com.hasUniqueId("items"))
+        if(com.contains("items"))
         {
             mixer.reset();
             ListNBT list = com.getList("items", 10);

+ 3 - 3
src/main/java/me/km/entities/EntityHuman.java

@@ -115,16 +115,16 @@ public class EntityHuman extends CreatureEntity implements IEntityAdditionalSpaw
     public void readAdditional(CompoundNBT com)
     {
         super.readAdditional(com);
-        if(com.hasUniqueId("HumanName"))
+        if(com.contains("HumanName"))
         {
             this.name = com.getString("HumanName");
         }
-        if(com.hasUniqueId("Scale"))
+        if(com.contains("Scale"))
         {
             this.scale = com.getFloat("Scale");
             setSize(originalWidth * scale, originalHeight * scale);
         }
-        if(com.hasUniqueId("Slim"))
+        if(com.contains("Slim"))
         {
             this.slim = com.getByte("Slim");
         }

+ 7 - 3
src/main/java/me/km/entities/EntityItemProjectile.java

@@ -105,8 +105,12 @@ public class EntityItemProjectile extends ItemEntity implements IProjectile
                 return;
             }
             
-            Vec3d oldV = new Vec3d(this.prevPosX, prevPosY, prevPosZ);
-            Vec3d newV = new Vec3d(this.posX, this.posY, this.posZ);          
+            double minX = Math.min(prevPosX, posX);
+            double minY = Math.min(prevPosY, posY);
+            double minZ = Math.min(prevPosZ, posZ);
+            double maxX = Math.max(prevPosX, posX);
+            double maxY = Math.max(prevPosY, posY);
+            double maxZ = Math.max(prevPosZ, posZ);
             list.removeIf(ent -> 
             {
                 // this prevents the projectile from hitting its shooter during
@@ -116,7 +120,7 @@ public class EntityItemProjectile extends ItemEntity implements IProjectile
                     return true;
                 }
                 // size of the projectile is 0.25 x 0.25
-                return !ent.getBoundingBox().grow(0.25f).intersects(oldV, newV);
+                return !ent.getBoundingBox().grow(0.25f).intersects(minX, minY, minZ, maxX, maxY, maxZ);
             });
             if(!list.isEmpty())
             {

+ 5 - 5
src/main/java/me/km/items/ItemColoredSoup.java

@@ -54,7 +54,7 @@ public class ItemColoredSoup extends ItemFood
         String text = getLocalizedIngredientList(stack);
         if(!text.isEmpty())
         {
-            lore.add(1, new StringTextComponent(text));
+            lore.add(new StringTextComponent(text));
         }
     }
     
@@ -72,19 +72,19 @@ public class ItemColoredSoup extends ItemFood
         }
         else
         {
-            if(!com.hasUniqueId("color"))
+            if(!com.contains("color"))
             {
                 com.putInt("color", CookingPotColorMixer.DEFAULT.getRGB());   
             }
-            if(!com.hasUniqueId("ingredients"))
+            if(!com.contains("ingredients"))
             {
                 com.put("ingredients", new ListNBT());   
             }
-            if(!com.hasUniqueId("saturation"))
+            if(!com.contains("saturation"))
             {
                 com.putFloat("saturation", 0);   
             }
-            if(!com.hasUniqueId("food"))
+            if(!com.contains("food"))
             {
                 com.putInt("food", 0);   
             }

+ 1 - 1
src/main/java/me/km/items/ItemGemStone.java

@@ -31,7 +31,7 @@ public class ItemGemStone extends Item
         }
         else
         {
-            if(!com.hasUniqueId("color"))
+            if(!com.contains("color"))
             {
                 com.putInt("color", 0xFFFFFF);   
             }

+ 5 - 10
src/main/java/me/km/items/ModItems.java

@@ -1,6 +1,7 @@
 package me.km.items;
 
 import me.km.blocks.ModBlocks;
+import me.km.utils.ReflectionUtils;
 import net.minecraft.item.Items;
 import net.minecraft.inventory.EquipmentSlotType;
 import net.minecraft.item.IArmorMaterial;
@@ -19,7 +20,9 @@ import net.minecraft.item.ItemTier;
 import net.minecraft.potion.Effect;
 import net.minecraft.potion.EffectInstance;
 import net.minecraft.potion.Effects;
+import net.minecraft.potion.PotionBrewing;
 import net.minecraftforge.registries.IForgeRegistry;
+import org.apache.logging.log4j.LogManager;
 
 public class ModItems 
 {
@@ -420,7 +423,7 @@ public class ModItems
         {
             for(int i = 0; i < 3; i++)
             {
-                System.out.println("DOING EVIL SHIT");
+                LogManager.getLogger().info("DOING EVIL SHIT");
             }
             PotionItem potion = new ItemNoGlintPotion();
             register(r, Items.POTION, potion);
@@ -430,17 +433,9 @@ public class ModItems
             
             PotionItem lingeringPotion = new ItemNoGlintLingeringPotion();
             register(r, Items.LINGERING_POTION, lingeringPotion);
-            
-            // tests showed this is no more needed, more testing needed
-            //PotionHelper.addContainer(potion);
-            //PotionHelper.addContainer(splashPotion);
-            //PotionHelper.addContainer(lingeringPotion);
-            //PotionHelper.addContainerRecipe(potion, Items.GUNPOWDER, Items.SPLASH_POTION);
-            //PotionHelper.addContainerRecipe(splashPotion, Items.DRAGON_BREATH, Items.LINGERING_POTION);
-            
             for(int i = 0; i < 3; i++)
             {
-                System.out.println("DONE WITH EVIL SHIT");
+                LogManager.getLogger().info("DONE WITH EVIL SHIT");
             }
         }
         catch(Exception ex)

+ 5 - 14
src/main/java/me/km/networking/ItemStackDisplayGui.java

@@ -1,16 +1,14 @@
 package me.km.networking;
 
 import com.mojang.blaze3d.platform.GlStateManager;
-import java.util.Map;
 import me.km.KajetansMod;
+import me.km.utils.ClientReflectionUtils;
 import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.AbstractGui;
 import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.overlay.BossOverlayGui;
 import net.minecraft.util.ResourceLocation;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
-import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
 
 @OnlyIn(Dist.CLIENT)
 public class ItemStackDisplayGui extends AbstractGui
@@ -20,13 +18,12 @@ public class ItemStackDisplayGui extends AbstractGui
     public final static ItemStackDisplayGui INSTANCE = new ItemStackDisplayGui(Minecraft.getInstance());
     
     private final Minecraft mc;
-    private final int[] icons;
+    private final int[] icons = new int[27];
     private boolean inactive = true;
     
     public ItemStackDisplayGui(Minecraft mc)
     {
         this.mc = mc;
-        this.icons = new int[27];
         clear();
     }  
     
@@ -64,22 +61,16 @@ public class ItemStackDisplayGui extends AbstractGui
         }
         
         GlStateManager.enableBlend();
+        GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
         
         mc.getTextureManager().bindTexture(CUSTOM_ICONS);
         
         int screenWidth = (mc.mainWindow.getScaledWidth() >> 1) - 91;
         int y = 3;
         
-        try
-        {
-            Map info = ObfuscationReflectionHelper.getPrivateValue(BossOverlayGui.class, mc.ingameGUI.getBossOverlay(), "field_184060_g");
-            if(!info.isEmpty())
-            {
-                y += 20;
-            }
-        }
-        catch(Exception ex)
+        if(ClientReflectionUtils.isRenderingBossBar())
         {
+            y += 20;
         }
         
         blit(screenWidth, y - 3, 0, 0, 182, 22);

+ 106 - 92
src/main/java/me/km/overrides/ModPlayerList.java

@@ -5,30 +5,33 @@ import com.mojang.authlib.GameProfile;
 import io.netty.buffer.Unpooled;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.UUID;
 import me.km.KajetansMod;
 import me.km.networking.ModPacketHandler;
 import me.km.utils.ReflectionUtils;
 import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.NetHandlerPlayServer;
+import net.minecraft.entity.EntityType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.nbt.CompoundNBT;
 import net.minecraft.network.NetworkManager;
 import net.minecraft.network.PacketBuffer;
-import net.minecraft.network.play.server.SPacketChangeGameState;
-import net.minecraft.network.play.server.SPacketCustomPayload;
-import net.minecraft.network.play.server.SPacketEntityEffect;
-import net.minecraft.network.play.server.SPacketHeldItemChange;
-import net.minecraft.network.play.server.SPacketJoinGame;
-import net.minecraft.network.play.server.SPacketPlayerAbilities;
-import net.minecraft.network.play.server.SPacketRespawn;
-import net.minecraft.network.play.server.SPacketServerDifficulty;
-import net.minecraft.network.play.server.SPacketSetExperience;
-import net.minecraft.network.play.server.SPacketSpawnPosition;
-import net.minecraft.network.play.server.SPacketTagsList;
-import net.minecraft.network.play.server.SPacketUpdateRecipes;
-import net.minecraft.potion.PotionEffect;
+import net.minecraft.network.play.ServerPlayNetHandler;
+import net.minecraft.network.play.server.SChangeGameStatePacket;
+import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
+import net.minecraft.network.play.server.SHeldItemChangePacket;
+import net.minecraft.network.play.server.SJoinGamePacket;
+import net.minecraft.network.play.server.SPlayEntityEffectPacket;
+import net.minecraft.network.play.server.SPlayerAbilitiesPacket;
+import net.minecraft.network.play.server.SPlayerListItemPacket;
+import net.minecraft.network.play.server.SRespawnPacket;
+import net.minecraft.network.play.server.SServerDifficultyPacket;
+import net.minecraft.network.play.server.SSetExperiencePacket;
+import net.minecraft.network.play.server.SSpawnPositionPacket;
+import net.minecraft.network.play.server.STagsListPacket;
+import net.minecraft.network.play.server.SUpdateRecipesPacket;
+import net.minecraft.potion.EffectInstance;
 import net.minecraft.server.dedicated.DedicatedPlayerList;
 import net.minecraft.server.dedicated.DedicatedServer;
 import net.minecraft.server.management.DemoPlayerInteractionManager;
@@ -36,10 +39,10 @@ import net.minecraft.server.management.PlayerInteractionManager;
 import net.minecraft.server.management.PlayerList;
 import net.minecraft.server.management.PlayerProfileCache;
 import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.text.TextComponentTranslation;
+import net.minecraft.util.math.Vec3d;
+import net.minecraft.util.text.TranslationTextComponent;
 import net.minecraft.world.IWorld;
-import net.minecraft.world.WorldServer;
-import net.minecraft.world.chunk.storage.AnvilChunkLoader;
+import net.minecraft.world.ServerWorld;
 import net.minecraft.world.dimension.DimensionType;
 import net.minecraft.world.storage.WorldInfo;
 import org.apache.logging.log4j.LogManager;
@@ -47,9 +50,9 @@ import org.apache.logging.log4j.LogManager;
 public class ModPlayerList extends DedicatedPlayerList
 {
     private final DedicatedServer server;
-    private final List<EntityPlayerMP> players;
-    private final Map<UUID, EntityPlayerMP> uuidToPlayerMap;
-    
+    private final List<ServerPlayerEntity> players;
+    private final Map<UUID, ServerPlayerEntity> uuidToPlayerMap;
+
     public ModPlayerList(DedicatedServer server)
     {
         super(server);
@@ -57,23 +60,23 @@ public class ModPlayerList extends DedicatedPlayerList
         this.players = getPlayers();
         this.uuidToPlayerMap = ReflectionUtils.getFieldValue(Map.class, PlayerList.class, this, "field_177454_f");
     }
-    
+
     @Override
-    public void initializeConnectionToPlayer(NetworkManager netManager, EntityPlayerMP p)
+    public void initializeConnectionToPlayer(NetworkManager netManager, ServerPlayerEntity p)
     {
         GameProfile profile = p.getGameProfile();
         PlayerProfileCache cache = this.server.getPlayerProfileCache();
         GameProfile cachedProfile = cache.getProfileByUUID(profile.getId());
         String s = cachedProfile == null ? profile.getName() : cachedProfile.getName();
         cache.addEntry(profile);
-        NBTTagCompound tag = this.readPlayerDataFromFile(p);
+        CompoundNBT compoundnbt = this.readPlayerDataFromFile(p);
 
         //Forge: Make sure the dimension hasn't been deleted, if so stick them in the overworld.
         DimensionType type = p.dimension;
         boolean noSchedule = true;
         if(type == null || !type.isVanilla())
         {
-            WorldServer overWorld = this.server.getWorld(DimensionType.OVERWORLD);
+            ServerWorld overWorld = this.server.getWorld(DimensionType.OVERWORLD);
             p.dimension = DimensionType.OVERWORLD;
             if(type != null && this.server.getWorld(type) != null)
             {
@@ -85,7 +88,7 @@ public class ModPlayerList extends DedicatedPlayerList
                 noSchedule = false;
                 KajetansMod.scheduler.scheduleTask(() -> 
                 {
-                    WorldServer ws = server.getWorld(type);
+                    ServerWorld ws = server.getWorld(type);
                     if(ws != null)
                     {
                         p.teleport(ws, x, y, z, yaw, pitch);
@@ -96,10 +99,10 @@ public class ModPlayerList extends DedicatedPlayerList
             WorldInfo wi = overWorld.getWorldInfo();
             p.setPosition(wi.getSpawnX(), wi.getSpawnY(), wi.getSpawnZ());
         }
-        
-        WorldServer ws = this.server.getWorld(p.dimension);
-        p.setWorld(ws);
-        p.interactionManager.setWorld((WorldServer) p.world);
+               
+        ServerWorld sw = this.server.getWorld(p.dimension);
+        p.setWorld(sw);
+        p.interactionManager.setWorld((ServerWorld) p.world);
         String s1 = "local";
         if(netManager.getRemoteAddress() != null)
         {
@@ -107,43 +110,57 @@ public class ModPlayerList extends DedicatedPlayerList
         }
 
         LogManager.getLogger().info("{}[{}] logged in with entity id {} at ({}, {}, {})", p.getName().getString(), s1, p.getEntityId(), p.posX, p.posY, p.posZ);
-        WorldInfo wi = ws.getWorldInfo();
-        this.setPlayerGameTypeBasedOnOther(p, null, ws);
-        NetHandlerPlayServer nhps = new NetHandlerPlayServer(this.server, netManager, p);
+        WorldInfo wi = sw.getWorldInfo();
+        setPlayerGameTypeBasedOnOther(p, null, sw);
+        ServerPlayNetHandler spnh = new ServerPlayNetHandler(this.server, netManager, p);
         ModPacketHandler.syncDimensions(p);
-        nhps.sendPacket(new SPacketJoinGame(p.getEntityId(), p.interactionManager.getGameType(), wi.isHardcore(), ws.dimension.getType(), ws.getDifficulty(), this.getMaxPlayers(), wi.getTerrainType(), ws.getGameRules().getBoolean("reducedDebugInfo")));
-        nhps.sendPacket(new SPacketCustomPayload(SPacketCustomPayload.BRAND, (new PacketBuffer(Unpooled.buffer())).writeString(this.getServer().getServerModName())));
-        nhps.sendPacket(new SPacketServerDifficulty(wi.getDifficulty(), wi.isDifficultyLocked()));
-        nhps.sendPacket(new SPacketPlayerAbilities(p.abilities));
-        nhps.sendPacket(new SPacketHeldItemChange(p.inventory.currentItem));
-        nhps.sendPacket(new SPacketUpdateRecipes(this.server.getRecipeManager().getRecipes()));
-        nhps.sendPacket(new SPacketTagsList(this.server.getNetworkTagManager()));
+        spnh.sendPacket(new SJoinGamePacket(p.getEntityId(), p.interactionManager.getGameType(), wi.isHardcore(), sw.dimension.getType(), this.getMaxPlayers(), wi.getGenerator(), getViewDistance(), sw.getGameRules().getBoolean("reducedDebugInfo")));
+        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));
+        spnh.sendPacket(new SHeldItemChangePacket(p.inventory.currentItem));
+        spnh.sendPacket(new SUpdateRecipesPacket(this.server.getRecipeManager().getRecipes()));
+        spnh.sendPacket(new STagsListPacket(this.server.getNetworkTagManager()));
         this.updatePermissionLevel(p);
         p.getStats().markAllDirty();
         p.getRecipeBook().init(p);
-        this.sendScoreboard(ws.getScoreboard(), p);
+        this.sendScoreboard(sw.getScoreboard(), p);
         this.server.refreshStatusNextTick();
 
-        this.playerLoggedIn(p);
-        nhps.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
-        this.sendWorldInfo(p, ws);
+        spnh.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
+        this.players.add(p);
+        this.uuidToPlayerMap.put(p.getUniqueID(), p);
+        this.sendPacketToAllPlayers(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, p));
+
+        for(int i = 0; i < this.players.size(); ++i)
+        {
+            p.connection.sendPacket(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, this.players.get(i)));
+        }
+
+        sw.addNewPlayer(p);
+        this.server.getCustomBossEvents().onPlayerLogin(p);
+        this.sendWorldInfo(p, sw);
         if(!this.server.getResourcePackUrl().isEmpty())
         {
             p.loadResourcePack(this.server.getResourcePackUrl(), this.server.getResourcePackHash());
         }
 
-        for(PotionEffect potioneffect : p.getActivePotionEffects())
+        for(EffectInstance effectinstance : p.getActivePotionEffects())
         {
-            nhps.sendPacket(new SPacketEntityEffect(p.getEntityId(), potioneffect));
+            spnh.sendPacket(new SPlayEntityEffectPacket(p.getEntityId(), effectinstance));
         }
 
-        if(tag != null && tag.contains("RootVehicle", 10))
+        if(compoundnbt != null && compoundnbt.contains("RootVehicle", 10))
         {
-            NBTTagCompound nbttagcompound1 = tag.getCompound("RootVehicle");
-            Entity entity1 = AnvilChunkLoader.readWorldEntity(nbttagcompound1.getCompound("Entity"), ws, true);
+            CompoundNBT compoundnbt1 = compoundnbt.getCompound("RootVehicle");
+            final ServerWorld worldf = sw;
+            Entity entity1 = EntityType.func_220335_a(compoundnbt1.getCompound("Entity"), sw, (p_217885_1_) ->
+            {
+                return !worldf.summonEntity(p_217885_1_) ? null : p_217885_1_;
+            });
             if(entity1 != null)
             {
-                UUID uuid = nbttagcompound1.getUniqueId("Attach");
+                UUID uuid = compoundnbt1.getUniqueId("Attach");
                 if(entity1.getUniqueID().equals(uuid))
                 {
                     p.startRiding(entity1, true);
@@ -163,11 +180,11 @@ public class ModPlayerList extends DedicatedPlayerList
                 if(!p.isPassenger())
                 {
                     LogManager.getLogger().warn("Couldn't reattach entity to player");
-                    ws.removeEntityDangerously(entity1);
+                    sw.removeEntity(entity1);
 
                     for(Entity entity2 : entity1.getRecursivePassengers())
                     {
-                        ws.removeEntityDangerously(entity2);
+                        sw.removeEntity(entity2);
                     }
                 }
             }
@@ -181,29 +198,29 @@ public class ModPlayerList extends DedicatedPlayerList
     }
 
     @Override
-    public EntityPlayerMP createPlayerForUser(GameProfile profile)
+    public ServerPlayerEntity createPlayerForUser(GameProfile profile)
     {
-        UUID uuid = EntityPlayer.getUUID(profile);
-        List<EntityPlayerMP> list = Lists.newArrayList();
+        UUID uuid = PlayerEntity.getUUID(profile);
+        List<ServerPlayerEntity> list = Lists.newArrayList();
 
         for(int i = 0; i < this.players.size(); ++i)
         {
-            EntityPlayerMP entityplayermp = this.players.get(i);
-            if(entityplayermp.getUniqueID().equals(uuid))
+            ServerPlayerEntity serverplayerentity = this.players.get(i);
+            if(serverplayerentity.getUniqueID().equals(uuid))
             {
-                list.add(entityplayermp);
+                list.add(serverplayerentity);
             }
         }
 
-        EntityPlayerMP entityplayermp2 = this.uuidToPlayerMap.get(profile.getId());
-        if(entityplayermp2 != null && !list.contains(entityplayermp2))
+        ServerPlayerEntity serverplayerentity2 = this.uuidToPlayerMap.get(profile.getId());
+        if(serverplayerentity2 != null && !list.contains(serverplayerentity2))
         {
-            list.add(entityplayermp2);
+            list.add(serverplayerentity2);
         }
 
-        for(EntityPlayerMP entityplayermp1 : list)
+        for(ServerPlayerEntity serverplayerentity1 : list)
         {
-            entityplayermp1.connection.disconnect(new TextComponentTranslation("multiplayer.disconnect.duplicate_login"));
+            serverplayerentity1.connection.disconnect(new TranslationTextComponent("multiplayer.disconnect.duplicate_login"));
         }
 
         PlayerInteractionManager playerinteractionmanager;
@@ -218,11 +235,11 @@ public class ModPlayerList extends DedicatedPlayerList
 
         return new ModEntityPlayerMP(this.server, this.server.getWorld(DimensionType.OVERWORLD), profile, playerinteractionmanager);
     }
-
+        
     @Override
-    public EntityPlayerMP recreatePlayerEntity(EntityPlayerMP pIn, DimensionType dim, boolean conqueredEnd)
+    public ServerPlayerEntity recreatePlayerEntity(ServerPlayerEntity pIn, DimensionType dim, boolean conqueredEnd)
     {
-        WorldServer world = server.getWorld(dim);
+        ServerWorld world = server.getWorld(dim);
         if(world == null)
         {
             dim = pIn.getSpawnDimension();
@@ -236,11 +253,8 @@ public class ModPlayerList extends DedicatedPlayerList
             dim = DimensionType.OVERWORLD;
         }
 
-        pIn.getServerWorld().getEntityTracker().removePlayerFromTrackers(pIn);
-        pIn.getServerWorld().getEntityTracker().untrack(pIn);
-        pIn.getServerWorld().getPlayerChunkMap().removePlayer(pIn);
         this.players.remove(pIn);
-        this.server.getWorld(pIn.dimension).removeEntityDangerously(pIn, true); // Forge: keep data until copyFrom called
+        pIn.getServerWorld().removePlayer(pIn, true); // Forge: keep data until copyFrom called
         BlockPos blockpos = pIn.getBedLocation(dim);
         boolean flag = pIn.isSpawnForced(dim);
         pIn.dimension = dim;
@@ -254,7 +268,7 @@ public class ModPlayerList extends DedicatedPlayerList
             playerinteractionmanager = new PlayerInteractionManager(this.server.getWorld(pIn.dimension));
         }
 
-        EntityPlayerMP p = new ModEntityPlayerMP(this.server, this.server.getWorld(pIn.dimension), pIn.getGameProfile(), playerinteractionmanager);
+        ServerPlayerEntity p = new ModEntityPlayerMP(this.server, this.server.getWorld(pIn.dimension), pIn.getGameProfile(), playerinteractionmanager);
         p.connection = pIn.connection;
         p.copyFrom(pIn, conqueredEnd);
         pIn.remove(false); // Forge: clone event had a chance to see old data, now discard it
@@ -267,38 +281,38 @@ public class ModPlayerList extends DedicatedPlayerList
             p.addTag(s);
         }
 
-        WorldServer worldserver = this.server.getWorld(pIn.dimension);
-        this.setPlayerGameTypeBasedOnOther(p, pIn, worldserver);
+        ServerWorld serverworld = this.server.getWorld(pIn.dimension);
+        this.setPlayerGameTypeBasedOnOther(p, pIn, serverworld);
         if(blockpos != null)
         {
-            BlockPos blockpos1 = EntityPlayer.getBedSpawnLocation(this.server.getWorld(pIn.dimension), blockpos, flag);
-            if(blockpos1 != null)
+            Optional<Vec3d> optional = PlayerEntity.func_213822_a(this.server.getWorld(pIn.dimension), blockpos, flag);
+            if(optional.isPresent())
             {
-                p.setLocationAndAngles((double) ((float) blockpos1.getX() + 0.5F), (double) ((float) blockpos1.getY() + 0.1F), (double) ((float) blockpos1.getZ() + 0.5F), 0.0F, 0.0F);
-                p.setSpawnPoint(blockpos, flag, pIn.dimension);
+                Vec3d vec3d = optional.get();
+                p.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, 0.0F, 0.0F);
+                p.setSpawnPoint(blockpos, flag, dim);
             }
             else
             {
-                p.connection.sendPacket(new SPacketChangeGameState(0, 0.0F));
+                p.connection.sendPacket(new SChangeGameStatePacket(0, 0.0F));
             }
         }
 
-        worldserver.getChunkProvider().provideChunk((int) p.posX >> 4, (int) p.posZ >> 4, true, true);
-
-        while(!worldserver.isCollisionBoxesEmpty(p, p.getBoundingBox()) && p.posY < 256.0D)
+        while(!serverworld.areCollisionShapesEmpty(p) && p.posY < 256.0D)
         {
             p.setPosition(p.posX, p.posY + 1.0D, p.posZ);
         }
 
-        p.connection.sendPacket(new SPacketRespawn(p.dimension, world.getDifficulty(), world.getWorldInfo().getTerrainType(), p.interactionManager.getGameType())); // Forge: Use new dimensions information 
-        BlockPos blockpos2 = worldserver.getSpawnPoint();
+        WorldInfo wi = p.world.getWorldInfo();
+        p.connection.sendPacket(new SRespawnPacket(p.dimension, wi.getGenerator(), p.interactionManager.getGameType()));
+        BlockPos pos = serverworld.getSpawnPoint();
         p.connection.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
-        p.connection.sendPacket(new SPacketSpawnPosition(blockpos2));
-        p.connection.sendPacket(new SPacketSetExperience(p.experience, p.experienceTotal, p.experienceLevel));
-        this.sendWorldInfo(p, worldserver);
+        p.connection.sendPacket(new SSpawnPositionPacket(pos));
+        p.connection.sendPacket(new SServerDifficultyPacket(wi.getDifficulty(), wi.isDifficultyLocked()));
+        p.connection.sendPacket(new SSetExperiencePacket(p.experience, p.experienceTotal, p.experienceLevel));
+        this.sendWorldInfo(p, serverworld);
         this.updatePermissionLevel(p);
-        worldserver.getPlayerChunkMap().addPlayer(p);
-        worldserver.spawnEntity(p);
+        serverworld.addRespawnedPlayer(p);
         this.players.add(p);
         this.uuidToPlayerMap.put(p.getUniqueID(), p);
         p.addSelfToInternalCraftingInventory();
@@ -306,8 +320,8 @@ public class ModPlayerList extends DedicatedPlayerList
         net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerRespawnEvent(p, conqueredEnd);
         return p;
     }
-    
-    private void setPlayerGameTypeBasedOnOther(EntityPlayerMP target, EntityPlayerMP source, IWorld w) 
+
+    private void setPlayerGameTypeBasedOnOther(ServerPlayerEntity target, ServerPlayerEntity source, IWorld w) 
     {
         ReflectionUtils.setPlayerGameTypeBasedOnOther(this, target, source, w);
     }

Datei-Diff unterdrückt, da er zu groß ist
+ 192 - 327
src/main/java/me/km/snuviscript/MinecraftFunctions.java


+ 9 - 1
src/main/java/me/km/snuviscript/SnuviInventory.java

@@ -5,21 +5,29 @@ import me.km.inventory.InventoryBase;
 public class SnuviInventory extends InventoryBase
 {
     private final int id;
+    private final String title;
     
-    public SnuviInventory(int slotCount, int id) 
+    public SnuviInventory(String title, int slotCount, int id) 
     {
         super(slotCount, null);
         this.id = id;
+        this.title = title;
     }
     
     public SnuviInventory(String title, String slots, int id) 
     {
         super(slots, null);
         this.id = id;
+        this.title = title;
     }
     
     public int getId()
     {
         return id;
     }
+    
+    public String getTitle()
+    {
+        return title;
+    }
 }

+ 24 - 0
src/main/java/me/km/utils/ClientReflectionUtils.java

@@ -0,0 +1,24 @@
+package me.km.utils;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+import static me.km.utils.ReflectionUtils.getField;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.overlay.BossOverlayGui;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class ClientReflectionUtils
+{
+    // -----------------------------------------------------------------------------------
+    // BossOverlayGui
+    // -----------------------------------------------------------------------------------
+    
+    private final static Field BOSS_BAR_MAP = getField(BossOverlayGui.class, "field_184060_g");
+
+    public static boolean isRenderingBossBar()
+    {
+        return !ReflectionUtils.getFieldValue(Map.class, Minecraft.getInstance().ingameGUI.getBossOverlay(), BOSS_BAR_MAP).isEmpty();
+    }
+}

+ 18 - 50
src/main/java/me/km/utils/ReflectionUtils.java

@@ -10,6 +10,7 @@ import net.minecraft.entity.LivingEntity;
 import net.minecraft.entity.item.ItemEntity;
 import net.minecraft.entity.player.PlayerAbilities;
 import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.entity.projectile.AbstractArrowEntity;
 import net.minecraft.entity.projectile.ArrowEntity;
 import net.minecraft.server.MinecraftServer;
 import net.minecraft.server.management.PlayerList;
@@ -20,6 +21,7 @@ import net.minecraft.world.IWorld;
 import net.minecraftforge.common.DimensionManager;
 import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
 import static net.minecraftforge.fml.common.ObfuscationReflectionHelper.remapName;
+import org.apache.logging.log4j.LogManager;
 
 public class ReflectionUtils 
 {    
@@ -35,7 +37,7 @@ public class ReflectionUtils
         }
         catch(Exception ex)
         {
-            System.out.println(name + " - " + ex);
+            LogManager.getLogger().warn(name + " - " + ex);
         }
         return null;
     }
@@ -50,7 +52,7 @@ public class ReflectionUtils
         }
         catch(Exception ex)
         {
-            System.out.println(field + " - " + ex);
+            LogManager.getLogger().warn(field + " - " + ex);
         }
         return null;
     } 
@@ -63,7 +65,7 @@ public class ReflectionUtils
         }
         catch(SecurityException | IllegalArgumentException | IllegalAccessException | NullPointerException ex)
         {
-            System.out.println(f + " - " + ex);
+            LogManager.getLogger().warn(f + " - " + ex);
         }
     }
     
@@ -75,7 +77,7 @@ public class ReflectionUtils
         }
         catch(SecurityException | IllegalArgumentException | IllegalAccessException | NullPointerException ex)
         {
-            System.out.println(f + " - " + ex);
+            LogManager.getLogger().warn(f + " - " + ex);
             return error;
         }
     }
@@ -88,7 +90,7 @@ public class ReflectionUtils
         }
         catch(SecurityException | IllegalArgumentException | IllegalAccessException | NullPointerException ex)
         {
-            System.out.println(f + " - " + ex);
+            LogManager.getLogger().warn(f + " - " + ex);
         }
     }
     
@@ -100,7 +102,7 @@ public class ReflectionUtils
         }
         catch(SecurityException | IllegalArgumentException | IllegalAccessException | NullPointerException ex)
         {
-            System.out.println(f + " - " + ex);
+            LogManager.getLogger().warn(f + " - " + ex);
             return error;
         }
     }
@@ -113,12 +115,12 @@ public class ReflectionUtils
         }
         catch(SecurityException | IllegalArgumentException | IllegalAccessException | NullPointerException ex)
         {
-            System.out.println(f + " - " + ex);
+            LogManager.getLogger().warn(f + " - " + ex);
             return error;
         }
     }
     
-    private static <T> T getFieldValue(Class<T> cast, Object o, Field f)
+    public static <T> T getFieldValue(Class<T> cast, Object o, Field f)
     {
         try
         {
@@ -126,7 +128,7 @@ public class ReflectionUtils
         }
         catch(SecurityException | IllegalAccessException | IllegalArgumentException ex)
         {
-            System.out.println(f + " - " + ex);
+            LogManager.getLogger().warn(f + " - " + ex);
             return null;
         }
     }
@@ -139,7 +141,7 @@ public class ReflectionUtils
         }
         catch(SecurityException | IllegalAccessException | IllegalArgumentException ex)
         {
-            System.out.println(f + " - " + ex);
+            LogManager.getLogger().warn(f + " - " + ex);
         }
     }
     
@@ -151,18 +153,7 @@ public class ReflectionUtils
             return null;
         }
         return getFieldValue(cast, instance, f);
-    } 
-    
-    // -----------------------------------------------------------------------------------
-    // villager stuff
-    // -----------------------------------------------------------------------------------
-    
-    /*private final static Field CARRER_LEVEL = getField(VillagerEntity.class, "field_175562_bw"); // careerLevel
-    
-    public static void setCareerLevel(VillagerEntity v, int level)
-    {
-        setInt(v, CARRER_LEVEL, level);
-    }*/
+    }    
     
     // -----------------------------------------------------------------------------------
     // food stats
@@ -268,20 +259,13 @@ public class ReflectionUtils
     // random field gets
     // -----------------------------------------------------------------------------------
     
-    private final static Field TIME_IN_GROUND = getField(ArrowEntity.class, "field_184552_b"); // timeInGround
+    private final static Field TIME_IN_GROUND = getField(AbstractArrowEntity.class, "field_184552_b"); // timeInGround
     
-    public static int getArrowTimeInGround(ArrowEntity arrow)
+    public static int getArrowTimeInGround(AbstractArrowEntity arrow)
     {
         return getInt(arrow, TIME_IN_GROUND, 0);
     }
     
-    /*private final static Field UUID_TO_PLAYER_MAP = getField(PlayerList.class, "field_177454_f", "uuidToPlayerMap");
-    
-    public static Map<UUID, ServerPlayerEntity> getUuidToPlayerMap(PlayerList list)
-    {
-        return getFieldValue(Map.class, list, UUID_TO_PLAYER_MAP);
-    }*/
-    
     private final static Field ENTITY_ITEM_AGE = getField(ItemEntity.class, "field_70292_b"); // age
     
     public static int getAge(ItemEntity item)
@@ -294,13 +278,6 @@ public class ReflectionUtils
         setInt(item, ENTITY_ITEM_AGE, age);
     }
     
-    /*private final static Field BLOCK_MATERIAL = getField(Block.class, "field_149764_J", "blockMaterial");
-    
-    public static Material getBlockMaterial(Block b)
-    {
-        return getFieldValue(Material.class, b, BLOCK_MATERIAL);
-    }*/
-    
     // -----------------------------------------------------------------------------------
     // minecraft server 
     // -----------------------------------------------------------------------------------
@@ -311,18 +288,7 @@ public class ReflectionUtils
     {
         setFieldValue(server, COMMAND_MANAGER, manager);
     }
-    
-    // -----------------------------------------------------------------------------------
-    // WorldSavedDataStorage
-    // -----------------------------------------------------------------------------------
-    
-    /*private final static Field DIMENSION_MAP = getField(WorldSavedDataStorage.class, "field_212427_a"); // no name yet
-    
-    public static void setDimensionStorage(WorldSavedDataStorage wsds, Map<DimensionType, DimensionSavedDataManager> map)
-    {
-        setFieldValue(wsds, DIMENSION_MAP, map);
-    }*/
-      
+       
     // -----------------------------------------------------------------------------------
     // DimensionManager
     // -----------------------------------------------------------------------------------
@@ -351,6 +317,7 @@ public class ReflectionUtils
         }
         catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
         {
+            ex.printStackTrace();
             return damage;
         }
     }
@@ -367,6 +334,7 @@ public class ReflectionUtils
         }
         catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
         {
+            ex.printStackTrace();
         }
     }
 }

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

@@ -329,7 +329,7 @@ public class Utils
     // Player-Tools
     // -------------------------------------------------------------------------
 
-    public static BlockPos getTargetBlock(Entity ent, double range)
+    public static BlockPos getTargetBlock(Entity ent, double range, boolean lastBlock, boolean fluid)
     {
         if(range > 128)
         {
@@ -339,8 +339,10 @@ public class Utils
         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, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, ent));
+                new RayTraceContext(start, end, blockMode, fluidMode, ent));
         if(ray == null || ray.getHitVec() == null)
         {
             return new BlockPos(end);
@@ -348,6 +350,11 @@ public class Utils
         return new BlockPos(ray.getHitVec());  
     }
     
+    public static BlockPos getTargetBlock(Entity ent, double range)
+    {
+        return getTargetBlock(ent, range, true, false);
+    }
+    
     public static ServerPlayerEntity getPlayerByName(String name) throws PlayerNotFoundException
     {
         String nameLower = name.toLowerCase();

+ 1 - 3
src/main/java/me/km/world/WorldManager.java

@@ -1,6 +1,5 @@
 package me.km.world;
 
-import com.google.common.collect.ImmutableMap;
 import java.util.ArrayList;
 import java.util.function.Consumer;
 import me.km.KajetansMod;
@@ -9,7 +8,6 @@ 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.storage.DimensionSavedDataManager;
 import net.minecraftforge.common.DimensionManager;
 import net.minecraftforge.common.ModDimension;
 import net.minecraftforge.registries.ClearableRegistry;
@@ -73,7 +71,7 @@ public class WorldManager
     
     private static boolean containsRegistry(ResourceLocation rl)
     {
-        return DimensionManager.getRegistry().containsKey(rl);
+        return DimensionManager.getRegistry().getOrDefault(rl) != null;
     }
     
     private static void unregister(ResourceLocation rl, DimensionType removeType)

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.