Skip to content

Commit

Permalink
Update to 1.16-pre2
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Jun 7, 2020
1 parent 3909419 commit 1de67c8
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 117 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------
Version 1.4.0
------------------------------------------------------
Updated to 20w10a
Updated to 1.16-pre2

------------------------------------------------------
Version 1.3.6
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program; If not, see <https://www.gnu.org/licenses>.
*/
package io.github.ladysnake.creeperspores.common.gamerule;
package io.github.ladysnake.creeperspores;

public enum CreeperGrief {
VANILLA, CHARGED, NEVER;
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/io/github/ladysnake/creeperspores/CreeperSpores.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<EnumRule<CreeperGrief>> CREEPER_GRIEF = registerGamerule(
"cspores_creeperGrief",
RuleFactory.createEnumRule(CreeperGrief.CHARGED)
);

public static Identifier id(String path) {
return new Identifier("creeperspores", path);
}
Expand All @@ -84,6 +93,10 @@ public void onInitialize() {
});
}

private static <T extends GameRules.Rule<T>> GameRules.Key<T> registerGamerule(String name, GameRules.Type<T> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Boolean> cir) {
Expand All @@ -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;
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> cir) {
for (CreeperEntry creeperEntry : CreeperEntry.all()) {
StatusEffectInstance spores = this.getStatusEffect(creeperEntry.sporeEffect);
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/mixins.creeperspores.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"EntityAccessor",
"EntityTypeAccessor",
"ExplosionMixin",
"GameRulesAccessor",
"GameRulesMixin",
"HostileEntityMixin",
"LivingEntityMixin",
"SpawnHelperMixin"
Expand Down

0 comments on commit 1de67c8

Please sign in to comment.