Skip to content

Commit

Permalink
1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Jun 15, 2024
1 parent 298e67b commit 13b781c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id 'io.github.juuxel.loom-quiltflower' version '1.7.3'
}

version = project.mod_version + "+" + project.minecraft_base_version
Expand All @@ -26,7 +25,7 @@ processResources {
}
}

def targetJavaVersion = 17
def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_base_version=1.20
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21
minecraft_base_version=1.21
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
# Mod Properties
mod_version=0.1.0
maven_group=io.wispforest
archives_base_name=delightful-froge
# Dependencies
# check this on https://fabricmc.net/develop
fabric_version=0.83.0+1.20
fabric_version=0.100.1+1.21
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 8 additions & 11 deletions src/main/java/io/wispforest/delightfulfroge/DelightfulFroge.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.predicate.entity.DamageSourcePredicate;
import net.minecraft.predicate.entity.EntityPredicate;
import net.minecraft.predicate.entity.TypeSpecificPredicate;
import net.minecraft.predicate.entity.EntitySubPredicateTypes;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
Expand Down Expand Up @@ -64,23 +64,20 @@ public void onInitialize() {
ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(DelightfulFroge::insertFrogelight);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(DelightfulFroge::insertFrogelight);

LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> {
if (!id.equals(EntityType.MAGMA_CUBE.getLootTableId())) return;
tableBuilder.pool(
LootPool.builder().with(ItemEntry.builder(FROGELIGHT).conditionally(
DamageSourcePropertiesLootCondition.builder(DamageSourcePredicate.Builder.create()
.sourceEntity(EntityPredicate.Builder.create().typeSpecific(TypeSpecificPredicate.frog(FROGE))))
)).build()
);
LootTableEvents.MODIFY.register((key, tableBuilder, source) -> {
if (!key.getValue().equals(EntityType.MAGMA_CUBE.getLootTableId())) return;
tableBuilder.pool(LootPool.builder().with(ItemEntry.builder(FROGELIGHT).conditionally(
DamageSourcePropertiesLootCondition.builder(DamageSourcePredicate.Builder.create()
.sourceEntity(EntityPredicate.Builder.create().typeSpecific(EntitySubPredicateTypes.frogVariant(Registries.FROG_VARIANT.getEntry(FROGE))))))
));
});
}

@SuppressWarnings("UnstableApiUsage")
private static void insertFrogelight(FabricItemGroupEntries entries) {
entries.addAfter(Blocks.PEARLESCENT_FROGLIGHT, FROGELIGHT);
}

public static Identifier id(String path) {
return new Identifier("delightful", path);
return Identifier.of("delightful", path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import net.minecraft.entity.passive.FrogEntity;
import net.minecraft.entity.passive.FrogVariant;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
Expand All @@ -32,18 +33,20 @@ protected FrogEntityMixin(EntityType<? extends MobEntity> entityType, World worl
}

@Shadow
public abstract void setVariant(FrogVariant variant);
@Final
public AnimationState usingTongueAnimationState;

@Shadow
public abstract FrogVariant getVariant();
public abstract RegistryEntry<FrogVariant> getVariant();

@Shadow
@Final
public AnimationState usingTongueAnimationState;
public abstract void setVariant(RegistryEntry<FrogVariant> registryEntry);

@Override
protected ActionResult interactMob(PlayerEntity player, Hand hand) {
if (player.isSneaking() || !player.getStackInHand(hand).isEmpty() || this.getVariant() != DelightfulFroge.FROGE) return super.interactMob(player, hand);
if (player.isSneaking() || !player.getStackInHand(hand).isEmpty() || this.getVariant().value() != DelightfulFroge.FROGE) {
return super.interactMob(player, hand);
}
if (this.getWorld().isClient) {
for (int i = 0; i < 5; i++) {
double x = this.getX() + (this.random.nextDouble() - .5);
Expand All @@ -60,18 +63,18 @@ protected ActionResult interactMob(PlayerEntity player, Hand hand) {
}

@Inject(method = "initialize", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/FrogBrain;coolDownLongJump(Lnet/minecraft/entity/passive/FrogEntity;Lnet/minecraft/util/math/random/Random;)V"))
private void injectFroge(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityNbt, CallbackInfoReturnable<EntityData> cir) {
private void injectFroge(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CallbackInfoReturnable<EntityData> cir) {
if (!(world instanceof ServerWorld serverWorld)) return;

if (world.getBiome(this.getBlockPos()).isIn(DelightfulFroge.FROGE_PLACES)) {
this.setVariant(DelightfulFroge.FROGE);
this.setVariant(Registries.FROG_VARIANT.getEntry(DelightfulFroge.FROGE));
return;
}

final var chance = serverWorld.getGameRules().getInt(DelightfulFroge.FROGE_CHANCE);
if (serverWorld.random.nextBetween(0, 100) > chance) return;

this.setVariant(DelightfulFroge.FROGE);
this.setVariant(Registries.FROG_VARIANT.getEntry(DelightfulFroge.FROGE));
}

}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"depends": {
"fabricloader": "*",
"fabric": "*",
"minecraft": "1.20.x"
"minecraft": ">=1.21"
},

"custom": {
Expand Down

0 comments on commit 13b781c

Please sign in to comment.