Browse Source

fix duplication bugs

Kajetan Johannes Hammerle 2 years ago
parent
commit
3be826d1df

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

@@ -61,7 +61,7 @@ public class ProtectionEvents {
     @SubscribeEvent(priority = EventPriority.HIGHEST)
     public void onBossSpawn(EntityJoinWorldEvent e) {
         EntityType<?> type = e.getEntity().getType();
-        if(type == EntityType.WITHER && e.getWorld().getDimensionType().isUltrawarm()) {
+        if(type == EntityType.WITHER && !e.getWorld().getDimensionType().isUltrawarm()) {
             e.setCanceled(true);
         } else if(type == EntityType.ENDER_DRAGON
                 && !e.getWorld().getDimensionType().doesHasDragonFight()) {

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

@@ -17,10 +17,12 @@ import me.km.utils.*;
 import net.minecraft.block.*;
 import net.minecraft.command.ICommandSource;
 import net.minecraft.entity.*;
+import net.minecraft.entity.passive.horse.AbstractHorseEntity;
 import net.minecraft.entity.player.*;
 import net.minecraft.inventory.*;
 import net.minecraft.inventory.container.ClickType;
 import net.minecraft.inventory.container.Container;
+import net.minecraft.inventory.container.HorseInventoryContainer;
 import net.minecraft.item.ItemStack;
 import net.minecraft.item.crafting.ICraftingRecipe;
 import net.minecraft.item.crafting.IRecipeType;
@@ -226,6 +228,9 @@ public class ScriptEvents implements BlockHarvest, Craft, ContainerClick {
 
     @SubscribeEvent(receiveCanceled = true)
     public void onLivingHurt(LivingHurtEvent e) {
+        if(e.getSource().getDamageType().equals("fireworks")) {
+            e.setCanceled(true);
+        }
         handleEvent(e, "living_hurt", (sc) -> {
             setLiving(sc, e.getEntityLiving());
             sc.setVar("damage_source", e.getSource());
@@ -563,9 +568,19 @@ public class ScriptEvents implements BlockHarvest, Craft, ContainerClick {
 
     @SubscribeEvent(receiveCanceled = true)
     public void onEntityMount(EntityMountEvent e) {
+        Entity ent = e.getEntityBeingMounted();
+        if(ent instanceof AbstractHorseEntity) {
+            for(PlayerEntity p : ent.getEntityWorld().getPlayers()) {
+                if(p.openContainer == null
+                        || !(p.openContainer instanceof HorseInventoryContainer)) {
+                    continue;
+                }
+                p.closeScreen();
+            }
+        }
         handleEvent(e, "entity_mount", (sc) -> {
             sc.setVar("mounting", e.isMounting());
-            setEntity(sc, e.getEntityBeingMounted());
+            setEntity(sc, ent);
             sc.setVar("rider", e.getEntityMounting());
         });
     }