Forráskód Böngészése

item stack display gui, new snuvi functions

Kajetan Johannes Hammerle 6 éve
szülő
commit
2953a61c4c

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

@@ -67,7 +67,7 @@ public class KajetansMod
 
     public static final String MODID = "km";
     public static final String NAME = "Kajetans Mod";
-    public static final String VERSION = "0.0.31";
+    public static final String VERSION = "0.0.32";
 
     @Mod.Instance(MODID)
     public static KajetansMod instance;

+ 37 - 20
src/main/java/me/km/networking/ItemStackDisplayGui.java

@@ -1,9 +1,14 @@
 package me.km.networking;
 
+import java.lang.reflect.Field;
+import java.util.Map;
 import me.km.KajetansMod;
+import me.km.utils.ReflectionUtils;
+import net.minecraft.block.Block;
 import net.minecraft.client.Minecraft;
 import net.minecraft.client.gui.FontRenderer;
 import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiBossOverlay;
 import net.minecraft.client.gui.ScaledResolution;
 import net.minecraft.client.renderer.GlStateManager;
 import net.minecraft.util.ResourceLocation;
@@ -38,8 +43,8 @@ public class ItemStackDisplayGui extends Gui
         if(index >= 0 && index < 9)
         {
             index *= 3;
-            icons[index] = i < 48 ? 64 + ((i % 12) << 4) : (((i - 48) & 0xF) << 4);
-            icons[index + 1] = i < 48 ? (i / 12) << 4 : 64 + (((i - 48) >> 4) << 4);
+            icons[index] = i < 8 ? 192 + ((i % 4) << 4) : (((i - 8) & 0xF) << 4);
+            icons[index + 1] = i < 8 ? (i / 4) << 4 : 32 + (((i - 8) >> 4) << 4);
             icons[index + 2] = count;
         }
     }
@@ -48,15 +53,17 @@ public class ItemStackDisplayGui extends Gui
     {
         for(int i = 0; i < 27; i += 3)
         {
-            icons[i] = 64;
+            icons[i] = -1;
             icons[i + 1] = 0;
             icons[i + 2] = 0;
         }
     }
     
+    private final static Field MAP_BOSS_INFO = ReflectionUtils.getField(GuiBossOverlay.class, "field_184060_g", "mapBossInfos");
+    
     public void paint()
     {
-        if(inactive || mc.ingameGUI.getChatGUI().getChatOpen())
+        if(inactive)
         {
             return;
         }
@@ -66,18 +73,31 @@ public class ItemStackDisplayGui extends Gui
         mc.getTextureManager().bindTexture(CUSTOM_ICONS);
         
         ScaledResolution scaledresolution = new ScaledResolution(mc);
-        int screenWidth = scaledresolution.getScaledWidth();
-        int screenHeight = scaledresolution.getScaledHeight();
-        drawTexturedModalRect(screenWidth - 62, screenHeight - 62, 0, 0, 62, 62);
+        int screenWidth = (scaledresolution.getScaledWidth() >> 1) - 91;
+        int y = 3;
+        
+        try
+        {
+            Map info = (Map) MAP_BOSS_INFO.get(mc.ingameGUI.getBossOverlay());
+            if(!info.isEmpty())
+            {
+                y += 20;
+            }
+        }
+        catch(IllegalAccessException | IllegalArgumentException ex)
+        {
+        }
+        
+        drawTexturedModalRect(screenWidth, y - 3, 0, 0, 182, 22);
         
         int i = 0;
-        for(int y = 59; y > 0; y -= 20)
+        for(int x = 3; x < 164; x += 20)
         {
-            for(int x = 59; x > 0; x -= 20)
+            if(icons[i] != -1)
             {
-                drawTexturedModalRect(screenWidth - x, screenHeight - y, icons[i], icons[i + 1], 16, 16);    
-                i += 3;
+                drawTexturedModalRect(screenWidth + x, y, icons[i], icons[i + 1], 16, 16); 
             }
+            i += 3;
         }
         
         GlStateManager.disableBlend();
@@ -85,17 +105,14 @@ public class ItemStackDisplayGui extends Gui
         FontRenderer fr = mc.fontRenderer;
         String s;
         i = 2;
-        for(int y = 50; y > 0; y -= 20)
+        for(int x = 20; x < 181; x += 20)
         {
-            for(int x = 42; x > 0; x -= 20)
+            if(icons[i] != 0)
             {
-                if(icons[i] != 0)
-                {
-                    s = String.valueOf(icons[i]);
-                    fr.drawStringWithShadow(s, (float)(screenWidth - x - fr.getStringWidth(s)), (float)(screenHeight - y), 16777215);
-                } 
-                i += 3;
-            }
+                s = String.valueOf(icons[i]);
+                fr.drawStringWithShadow(s, (float)(screenWidth + x - fr.getStringWidth(s)), y + 9, 16777215);
+            }             
+            i += 3;
         }
     }
 }

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

@@ -389,7 +389,7 @@ public class MinecraftFunctions
         });
         parser.registerFunction("player.getspawn", (sc, in) -> 
         {   
-            WorldServer ws = ModDimensions.getWorldFromName(in[1].getString(sc));
+            WorldServer ws = (WorldServer) in[1].get(sc);
             return new Location(ws, ((EntityPlayer) in[0].get(sc)).getBedLocation(ws.provider.getDimension()));
         });
         parser.registerAlias("player.getspawn", "player.getbedspawn");
@@ -418,7 +418,7 @@ public class MinecraftFunctions
         });    
         parser.registerFunction("players.toworldlist", (sc, in) -> 
         {     
-            in[0].set(sc, new ArrayList(ModDimensions.getWorldFromName(in[1].getString(sc)).playerEntities)); 
+            in[0].set(sc, new ArrayList(((World) in[1].get(sc)).playerEntities)); 
             return Void.TYPE; 
         });
         parser.registerFunction("players.near", (sc, in) -> 
@@ -614,6 +614,16 @@ public class MinecraftFunctions
         // Location-Bibliothek
         // ---------------------------------------------------------------------  
         parser.registerFunction("loc.new", (sc, in) -> 
+        { 
+            if(in.length >= 6)
+            {
+                return new Location((World) in[0].get(sc), 
+                        in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc), 
+                        in[4].getFloat(sc), in[5].getFloat(sc));
+            }
+            return new Location((World) in[0].get(sc), in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc), 0, 0);
+        });  
+        parser.registerFunction("loc.new2", (sc, in) -> 
         { 
             if(in.length >= 6)
             {

+ 48 - 10
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -161,14 +161,7 @@ public class ScriptEvents extends ModuleListener
         EntityPlayer p = e.getEntityPlayer();  
         handleEvent(p, "player_hurt", (sc) -> 
         {
-            if(p.getHealth() <= e.getAmount())
-            {
-                sc.setVar("player_killed", true);   
-            }  
-            else
-            {
-                sc.setVar("player_killed", false); 
-            }
+            sc.setVar("player_killed", p.getHealth() <= e.getAmount());   
             sc.setVar("player_damage", (double) e.getAmount());   
             sc.setVar("player_damage_cause", e.getSource().getDamageType());
             EntityPlayer ent = Utils.getDamager(e.getSource());
@@ -196,6 +189,51 @@ public class ScriptEvents extends ModuleListener
         });
     } 
     
+    @SubscribeEvent
+    public void onPlayerAttack(LivingAttackEvent e)
+    {        
+        EntityLivingBase liv = e.getEntityLiving();
+        if(liv instanceof EntityPlayer)
+        {
+            EntityPlayer p = (EntityPlayer) liv;
+            handleEvent(p, "player_is_attacked", (sc) -> 
+            {
+                sc.setVar("player_killed", p.getHealth() <= e.getAmount());   
+                sc.setVar("player_damage_cause", e.getSource().getDamageType());
+                EntityPlayer ent = Utils.getDamager(e.getSource());
+                if(ent != null)
+                {
+                    sc.setVar("player_involved", true);
+                    ScriptVars.setSecPlayer(sc, ent);
+                }
+                else
+                {
+                    sc.setVar("player_involved", false);
+                }
+                sc.setVar("cancel", e.isCanceled()); 
+            }, (sc) -> 
+            {
+                simpleCancel(sc, e, "player_attacked");
+            });
+        }
+        else
+        {
+            EntityPlayer ent = Utils.getDamager(e.getSource());
+            if(ent != null)
+            {
+                EntityPlayer p = (EntityPlayer) liv;
+                handleEvent(p, "player_attacks", (sc) -> 
+                {
+                    ScriptVars.setEntityVars(sc, liv);
+                    sc.setVar("cancel", e.isCanceled()); 
+                }, (sc) -> 
+                {
+                    simpleCancel(sc, e, "player_attacks");
+                });
+            }
+        }
+    } 
+    
     @SubscribeEvent
     public void onPlayerDamage(LivingHealEvent e)
     {        
@@ -446,7 +484,7 @@ public class ScriptEvents extends ModuleListener
     @SubscribeEvent
     public void onBucketFill(FillBucketEvent e)
     {      
-        handleEvent(e.getEntityPlayer(), "bucket_fill", (sc) -> 
+        handleEvent(e.getEntityPlayer(), "bucket_use", (sc) -> 
         {
             RayTraceResult ray = e.getTarget();
             if(ray != null)
@@ -469,7 +507,7 @@ public class ScriptEvents extends ModuleListener
             sc.setVar("cancel", e.isCanceled()); 
         }, (sc) -> 
         {
-            simpleCancel(sc, e, "bucket_fill");
+            simpleCancel(sc, e, "bucket_use");
         });
     } 
        

+ 1 - 1
src/main/java/me/km/utils/ReflectionUtils.java

@@ -41,7 +41,7 @@ public class ReflectionUtils
         return null;
     }
     
-    private static Field getField(Class c, String... field)
+    public static Field getField(Class c, String... field)
     {
         try
         {

BIN
src/main/resources/assets/km/textures/gui/itemstacks.png