Kajetan Johannes Hammerle hace 7 años
padre
commit
f70c10a4b9

+ 7 - 4
src/main/java/me/km/KajetansMod.java

@@ -69,7 +69,7 @@ public class KajetansMod
 
     public static final String MODID = "km";
     public static final String NAME = "Kajetans Mod";
-    public static final String VERSION = "0.0.27";
+    public static final String VERSION = "0.0.28";
 
     @Mod.Instance(MODID)
     public static KajetansMod instance;
@@ -104,8 +104,11 @@ public class KajetansMod
                     try
                     {
                         EntityPlayerMP p = e.getPlayer();
-                        BlockPos pos = p.getPosition().down();
-                        NBTUtils.cloneBlock(p.world, pos, pos.add(0, 4, 0));
+                        EntityHuman human = new EntityHuman(p.world);
+                        human.setPosition(p.posX, p.posY, p.posZ);
+                        p.world.spawnEntity(human);
+                        
+                        human.setSkinName("e41b53353c7446e9a6c5dafc6334a477");
                     }
                     catch(Exception ex)
                     {
@@ -130,7 +133,7 @@ public class KajetansMod
     
     @Mod.EventHandler
     public void serverStarting(FMLServerStartingEvent e) 
-    {
+    {      
         singlePlayer = e.getServer().isSinglePlayer();
         if(singlePlayer)
         {

+ 13 - 8
src/main/java/me/km/api/Utils.java

@@ -459,9 +459,9 @@ public class Utils
     // -------------------------------------------------------------------------
 
     @SuppressWarnings("unchecked")
-    public static List<Entity> getEntitiesExcluding(Entity ent, World w, BlockPos pos, BlockPos pos2)
+    public static List<Entity> getEntitiesExcluding(Entity ent, World w, double x1, double y1, double z1, double x2, double y2, double z2)
     {       
-        return w.getEntitiesWithinAABBExcludingEntity(ent, new AxisAlignedBB(pos, pos2).grow(1));
+        return w.getEntitiesWithinAABBExcludingEntity(ent, new AxisAlignedBB(x1, y1, z1, x2, y2, z2));
     }
     
     @SuppressWarnings("unchecked")
@@ -554,7 +554,7 @@ public class Utils
             double radius, double mX, double mY, double mZ, Class<T> type)
     {
         World w = p.getEntityWorld();
-        BlockPos l = getPlayerTarget(p, radius);
+        Vec3d l = getPlayerTargetVector(p, radius, false);
         Vec3d eye = getEyeLocation(p);
         if(mX != 0 || mY != 0 || mZ != 0)
         {
@@ -563,9 +563,9 @@ public class Utils
             mY *= r.nextDouble();
             mZ *= r.nextDouble();
         }
-        Vec3d unit = new Vec3d(l.getX() - eye.x + mX, l.getY() - eye.y + mY, l.getZ() - eye.z + mZ);
+        Vec3d unit = new Vec3d(l.x - eye.x + mX, l.y - eye.y + mY, l.z - eye.z + mZ);
         
-        List<Entity> col = getEntitiesExcluding(p, w, new BlockPos(eye), l);
+        List<Entity> col = getEntitiesExcluding(p, w, eye.x, eye.y, eye.z, l.x, l.y, l.z);
         col.removeIf(ent -> !type.isAssignableFrom(ent.getClass()));
         // Entfernt Entities, die sich nicht mit dem Blick-Vektor schneiden
         col.removeIf(ent -> !doesIntersect(ent.getEntityBoundingBox().grow(0.1), eye, unit));
@@ -591,7 +591,7 @@ public class Utils
         return w.playerEntities.stream().min((p1, p2) -> Double.compare(p1.getDistanceSq(v.x, v.y, v.z), p2.getDistanceSq(v.x, v.y, v.z))).orElse(null);
     }
     
-    public static BlockPos getPlayerTarget(EntityPlayer p, double range, boolean boundingBox)
+    public static Vec3d getPlayerTargetVector(EntityPlayer p, double range, boolean boundingBox)
     {
         if(range > 128)
         {
@@ -603,9 +603,14 @@ public class Utils
         RayTraceResult ray = w.rayTraceBlocks(start, end, true, !boundingBox, false);
         if(ray == null)
         {
-            return new BlockPos(end);
+            return end;
         }
-        return ray.getBlockPos();   
+        return ray.hitVec;   
+    }
+    
+    public static BlockPos getPlayerTarget(EntityPlayer p, double range, boolean boundingBox)
+    {
+        return new BlockPos(getPlayerTargetVector(p, range, boundingBox));
     }
     
     public static BlockPos getPlayerTarget(EntityPlayer p, double range)

+ 0 - 1
src/main/java/me/km/datatools/CommandVillager.java

@@ -8,7 +8,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import me.km.inventory.CustomContainer;
-import me.km.inventory.CustomContainerBase;
 import me.km.permissions.Permissions;
 import me.km.inventory.InventoryBase;
 import me.km.inventory.InventoryUtils;

+ 38 - 34
src/main/java/me/km/datatools/DataToolsEvents.java

@@ -2,12 +2,13 @@ package me.km.datatools;
 
 import me.km.api.Module;
 import me.km.api.ModuleListener;
-import me.km.dimensions.ModDimensions;
 import me.km.inventory.CustomContainer;
 import me.km.inventory.InventoryBase;
 import me.km.inventory.InventoryUtils;
 import me.km.utils.ReflectionUtils;
 import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.IInventory;
 import net.minecraft.item.ItemStack;
 import net.minecraft.village.MerchantRecipe;
 import net.minecraft.village.MerchantRecipeList;
@@ -26,46 +27,49 @@ public class DataToolsEvents extends ModuleListener
     @SubscribeEvent
     public void onVillagerMenuClose(PlayerContainerEvent.Close e)
     {             
-        if(!(e.getContainer() instanceof CustomContainer))
+        if(e.getContainer() instanceof CustomContainer)
         {
-            return;
-        }
-        CustomContainer c = (CustomContainer) e.getContainer();
-        InventoryBase inv = c.getInventoryBase();
-        
-        if(inv.getName().startsWith("ChangeInventory"))
-        {
-            InventoryUtils.setInventory(inv);
-            this.getModule().send(e.getEntityPlayer(), "Der Villager-Inventar wurde überschrieben.");
-        }
-        else if(inv.getName().startsWith("ChangeTrades"))
-        {
-            EntityVillager v = (EntityVillager) inv.getOwner();
-            MerchantRecipeList list = v.getRecipes(null);
-            if(list == null)
+            CustomContainer c = (CustomContainer) e.getContainer();
+            InventoryBase inv = c.getInventoryBase();
+            if(inv.getName().startsWith("ChangeTrades"))
             {
-                return; // will never happen
-            }
-            else
-            {
-                list.clear();
-            }
-            MerchantRecipe mr;
-            for(int i = 0; i < 36; i++)
-            {
-                if(i == 9)
+                EntityVillager v = (EntityVillager) inv.getOwner();
+                MerchantRecipeList list = v.getRecipes(null);
+                if(list == null)
                 {
-                    i = 27;
+                    return; // will never happen
                 }
-                if(inv.getStackInSlot(i) == ItemStack.EMPTY)
+                else
                 {
-                    continue;                
-                }          
+                    list.clear();
+                }
+                MerchantRecipe mr;
+                for(int i = 0; i < 36; i++)
+                {
+                    if(i == 9)
+                    {
+                        i = 27;
+                    }
+                    if(inv.getStackInSlot(i) == ItemStack.EMPTY)
+                    {
+                        continue;                
+                    }          
 
-                mr = new MerchantRecipe(inv.getStackInSlot(i + 9), inv.getStackInSlot(i + 18), inv.getStackInSlot(i), 0, Integer.MAX_VALUE);
-                list.add(mr);
+                    mr = new MerchantRecipe(inv.getStackInSlot(i + 9), inv.getStackInSlot(i + 18), inv.getStackInSlot(i), 0, Integer.MAX_VALUE);
+                    list.add(mr);
+                }
+                this.getModule().send(e.getEntityPlayer(), "Die Villager-Trades wurde überschrieben.");
+            }
+        }
+        else if(e.getContainer() instanceof ContainerChest)
+        {
+            ContainerChest c = (ContainerChest) e.getContainer();
+            IInventory inv = c.getLowerChestInventory();
+            if(inv.getName().startsWith("ChangeInventory") && inv instanceof InventoryBase)
+            {
+                InventoryUtils.setInventory((InventoryBase) inv);
+                this.getModule().send(e.getEntityPlayer(), "Der Villager-Inventar wurde überschrieben.");
             }
-            this.getModule().send(e.getEntityPlayer(), "Die Villager-Trades wurde überschrieben.");
         }
     }
     

+ 4 - 3
src/main/java/me/km/entities/HumanSkinLoader.java

@@ -28,8 +28,8 @@ public class HumanSkinLoader
     
     private final HashMap<String, ArrayList<Consumer<ResourceLocation>>> queue;
     
-    private TextureManager manager;
-    private ImageBufferDownload converter;
+    private final TextureManager manager;
+    private final ImageBufferDownload converter;
     
     public HumanSkinLoader()
     {
@@ -96,8 +96,9 @@ public class HumanSkinLoader
                 if(code != 200)
                 {
                     // Failed own server, trying mojangs
+                    //System.out.println("https://crafatar.com/skins/" + name + ".png");
                     httpurlconnection.disconnect();
-                    httpurlconnection = (HttpURLConnection) (new URL("http://skins.minecraft.net/MinecraftSkins/" + name + ".png"))
+                    httpurlconnection = (HttpURLConnection) (new URL("https://crafatar.com/skins/" + name + ".png"))
                             .openConnection(Minecraft.getMinecraft().getProxy());
                     httpurlconnection.setDoInput(true);
                     httpurlconnection.setDoOutput(false);

+ 2 - 2
src/main/java/me/km/inventory/InventoryUtils.java

@@ -8,9 +8,9 @@ import net.minecraft.item.ItemStack;
 
 public class InventoryUtils
 {       
-    public static InventoryBasic getInventory(EntityVillager v)
+    public static InventoryBase getInventory(EntityVillager v)
     {
-        InventoryBase real = new InventoryBase("Villager", 9, v);
+        InventoryBase real = new InventoryBase("ChangeInventory - " + v.getEntityId(), 9, v);
         InventoryBasic old = v.getVillagerInventory();
         for(int i = 0; i < 9; i++)
         {

+ 2 - 3
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -1312,8 +1312,7 @@ public class MinecraftFunctions
         });
         parser.registerFunction("gdmap.get", (sc, in) -> 
         {    
-            KajetansMod.scripts.getDataBank(ScriptBank.class).getDualMapValue(in[0].getString(sc), in[1].getString(sc), in[2].getString(sc)); 
-            return Void.TYPE;
+            return KajetansMod.scripts.getDataBank(ScriptBank.class).getDualMapValue(in[0].getString(sc), in[1].getString(sc), in[2].getString(sc)); 
         });
         parser.registerFunction("gdmap.getordefault", (sc, in) -> 
         {
@@ -1676,7 +1675,7 @@ public class MinecraftFunctions
                 String left = SnuviUtils.connect(sc, in, 1);
                 return ItemStackUtils.getStackFromNbtString((s + left).replace('\'', '"'));
             }
-            if(!s.equals("km") && !s.equals("minecraft"))
+            if(s.indexOf(':') == -1)
             {
                 s = "minecraft:" + s;
             }