Pārlūkot izejas kodu

many bugfixes, changes in snuvi events

Kajetan Johannes Hammerle 4 gadi atpakaļ
vecāks
revīzija
6981f90003

+ 31 - 133
src/main/java/me/km/Client.java

@@ -169,156 +169,54 @@ public class Client
         }
     }
     
-    /*private static int[] counter = new int[5];
-    private static final double BASE_ARRAY_SIZE = 16 * 256 * 16 * 16 + 32;
-    
-    @SubscribeEvent
+    /*@SubscribeEvent
     public void test(net.minecraftforge.client.event.ClientChatEvent e)
     {
         net.minecraft.world.chunk.Chunk c = Minecraft.getInstance().player.world.getChunkAt(Minecraft.getInstance().player.getPosition());
         
-        if(e.getMessage().equals("run"))
-        {
-            countRun(Minecraft.getInstance().player.world, 
-                    c.getPos().getXStart(), c.getPos().getZStart(), 
-                    c.getPos().getXStart() + 16, c.getPos().getZStart() + 16);
-            return;
-        }
-        if(!e.getMessage().equals("octree"))
-        {
-            return;
-        }
-        
-        counter[0] = 0; // 16
-        counter[1] = 0; // 8
-        counter[2] = 0; // 4
-        counter[3] = 0; // 2
-        counter[4] = 0; // 1
-        
-        for(int i = 0; i < 256; i += 16)
-        {
-            count(Minecraft.getInstance().player.world, 
-                    c.getPos().getXStart(), i, c.getPos().getZStart(), 
-                    c.getPos().getXStart() + 16, i + 16, c.getPos().getZStart() + 16, 
-                    0);
-        }
-        
-        System.out.println("16: " + counter[0]);
-        System.out.println("8: " + counter[1]);
-        System.out.println("4: " + counter[2]);
-        System.out.println("2: " + counter[3]);
-        System.out.println("1: " + counter[4]);
-        
-        int size = 16 + 32 * 16;
-        int a = 16 - counter[0];
-        size += a * 264;
-        
-        a *= 8;
-        a -= counter[1];
-        size += a * 264;
-        
-        a *= 8;
-        a -= counter[2];
-        size += a * 264;
-        
-        a *= 8;
-        a -= counter[3];
-        size += a * 128;
-        
-        a *= 8;
-        a -= counter[4];
-        
-        System.out.println("Size: " + size + " Bit check " + a);
-        System.out.println("Compression: " + (BASE_ARRAY_SIZE / size));
-    }
-    
-    private static void countRun(net.minecraft.world.World w, int minX, int minZ, int maxX, int maxZ)
-    {
-        int groups = 0;
-        for(int x = minX; x < maxX; x++)
-        {
-            for(int z = minZ; z < maxZ; z++)
-            {
-                groups += countTower(w, x, z);
-            }
-        }
-        
-        int size = groups * (16 + 8 + 32);
-        int doubleSize = groups * (16 + 8 + 32 * 2);
-        
-        System.out.println("Size 1: " + size);
-        System.out.println("Size 2: " + doubleSize);
-        System.out.println("Compression 1: " + (BASE_ARRAY_SIZE / size));
-        System.out.println("Compression 2: " + (BASE_ARRAY_SIZE / doubleSize));
-    }
-    
-    private static int countTower(net.minecraft.world.World w, int x, int z)
-    {
-        net.minecraft.util.math.BlockPos.MutableBlockPos pos = new net.minecraft.util.math.BlockPos.MutableBlockPos();
-        pos.setPos(x, 255, z);
-        net.minecraft.block.Block b = w.getBlockState(pos).getBlock();
-        int groups = 1;
-        for(int y = 255; y >= 0; y--)
-        {
-            pos.setPos(x, y, z);
-            net.minecraft.block.Block ob = w.getBlockState(pos).getBlock();
-            if(b != ob)
-            {
-                groups++;
-                b = ob;
-            }
-        }
-        return groups;
-    }
-    
-    private static void count(net.minecraft.world.World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int depth)
-    {
-        if(isSameBlock(w, minX, minY, minZ, maxX, maxY, maxZ))
+        if(!e.getMessage().equals("run"))
         {
-            counter[depth]++;
             return;
         }
-        if(depth == 4)
-        {
-            counter[4]++;
-            return;
-        }
-        
-        int midX = (minX + maxX) >> 1;
-        int midY = (minY + maxY) >> 1;
-        int midZ = (minZ + maxZ) >> 1;
-        
-        depth++;
-        count(w, minX, minY, minZ, midX, midY, midZ, depth);
-        count(w, midX, minY, minZ, maxX, midY, midZ, depth);
-        count(w, minX, minY, midZ, midX, midY, maxZ, depth);
-        count(w, midX, minY, midZ, maxX, midY, maxZ, depth);
+
+        int cluster = 0;
+        int blocks = 0;
         
-        count(w, minX, midY, minZ, midX, maxY, midZ, depth);
-        count(w, midX, midY, minZ, maxX, maxY, midZ, depth);
-        count(w, minX, midY, midZ, midX, maxY, maxZ, depth);
-        count(w, midX, midY, midZ, maxX, maxY, maxZ, depth);
-    }
-    
-    private static boolean isSameBlock(net.minecraft.world.World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
-    {
         net.minecraft.util.math.BlockPos.MutableBlockPos pos = new net.minecraft.util.math.BlockPos.MutableBlockPos();
-        pos.setPos(minX, minY, minZ);
-        net.minecraft.block.Block b = w.getBlockState(pos).getBlock();
-        for(int x = minX; x < maxX; x++)
+
+        for(int x = 0; x < 16; x += 4)
         {
-            for(int y = minY; y < maxY; y++)
+            for(int z = 0; z < 16; z += 4)
             {
-                for(int z = minZ; z < maxZ; z++)
+                for(int y = 0; y < 256; y += 16)
                 {
+                    cluster++;
                     pos.setPos(x, y, z);
-                    if(b != w.getBlockState(pos).getBlock())
+                    blocks++;
+                    net.minecraft.block.Block current = c.getBlockState(pos).getBlock();
+                    for(int mx = 0; mx < 4; mx++)
                     {
-                        return false;
+                        for(int mz = 0; mz < 4; mz++)
+                        {
+                            for(int my = 0; my < 16; my++)
+                            {
+                                pos.setPos(x + mx, y + my, z + mz);
+                                net.minecraft.block.Block next = c.getBlockState(pos).getBlock();
+                                if(current != next)
+                                {
+                                    current = next;
+                                    blocks++;
+                                }
+                            }
+                        }
                     }
                 }
             }
         }
-        return true;
+        
+        System.out.println(String.format("%d cluster %d blocks", cluster, blocks));
+        double whole = cluster * 32 + blocks * 16;
+        System.out.println(whole);
+        System.out.println(whole / (16 * 16 * 256 * 16));
     }*/
 }

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

@@ -118,7 +118,7 @@ public class Server
         
         PlayerManager playerManager = new PlayerManager(logger, playerBank);
         MinecraftForge.EVENT_BUS.register(playerManager);
-        CustomEventCaller customEventCaller = new CustomEventCaller(playerManager, server, scheduler);
+        CustomEventCaller customEventCaller = new CustomEventCaller(server, scheduler);
         scripts.setCustomEventCaller(customEventCaller);
         MinecraftForge.EVENT_BUS.register(customEventCaller);
         

+ 135 - 84
src/main/java/me/km/entities/EntityItemProjectile.java

@@ -1,146 +1,197 @@
 package me.km.entities;
 
-import java.util.List;
 import me.km.Server;
 import me.km.overrides.ModEntityPlayerMP;
-import me.km.utils.ReflectionUtils;
+import net.minecraft.block.Blocks;
 import net.minecraft.entity.Entity;
 import net.minecraft.entity.LivingEntity;
 import net.minecraft.entity.IProjectile;
 import net.minecraft.entity.item.ItemEntity;
+import net.minecraft.entity.projectile.ProjectileHelper;
 import net.minecraft.item.ItemStack;
+import net.minecraft.particles.ParticleTypes;
 import net.minecraft.util.DamageSource;
 import net.minecraft.util.math.AxisAlignedBB;
+import net.minecraft.util.math.BlockRayTraceResult;
+import net.minecraft.util.math.EntityRayTraceResult;
 import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.math.RayTraceContext;
+import net.minecraft.util.math.RayTraceResult;
+import net.minecraft.util.math.Vec3d;
 
 public class EntityItemProjectile extends ItemEntity implements IProjectile
 {
-    private final LivingEntity thrower;
-    private boolean noHit;
+    private LivingEntity owner;
+    private boolean hit = false;
     private final float damage;
+    private Entity ignoreEntity = null;
+    private int ignoreTime = 0;
 
-    public EntityItemProjectile(LivingEntity thrower, ItemStack stack, float damage) 
+    public EntityItemProjectile(LivingEntity thrower, ItemStack stack, float damage)
     {
         super(thrower.world, thrower.posX, thrower.posY + thrower.getEyeHeight() - 0.1d, thrower.posZ, stack);
-        this.thrower = thrower;
-        this.noHit = true;
+        this.owner = thrower;
         super.setInfinitePickupDelay();
         this.damage = damage;
     }
-    
-    public EntityItemProjectile(LivingEntity thrower, ItemStack stack) 
+
+    public EntityItemProjectile(LivingEntity thrower, ItemStack stack)
     {
         this(thrower, stack, -1);
     }
 
-    public LivingEntity getItemThrower() 
+    public LivingEntity getItemThrower()
     {
-        return thrower;
+        return owner;
     }
 
     public void setHeadingFromThrower(Entity thrower, float rotationPitchIn, float rotationYawIn, float pitchOffset, float velocity, float inaccuracy)
     {
-        float f = -MathHelper.sin(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F);
-        float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * 0.017453292F);
-        float f2 = MathHelper.cos(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F);
-        this.shoot(f, f1, f2, velocity, inaccuracy);
-
-        double y = thrower.onGround ? 0.0 : thrower.getMotion().getY();
-        this.setMotion(this.getMotion().add(thrower.getMotion().getX(), y, thrower.getMotion().getZ()));
-    }
-    
-    public void shoot(Entity shooter, float pitch, float yaw, float velocity, float inaccuracy)
-    {
-        float f = -MathHelper.sin(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F);
-        float f1 = -MathHelper.sin(pitch * 0.017453292F);
-        float f2 = MathHelper.cos(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F);
-        this.shoot(f, f1, f2, velocity, inaccuracy);
-        
-        double y = shooter.onGround ? 0.0 : shooter.getMotion().getY();
-        this.setMotion(this.getMotion().add(shooter.getMotion().getX(), y, shooter.getMotion().getZ()));
+        float f = -MathHelper.sin(rotationYawIn * ((float) Math.PI / 180.0f)) * MathHelper.cos(rotationPitchIn * ((float) Math.PI / 180.0f));
+        float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * ((float) Math.PI / 180.0f));
+        float f2 = MathHelper.cos(rotationYawIn * ((float) Math.PI / 180.0f)) * MathHelper.cos(rotationPitchIn * ((float) Math.PI / 180.0f));
+        shoot(f, f1, f2, velocity, inaccuracy);
+        Vec3d vec3d = thrower.getMotion();
+        this.setMotion(this.getMotion().add(vec3d.x, thrower.onGround ? 0.0D : vec3d.y, vec3d.z));
     }
-    
+
     @Override
     public void shoot(double x, double y, double z, float velocity, float inaccuracy)
     {
-        float f = MathHelper.sqrt(x * x + y * y + z * z);
-        x = x / (double)f;
-        y = y / (double)f;
-        z = z / (double)f;
-        x = x + this.rand.nextGaussian() * 0.0075d * (double)inaccuracy;
-        y = y + this.rand.nextGaussian() * 0.0075d * (double)inaccuracy;
-        z = z + this.rand.nextGaussian() * 0.0075d * (double)inaccuracy;
-        x = x * (double)velocity;
-        y = y * (double)velocity;
-        z = z * (double)velocity;
-        this.setMotion(x, y, z);
-        float f1 = MathHelper.sqrt(x * x + z * z);
-        this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
-        this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI));
+        Vec3d vec3d = new Vec3d(x, y, z)
+                .normalize()
+                .add(rand.nextGaussian() * 0.0075 * inaccuracy, rand.nextGaussian() * 0.0075 * inaccuracy, rand.nextGaussian() * 0.0075 * inaccuracy)
+                .scale(velocity);
+        setMotion(vec3d);
+        float f1 = MathHelper.sqrt(func_213296_b(vec3d));
+        this.rotationYaw = (float) (MathHelper.atan2(x, z) * (180.0 / Math.PI));
+        this.rotationPitch = (float) (MathHelper.atan2(y, f1) * (180.0 / Math.PI));
         this.prevRotationYaw = this.rotationYaw;
         this.prevRotationPitch = this.rotationPitch;
     }
 
+    private void onImpact(RayTraceResult ray)
+    {
+        if(damage == -1)
+        {
+            if(!(owner instanceof ModEntityPlayerMP))
+            {
+                return;
+            }
+            ModEntityPlayerMP p = (ModEntityPlayerMP) owner;
+            switch(ray.getType())
+            {
+                case ENTITY:
+                    Server.scriptEvents.onEntityItemProjectileHit(this, p, this.getItem(), ((EntityRayTraceResult) ray).getEntity(), null);
+                    break;
+                case BLOCK:
+                    Server.scriptEvents.onEntityItemProjectileHit(this, p, this.getItem(), null, ((BlockRayTraceResult) ray).getPos());
+                    break;
+            }
+        }
+        else if(ray.getType() == RayTraceResult.Type.ENTITY)
+        {
+            ((EntityRayTraceResult) ray).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, owner), damage);
+        }
+    }
+
     @Override
-    public void tick() 
+    public void tick()
     {
         super.tick();
-        if(noHit)
+        if(hit)
         {
-            if(this.onGround)
+            return;
+        }
+
+        AxisAlignedBB axisalignedbb = this.getBoundingBox().expand(this.getMotion()).grow(2.0D);
+
+        for(Entity entity : this.world.getEntitiesInAABBexcluding(this, axisalignedbb, (p) -> !p.isSpectator() && p.canBeCollidedWith()))
+        {
+            if(entity == this.ignoreEntity)
             {
-                noHit = false;
-                this.setDefaultPickupDelay();
-                return;
+                this.ignoreTime++;
+                break;
             }
-            
-            float fw = this.getWidth() / 2;
-            float fh = this.getHeight() / 2;
-            List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, 
-                    new AxisAlignedBB(prevPosX, prevPosY, prevPosZ, posX, posY, posZ).expand(fw, fh, fw));
-            if(list.isEmpty())
+
+            if(this.owner != null && this.ticksExisted < 2 && this.ignoreEntity == null)
             {
-                return;
+                this.ignoreEntity = entity;
+                this.ignoreTime = 3;
+                break;
             }
-            
-            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 -> 
+        }
+
+        RayTraceResult ray = ProjectileHelper.func_221267_a(this, axisalignedbb, 
+                (p) -> !p.isSpectator() && p.canBeCollidedWith() && p != this.ignoreEntity, RayTraceContext.BlockMode.OUTLINE, true);
+        if(this.ignoreEntity != null && this.ignoreTime-- <= 0)
+        {
+            this.ignoreEntity = null;
+        }
+
+        if(ray.getType() != RayTraceResult.Type.MISS)
+        {
+            if(ray.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult) ray).getPos()).getBlock() == Blocks.NETHER_PORTAL)
             {
-                // this prevents the projectile from hitting its shooter during
-                // the first ticks
-                if(ent == thrower && ReflectionUtils.getAge(this) < 5)
-                {
-                    return true;
-                }
-                // size of the projectile is 0.25 x 0.25
-                return !ent.getBoundingBox().grow(0.25f).intersects(minX, minY, minZ, maxX, maxY, maxZ);
-            });
-            if(!list.isEmpty())
+                this.setPortal(((BlockRayTraceResult) ray).getPos());
+            }
+            else
             {
-                noHit = false;
+                this.onImpact(ray);
+                hit = true;
                 this.setDefaultPickupDelay();
-                onImpact(list);
             }
         }
-    }
 
-    protected void onImpact(List<Entity> list)
-    {
-        if(damage == -1)
+        Vec3d vec3d = this.getMotion();
+        this.posX += vec3d.x;
+        this.posY += vec3d.y;
+        this.posZ += vec3d.z;
+        float f = MathHelper.sqrt(func_213296_b(vec3d));
+        this.rotationYaw = (float) (MathHelper.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI));
+
+        for(this.rotationPitch = (float) (MathHelper.atan2(vec3d.y, (double) f) * (double) (180F / (float) Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
+        {
+        }
+
+        while(this.rotationPitch - this.prevRotationPitch >= 180.0F)
         {
-            if(thrower instanceof ModEntityPlayerMP)
+            this.prevRotationPitch += 360.0F;
+        }
+
+        while(this.rotationYaw - this.prevRotationYaw < -180.0F)
+        {
+            this.prevRotationYaw -= 360.0F;
+        }
+
+        while(this.rotationYaw - this.prevRotationYaw >= 180.0F)
+        {
+            this.prevRotationYaw += 360.0F;
+        }
+
+        this.rotationPitch = MathHelper.lerp(0.2F, this.prevRotationPitch, this.rotationPitch);
+        this.rotationYaw = MathHelper.lerp(0.2F, this.prevRotationYaw, this.rotationYaw);
+        float f1;
+        if(this.isInWater())
+        {
+            for(int i = 0; i < 4; ++i)
             {
-                Server.scriptEvents.onEntityItemProjectileHit(this, (ModEntityPlayerMP) thrower, this.getItem(), list);
+                this.world.addParticle(ParticleTypes.BUBBLE, this.posX - vec3d.x * 0.25D, this.posY - vec3d.y * 0.25D, this.posZ - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
             }
+            f1 = 0.8F;
         }
         else
         {
-            list.forEach(ent -> ent.attackEntityFrom(DamageSource.causeThrownDamage(this, thrower), damage));
+            f1 = 0.99F;
+        }
+
+        this.setMotion(vec3d.scale((double) f1));
+        if(!this.hasNoGravity())
+        {
+            Vec3d vec3d1 = this.getMotion();
+            this.setMotion(vec3d1.x, vec3d1.y - 0.03, vec3d1.z);
         }
+
+        this.setPosition(this.posX, this.posY, this.posZ);
     }
 }

+ 3 - 4
src/main/java/me/km/events/CustomEventCaller.java

@@ -4,11 +4,12 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import me.hammerle.snuviscript.code.Script;
 import me.km.DamageUtils;
-import me.km.playerbank.PlayerManager;
 import me.km.scheduler.SnuviScheduler;
 import me.km.utils.ReflectionUtils;
 import net.minecraft.entity.LivingEntity;
 import net.minecraft.entity.SharedMonsterAttributes;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.server.MinecraftServer;
 import net.minecraft.util.CombatRules;
 import net.minecraft.util.DamageSource;
@@ -24,13 +25,11 @@ public class CustomEventCaller
     private final LinkedList<Integer> removeQueue = new LinkedList<>();
     private final LinkedList<PlayerMoveData> addQueue = new LinkedList<>();
     
-    private final PlayerManager pManager;
     private final MinecraftServer server;
     private final SnuviScheduler scheduler;
     
-    public CustomEventCaller(PlayerManager pManager, MinecraftServer server, SnuviScheduler scheduler)
+    public CustomEventCaller(MinecraftServer server, SnuviScheduler scheduler)
     {
-        this.pManager = pManager;
         this.server = server;
         this.scheduler = scheduler;
     }

+ 8 - 36
src/main/java/me/km/events/PlayerMoveData.java

@@ -1,6 +1,6 @@
 package me.km.events;
 
-import java.util.function.BiPredicate;
+import java.util.UUID;
 import me.hammerle.snuviscript.code.Script;
 import me.km.Server;
 import me.km.utils.Location;
@@ -12,13 +12,10 @@ public class PlayerMoveData
     private static int idCounter = 0;
     
     private final Script sc;
-    private final BiPredicate<ServerPlayerEntity, Object> c;
     private final int coolDown;
     private int ticks;
     private int livingTime;
     
-    private Object data;
-    
     private final IWorld w;
     private final double minX;
     private final double minY;
@@ -27,13 +24,12 @@ public class PlayerMoveData
     private final double maxY;
     private final double maxZ;
     
-    private final int id;
+    private final int id = idCounter++;
+    private final UUID uuid;
     
-    private PlayerMoveData(Script sc, BiPredicate<ServerPlayerEntity, Object> c, Location l1, Location l2, int cooldown, int livingTime, Object data)
+    public PlayerMoveData(Script sc, Location l1, Location l2, int cooldown, int livingTime, UUID uuid)
     {
-        this.id = idCounter++;
         this.sc = sc;
-        this.c = c;
         this.coolDown = cooldown;
         this.ticks = cooldown;
         this.livingTime = livingTime;
@@ -44,20 +40,7 @@ public class PlayerMoveData
         this.maxX = Math.max(l1.getX(), l2.getX());
         this.maxY = Math.max(l1.getY(), l2.getY());
         this.maxZ = Math.max(l1.getZ(), l2.getZ());
-        this.data = data;
-        //System.out.println("X DATA FROM " + minX +" TO " + maxX);
-        //System.out.println("Y DATA FROM " + minY +" TO " + maxY);
-        //System.out.println("Z DATA FROM " + minZ +" TO " + maxZ);
-    }
-    
-    public PlayerMoveData(Script sc, Location l1, Location l2, int cooldown, int livingTime)
-    {
-        this(sc, null, l1, l2, cooldown, livingTime, null);
-    }
-    
-    public PlayerMoveData(BiPredicate<ServerPlayerEntity, Object> c, Location l1, Location l2, int cooldown, int livingTime, Object data)
-    {
-        this(null, c, l1, l2, cooldown, livingTime, data);
+        this.uuid = uuid;
     }
 
     public int getId() 
@@ -70,11 +53,6 @@ public class PlayerMoveData
         return this.sc == sc;
     }
     
-    public Object getData()
-    {
-        return data;
-    }
-    
     public boolean tickLiving()
     {
         if(livingTime == -1)
@@ -102,17 +80,11 @@ public class PlayerMoveData
         {
             return false;
         }
-        if(sc != null)
+        boolean b = (uuid == null || p.getUniqueID().equals(uuid));
+        if(sc != null && b)
         {
             Server.scriptEvents.onPlayerMove(p, id);
         }
-        if(c != null)
-        {
-            if(c.test(p, data))
-            {
-                return true;
-            }
-        }
-        return coolDown == -1;
+        return coolDown == -1 && b;
     }
 }

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

@@ -96,7 +96,7 @@ public class ItemSling extends Item
                         ItemStack ammoCopy = ammo.copy();
                         ammoCopy.setCount(1);
                         EntityItemProjectile proj = new EntityItemProjectile(p, ammoCopy, 2.0f);
-                        proj.shoot(p, p.rotationPitch, p.rotationYaw, f, 1.0f);
+                        proj.setHeadingFromThrower(p, p.rotationPitch, p.rotationYaw, 0.0f, f, 1.0f);
                         stack.damageItem(1, p, (c) -> {});
                         w.addEntity(proj);
                     }

+ 16 - 6
src/main/java/me/km/networking/CustomInventoryScreen.java

@@ -6,8 +6,6 @@ import me.km.inventory.CustomContainer;
 import me.km.inventory.ModInventory;
 import net.minecraft.client.gui.IHasContainer;
 import net.minecraft.client.gui.screen.inventory.ContainerScreen;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.text.ITextComponent;
@@ -17,10 +15,12 @@ import net.minecraftforge.api.distmarker.OnlyIn;
 @OnlyIn(Dist.CLIENT)
 public class CustomInventoryScreen extends ContainerScreen<CustomContainer> implements IHasContainer<CustomContainer>
 {
-    /** The ResourceLocation containing the chest GUI texture. */
+    /**
+     * The ResourceLocation containing the chest GUI texture.
+     */
     private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
     private static final ResourceLocation EMPTY_TILE = new ResourceLocation(KajetansMod.MODID, "textures/gui/container/empty_tile.png");
-    
+
     private final int inventoryRows;
 
     public CustomInventoryScreen(CustomContainer cc, PlayerInventory pInv, ITextComponent title)
@@ -55,7 +55,7 @@ public class CustomInventoryScreen extends ContainerScreen<CustomContainer> impl
         int j = (height - ySize) / 2;
         blit(i, j, 0, 0, this.xSize, inventoryRows * 18 + 17);
         blit(i, j + inventoryRows * 18 + 17, 0, 126, xSize, 96);
-        
+
         i += 7;
         j += 17;
         minecraft.getTextureManager().bindTexture(EMPTY_TILE);
@@ -75,7 +75,7 @@ public class CustomInventoryScreen extends ContainerScreen<CustomContainer> impl
             }
         }
     }
-    
+
     /*public void blit(int startX, int startY, int tStartX, int tStartY, int width, int height)
     {
         blit(startX, startY, this.blitOffset, tStartX, tStartY, width, height, 256, 256);
@@ -85,7 +85,17 @@ public class CustomInventoryScreen extends ContainerScreen<CustomContainer> impl
     {
         innerBlit(startX, startX + width, startY, startY + height, z, width, height, tStartX, tStartY, rHeight, rWidth);
     }
+
+    public static void blit(int minX, int minY, int width, int height, float tStartX, float tStartY, int tWidth, int tHeight, int rWidth, int rHeight)
+    {
+        innerBlit(minX, minX + width, minY, minY + height, 0, tWidth, tHeight, tStartX, tStartY, rWidth, rHeight);
+    }
     
+    public static void blit(int p_blit_0_, int p_blit_1_, float p_blit_2_, float p_blit_3_, int p_blit_4_, int p_blit_5_, int p_blit_6_, int p_blit_7_)
+    {
+        blit(p_blit_0_, p_blit_1_, p_blit_4_, p_blit_5_, p_blit_2_, p_blit_3_, p_blit_4_, p_blit_5_, p_blit_6_, p_blit_7_);
+    }
+
     private static void innerBlit(int minX, int maxX, int minY, int maxY, int z, int tWidth, int tHight, float tStartX, float tStartY, int rWidth, int rHeight)
     {
         innerBlit(minX, maxX, minY, maxY, z, 

+ 2 - 1
src/main/java/me/km/networking/PlayerDisplayGui.java

@@ -163,8 +163,9 @@ public class PlayerDisplayGui extends AbstractGui
     
     private int paintIcons(IconStorage is, int x, int y)
     {
-        bind(CUSTOM_ICONS);
         GlStateManager.enableBlend();
+        GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+        bind(CUSTOM_ICONS);
         Icon icon = is.icon;
         int width = icon.getWidth();
         int height = icon.getHeight();

+ 13 - 11
src/main/java/me/km/networking/PlayerHeadGui.java

@@ -1,5 +1,6 @@
 package me.km.networking;
 
+import com.mojang.blaze3d.platform.GlStateManager;
 import java.util.TreeMap;
 import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.AbstractGui;
@@ -19,7 +20,7 @@ public class PlayerHeadGui extends AbstractGui
         private final int y;
         private final int scale;
         private final ResourceLocation rl;
-        
+
         public HeadData(int x, int y, int scale, ResourceLocation rl)
         {
             this.x = x;
@@ -27,24 +28,25 @@ public class PlayerHeadGui extends AbstractGui
             this.scale = scale;
             this.rl = rl;
         }
-        
+
         public void paint(Minecraft mc)
         {
+            GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
             mc.getTextureManager().bindTexture(rl);
-            AbstractGui.blit(x, y, 8, 8, 8.0F, 8 * scale, 8, 8 * scale, 64, 64);
-            AbstractGui.blit(x, y, 8, 8, 40.0F, 8 * scale, 8, 8 * scale, 64, 64);
+            AbstractGui.blit(x, y, 8 * scale, 8 * scale, 8.0f, 8.0f, 8, 8, 64, 64);
+            AbstractGui.blit(x, y, 8 * scale, 8 * scale, 40.0f, 8.0f, 8, 8, 64, 64);
         }
     }
-    
+
     private final TreeMap<Integer, HeadData> data;
     private final Minecraft mc;
-    
+
     public PlayerHeadGui(Minecraft mc)
     {
         this.mc = mc;
-        this.data = new TreeMap<>(); 
+        this.data = new TreeMap<>();
     }
-    
+
     public void add(int i, int x, int y, int scale, String name)
     {
         NetworkPlayerInfo info = this.mc.player.connection.getPlayerInfo(name);
@@ -53,17 +55,17 @@ public class PlayerHeadGui extends AbstractGui
             data.put(i, new HeadData(x, y, scale, info.getLocationSkin()));
         }
     }
-    
+
     public void remove(int i)
     {
         data.remove(i);
     }
-    
+
     public void clear()
     {
         data.clear();
     }
-    
+
     public void paint()
     {
         data.values().forEach(head -> head.paint(mc));

+ 2 - 2
src/main/java/me/km/plots/PlotMap.java

@@ -250,7 +250,7 @@ public class PlotMap
     
     public List<Plot> getPlotAt(int x, int y, int z)
     {
-        ArrayList<Plot> list = plots[hash(x / SIZE_FACTOR, z / SIZE_FACTOR, plots.length)];
+        ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
         if(list == null)
         {
             return new ArrayList<>();
@@ -260,7 +260,7 @@ public class PlotMap
     
     public boolean anyPlotMatches(int x, int y, int z, boolean empty, Predicate<Plot> pred)
     {
-        ArrayList<Plot> list = plots[hash(x / SIZE_FACTOR, z / SIZE_FACTOR, plots.length)];
+        ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
         if(list == null)
         {
             return empty;

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

@@ -110,7 +110,7 @@ public class ProtectionEvents
     }
 
     @SubscribeEvent
-    public void onThrowableImpace(ProjectileImpactEvent.Throwable e)
+    public void onThrowableImpact(ProjectileImpactEvent.Throwable e)
     {
         if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY)
         {

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

@@ -1130,8 +1130,12 @@ public class MinecraftFunctions
         // ---------------------------------------------------------------------    
         // Event-library 
         // ---------------------------------------------------------------------  
-        sm.registerFunction("event.addmovedata", (sc, in) -> (double) cec.registerMoveData(new PlayerMoveData(
-                sc, (Location) in[0].get(sc), (Location) in[1].get(sc), in[2].getInt(sc), in[3].getInt(sc))));
+        sm.registerFunction("event.addmovedata", (sc, in) -> 
+        {
+            UUID uuid = in.length >= 5 ? getUUID(in[4].get(sc)) : null;
+            PlayerMoveData pmd = new PlayerMoveData(sc, (Location) in[0].get(sc), (Location) in[1].get(sc), in[2].getInt(sc), in[3].getInt(sc), uuid);
+            return (double) cec.registerMoveData(pmd);
+        });
         sm.registerFunction("event.removemovedata", (sc, in) -> 
         { 
             cec.removeMoveData(in[0].getInt(sc));

+ 38 - 23
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -29,6 +29,7 @@ import net.minecraft.server.MinecraftServer;
 import net.minecraft.server.management.PlayerList;
 import net.minecraft.util.Hand;
 import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.BlockRayTraceResult;
 import net.minecraft.util.math.EntityRayTraceResult;
 import net.minecraft.util.math.RayTraceResult;
 import net.minecraft.util.text.ITextComponent;
@@ -403,35 +404,49 @@ public class ScriptEvents
     @SubscribeEvent
     public void onProjectileHit(ProjectileImpactEvent e)
     {        
-        Entity hitEntity;
-        boolean hit;
+        final Entity hitEntity;
+        final Location loc;
         
-        if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY && e.getRayTraceResult() instanceof EntityRayTraceResult)
-        {
-            hit = true;
-            hitEntity = ((EntityRayTraceResult) e.getRayTraceResult()).getEntity(); 
-        }
-        else
-        {
-            hit = false;
-            hitEntity = null;
+        RayTraceResult ray = e.getRayTraceResult();
+        switch(ray.getType())
+        {
+            case ENTITY:
+                hitEntity = ((EntityRayTraceResult) e.getRayTraceResult()).getEntity();
+                loc = null;
+                break;
+            case BLOCK:
+                loc = new Location(e.getEntity().world, ((BlockRayTraceResult) e.getRayTraceResult()).getPos());
+                hitEntity = null;
+                break;
+            default:
+                return;
         }
         
         handleEvent(Utils.getPlayerFromProjectile(e.getEntity()), "throw_hit", (sc) -> 
         {
-            sc.setVar("is_entity_hit", hit);
             sc.setVar("entity_hit", hitEntity);
+            sc.setVar("loc_hit", loc);
             ScriptVars.setEntityVars(sc, e.getEntity());
         });   
     }
     
-    public void onEntityItemProjectileHit(EntityItemProjectile ent, PlayerEntity p, ItemStack stack, List<Entity> ents)
+    public void onEntityItemProjectileHit(EntityItemProjectile ent, PlayerEntity p, ItemStack stack, Entity hitEntity, BlockPos pos)
     {        
+        Location loc;
+        if(pos == null)
+        {
+            loc = null;
+        }
+        else
+        {
+            loc = new Location(ent.world, pos);
+        }
         handleEvent(p, "item_hit", (sc) -> 
         {
             ScriptVars.setEntityVars(sc, ent);
             ScriptVars.setItemVars(sc, stack);
-            sc.setVar("entities", ents);
+            sc.setVar("entity_hit", hitEntity);
+            sc.setVar("loc_hit", loc);
         });      
     }
     
@@ -442,7 +457,7 @@ public class ScriptEvents
         {
             return;
         }
-        PlayerEntity p = e.getEntityPlayer();   
+        PlayerEntity p = e.getPlayer();   
         if(p.getHeldItemMainhand().getItem() != Items.SHEARS)
         {
             return;
@@ -503,10 +518,10 @@ public class ScriptEvents
     @SubscribeEvent
     public void onBucketFill(FillBucketEvent e)
     {     
-        handleEvent(e.getEntityPlayer(), "bucket_use", (sc) -> 
+        handleEvent(e.getPlayer(), "bucket_use", (sc) -> 
         {
             RayTraceResult ray = e.getTarget();
-            if(ray != null || ray.hitInfo != null || ray.hitInfo instanceof BlockPos)
+            if(ray != null && ray.hitInfo != null && ray.hitInfo instanceof BlockPos)
             {
                 BlockPos pos = (BlockPos) ray.hitInfo;
                 sc.setVar("has_block", true); 
@@ -548,7 +563,7 @@ public class ScriptEvents
         {
             return;
         }
-        handleEvent(e.getEntityPlayer(), "block_click", (sc) -> 
+        handleEvent(e.getPlayer(), "block_click", (sc) -> 
         {
             sc.setVar("action", "right");
             ScriptVars.setBlockVars(sc, e.getWorld(), e.getPos());
@@ -566,7 +581,7 @@ public class ScriptEvents
         {
             return;
         }
-        handleEvent(e.getEntityPlayer(), "block_click", (sc) -> 
+        handleEvent(e.getPlayer(), "block_click", (sc) -> 
         {
             sc.setVar("action", "left");
             ScriptVars.setBlockVars(sc, e.getWorld(), e.getPos());
@@ -582,7 +597,7 @@ public class ScriptEvents
     {
         if(e.getHand() != Hand.OFF_HAND)
         {
-            handleEvent(e.getEntityPlayer(), "entity_click", (sc) -> 
+            handleEvent(e.getPlayer(), "entity_click", (sc) -> 
             {
                 ScriptVars.setEntityVars(sc, e.getTarget());
                 sc.setVar("cancel", e.isCanceled()); 
@@ -596,7 +611,7 @@ public class ScriptEvents
     @SubscribeEvent
     public void onFishing(ItemFishedEvent e)
     {
-        handleEvent(e.getEntityPlayer(), "fishing", (sc) -> 
+        handleEvent(e.getPlayer(), "fishing", (sc) -> 
         {
             sc.setVar("drops", e.getDrops());
             sc.setVar("cancel", e.isCanceled()); 
@@ -609,7 +624,7 @@ public class ScriptEvents
     @SubscribeEvent
     public void onItemClick(PlayerInteractEvent.RightClickItem e)
     {        
-        handleEvent(e.getEntityPlayer(), "item_air_click", (sc) -> 
+        handleEvent(e.getPlayer(), "item_air_click", (sc) -> 
         {
             ScriptVars.setItemVars(sc, e.getItemStack());
             sc.setVar("hand", e.getHand().toString());
@@ -691,7 +706,7 @@ public class ScriptEvents
     @SubscribeEvent
     public void onItemPickup(EntityItemPickupEvent e)
     {
-        handleEvent(e.getEntityPlayer(), "player_pickup", (sc) -> 
+        handleEvent(e.getPlayer(), "player_pickup", (sc) -> 
         {
             ScriptVars.setEntityVars(sc, e.getItem()); 
             ScriptVars.setItemVars(sc, e.getItem().getItem());  

+ 0 - 3
src/main/java/me/km/utils/ReflectionUtils.java

@@ -4,7 +4,6 @@ import cpw.mods.modlauncher.api.INameMappingService;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.HashMap;
 import java.util.Map;
 import net.minecraft.command.Commands;
 import net.minecraft.entity.Entity;
@@ -14,8 +13,6 @@ import net.minecraft.entity.player.PlayerAbilities;
 import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.server.MinecraftServer;
 import net.minecraft.server.management.PlayerList;
-import net.minecraft.state.IProperty;
-import net.minecraft.state.properties.BlockStateProperties;
 import net.minecraft.util.DamageSource;
 import net.minecraft.util.FoodStats;
 import net.minecraft.util.ResourceLocation;

+ 0 - 2
src/main/java/me/km/utils/TableUtils.java

@@ -1,7 +1,5 @@
 package me.km.utils;
 
-import java.util.List;
-
 public class TableUtils 
 {
     public static String getTable(int width, String color, String... args)

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

@@ -2,7 +2,7 @@ modLoader="javafml"
 loaderVersion="[28,)"
 [[mods]]
 modId="km"
-version="0.0.39"
+version="0.0.40"
 displayName="Kajetans Mod"
 credits="kajetanjohannes"
 authors="kajetanjohannes"