From 7ac73269e04fa316af8af87f4cd5c4dc15f51c23 Mon Sep 17 00:00:00 2001 From: Tschipp Date: Tue, 5 May 2020 13:51:18 +0200 Subject: [PATCH 1/6] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index aea4cfe..cd46bc4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # Carry On [![](http://cf.way2muchnoise.eu/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on) [![](http://cf.way2muchnoise.eu/versions/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on) + +To use CarryOn in your projects, include this in your build.gradle: +``` +repositories { + maven { + url "http://maven.blamejared.com/" + } +} + +dependencies { + deobfCompile "tschipp.linear:linear-MCVERSION:MODVERSION" +} +``` +Make sure to replace `MCVERSION` and `MODVERSION` with the appropriate versions. From dc1144812a42d8a52b0e5647f4a27c739ccd746f Mon Sep 17 00:00:00 2001 From: Tschipp Date: Tue, 5 May 2020 13:51:37 +0200 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd46bc4..54f2fb9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ repositories { } dependencies { - deobfCompile "tschipp.linear:linear-MCVERSION:MODVERSION" + deobfCompile "tschipp.carryon:carryon-MCVERSION:MODVERSION" } ``` Make sure to replace `MCVERSION` and `MODVERSION` with the appropriate versions. From 08fd683757fecee73a68e5536a9fa5399b2e49e5 Mon Sep 17 00:00:00 2001 From: Jared Date: Wed, 6 May 2020 16:35:38 +0200 Subject: [PATCH 3/6] http -> https --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54f2fb9..0900fdd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ To use CarryOn in your projects, include this in your build.gradle: ``` repositories { maven { - url "http://maven.blamejared.com/" + url "https://maven.blamejared.com/" } } From 3906ea4a1e613e89425541dc14e9752e3ff90c81 Mon Sep 17 00:00:00 2001 From: KandiPanda <43508599+KandiPanda@users.noreply.github.com> Date: Thu, 11 Jun 2020 22:59:53 -0500 Subject: [PATCH 4/6] Update Configs.java Add tamedHostileMobExemption option --- src/main/java/tschipp/carryon/common/config/Configs.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/tschipp/carryon/common/config/Configs.java b/src/main/java/tschipp/carryon/common/config/Configs.java index 085e0c0..069f330 100644 --- a/src/main/java/tschipp/carryon/common/config/Configs.java +++ b/src/main/java/tschipp/carryon/common/config/Configs.java @@ -34,6 +34,9 @@ public class Configs { @Comment("Whether hostile mobs should be able to picked up in survival mode") public boolean pickupHostileMobs = false; + @Comment("Whether tamed hostile mobs should be exempt from the above") + public boolean tamedHostileMobExemption = true; + @Comment("Larger Entities slow down the player more") public boolean heavyEntities = true; From b0e694f0248944c8260337a4eae7675d3d2bebba Mon Sep 17 00:00:00 2001 From: KandiPanda <43508599+KandiPanda@users.noreply.github.com> Date: Thu, 11 Jun 2020 23:04:46 -0500 Subject: [PATCH 5/6] Update PickupHandler.java --- .../carryon/common/handler/PickupHandler.java | 165 +++++++++++++----- 1 file changed, 119 insertions(+), 46 deletions(-) diff --git a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java b/src/main/java/tschipp/carryon/common/handler/PickupHandler.java index d0bb495..4ef119e 100644 --- a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java +++ b/src/main/java/tschipp/carryon/common/handler/PickupHandler.java @@ -219,73 +219,146 @@ public class PickupHandler } } - if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative())) - { - if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative())) + if(toPickUp instanceof EntityTameable) { + EntityTameable tamecheck = (EntityTameable) toPickUp; + UUID OwnerCheck = tamecheck.getOwnerId(); + if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || (CarryOnConfig.settings.tamedHostileMobExemption ? (OwnerCheck != null) : false) || player.isCreative())) { - if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative())) + if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || (CarryOnConfig.settings.tamedHostileMobExemption ? (OwnerCheck != null) : false) || player.isCreative())) { - double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ); - if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2)) + if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative())) { - if (toPickUp instanceof EntityTameable) + double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ); + if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2)) { - EntityTameable tame = (EntityTameable) toPickUp; - UUID owner = tame.getOwnerId(); - UUID playerID = player.getUUID(player.getGameProfile()); - if (owner != null && !owner.equals(playerID)) - return false; - } - - if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp)) - { - try + if (toPickUp instanceof EntityTameable) { - Class gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper"); - Class iStageData = Class.forName("net.darkhax.gamestages.data.IStageData"); - - Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class); - Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class); - - Object stageData = getPlayerData.invoke(null, player); - String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp); - boolean has = (boolean) hasStage.invoke(stageData, condition); - - if (has) - return handleProtections((EntityPlayerMP) player, toPickUp); + EntityTameable tame = (EntityTameable) toPickUp; + UUID owner = tame.getOwnerId(); + UUID playerID = player.getUUID(player.getGameProfile()); + if (owner != null && !owner.equals(playerID)) + return false; } - catch (Exception e) + + if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp)) { try { - Class playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler"); - Class iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData"); - - Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class); - Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class); - - Object stageData = getStageData.invoke(null, player); + Class gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper"); + Class iStageData = Class.forName("net.darkhax.gamestages.data.IStageData"); + + Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class); + Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class); + + Object stageData = getPlayerData.invoke(null, player); String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp); - boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition); - + boolean has = (boolean) hasStage.invoke(stageData, condition); + if (has) return handleProtections((EntityPlayerMP) player, toPickUp); } - catch (Exception ex) + catch (Exception e) { - return handleProtections((EntityPlayerMP) player, toPickUp); + try + { + Class playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler"); + Class iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData"); + + Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class); + Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class); + + Object stageData = getStageData.invoke(null, player); + String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp); + boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition); + + if (has) + return handleProtections((EntityPlayerMP) player, toPickUp); + } + catch (Exception ex) + { + return handleProtections((EntityPlayerMP) player, toPickUp); + } } } + else + return handleProtections((EntityPlayerMP) player, toPickUp); } - else - return handleProtections((EntityPlayerMP) player, toPickUp); + + } - - } + + } + } else { + if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative())) + { + if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative())) + { + if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative())) + { + double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ); + if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2)) + { + if (toPickUp instanceof EntityTameable) + { + EntityTameable tame = (EntityTameable) toPickUp; + UUID owner = tame.getOwnerId(); + UUID playerID = player.getUUID(player.getGameProfile()); + if (owner != null && !owner.equals(playerID)) + return false; + } + + if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp)) + { + try + { + Class gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper"); + Class iStageData = Class.forName("net.darkhax.gamestages.data.IStageData"); + + Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class); + Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class); + + Object stageData = getPlayerData.invoke(null, player); + String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp); + boolean has = (boolean) hasStage.invoke(stageData, condition); + + if (has) + return handleProtections((EntityPlayerMP) player, toPickUp); + } + catch (Exception e) + { + try + { + Class playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler"); + Class iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData"); + + Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class); + Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class); + + Object stageData = getStageData.invoke(null, player); + String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp); + boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition); + + if (has) + return handleProtections((EntityPlayerMP) player, toPickUp); + } + catch (Exception ex) + { + return handleProtections((EntityPlayerMP) player, toPickUp); + } + } + } + else + return handleProtections((EntityPlayerMP) player, toPickUp); + } + + + } + } + } - } + } return false; From afe45abd1b920d5388b514592256a1d0f75ad4c0 Mon Sep 17 00:00:00 2001 From: KandiPanda <43508599+KandiPanda@users.noreply.github.com> Date: Fri, 12 Jun 2020 01:52:18 -0500 Subject: [PATCH 6/6] Update PickupHandler.java Removed redundant EntityTameable check from within code already covered by another EntityTameable check (would always be "true" anyways). Removed redundant EntityTameable check and contents from within the "else" of same outer check (else means it's already failed, and will never succeed this check or run the code within it anyways). --- .../carryon/common/handler/PickupHandler.java | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java b/src/main/java/tschipp/carryon/common/handler/PickupHandler.java index 4ef119e..d62a368 100644 --- a/src/main/java/tschipp/carryon/common/handler/PickupHandler.java +++ b/src/main/java/tschipp/carryon/common/handler/PickupHandler.java @@ -231,14 +231,9 @@ public class PickupHandler double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ); if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2)) { - if (toPickUp instanceof EntityTameable) - { - EntityTameable tame = (EntityTameable) toPickUp; - UUID owner = tame.getOwnerId(); - UUID playerID = player.getUUID(player.getGameProfile()); - if (owner != null && !owner.equals(playerID)) - return false; - } + UUID playerID = player.getUUID(player.getGameProfile()); + if (OwnerCheck != null && !OwnerCheck.equals(playerID)) + return false; if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp)) { @@ -299,15 +294,6 @@ public class PickupHandler double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ); if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2)) { - if (toPickUp instanceof EntityTameable) - { - EntityTameable tame = (EntityTameable) toPickUp; - UUID owner = tame.getOwnerId(); - UUID playerID = player.getUUID(player.getGameProfile()); - if (owner != null && !owner.equals(playerID)) - return false; - } - if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp)) { try