From c96eee0c1b9c8b2a3f3b56808522803f95dfcd3b Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Mon, 19 Apr 2021 16:01:18 +0800 Subject: [PATCH 1/5] fixed missing static keyword at method carpet.logging.HUDController.register --- src/main/java/carpet/logging/HUDController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/logging/HUDController.java b/src/main/java/carpet/logging/HUDController.java index 312c0629..06891708 100644 --- a/src/main/java/carpet/logging/HUDController.java +++ b/src/main/java/carpet/logging/HUDController.java @@ -36,7 +36,7 @@ public class HUDController * Adds listener to be called when HUD is updated for logging information * @param listener - a method to be called when new HUD inforation are collected */ - public void register(Consumer listener) + public static void register(Consumer listener) { HUDListeners.add(listener); } From e26e332a6d319cd818f8c8d29f4dc20ca9a0d238 Mon Sep 17 00:00:00 2001 From: replaceitem <40722305+replaceitem@users.noreply.github.com> Date: Tue, 20 Apr 2021 22:14:08 +0200 Subject: [PATCH 2/5] Adding getTextByValue method to replace duplicate code (#823) * Added FormattedTextValue.getTextByValue() * changed getBoolean() and added to display_title --- .../java/carpet/script/api/Auxiliary.java | 14 +++------- .../java/carpet/script/api/Scoreboards.java | 26 ++++--------------- .../java/carpet/script/value/EntityValue.java | 2 +- .../script/value/FormattedTextValue.java | 6 ++++- 4 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index c2217953..76d73c31 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -520,7 +520,7 @@ public class Auxiliary { targets = playerTargets; res = lv.get(1).evalValue(c); } - Text message = (res instanceof FormattedTextValue)?((FormattedTextValue) res).getText():new LiteralText(res.getString()); + Text message = FormattedTextValue.getTextByValue(res); if (targets == null) { s.sendFeedback(message, false); @@ -573,16 +573,8 @@ public class Auxiliary { if (lv.size() > 2) { pVal = lv.get(2).evalValue(c); - if (pVal instanceof FormattedTextValue) - { - title = ((FormattedTextValue) pVal).getText(); - soundsTrue = !title.asString().isEmpty(); - } - else - { - title = new LiteralText(pVal.getString()); - soundsTrue = pVal.getBoolean(); - } + title = FormattedTextValue.getTextByValue(pVal); + soundsTrue = pVal.getBoolean(); } else title = null; // Will never happen, just to make lambda happy if (action == null) diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index f60ca14a..a83812cf 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -195,7 +195,7 @@ public class Scoreboards { return (_c, _t) -> StringValue.of(objective.getCriterion().getName()); case "display_name": if(modify) { - Text text = (setValue instanceof FormattedTextValue)?((FormattedTextValue) setValue).getText():new LiteralText(setValue.getString()); + Text text = FormattedTextValue.getTextByValue(setValue); objective.setDisplayName(text); return LazyValue.TRUE; } @@ -408,11 +408,7 @@ public class Scoreboards { Text displayName; - if(settingVal instanceof FormattedTextValue) { - displayName = ((FormattedTextValue) settingVal).getText(); - } else { - displayName = new LiteralText(settingVal.getString()); - } + displayName = FormattedTextValue.getTextByValue(settingVal); team.setDisplayName(displayName); @@ -451,11 +447,7 @@ public class Scoreboards { Text prefix; - if(settingVal instanceof FormattedTextValue) { - prefix = ((FormattedTextValue) settingVal).getText(); - } else { - prefix = new LiteralText(settingVal.getString()); - } + prefix = FormattedTextValue.getTextByValue(settingVal); team.setPrefix(prefix); break; @@ -481,11 +473,7 @@ public class Scoreboards { Text suffix; - if(settingVal instanceof FormattedTextValue) { - suffix = ((FormattedTextValue) settingVal).getText(); - } else { - suffix = new LiteralText(settingVal.getString()); - } + suffix = FormattedTextValue.getTextByValue(settingVal); team.setSuffix(suffix); break; @@ -547,11 +535,7 @@ public class Scoreboards { case "name": if(propertyValue == null) return (_c, _t) -> new FormattedTextValue(bossBar.getName()); - if(propertyValue instanceof FormattedTextValue) { - bossBar.setName(((FormattedTextValue) propertyValue).getText()); - } else { - bossBar.setName(new LiteralText(propertyValue.getString())); - } + bossBar.setName(FormattedTextValue.getTextByValue(propertyValue)); return LazyValue.TRUE; case "add_player": if(propertyValue == null) throw new InternalExpressionException("Bossbar property " + property + " can't be queried, add a third parameter"); diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index caa93ed7..d2882c2e 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -1106,7 +1106,7 @@ public class EntityValue extends Value v = ((ListValue) v).getItems().get(0); } e.setCustomNameVisible(showName); - e.setCustomName(new LiteralText(v.getString())); + e.setCustomName(FormattedTextValue.getTextByValue(v)); }); put("persistence", (e, v) -> diff --git a/src/main/java/carpet/script/value/FormattedTextValue.java b/src/main/java/carpet/script/value/FormattedTextValue.java index ae8bc966..e6225e1d 100644 --- a/src/main/java/carpet/script/value/FormattedTextValue.java +++ b/src/main/java/carpet/script/value/FormattedTextValue.java @@ -54,7 +54,7 @@ public class FormattedTextValue extends StringValue @Override public boolean getBoolean() { - return text.getSiblings().size() > 0; + return !text.asString().isEmpty(); } @Override @@ -96,4 +96,8 @@ public class FormattedTextValue extends StringValue return new FormattedTextValue(Text.Serializer.fromJson(serialized)); } + public static Text getTextByValue(Value value) { + return (value instanceof FormattedTextValue) ? ((FormattedTextValue) value).getText() : new LiteralText(value.getString()); + } + } From 72a3d74a975cdeaa2a47309d0f7429325e7c7f3e Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 20 Apr 2021 17:35:41 -0300 Subject: [PATCH 3/5] extremeBehaviours let wither spawn charged skulls at 10%, not 0.1% --- .../mixins/WitherEntity_extremeMixin.java | 22 +++++++++++++++++++ src/main/resources/carpet.mixins.json | 1 + 2 files changed, 23 insertions(+) create mode 100644 src/main/java/carpet/mixins/WitherEntity_extremeMixin.java diff --git a/src/main/java/carpet/mixins/WitherEntity_extremeMixin.java b/src/main/java/carpet/mixins/WitherEntity_extremeMixin.java new file mode 100644 index 00000000..e6b5aca4 --- /dev/null +++ b/src/main/java/carpet/mixins/WitherEntity_extremeMixin.java @@ -0,0 +1,22 @@ +package carpet.mixins; + + +import carpet.CarpetSettings; +import net.minecraft.entity.boss.WitherEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Random; + +@Mixin(WitherEntity.class) +public class WitherEntity_extremeMixin +{ + @Redirect(method = "method_6878", at = @At(value = "INVOKE", target = "Ljava/util/Random;nextFloat()F")) + private float nextFloatAmplfied(Random random) + { + if (CarpetSettings.extremeBehaviours) return random.nextFloat()/100; + return random.nextFloat(); + } + +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index bdaa2cdb..bf1f0789 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -159,6 +159,7 @@ "MobEntity_extremeMixin", "ProjectileEntity_extremeMixin", "Projectile_extremeMixin", + "WitherEntity_extremeMixin", "ArmorStandEntity_scarpetMarkerMixin", "Entity_scarpetEventsMixin", From 6083b702f91c1fdbe651364a5819b70c05c4eb4c Mon Sep 17 00:00:00 2001 From: altrisi Date: Sun, 18 Apr 2021 12:47:43 +0200 Subject: [PATCH 4/5] Make NBT's get() always return a list if requested item ends with [] --- src/main/java/carpet/script/value/NBTSerializableValue.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 9c26f252..346cdbb7 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -569,13 +569,14 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa @Override public Value get(Value value) { - NbtPathArgumentType.NbtPath path = cachePath(value.getString()); + String valString = value.getString(); + NbtPathArgumentType.NbtPath path = cachePath(valString); try { List tags = path.get(getTag()); if (tags.size()==0) return Value.NULL; - if (tags.size()==1) + if (tags.size()==1 && !valString.endsWith("[]")) return NBTSerializableValue.decodeTag(tags.get(0)); return ListValue.wrap(tags.stream().map(NBTSerializableValue::decodeTag).collect(Collectors.toList())); } From 8c9dabdbbc0401407cd05bffb13fa87d89e2ce79 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 21 Apr 2021 18:41:39 -0300 Subject: [PATCH 5/5] 1.4.33 --- gradle.properties | 2 +- src/main/java/carpet/CarpetSettings.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index feda6b1a..58e6c425 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx1G fabric_version=0.29.4+1.16 # Mod Properties - mod_version = 1.4.32 + mod_version = 1.4.33 maven_group = carpet archives_base_name = fabric-carpet diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index be17fbb0..6ba2e5ca 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -42,7 +42,7 @@ import static carpet.settings.RuleCategory.CLIENT; @SuppressWarnings("CanBeFinal") public class CarpetSettings { - public static final String carpetVersion = "1.4.32+v210414"; + public static final String carpetVersion = "1.4.33+v210421"; public static final Logger LOG = LogManager.getLogger("carpet"); public static boolean skipGenerationChecks = false; public static boolean impendingFillSkipUpdates = false;