From 1de67c86a50979c88c8a519eea320764583fef06 Mon Sep 17 00:00:00 2001 From: Pyrofab Date: Sun, 7 Jun 2020 19:18:55 +0200 Subject: [PATCH] Update to 1.16-pre2 --- changelog.md | 2 +- gradle.properties | 10 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../{common/gamerule => }/CreeperGrief.java | 2 +- .../creeperspores/CreeperSpores.java | 13 +++++++ .../common/CreeperlingEntity.java | 10 +++--- .../common/gamerule/CSGamerules.java | 34 ------------------- .../mixin/CreeperEntityMixin.java | 7 ++-- .../mixin/GameRulesAccessor.java | 30 ---------------- .../creeperspores/mixin/GameRulesMixin.java | 34 ------------------- .../mixin/LivingEntityMixin.java | 2 +- .../mixins.creeperspores.common.json | 2 -- 12 files changed, 31 insertions(+), 117 deletions(-) rename src/main/java/io/github/ladysnake/creeperspores/{common/gamerule => }/CreeperGrief.java (95%) delete mode 100644 src/main/java/io/github/ladysnake/creeperspores/common/gamerule/CSGamerules.java delete mode 100644 src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesAccessor.java delete mode 100644 src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesMixin.java diff --git a/changelog.md b/changelog.md index ccab39a..2ed2e3e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,7 @@ ------------------------------------------------------ Version 1.4.0 ------------------------------------------------------ -Updated to 20w10a +Updated to 1.16-pre2 ------------------------------------------------------ Version 1.3.6 diff --git a/gradle.properties b/gradle.properties index e0a8c39..208c31d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ # General # see https://modmuss50.me/fabric.html -minecraft_version=20w21a -yarn_mappings=20w21a+build.15 -loader_version=0.8.4+build.198 +minecraft_version=1.16-pre2 +yarn_mappings=1.16-pre2+build.2 +loader_version=0.8.7+build.201 #Fabric api -fabric_version=0.10.10+build.347-1.16 +fabric_version=0.11.7+build.356-1.16 # Base properties mod_name = Creeper Spores -mod_version = 1.4.0-nightly.20w21a +mod_version = 1.4.0-nightly.1.16-pre2 owners = Ladysnake maven_group = io.github.Ladysnake diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5289c0a..9bdecd0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/src/main/java/io/github/ladysnake/creeperspores/common/gamerule/CreeperGrief.java b/src/main/java/io/github/ladysnake/creeperspores/CreeperGrief.java similarity index 95% rename from src/main/java/io/github/ladysnake/creeperspores/common/gamerule/CreeperGrief.java rename to src/main/java/io/github/ladysnake/creeperspores/CreeperGrief.java index ada2ffa..bd0e099 100644 --- a/src/main/java/io/github/ladysnake/creeperspores/common/gamerule/CreeperGrief.java +++ b/src/main/java/io/github/ladysnake/creeperspores/CreeperGrief.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; If not, see . */ -package io.github.ladysnake.creeperspores.common.gamerule; +package io.github.ladysnake.creeperspores; public enum CreeperGrief { VANILLA, CHARGED, NEVER; diff --git a/src/main/java/io/github/ladysnake/creeperspores/CreeperSpores.java b/src/main/java/io/github/ladysnake/creeperspores/CreeperSpores.java index 3040add..2319a7b 100644 --- a/src/main/java/io/github/ladysnake/creeperspores/CreeperSpores.java +++ b/src/main/java/io/github/ladysnake/creeperspores/CreeperSpores.java @@ -17,6 +17,9 @@ */ package io.github.ladysnake.creeperspores; +import io.github.fablabsmc.fablabs.api.gamerule.v1.GameRuleRegistry; +import io.github.fablabsmc.fablabs.api.gamerule.v1.RuleFactory; +import io.github.fablabsmc.fablabs.api.gamerule.v1.rule.EnumRule; import io.github.ladysnake.creeperspores.common.CreeperSporeEffect; import io.github.ladysnake.creeperspores.common.CreeperlingEntity; import io.github.ladysnake.creeperspores.mixin.EntityTypeAccessor; @@ -38,6 +41,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Lazy; import net.minecraft.util.registry.Registry; +import net.minecraft.world.GameRules; import net.minecraft.world.World; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -64,6 +68,11 @@ public class CreeperSpores implements ModInitializer { public static final String GIVE_SPORES_TAG = "cspores:giveSpores"; public static final int MAX_SPORE_TIME = 20 * 180; + public static final GameRules.Key> CREEPER_GRIEF = registerGamerule( + "cspores_creeperGrief", + RuleFactory.createEnumRule(CreeperGrief.CHARGED) + ); + public static Identifier id(String path) { return new Identifier("creeperspores", path); } @@ -84,6 +93,10 @@ public void onInitialize() { }); } + private static > GameRules.Key registerGamerule(String name, GameRules.Type type) { + return GameRuleRegistry.register(name, GameRules.Category.MOBS, type); + } + @ApiStatus.Internal public static void registerCreeperLike(Identifier id) { // can't actually check that the entity type is living, so just hope nothing goes wrong diff --git a/src/main/java/io/github/ladysnake/creeperspores/common/CreeperlingEntity.java b/src/main/java/io/github/ladysnake/creeperspores/common/CreeperlingEntity.java index 7f9de3f..b373886 100644 --- a/src/main/java/io/github/ladysnake/creeperspores/common/CreeperlingEntity.java +++ b/src/main/java/io/github/ladysnake/creeperspores/common/CreeperlingEntity.java @@ -53,6 +53,7 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.tag.BlockTags; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; @@ -120,17 +121,17 @@ public void setTrusting(boolean trusting) { } @Override - protected boolean interactMob(PlayerEntity player, Hand hand) { + protected ActionResult interactMob(PlayerEntity player, Hand hand) { ItemStack held = player.getStackInHand(hand); if (CreeperSpores.FERTILIZERS.contains(held.getItem())) { if (!world.isClient) { this.applyFertilizer(held); this.setTrusting(true); } - return true; + return ActionResult.SUCCESS; } else { if (interactSpawnEgg(player, this, held, this.kind)) { - return true; + return ActionResult.SUCCESS; } } return super.interactMob(player, hand); @@ -286,10 +287,11 @@ public void tickMovement() { UUID adultUuid = adult.getUuid(); EntityAttributeInstance adultMaxHealth = adult.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH); EntityAttributeInstance babyMaxHealth = this.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH); + assert adultMaxHealth != null && babyMaxHealth != null; int healthMultiplier = (int)adultMaxHealth.getValue() / (int)babyMaxHealth.getValue(); adult.fromTag(this.toTag(new CompoundTag())); adult.setUuid(adultUuid); - adultMaxHealth.setBaseValue(adult.defaultMaximumHealth); + adultMaxHealth.setBaseValue(adult.defaultMaxHealth); adult.setHealth(adult.getHealth() * healthMultiplier); world.spawnEntity(adult); pushOutOfBlocks(adult); diff --git a/src/main/java/io/github/ladysnake/creeperspores/common/gamerule/CSGamerules.java b/src/main/java/io/github/ladysnake/creeperspores/common/gamerule/CSGamerules.java deleted file mode 100644 index 46b8746..0000000 --- a/src/main/java/io/github/ladysnake/creeperspores/common/gamerule/CSGamerules.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Creeper-Spores - * Copyright (C) 2019-2020 Ladysnake - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; If not, see . - */ -package io.github.ladysnake.creeperspores.common.gamerule; - -import io.github.fablabsmc.fablabs.api.gamerule.v1.GameRuleRegistry; -import io.github.fablabsmc.fablabs.api.gamerule.v1.RuleFactory; -import io.github.fablabsmc.fablabs.api.gamerule.v1.rule.EnumRule; -import net.minecraft.world.GameRules; - -public class CSGamerules { - public static final GameRules.RuleKey> CREEPER_GRIEF = register( - "cspores_creeperGrief", - RuleFactory.createEnumRule(CreeperGrief.CHARGED)); - - public static > GameRules.RuleKey register(String name, GameRules.RuleType type) { - return GameRuleRegistry.register(name, GameRules.RuleCategory.MOBS, type); - } - -} diff --git a/src/main/java/io/github/ladysnake/creeperspores/mixin/CreeperEntityMixin.java b/src/main/java/io/github/ladysnake/creeperspores/mixin/CreeperEntityMixin.java index fa1a9f9..43d892b 100644 --- a/src/main/java/io/github/ladysnake/creeperspores/mixin/CreeperEntityMixin.java +++ b/src/main/java/io/github/ladysnake/creeperspores/mixin/CreeperEntityMixin.java @@ -18,11 +18,10 @@ package io.github.ladysnake.creeperspores.mixin; import io.github.ladysnake.creeperspores.CreeperEntry; +import io.github.ladysnake.creeperspores.CreeperGrief; import io.github.ladysnake.creeperspores.CreeperSpores; import io.github.ladysnake.creeperspores.common.CreeperlingEntity; import io.github.ladysnake.creeperspores.common.SporeSpreader; -import io.github.ladysnake.creeperspores.common.gamerule.CSGamerules; -import io.github.ladysnake.creeperspores.common.gamerule.CreeperGrief; import net.fabricmc.fabric.api.util.TriState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -78,7 +77,7 @@ public void spreadSpores(Explosion explosion, Vec3d center, Entity affectedEntit @Inject( method = "interactMob", - at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/HostileEntity;interactMob(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Z"), + at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/HostileEntity;interactMob(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"), cancellable = true ) private void interactSpawnEgg(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { @@ -91,7 +90,7 @@ private void interactSpawnEgg(PlayerEntity player, Hand hand, CallbackInfoReturn @ModifyVariable(method = "explode", ordinal = 0, at = @At(value = "STORE", ordinal = 0)) private Explosion.DestructionType griefLessExplosion(Explosion.DestructionType explosionType) { - CreeperGrief grief = world.getGameRules().get(CSGamerules.CREEPER_GRIEF).get(); + CreeperGrief grief = world.getGameRules().get(CreeperSpores.CREEPER_GRIEF).get(); if (!grief.shouldGrief(this.dataTracker.get(CHARGED))) { return Explosion.DestructionType.NONE; } diff --git a/src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesAccessor.java b/src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesAccessor.java deleted file mode 100644 index 6e2e78a..0000000 --- a/src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesAccessor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Creeper-Spores - * Copyright (C) 2019-2020 Ladysnake - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; If not, see . - */ -package io.github.ladysnake.creeperspores.mixin; - -import net.minecraft.world.GameRules; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(GameRules.class) -public interface GameRulesAccessor { - @Invoker - static > GameRules.RuleKey invokeRegister(String name, GameRules.RuleCategory cat, GameRules.RuleType type) { - throw new AssertionError(); - } -} diff --git a/src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesMixin.java b/src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesMixin.java deleted file mode 100644 index 72b3ba0..0000000 --- a/src/main/java/io/github/ladysnake/creeperspores/mixin/GameRulesMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Creeper-Spores - * Copyright (C) 2019-2020 Ladysnake - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; If not, see . - */ -package io.github.ladysnake.creeperspores.mixin; - -import io.github.ladysnake.creeperspores.common.gamerule.CSGamerules; -import net.minecraft.world.GameRules; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(GameRules.class) -public abstract class GameRulesMixin { - @SuppressWarnings({"UnresolvedMixinReference", "ResultOfMethodCallIgnored"}) - @Inject(method = "", at = @At("RETURN")) - private static void initCustomGamerules(CallbackInfo ci) { - CSGamerules.CREEPER_GRIEF.getClass(); - } -} diff --git a/src/main/java/io/github/ladysnake/creeperspores/mixin/LivingEntityMixin.java b/src/main/java/io/github/ladysnake/creeperspores/mixin/LivingEntityMixin.java index 2e05c8e..fa19a94 100644 --- a/src/main/java/io/github/ladysnake/creeperspores/mixin/LivingEntityMixin.java +++ b/src/main/java/io/github/ladysnake/creeperspores/mixin/LivingEntityMixin.java @@ -44,7 +44,7 @@ public LivingEntityMixin(EntityType type, World world) { super(type, world); } - @Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getHealth()F", ordinal = 1)) + @Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;method_29504()Z", ordinal = 1)) private void spawnCreeperling(DamageSource cause, float amount, CallbackInfoReturnable cir) { for (CreeperEntry creeperEntry : CreeperEntry.all()) { StatusEffectInstance spores = this.getStatusEffect(creeperEntry.sporeEffect); diff --git a/src/main/resources/mixins.creeperspores.common.json b/src/main/resources/mixins.creeperspores.common.json index ad300e0..f4adf1e 100644 --- a/src/main/resources/mixins.creeperspores.common.json +++ b/src/main/resources/mixins.creeperspores.common.json @@ -9,8 +9,6 @@ "EntityAccessor", "EntityTypeAccessor", "ExplosionMixin", - "GameRulesAccessor", - "GameRulesMixin", "HostileEntityMixin", "LivingEntityMixin", "SpawnHelperMixin"