diff --git a/build.gradle b/build.gradle index 634dc59..33872b0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.0-SNAPSHOT' + id 'fabric-loom' version '1.1-SNAPSHOT' id 'maven-publish' } @@ -33,31 +33,34 @@ repositories { url = 'https://ladysnake.jfrog.io/artifactory/mods' } maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' } + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/releases/" } } dependencies { - modImplementation 'software.bernie.geckolib:geckolib-fabric-1.19:3.1.5' - minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation 'software.bernie.geckolib:geckolib-fabric-1.19:3.1.5' - + modImplementation "software.bernie.geckolib:geckolib-fabric-1.19.4:${project.geckolib_version}" modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}" modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca_version}" include "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}" include "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca_version}" - implementation "com.github.LlamaLad7:MixinExtras:${mixin_extras_version}" - annotationProcessor "com.github.LlamaLad7:MixinExtras:${mixin_extras_version}" - include "com.github.LlamaLad7:MixinExtras:${mixin_extras_version}" + implementation "com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}" + annotationProcessor "com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}" + include "com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}" - modCompileOnly "maven.modrinth:sodium:${sodium_version}" - modRuntimeOnly "maven.modrinth:sodium:${sodium_version}" - implementation "org.joml:joml:1.10.4" + modCompileOnly "maven.modrinth:sodium:${project.sodium_version}" + modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}" + + modApi ("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + modApi "com.terraformersmc:modmenu:${project.modmenu_version}" } processResources { diff --git a/gradle.properties b/gradle.properties index d33817e..17eec1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,15 +2,18 @@ org.gradle.jvmargs=-Xmx4G org.gradle.parallel=true -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.28 -loader_version=0.14.11 +minecraft_version=1.19.4 +yarn_mappings=1.19.4+build.2 +loader_version=0.14.19 -mod_version = 1.0.0 +mod_version = 1.1.0 maven_group = com.eightsidedsquare archives_base_name = angling -fabric_version=0.68.0+1.19.2 +fabric_version=0.78.0+1.19.4 mixin_extras_version=0.1.1 -sodium_version=mc1.19.2-0.4.4 -cca_version=5.0.0 +sodium_version=mc1.19.4-0.4.10 +cca_version=5.1.0 +geckolib_version=4.1.3 +cloth_config_version=10.0.96 +modmenu_version=6.1.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cb..ccebba7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f398c33..0c85a1f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index 65dcd68..79a61d4 --- a/gradlew +++ b/gradlew @@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/src/main/java/com/eightsidedsquare/angling/client/AnglingClient.java b/src/main/java/com/eightsidedsquare/angling/client/AnglingClient.java index 58eb7ac..3174d0d 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/AnglingClient.java +++ b/src/main/java/com/eightsidedsquare/angling/client/AnglingClient.java @@ -18,12 +18,12 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; -import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.item.ModelPredicateProviderRegistry; import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.block.entity.BlockEntityRendererFactories; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.TropicalFishEntity; @@ -33,11 +33,12 @@ import net.minecraft.nbt.NbtElement; import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.core.util.Color; +import software.bernie.geckolib.core.object.Color; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; public class AnglingClient implements ClientModInitializer { + @Override public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), @@ -61,12 +62,12 @@ public void onInitializeClient() { EntityRendererRegistry.register(AnglingEntities.ANGLERFISH, AnglerfishEntityRenderer::new); EntityRendererRegistry.register(AnglingEntities.MAHI_MAHI, BasicEntityRenderer.create("mahi_mahi", true)); - BlockEntityRendererRegistry.register(AnglingEntities.STARFISH, StarfishBlockEntityRenderer::new); - BlockEntityRendererRegistry.register(AnglingEntities.ANEMONE, AnemoneBlockEntityRenderer::new); - BlockEntityRendererRegistry.register(AnglingEntities.URCHIN, UrchinBlockEntityRenderer::new); + BlockEntityRendererFactories.register(AnglingEntities.STARFISH, StarfishBlockEntityRenderer::new); + BlockEntityRendererFactories.register(AnglingEntities.ANEMONE, AnemoneBlockEntityRenderer::new); + BlockEntityRendererFactories.register(AnglingEntities.URCHIN, UrchinBlockEntityRenderer::new); if(FabricLoader.getInstance().isModLoaded("sodium")) { - BlockEntityRendererRegistry.register(AnglingEntities.ROE, RoeBlockEntityRenderer::new); - BlockEntityRendererRegistry.register(AnglingEntities.SEA_SLUG_EGGS, SeaSlugEggsBlockEntityRenderer::new); + BlockEntityRendererFactories.register(AnglingEntities.ROE, RoeBlockEntityRenderer::new); + BlockEntityRendererFactories.register(AnglingEntities.SEA_SLUG_EGGS, SeaSlugEggsBlockEntityRenderer::new); } ColorProviderRegistry.BLOCK.register(RoeBlockEntity::getColor, AnglingBlocks.ROE); @@ -84,7 +85,6 @@ public void onInitializeClient() { ParticleFactoryRegistry.getInstance().register(AnglingParticles.WORM, WormParticle.Factory::new); ModelPredicateProviderRegistry.register(AnglingItems.DONGFISH_BUCKET, new Identifier(MOD_ID, "has_horngus"), this::dongfishBucketItemHasHorngus); - } private float dongfishBucketItemHasHorngus(ItemStack stack, ClientWorld clientWorld, LivingEntity livingEntity, int i) { diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/AnemoneBlockEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/AnemoneBlockEntityModel.java index 9367a20..7610bf2 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/AnemoneBlockEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/AnemoneBlockEntityModel.java @@ -2,11 +2,11 @@ import com.eightsidedsquare.angling.common.entity.AnemoneBlockEntity; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.model.AnimatedGeoModel; +import software.bernie.geckolib.model.GeoModel; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; -public class AnemoneBlockEntityModel extends AnimatedGeoModel { +public class AnemoneBlockEntityModel extends GeoModel { @Override public Identifier getModelResource(AnemoneBlockEntity object) { return new Identifier(MOD_ID, "geo/anemone.geo.json"); @@ -21,10 +21,4 @@ public Identifier getTextureResource(AnemoneBlockEntity entity) { public Identifier getAnimationResource(AnemoneBlockEntity animatable) { return new Identifier(MOD_ID, "animations/anemone.animation.json"); } - - @Override - public void setLivingAnimations(AnemoneBlockEntity entity, Integer uniqueID) { - - super.setLivingAnimations(entity, uniqueID); - } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/BasicEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/BasicEntityModel.java index 732d7e1..49da504 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/BasicEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/BasicEntityModel.java @@ -3,17 +3,17 @@ import com.eightsidedsquare.angling.core.AnglingUtil; import net.minecraft.entity.LivingEntity; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.processor.IBone; -import software.bernie.geckolib3.model.AnimatedGeoModel; -import software.bernie.geckolib3.model.provider.data.EntityModelData; - -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; +import software.bernie.geckolib.constant.DataTickets; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.model.CoreGeoBone; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.model.GeoModel; +import software.bernie.geckolib.model.data.EntityModelData; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; -public class BasicEntityModel extends AnimatedGeoModel { +public class BasicEntityModel extends GeoModel { private final Identifier model; private final Identifier texture; @@ -57,24 +57,24 @@ public Identifier getAnimationResource(A entity) { } @Override - @SuppressWarnings("unchecked") - public void setLivingAnimations(A entity, Integer uniqueID, AnimationEvent event) { + public void setCustomAnimations(A animatable, long instanceId, AnimationState animationState) { if(!AnglingUtil.isReloadingResources()) { - super.setLivingAnimations(entity, uniqueID, event); + super.setCustomAnimations(animatable, instanceId, animationState); if(liesOutOfWater) { - IBone root = getAnimationProcessor().getBone("root"); - if (!entity.isTouchingWater() && root != null) { - root.setRotationZ((float) (Math.PI / 2d)); + CoreGeoBone root = getAnimationProcessor().getBone("root"); + if (!animatable.isTouchingWater() && root != null) { + root.setRotZ((float) (Math.PI / 2d)); } } if(head != null) { - IBone headBone = this.getAnimationProcessor().getBone(head); - EntityModelData extraData = (EntityModelData) event.getExtraDataOfType(EntityModelData.class).get(0); + CoreGeoBone headBone = this.getAnimationProcessor().getBone(head); + EntityModelData extraData = animationState.getData(DataTickets.ENTITY_MODEL_DATA); if (headBone != null) { - headBone.setRotationX(extraData.headPitch * ((float) Math.PI / 180F)); - headBone.setRotationY(extraData.netHeadYaw * ((float) Math.PI / 180F)); + headBone.setRotX(extraData.headPitch() * ((float) Math.PI / 180F)); + headBone.setRotY(extraData.netHeadYaw() * ((float) Math.PI / 180F)); } } } } + } diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/CrabEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/CrabEntityModel.java index aec191f..4defcee 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/CrabEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/CrabEntityModel.java @@ -3,14 +3,15 @@ import com.eightsidedsquare.angling.common.entity.CrabEntity; import com.eightsidedsquare.angling.core.AnglingUtil; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.processor.IBone; -import software.bernie.geckolib3.model.AnimatedGeoModel; -import software.bernie.geckolib3.model.provider.data.EntityModelData; +import software.bernie.geckolib.constant.DataTickets; +import software.bernie.geckolib.core.animatable.model.CoreGeoBone; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.model.GeoModel; +import software.bernie.geckolib.model.data.EntityModelData; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; -public class CrabEntityModel extends AnimatedGeoModel { +public class CrabEntityModel extends GeoModel { @Override public Identifier getModelResource(CrabEntity entity) { @@ -27,21 +28,21 @@ public Identifier getAnimationResource(CrabEntity entity) { return new Identifier(MOD_ID, "animations/crab.animation.json"); } - @Override @SuppressWarnings("unchecked") - public void setLivingAnimations(CrabEntity entity, Integer uniqueID, AnimationEvent event) { + @Override + public void setCustomAnimations(CrabEntity animatable, long instanceId, AnimationState animationState) { if(!AnglingUtil.isReloadingResources()) { - super.setLivingAnimations(entity, uniqueID, event); - IBone root = getAnimationProcessor().getBone("root"); - IBone eyes = getAnimationProcessor().getBone("eyes"); - EntityModelData extraData = (EntityModelData) event.getExtraDataOfType(EntityModelData.class).get(0); + super.setCustomAnimations(animatable, instanceId, animationState); + CoreGeoBone root = getAnimationProcessor().getBone("root"); + CoreGeoBone eyes = getAnimationProcessor().getBone("eyes"); + EntityModelData extraData = animationState.getData(DataTickets.ENTITY_MODEL_DATA); if (eyes != null) { - eyes.setRotationX(extraData.headPitch * ((float) Math.PI / 180F)); + eyes.setRotX(extraData.headPitch() * ((float) Math.PI / 180F)); } - if(extraData.isChild && root != null) { + if(extraData.isChild() && root != null) { root.setScaleX(0.35f); root.setScaleY(0.35f); root.setScaleZ(0.35f); - root.setPositionY(-1.75f); + root.setPosY(-1.75f); } } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/DongfishEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/DongfishEntityModel.java index 1d7c89d..8efd941 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/DongfishEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/DongfishEntityModel.java @@ -2,8 +2,8 @@ import com.eightsidedsquare.angling.common.entity.DongfishEntity; import com.eightsidedsquare.angling.core.AnglingUtil; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.processor.IBone; +import software.bernie.geckolib.core.animatable.model.CoreGeoBone; +import software.bernie.geckolib.core.animation.AnimationState; public class DongfishEntityModel extends BasicEntityModel { @@ -12,12 +12,12 @@ public DongfishEntityModel() { } @Override - public void setLivingAnimations(DongfishEntity entity, Integer uniqueID, AnimationEvent customPredicate) { - super.setLivingAnimations(entity, uniqueID, customPredicate); + public void setCustomAnimations(DongfishEntity animatable, long instanceId, AnimationState animationState) { + super.setCustomAnimations(animatable, instanceId, animationState); if(!AnglingUtil.isReloadingResources()) { - IBone scungle = getAnimationProcessor().getBone("scungle"); + CoreGeoBone scungle = getAnimationProcessor().getBone("scungle"); if(scungle != null) { - scungle.setHidden(!entity.hasHorngus()); + scungle.setHidden(!animatable.hasHorngus()); } } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/NautilusEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/NautilusEntityModel.java index e106d8c..8566e53 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/NautilusEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/NautilusEntityModel.java @@ -2,8 +2,8 @@ import com.eightsidedsquare.angling.common.entity.NautilusEntity; import com.eightsidedsquare.angling.core.AnglingUtil; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.processor.IBone; +import software.bernie.geckolib.core.animatable.model.CoreGeoBone; +import software.bernie.geckolib.core.animation.AnimationState; public class NautilusEntityModel extends BasicEntityModel { public NautilusEntityModel() { @@ -11,13 +11,13 @@ public NautilusEntityModel() { } @Override - public void setLivingAnimations(NautilusEntity entity, Integer uniqueID, AnimationEvent customPredicate) { + public void setCustomAnimations(NautilusEntity animatable, long instanceId, AnimationState animationState) { if(!AnglingUtil.isReloadingResources()) { - super.setLivingAnimations(entity, uniqueID, customPredicate); - IBone root = getAnimationProcessor().getBone("root"); - if(!entity.isTouchingWater() && root != null) { - root.setRotationZ((float) (Math.PI / -2d)); - root.setPositionY(-1.5f); + super.setCustomAnimations(animatable, instanceId, animationState); + CoreGeoBone root = getAnimationProcessor().getBone("root"); + if(!animatable.isTouchingWater() && root != null) { + root.setRotZ((float) (Math.PI / -2d)); + root.setPosY(-1.5f); } } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/StarfishBlockEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/StarfishBlockEntityModel.java index ef30d2d..46b02d8 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/StarfishBlockEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/StarfishBlockEntityModel.java @@ -5,13 +5,18 @@ import com.eightsidedsquare.angling.core.AnglingUtil; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3i; -import software.bernie.geckolib3.model.AnimatedGeoModel; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.model.GeoModel; import java.util.Optional; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; -public class StarfishBlockEntityModel extends AnimatedGeoModel { +public class StarfishBlockEntityModel extends GeoModel { + + public StarfishBlockEntityModel() { + } + @Override public Identifier getModelResource(StarfishBlockEntity object) { return new Identifier(MOD_ID, "geo/starfish.geo.json"); @@ -30,17 +35,17 @@ public Identifier getAnimationResource(StarfishBlockEntity animatable) { } @Override - public void setLivingAnimations(StarfishBlockEntity entity, Integer uniqueID) { + public void setCustomAnimations(StarfishBlockEntity animatable, long instanceId, AnimationState animationState) { if(!AnglingUtil.isReloadingResources()){ - super.setLivingAnimations(entity, uniqueID); + super.setCustomAnimations(animatable, instanceId, animationState); Optional.ofNullable(getAnimationProcessor().getBone("root")).ifPresent(bone -> { - Vec3i rotation = entity.getRotation(); - bone.setRotationX((float) Math.toRadians(rotation.getX())); - bone.setRotationY((float) Math.toRadians(rotation.getY())); - bone.setRotationZ((float) Math.toRadians(rotation.getZ())); + Vec3i rotation = animatable.getRotation(); + bone.setRotX((float) Math.toRadians(rotation.getX())); + bone.setRotY((float) Math.toRadians(rotation.getY())); + bone.setRotZ((float) Math.toRadians(rotation.getZ())); }); Optional.ofNullable(getAnimationProcessor().getBone("starfish")).ifPresent(bone -> - bone.setRotationY((float) entity.getRandomRotation())); + bone.setRotZ((float) animatable.getRandomRotation())); } } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/SunfishEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/SunfishEntityModel.java index e110241..7be12bc 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/SunfishEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/SunfishEntityModel.java @@ -2,19 +2,13 @@ import com.eightsidedsquare.angling.common.entity.SunfishEntity; import com.eightsidedsquare.angling.common.entity.util.SunfishVariant; -import com.eightsidedsquare.angling.core.AnglingUtil; import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.processor.IBone; -import software.bernie.geckolib3.model.AnimatedGeoModel; - -import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; public class SunfishEntityModel extends BasicEntityModel { public SunfishEntityModel() { super("sunfish", true); } + @Override public Identifier getTextureResource(SunfishEntity entity) { SunfishVariant variant = entity.getVariant(); diff --git a/src/main/java/com/eightsidedsquare/angling/client/model/UrchinBlockEntityModel.java b/src/main/java/com/eightsidedsquare/angling/client/model/UrchinBlockEntityModel.java index e7936b6..1385e66 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/model/UrchinBlockEntityModel.java +++ b/src/main/java/com/eightsidedsquare/angling/client/model/UrchinBlockEntityModel.java @@ -2,11 +2,11 @@ import com.eightsidedsquare.angling.common.entity.UrchinBlockEntity; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.model.AnimatedGeoModel; +import software.bernie.geckolib.model.GeoModel; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; -public class UrchinBlockEntityModel extends AnimatedGeoModel { +public class UrchinBlockEntityModel extends GeoModel { @Override public Identifier getModelResource(UrchinBlockEntity object) { diff --git a/src/main/java/com/eightsidedsquare/angling/client/particle/AlgaeParticle.java b/src/main/java/com/eightsidedsquare/angling/client/particle/AlgaeParticle.java index 70d0244..1b1f8d1 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/particle/AlgaeParticle.java +++ b/src/main/java/com/eightsidedsquare/angling/client/particle/AlgaeParticle.java @@ -4,7 +4,7 @@ import net.minecraft.client.particle.*; import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.DefaultParticleType; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; @@ -21,7 +21,7 @@ protected AlgaeParticle(ClientWorld clientWorld, double x, double y, double z, d @Override public void tick() { super.tick(); - if (!this.dead && !this.world.getFluidState(new BlockPos(this.x, this.y, this.z)).isIn(FluidTags.WATER)) { + if (!this.dead && !this.world.getFluidState(BlockPos.ofFloored(this.x, this.y, this.z)).isIn(FluidTags.WATER)) { this.markDead(); } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/particle/WormParticle.java b/src/main/java/com/eightsidedsquare/angling/client/particle/WormParticle.java index f7301c0..60462ce 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/particle/WormParticle.java +++ b/src/main/java/com/eightsidedsquare/angling/client/particle/WormParticle.java @@ -1,12 +1,22 @@ package com.eightsidedsquare.angling.client.particle; import net.minecraft.block.Block; -import net.minecraft.client.particle.*; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleFactory; +import net.minecraft.client.particle.ParticleTextureSheet; +import net.minecraft.client.particle.SpriteBillboardParticle; +import net.minecraft.client.particle.SpriteProvider; import net.minecraft.client.render.Camera; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.math.*; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.RotationAxis; +import net.minecraft.util.math.Vec3d; +import org.joml.Quaternionf; +import org.joml.Vector3f; public class WormParticle extends SpriteBillboardParticle { @@ -25,8 +35,8 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti float currentX = (float)(MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX()); float currentY = (float)(MathHelper.lerp(tickDelta, this.prevPosY, this.y) - vec3d.getY()); float currentZ = (float)(MathHelper.lerp(tickDelta, this.prevPosZ, this.z) - vec3d.getZ()); - Quaternion quaternion = Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()); - Quaternion flip = Vec3f.POSITIVE_Y.getDegreesQuaternion(180 - camera.getYaw()); + Quaternionf quaternion = RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw()); + Quaternionf flip = RotationAxis.POSITIVE_Y.rotationDegrees(180 - camera.getYaw()); float size = this.getSize(tickDelta); float minU = this.getMinU(); @@ -39,19 +49,19 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti renderFace(vertexConsumer, flip, size, currentX, currentY, currentZ, minU, maxU, minV, maxV, light); } - private void renderFace(VertexConsumer vertexConsumer, Quaternion quaternion, float size, float x, float y, float z, float minU, float maxU, float minV, float maxV, int light) { - Vec3f[] vec3fs = new Vec3f[]{new Vec3f(-1.0F, -1.0F, 0.0F), new Vec3f(-1.0F, 1.0F, 0.0F), new Vec3f(1.0F, 1.0F, 0.0F), new Vec3f(1.0F, -1.0F, 0.0F)}; + private void renderFace(VertexConsumer vertexConsumer, Quaternionf quaternion, float size, float x, float y, float z, float minU, float maxU, float minV, float maxV, int light) { + Vector3f[] vec3fs = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)}; for(int k = 0; k < 4; ++k) { - Vec3f vec3f2 = vec3fs[k]; + Vector3f vec3f2 = vec3fs[k]; vec3f2.rotate(quaternion); - vec3f2.scale(size); + vec3f2.mul(size); vec3f2.add(x, y, z); } - vertexConsumer.vertex(vec3fs[0].getX(), vec3fs[0].getY(), vec3fs[0].getZ()).texture(maxU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); - vertexConsumer.vertex(vec3fs[1].getX(), vec3fs[1].getY(), vec3fs[1].getZ()).texture(maxU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); - vertexConsumer.vertex(vec3fs[2].getX(), vec3fs[2].getY(), vec3fs[2].getZ()).texture(minU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); - vertexConsumer.vertex(vec3fs[3].getX(), vec3fs[3].getY(), vec3fs[3].getZ()).texture(minU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); + vertexConsumer.vertex(vec3fs[0].x(), vec3fs[0].y(), vec3fs[0].z()).texture(maxU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); + vertexConsumer.vertex(vec3fs[1].x(), vec3fs[1].y(), vec3fs[1].z()).texture(maxU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); + vertexConsumer.vertex(vec3fs[2].x(), vec3fs[2].y(), vec3fs[2].z()).texture(minU, minV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); + vertexConsumer.vertex(vec3fs[3].x(), vec3fs[3].y(), vec3fs[3].z()).texture(minU, maxV).color(this.red, this.green, this.blue, this.alpha).light(light).next(); } @Override @@ -69,7 +79,7 @@ public void tick() { setVelocity(0, 0, 0); } super.tick(); - if(!Block.isFaceFullSquare(world.getBlockState(new BlockPos(x, y - 0.5d, z)).getSidesShape(world, new BlockPos(x, y - 0.5d, z)), Direction.UP)) { + if(!Block.isFaceFullSquare(world.getBlockState(BlockPos.ofFloored(x, y - 0.5d, z)).getSidesShape(world, BlockPos.ofFloored(x, y - 0.5d, z)), Direction.UP)) { markDead(); } setSpriteForAge(this.spriteProvider); diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/AnemoneBlockEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/AnemoneBlockEntityRenderer.java index c7ba68c..7c43fe2 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/AnemoneBlockEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/AnemoneBlockEntityRenderer.java @@ -3,12 +3,10 @@ import com.eightsidedsquare.angling.client.model.AnemoneBlockEntityModel; import com.eightsidedsquare.angling.common.entity.AnemoneBlockEntity; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.renderers.geo.GeoBlockRenderer; +import software.bernie.geckolib.renderer.GeoBlockRenderer; public class AnemoneBlockEntityRenderer extends GeoBlockRenderer { @@ -17,7 +15,7 @@ public AnemoneBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) { } @Override - public RenderLayer getRenderType(AnemoneBlockEntity animatable, float partialTicks, MatrixStack stack, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, Identifier textureLocation) { - return RenderLayer.getEntityTranslucent(getTextureResource(animatable)); + public RenderLayer getRenderType(AnemoneBlockEntity animatable, Identifier texture, VertexConsumerProvider bufferSource, float partialTick) { + return RenderLayer.getEntityTranslucent(getTextureLocation(animatable)); } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/AnglerfishEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/AnglerfishEntityRenderer.java index fdc6a28..af05685 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/AnglerfishEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/AnglerfishEntityRenderer.java @@ -6,9 +6,10 @@ import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; -import software.bernie.geckolib3.renderers.geo.GeoLayerRenderer; -import software.bernie.geckolib3.renderers.geo.IGeoRenderer; +import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.renderer.GeoEntityRenderer; +import software.bernie.geckolib.renderer.GeoRenderer; +import software.bernie.geckolib.renderer.layer.GeoRenderLayer; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; @@ -18,33 +19,27 @@ public class AnglerfishEntityRenderer extends GeoEntityRenderer("anglerfish", true)); - addLayer(new AnglerfishLayerRenderer(this)); + addRenderLayer(new AnglerfishLayerRenderer(this)); } @Override - public RenderLayer getRenderType(AnglerfishEntity entity, float partialTicks, MatrixStack stack, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, Identifier textureLocation) { - return RenderLayer.getEntityTranslucent(getTextureResource(entity)); + public RenderLayer getRenderType(AnglerfishEntity animatable, Identifier texture, VertexConsumerProvider bufferSource, float partialTick) { + return RenderLayer.getEntityTranslucent(getTextureLocation(animatable)); } - static class AnglerfishLayerRenderer extends GeoLayerRenderer { + static class AnglerfishLayerRenderer extends GeoRenderLayer { - public AnglerfishLayerRenderer(IGeoRenderer entityRendererIn) { + public AnglerfishLayerRenderer(GeoRenderer entityRendererIn) { super(entityRendererIn); } @Override - public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, AnglerfishEntity entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { + public void render(MatrixStack poseStack, AnglerfishEntity animatable, BakedGeoModel bakedModel, RenderLayer renderType, VertexConsumerProvider bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { int overlay = OverlayTexture.getUv(0, - entity.hurtTime > 0 || entity.deathTime > 0); + animatable.hurtTime > 0 || animatable.deathTime > 0); - this.getRenderer().render(this.getEntityModel().getModel(getEntityModel().getModelResource(entity)), entity, partialTicks, this.getRenderType(OVERLAY), matrixStackIn, bufferIn, - bufferIn.getBuffer(this.getRenderType(OVERLAY)), LightmapTextureManager.MAX_LIGHT_COORDINATE, overlay, 1, 1, 1, 1); - } - - @Override - public RenderLayer getRenderType(Identifier texture) { - return RenderLayer.getEntityCutoutNoCull(texture); + super.render(poseStack, animatable, bakedModel, renderType, bufferSource, buffer, partialTick, packedLight, overlay); } } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/BasicEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/BasicEntityRenderer.java index ca80f95..514ffc1 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/BasicEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/BasicEntityRenderer.java @@ -2,36 +2,34 @@ import com.eightsidedsquare.angling.client.model.BasicEntityModel; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.model.AnimatedGeoModel; -import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.model.GeoModel; +import software.bernie.geckolib.renderer.GeoEntityRenderer; -public class BasicEntityRenderer extends GeoEntityRenderer { +public class BasicEntityRenderer extends GeoEntityRenderer { - public BasicEntityRenderer(EntityRendererFactory.Context ctx, AnimatedGeoModel modelProvider) { + public BasicEntityRenderer(EntityRendererFactory.Context ctx, GeoModel modelProvider) { super(ctx, modelProvider); } - public static EntityRendererFactory create(AnimatedGeoModel model) { + public static EntityRendererFactory create(GeoModel model) { return ctx -> new BasicEntityRenderer<>(ctx, model); } - public static EntityRendererFactory create(String name, boolean liesOutOfWater) { + public static EntityRendererFactory create(String name, boolean liesOutOfWater) { return ctx -> new BasicEntityRenderer<>(ctx, new BasicEntityModel<>(name, liesOutOfWater)); } - public static EntityRendererFactory create(String name, boolean liesOutOfWater, String head) { + public static EntityRendererFactory create(String name, boolean liesOutOfWater, String head) { return ctx -> new BasicEntityRenderer<>(ctx, new BasicEntityModel<>(name, liesOutOfWater, head)); } @Override - public RenderLayer getRenderType(A entity, float partialTicks, MatrixStack stack, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, Identifier textureLocation) { - return RenderLayer.getEntityTranslucent(getTextureResource(entity)); + public RenderLayer getRenderType(A animatable, Identifier texture, VertexConsumerProvider bufferSource, float partialTick) { + return RenderLayer.getEntityTranslucent(getTextureLocation(animatable)); } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/FryEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/FryEntityRenderer.java index a733baa..a29b1de 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/FryEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/FryEntityRenderer.java @@ -4,46 +4,47 @@ import com.eightsidedsquare.angling.common.entity.FryEntity; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; -import software.bernie.geckolib3.renderers.geo.GeoLayerRenderer; -import software.bernie.geckolib3.renderers.geo.IGeoRenderer; +import software.bernie.geckolib.renderer.GeoEntityRenderer; +import software.bernie.geckolib.renderer.GeoRenderer; +import software.bernie.geckolib.renderer.layer.GeoRenderLayer; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; public class FryEntityRenderer extends GeoEntityRenderer { public FryEntityRenderer(EntityRendererFactory.Context ctx) { super(ctx, new FryEntityModel()); - addLayer(new FryEntityLayerRenderer(this)); + addRenderLayer(new FryEntityLayerRenderer(this)); } @Override - public RenderLayer getRenderType(FryEntity animatable, float partialTicks, MatrixStack stack, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, Identifier textureLocation) { - return RenderLayer.getEntityTranslucent(getTextureResource(animatable)); + public RenderLayer getRenderType(FryEntity animatable, Identifier texture, VertexConsumerProvider bufferSource, float partialTick) { + return RenderLayer.getEntityTranslucent(getTextureLocation(animatable)); } - static class FryEntityLayerRenderer extends GeoLayerRenderer { + static class FryEntityLayerRenderer extends GeoRenderLayer { private static final Identifier OUTSIDE_LAYER = new Identifier(MOD_ID, "textures/entity/fry/fry.png"); private static final Identifier INSIDE_LAYER = new Identifier(MOD_ID, "textures/entity/fry/fry_innards.png"); private static final Identifier MODEL = new Identifier(MOD_ID, "geo/fry.geo.json"); - public FryEntityLayerRenderer(IGeoRenderer entityRendererIn) { + public FryEntityLayerRenderer(GeoRenderer entityRendererIn) { super(entityRendererIn); } private void render(Identifier layer, MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, int overlay, FryEntity entity, float partialTicks, float r, float g, float b) { RenderLayer renderLayer = RenderLayer.getEntityTranslucent(layer); matrixStackIn.push(); - this.getRenderer().render(this.getEntityModel().getModel(MODEL), entity, partialTicks, renderLayer, matrixStackIn, bufferIn, + /*this.getRenderer().(this.getEntityModel().getModel(MODEL), entity, partialTicks, renderLayer, matrixStackIn, bufferIn, bufferIn.getBuffer(renderLayer), packedLightIn, overlay, r, g, b, 1f); + + */ matrixStackIn.pop(); } - @Override + public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, FryEntity entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { int color = entity.getColor(); float r = ((color >> 16) & 0xFF) / 255f; diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/NautilusEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/NautilusEntityRenderer.java index c1df9de..046b64c 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/NautilusEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/NautilusEntityRenderer.java @@ -7,13 +7,14 @@ import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.util.math.MatrixStack; -import software.bernie.geckolib3.geo.render.built.GeoModel; +import software.bernie.geckolib.model.GeoModel; public class NautilusEntityRenderer extends BasicEntityRenderer { public NautilusEntityRenderer(EntityRendererFactory.Context ctx) { super(ctx, new NautilusEntityModel()); } + /* @Override public void render(GeoModel model, NautilusEntity animatable, float partialTicks, RenderLayer type, MatrixStack matrices, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { matrices.push(); @@ -21,4 +22,7 @@ public void render(GeoModel model, NautilusEntity animatable, float partialTicks super.render(model, animatable, partialTicks, type, matrices, renderTypeBuffer, vertexBuilder, packedLightIn, packedOverlayIn, red, green, blue, alpha); matrices.pop(); } + + + */ } diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/PelicanEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/PelicanEntityRenderer.java index 38b22a8..ca34bb9 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/PelicanEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/PelicanEntityRenderer.java @@ -8,13 +8,11 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.client.util.math.Vector3d; import net.minecraft.entity.Entity; -import net.minecraft.util.math.Quaternion; -import net.minecraft.util.math.Vec3f; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.geo.render.built.GeoBone; -import software.bernie.geckolib3.util.RenderUtils; +import org.joml.Vector3d; +import software.bernie.geckolib.cache.object.GeoBone; +import software.bernie.geckolib.util.RenderUtils; public class PelicanEntityRenderer extends BasicEntityRenderer { @@ -28,7 +26,7 @@ public PelicanEntityRenderer(EntityRendererFactory.Context ctx) { entityRenderDispatcher = ctx.getRenderDispatcher(); this.shadowRadius = 0.35f; } - +/* @Override public void renderEarly(PelicanEntity entity, MatrixStack stackIn, float ticks, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float tickDelta) { this.vertexConsumerProvider = renderTypeBuffer; @@ -73,6 +71,6 @@ public void renderRecursively(GeoBone bone, MatrixStack stack, VertexConsumer bu super.renderRecursively(bone, stack, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); } - +*/ } diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/SeaSlugEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/SeaSlugEntityRenderer.java index 147cd1e..c5f038d 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/SeaSlugEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/SeaSlugEntityRenderer.java @@ -9,42 +9,45 @@ import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; -import software.bernie.geckolib3.renderers.geo.GeoLayerRenderer; -import software.bernie.geckolib3.renderers.geo.IGeoRenderer; +import software.bernie.geckolib.renderer.GeoEntityRenderer; +import software.bernie.geckolib.renderer.GeoRenderer; +import software.bernie.geckolib.renderer.layer.GeoRenderLayer; public class SeaSlugEntityRenderer extends GeoEntityRenderer { public SeaSlugEntityRenderer(EntityRendererFactory.Context ctx) { super(ctx, new BasicEntityModel<>("sea_slug", false)); - this.addLayer(new SeaSlugLayerRenderer(this)); + this.addRenderLayer(new SeaSlugLayerRenderer(this)); this.shadowRadius = 0.1f; } - static class SeaSlugLayerRenderer extends GeoLayerRenderer { + static class SeaSlugLayerRenderer extends GeoRenderLayer { - public SeaSlugLayerRenderer(IGeoRenderer entityRendererIn) { + public SeaSlugLayerRenderer(GeoRenderer entityRendererIn) { super(entityRendererIn); } public void render(int color, Identifier texture, boolean glow, MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, SeaSlugEntity entity, float partialTicks) { if(texture != null) { - Identifier model = this.getEntityModel().getModelResource(entity); + Identifier model = this.getGeoModel().getModelResource(entity); float r = ((color >> 16) & 0xff) / 255f; float g = ((color >> 8) & 0xff) / 255f; float b = (color & 0xff) / 255f; int overlay = OverlayTexture.getUv(0, entity.hurtTime > 0 || entity.deathTime > 0); - this.getRenderer().render(this.getEntityModel().getModel(model), entity, partialTicks, this.getRenderType(texture), matrixStackIn, bufferIn, + /* this.getRenderer().renderRecursively(this.getGeoModel().getBakedModel(model), entity, partialTicks, this.getRenderType(texture), matrixStackIn, bufferIn, bufferIn.getBuffer(this.getRenderType(texture)), glow ? LightmapTextureManager.MAX_LIGHT_COORDINATE : packedLightIn, overlay, r, g, b, 1f); + TODO: ALL THIS STUFF + */ } } + /* @Override public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, SeaSlugEntity entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { - this.render(entity.getBaseColor().color(), this.getEntityTexture(entity), false, matrixStackIn, bufferIn, packedLightIn, entity, partialTicks); + this.render(entity.getBaseColor().color(), this.getTextureResource(entity), false, matrixStackIn, bufferIn, packedLightIn, entity, partialTicks); this.render(entity.getPatternColor().color(), entity.getPattern().texture(), entity.isBioluminescent(), matrixStackIn, bufferIn, packedLightIn, entity, partialTicks); } @@ -52,5 +55,7 @@ public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, i public RenderLayer getRenderType(Identifier texture) { return RenderLayer.getEntityCutoutNoCull(texture); } + + */ } } diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/StarfishBlockEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/StarfishBlockEntityRenderer.java index 81bab07..cbc074f 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/StarfishBlockEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/StarfishBlockEntityRenderer.java @@ -3,54 +3,50 @@ import com.eightsidedsquare.angling.client.model.StarfishBlockEntityModel; import com.eightsidedsquare.angling.common.entity.StarfishBlockEntity; import com.eightsidedsquare.angling.core.AnglingBlocks; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import software.bernie.geckolib3.core.util.Color; -import software.bernie.geckolib3.geo.render.built.GeoModel; -import software.bernie.geckolib3.model.AnimatedGeoModel; -import software.bernie.geckolib3.renderers.geo.GeoBlockRenderer; +import software.bernie.geckolib.core.object.Color; +import software.bernie.geckolib.model.GeoModel; +import software.bernie.geckolib.renderer.GeoBlockRenderer; public class StarfishBlockEntityRenderer extends GeoBlockRenderer { - private final AnimatedGeoModel modelProvider; + private final GeoModel modelProvider; public StarfishBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) { super(new StarfishBlockEntityModel()); this.modelProvider = new StarfishBlockEntityModel(); } - @Override - public RenderLayer getRenderType(StarfishBlockEntity animatable, float partialTicks, MatrixStack stack, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, Identifier textureLocation) { - return RenderLayer.getEntityTranslucent(getTextureResource(animatable)); + public RenderLayer getRenderType(StarfishBlockEntity animatable, Identifier texture, VertexConsumerProvider bufferSource, float partialTick) { + return RenderLayer.getEntityTranslucent(getTextureLocation(animatable)); } @Override - public Color getRenderColor(StarfishBlockEntity entity, float partialTicks, MatrixStack stack, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn) { - return entity.getCachedState().isOf(AnglingBlocks.DEAD_STARFISH) ? Color.WHITE : Color.ofOpaque(entity.isRainbow() ? StarfishBlockEntity.getRainbowColor() : entity.getColor()); + public Color getRenderColor(StarfishBlockEntity animatable, float partialTick, int packedLight) { + return animatable.getCachedState().isOf(AnglingBlocks.DEAD_STARFISH) ? Color.WHITE : Color.ofOpaque(animatable.isRainbow() ? StarfishBlockEntity.getRainbowColor() : animatable.getColor()); } + /* + @Override - public void render(StarfishBlockEntity entity, float partialTicks, MatrixStack stack, VertexConsumerProvider bufferIn, - int packedLightIn) { + public void render(StarfishBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { if(!entity.isRemoved()){ - GeoModel model = modelProvider.getModel(modelProvider.getModelResource(entity)); - modelProvider.setLivingAnimations(entity, this.getUniqueID(entity)); - stack.push(); - stack.translate(0.5, 0.01, 0.5); - - MinecraftClient.getInstance().getTextureManager().bindTexture(getTextureResource(entity)); - Color renderColor = getRenderColor(entity, partialTicks, stack, bufferIn, null, packedLightIn); - RenderLayer renderType = getRenderType(entity, partialTicks, stack, bufferIn, null, packedLightIn, - getTextureResource(entity)); - render(model, entity, partialTicks, renderType, stack, bufferIn, null, packedLightIn, OverlayTexture.DEFAULT_UV, - (float) renderColor.getRed() / 255f, (float) renderColor.getGreen() / 255f, - (float) renderColor.getBlue() / 255f, (float) renderColor.getAlpha() / 255); - stack.pop(); + BakedGeoModel model = modelProvider.getBakedModel(modelProvider.getModelResource(entity)); + // modelProvider.setCustomAnimations(entity, this.getInstanceId(entity)); + matrices.push(); + matrices.translate(0.5, 0.01, 0.5); + + MinecraftClient.getInstance().getTextureManager().bindTexture(getTextureLocation(entity)); + Color renderColor = getRenderColor(entity, tickDelta, light); + RenderLayer renderType = getRenderType(entity, getTextureLocation(entity), vertexConsumers, tickDelta); + + matrices.pop(); } } + + + */ + } diff --git a/src/main/java/com/eightsidedsquare/angling/client/renderer/UrchinBlockEntityRenderer.java b/src/main/java/com/eightsidedsquare/angling/client/renderer/UrchinBlockEntityRenderer.java index c7009b3..421871f 100644 --- a/src/main/java/com/eightsidedsquare/angling/client/renderer/UrchinBlockEntityRenderer.java +++ b/src/main/java/com/eightsidedsquare/angling/client/renderer/UrchinBlockEntityRenderer.java @@ -1,6 +1,7 @@ package com.eightsidedsquare.angling.client.renderer; import com.eightsidedsquare.angling.client.model.UrchinBlockEntityModel; +import com.eightsidedsquare.angling.common.entity.StarfishBlockEntity; import com.eightsidedsquare.angling.common.entity.UrchinBlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.OverlayTexture; @@ -10,12 +11,15 @@ import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import net.minecraft.util.math.Quaternion; -import net.minecraft.util.math.Vec3f; -import software.bernie.geckolib3.geo.render.built.GeoBone; -import software.bernie.geckolib3.renderers.geo.GeoBlockRenderer; +import org.joml.Quaternionf; +import org.joml.QuaternionfInterpolator; +import org.joml.Vector3f; +import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.cache.object.GeoBone; +import software.bernie.geckolib.renderer.GeoBlockRenderer; public class UrchinBlockEntityRenderer extends GeoBlockRenderer { @@ -27,29 +31,29 @@ public UrchinBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) { } @Override - public RenderLayer getRenderType(UrchinBlockEntity entity, float partialTicks, MatrixStack stack, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, Identifier textureLocation) { - return RenderLayer.getEntityTranslucent(getTextureResource(entity)); + public RenderLayer getRenderType(UrchinBlockEntity animatable, Identifier texture, VertexConsumerProvider bufferSource, float partialTick) { + return RenderLayer.getEntityTranslucent(getTextureLocation(animatable)); } @Override - public void renderEarly(UrchinBlockEntity entity, MatrixStack stackIn, float partialTicks, VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { - this.entity = entity; - this.vertexConsumerProvider = renderTypeBuffer; - super.renderEarly(entity, stackIn, partialTicks, renderTypeBuffer, vertexBuilder, packedLightIn, packedOverlayIn, red, green, blue, alpha); + public void preRender(MatrixStack poseStack, UrchinBlockEntity animatable, BakedGeoModel model, VertexConsumerProvider bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { + this.entity = animatable; + this.vertexConsumerProvider = vertexConsumerProvider; + super.preRender(poseStack, animatable, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); } @Override - public void renderRecursively(GeoBone bone, MatrixStack stack, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { + public void renderRecursively(MatrixStack poseStack, UrchinBlockEntity animatable, GeoBone bone, RenderLayer renderType, VertexConsumerProvider bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { if(bone.getName().equals("root")) { ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer(); - stack.push(); - stack.multiply(Quaternion.fromEulerXyz(new Vec3f(bone.getRotationX(), bone.getRotationY(), bone.getRotationZ()))); - stack.translate(0f, 0.625f, 0f); - stack.scale(0.5f, 0.5f, 0.5f); - itemRenderer.renderItem(entity.getHat(), ModelTransformation.Mode.FIXED, packedLightIn, OverlayTexture.DEFAULT_UV, stack, vertexConsumerProvider, 0); - stack.pop(); - bufferIn = vertexConsumerProvider.getBuffer(RenderLayer.getEntityTranslucent(getTextureResource(entity))); + poseStack.push(); + // poseStack.multiply(Quaternion.fromEulerXyz(new Vector3f(bone.getRotX(), bone.getRotY(), bone.getRotZ()))); TODO: Fix this + poseStack.translate(0f, 0.625f, 0f); + poseStack.scale(0.5f, 0.5f, 0.5f); + itemRenderer.renderItem(entity.getHat(), ModelTransformationMode.FIXED, packedLight, OverlayTexture.DEFAULT_UV, poseStack, vertexConsumerProvider, null,0); + poseStack.pop(); + buffer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityTranslucent(getTextureLocation(entity))); } - super.renderRecursively(bone, stack, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); + super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); } } diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/AlgaeBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/AlgaeBlock.java index cd5bc0b..61ece7a 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/AlgaeBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/AlgaeBlock.java @@ -10,11 +10,11 @@ import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.Items; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.FluidTags; import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; @@ -23,6 +23,7 @@ import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; +import net.minecraft.world.WorldView; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -41,7 +42,7 @@ public AlgaeBlock(Settings settings) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); @@ -51,14 +52,15 @@ public boolean canReplace(BlockState state, ItemPlacementContext context) { return !context.getStack().isOf(Items.GLOW_LICHEN) || super.canReplace(state, context); } - public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { - return canGrow(world, pos, state); - } - public boolean canGrow(BlockView world, BlockPos pos, BlockState state) { return state.get(WATERLOGGED) && Direction.stream().anyMatch((direction) -> this.grower.canGrow(state, world, pos, direction.getOpposite())); } + @Override + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { + return canGrow(world, pos, state); + } + public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { return true; } @@ -151,7 +153,7 @@ public void randomDisplayTick(BlockState state, World world, BlockPos pos, Rando double x = random.nextGaussian() + pos.getX(); double y = random.nextGaussian() + pos.getY(); double z = random.nextGaussian() + pos.getZ(); - if(world.getBlockState(new BlockPos(x, y, z)).getFluidState().isIn(FluidTags.WATER)) { + if(world.getBlockState(BlockPos.ofFloored(x, y, z)).getFluidState().isIn(FluidTags.WATER)) { double velocityX = random.nextGaussian() * 0.01d; double velocityY = random.nextGaussian() * 0.01d; double velocityZ = random.nextGaussian() * 0.01d; diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/AnemoneBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/AnemoneBlock.java index a43259c..e50a74f 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/AnemoneBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/AnemoneBlock.java @@ -39,7 +39,7 @@ protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/ClamBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/ClamBlock.java index a63e1eb..349511b 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/ClamBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/ClamBlock.java @@ -4,11 +4,11 @@ import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; @@ -46,12 +46,12 @@ public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos public BlockState getPlacementState(ItemPlacementContext ctx) { FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); boolean bl = fluidState.getFluid() == Fluids.WATER; - return getDefaultState().with(WATERLOGGED, bl).with(FACING, ctx.getPlayerFacing().getOpposite()); + return getDefaultState().with(WATERLOGGED, bl).with(FACING, ctx.getPlayerLookDirection().getOpposite()); } public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/OystersBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/OystersBlock.java index 6d6e75c..449f5cd 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/OystersBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/OystersBlock.java @@ -31,7 +31,7 @@ public OystersBlock(Settings settings) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/PapyrusBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/PapyrusBlock.java index fe6ecbc..bc3aa2b 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/PapyrusBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/PapyrusBlock.java @@ -4,12 +4,12 @@ import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; @@ -37,7 +37,7 @@ public PapyrusBlock(Settings settings) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); @@ -72,7 +72,7 @@ public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { } @Override - public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { return state.get(AGE) < 2; } diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/RoeBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/RoeBlock.java index 04a4d7d..3e45388 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/RoeBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/RoeBlock.java @@ -72,7 +72,7 @@ public BlockState getPlacementState(ItemPlacementContext ctx) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); @@ -96,7 +96,7 @@ public int getHatchTime(Random random) { @Override public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) { if(state.get(WATERLOGGED)) { - world.createAndScheduleBlockTick(pos, this, getHatchTime(world.getRandom())); + world.scheduleBlockTick(pos, this, getHatchTime(world.getRandom())); } } @@ -118,7 +118,7 @@ public static Pair getRoeColor(FishEntity entity) { SpawnEggItem eggItem = SpawnEggItem.forEntity(entity.getType()); FishSpawningComponent component = AnglingEntityComponents.FISH_SPAWNING.get(entity); if(entity instanceof TropicalFishEntity tropicalFishEntity) { - int parentColor = TropicalFishEntity.getBaseDyeColor(tropicalFishEntity.getVariant()).getSignColor(); + int parentColor = TropicalFishEntity.getBaseDyeColor(tropicalFishEntity.getVariant().getId()).getSignColor(); return new Pair<>(parentColor, component.getMateData() != null ? TropicalFishEntity.getBaseDyeColor(component.getMateData().getInt("Variant")).getSignColor() : parentColor); } diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/SeaSlugEggsBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/SeaSlugEggsBlock.java index c9ed2c4..0729ad6 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/SeaSlugEggsBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/SeaSlugEggsBlock.java @@ -62,7 +62,7 @@ public BlockState getPlacementState(ItemPlacementContext ctx) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); @@ -82,7 +82,7 @@ public int getHatchTime(Random random) { @Override public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) { if(state.get(WATERLOGGED)) { - world.createAndScheduleBlockTick(pos, this, getHatchTime(world.getRandom())); + world.scheduleBlockTick(pos, this, getHatchTime(world.getRandom())); } } diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/StarfishBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/StarfishBlock.java index e83d118..a959a01 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/StarfishBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/StarfishBlock.java @@ -14,11 +14,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.FluidTags; import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -121,7 +121,7 @@ private static int getRandomColor(Random random) { public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) { randomize(world, pos, world.getRandom()); if(shouldDie(state, world, pos)) { - world.createAndScheduleBlockTick(pos, this, 60 + world.getRandom().nextInt(40)); + world.scheduleBlockTick(pos, this, 60 + world.getRandom().nextInt(40)); } super.onBlockAdded(state, world, pos, oldState, notify); } @@ -142,13 +142,13 @@ private boolean shouldDie(BlockState state, WorldAccess world, BlockPos pos) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); } if(shouldDie(state, world, pos)) { - world.createAndScheduleBlockTick(pos, this, 60 + world.getRandom().nextInt(40)); + world.scheduleBlockTick(pos, this, 60 + world.getRandom().nextInt(40)); } return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/UrchinBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/UrchinBlock.java index c69767b..78bf1ff 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/UrchinBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/UrchinBlock.java @@ -71,7 +71,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if(!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/WaterFloatingPlant.java b/src/main/java/com/eightsidedsquare/angling/common/block/WaterFloatingPlant.java index e859b0d..6b1f428 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/WaterFloatingPlant.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/WaterFloatingPlant.java @@ -11,6 +11,7 @@ import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; import net.minecraft.world.World; +import net.minecraft.world.WorldView; @SuppressWarnings("deprecation") public class WaterFloatingPlant extends PlantBlock implements Fertilizable { @@ -32,7 +33,7 @@ protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) } @Override - public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { for(Direction d : Direction.Type.HORIZONTAL) { BlockPos offsetPos = pos.offset(d).down(); if(canPlantOnTop(world.getBlockState(offsetPos), world, offsetPos) && world.getBlockState(offsetPos.up()).isAir()) { diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/WaterloggableBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/WaterloggableBlock.java index af40152..180f15b 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/WaterloggableBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/WaterloggableBlock.java @@ -31,7 +31,7 @@ protected void appendProperties(StateManager.Builder builder) public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); } diff --git a/src/main/java/com/eightsidedsquare/angling/common/block/WormyBlock.java b/src/main/java/com/eightsidedsquare/angling/common/block/WormyBlock.java index c8e1fdb..7df382f 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/block/WormyBlock.java +++ b/src/main/java/com/eightsidedsquare/angling/common/block/WormyBlock.java @@ -7,12 +7,12 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.state.StateManager; import net.minecraft.state.property.IntProperty; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.FluidTags; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/AnemoneBlockEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/AnemoneBlockEntity.java index 9b8ae7b..49510de 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/AnemoneBlockEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/AnemoneBlockEntity.java @@ -7,17 +7,18 @@ import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class AnemoneBlockEntity extends BlockEntity implements IAnimatable { +public class AnemoneBlockEntity extends BlockEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public AnemoneBlockEntity(BlockPos pos, BlockState state) { super(AnglingEntities.ANEMONE, pos, state); @@ -35,17 +36,24 @@ public BlockEntityUpdateS2CPacket toUpdatePacket() { } @Override - public void registerControllers(AnimationData data) { - data.addAnimationController(new AnimationController<>(this, "controller", 0, this::controller)); + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 0, this::controller)); } - private PlayState controller(AnimationEvent event) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.anemone.idle", true)); - return PlayState.CONTINUE; + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } @Override - public AnimationFactory getFactory() { - return factory; + public double getTick(Object o) { + return 0; } + + private PlayState controller(AnimationState event) { + event.getController().setAnimation(RawAnimation.begin().thenLoop("animation.anemone.idle")); + return PlayState.CONTINUE; + } + + } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/AnglerfishEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/AnglerfishEntity.java index 17c6d84..ba4a198 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/AnglerfishEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/AnglerfishEntity.java @@ -9,17 +9,20 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class AnglerfishEntity extends FishEntity implements IAnimatable { +public class AnglerfishEntity extends FishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.anglerfish.flop"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.anglerfish.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public AnglerfishEntity(EntityType entityType, World world) { super(entityType, world); @@ -46,21 +49,27 @@ protected SoundEvent getDeathSound() { public ItemStack getBucketItem() { return new ItemStack(AnglingItems.ANGLERFISH_BUCKET); } + + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; + } + @Override - public AnimationFactory getFactory() { - return factory; + public double getTick(Object o) { + return 0; } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); } - private PlayState controller(AnimationEvent event) { + private PlayState controller(AnimationState state) { if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.anglerfish.flop", true)); + state.getController().setAnimation(flopAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.anglerfish.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/AnomalocarisEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/AnomalocarisEntity.java index f1c96a3..99ce186 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/AnomalocarisEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/AnomalocarisEntity.java @@ -14,17 +14,19 @@ import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class AnomalocarisEntity extends FishEntity implements IAnimatable { +public class AnomalocarisEntity extends FishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.anomalocaris.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public AnomalocarisEntity(EntityType entityType, World world) { super(entityType, world); @@ -53,18 +55,23 @@ protected SoundEvent getDeathSound() { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } - private PlayState controller(AnimationEvent event) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.anomalocaris.idle", true)); - return PlayState.CONTINUE; + @Override + public double getTick(Object o) { + return 0; } @Override - public AnimationFactory getFactory() { - return factory; + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); + } + + private PlayState controller(AnimationState state) { + state.getController().setAnimation(idleAnimation); + return PlayState.CONTINUE; } @SuppressWarnings({"deprecation", "unused"}) diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/BubbleEyeEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/BubbleEyeEntity.java index f44c8ea..3769c38 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/BubbleEyeEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/BubbleEyeEntity.java @@ -9,17 +9,20 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class BubbleEyeEntity extends SchoolingFishEntity implements IAnimatable { +public class BubbleEyeEntity extends SchoolingFishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.bubble_eye.flop"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.bubble_eye.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public BubbleEyeEntity(EntityType entityType, World world) { super(entityType, world); @@ -47,22 +50,29 @@ public ItemStack getBucketItem() { return new ItemStack(AnglingItems.BUBBLE_EYE_BUCKET); } + @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } - private PlayState controller(AnimationEvent event) { - if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bubble_eye.flop", true)); - }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bubble_eye.idle", true)); - } - return PlayState.CONTINUE; + @Override + public double getTick(Object o) { + return 0; } @Override - public AnimationFactory getFactory() { - return factory; + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); } + + private PlayState controller(AnimationState event) { + if (!touchingWater) { + event.getController().setAnimation(flopAnimation); + } else { + event.getController().setAnimation(idleAnimation); + } + return PlayState.CONTINUE; + } + } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/CatfishEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/CatfishEntity.java index 8f07b21..f6021a2 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/CatfishEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/CatfishEntity.java @@ -10,17 +10,20 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class CatfishEntity extends FishEntity implements IAnimatable { +public class CatfishEntity extends FishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.catfish.flop"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.catfish.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public CatfishEntity(EntityType entityType, World world) { super(entityType, world); @@ -52,22 +55,28 @@ public ItemStack getBucketItem() { return new ItemStack(AnglingItems.CATFISH_BUCKET); } + + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; + } + + @Override + public double getTick(Object o) { + return 0; + } + @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); } - private PlayState controller(AnimationEvent event) { + private PlayState controller(AnimationState event) { if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.catfish.flop", true)); + event.getController().setAnimation(flopAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.catfish.idle", true)); + event.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } - - @Override - public AnimationFactory getFactory() { - return factory; - } } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/CrabEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/CrabEntity.java index d205293..df1e177 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/CrabEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/CrabEntity.java @@ -6,8 +6,18 @@ import com.eightsidedsquare.angling.core.AnglingItems; import com.eightsidedsquare.angling.core.AnglingSounds; import com.eightsidedsquare.angling.core.tags.AnglingBlockTags; -import net.minecraft.entity.*; -import net.minecraft.entity.ai.goal.*; +import net.minecraft.entity.Bucketable; +import net.minecraft.entity.EntityData; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.MovementType; +import net.minecraft.entity.SpawnReason; +import net.minecraft.entity.ai.goal.AnimalMateGoal; +import net.minecraft.entity.ai.goal.EscapeDangerGoal; +import net.minecraft.entity.ai.goal.FollowParentGoal; +import net.minecraft.entity.ai.goal.LookAroundGoal; +import net.minecraft.entity.ai.goal.LookAtEntityGoal; +import net.minecraft.entity.ai.goal.TemptGoal; +import net.minecraft.entity.ai.goal.WanderAroundFarGoal; import net.minecraft.entity.ai.pathing.PathNodeType; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.attribute.EntityAttributes; @@ -23,6 +33,7 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.recipe.Ingredient; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; @@ -31,24 +42,27 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.random.Random; -import net.minecraft.util.registry.RegistryEntry; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; - -public class CrabEntity extends AnimalEntity implements IAnimatable, Bucketable { - - AnimationFactory factory = new AnimationFactory(this); +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; + +public class CrabEntity extends AnimalEntity implements GeoAnimatable, Bucketable { + + private final RawAnimation rotatedCrabAnimation = RawAnimation.begin().thenLoop("animation.crab.rotated"); + private final RawAnimation crabForwardsAnimation = RawAnimation.begin().thenLoop("animation.crab.forwards"); + private final RawAnimation crabMovingAnimation = RawAnimation.begin().thenLoop("animation.crab.moving"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); private static final TrackedData VARIANT = DataTracker.registerData(CrabEntity.class, CrabVariant.TRACKED_DATA_HANDLER); private static final TrackedData FROM_BUCKET = DataTracker.registerData(CrabEntity.class, TrackedDataHandlerRegistry.BOOLEAN); @@ -151,26 +165,37 @@ public void readCustomDataFromNbt(NbtCompound nbt) { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "rotation_controller", 6, this::rotationController)); - animationData.addAnimationController(new AnimationController<>(this, "controller", 4, this::controller)); + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "rotation_controller", 6, this::rotationController)); + controllerRegistrar.add(new AnimationController<>(this, "controller", 4, this::controller)); + } + + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; + } + + @Override + public double getTick(Object o) { + return 0; } - private PlayState rotationController(AnimationEvent event) { - if(event.isMoving()) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.crab.rotated", true)); + private PlayState rotationController(AnimationState state) { + if(state.isMoving()) { + state.getController().setAnimation(rotatedCrabAnimation); return PlayState.CONTINUE; } - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.crab.forwards", true)); + state.getController().setAnimation(crabForwardsAnimation); + return PlayState.CONTINUE; } - private PlayState controller(AnimationEvent event) { - if(event.isMoving()) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.crab.moving", true)); + private PlayState controller(AnimationState state) { + if(state.isMoving()) { + state.getController().setAnimation(crabMovingAnimation); return PlayState.CONTINUE; } - event.getController().clearAnimationCache(); + state.getController().forceAnimationReset(); return PlayState.STOP; } @@ -183,11 +208,6 @@ public ActionResult interactMob(PlayerEntity player, Hand hand) { return Bucketable.tryBucket(player, hand, this).orElse(super.interactMob(player, hand)); } - @Override - public AnimationFactory getFactory() { - return factory; - } - public static DefaultAttributeContainer.Builder createAttributes() { return MobEntity.createMobAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 10).add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2d); } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/DongfishEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/DongfishEntity.java index e0aecf9..7351c99 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/DongfishEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/DongfishEntity.java @@ -4,6 +4,7 @@ import com.eightsidedsquare.angling.core.AnglingSounds; import net.minecraft.entity.EntityType; import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageSources; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; @@ -17,17 +18,20 @@ import net.minecraft.util.Hand; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; - -public class DongfishEntity extends FishEntity implements IAnimatable { - - AnimationFactory factory = new AnimationFactory(this); +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; + +public class DongfishEntity extends FishEntity implements GeoAnimatable { + + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.dongfish.flop"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.dongfish.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); private static final TrackedData HAS_HORNGUS = DataTracker.registerData(DongfishEntity.class, TrackedDataHandlerRegistry.BOOLEAN); public DongfishEntity(EntityType entityType, World world) { @@ -40,7 +44,7 @@ protected ActionResult interactMob(PlayerEntity player, Hand hand) { if(hasHorngus() && stack.isOf(Items.SHEARS)) { playSound(AnglingSounds.ENTITY_DONGFISH_SHEAR, 1, 1); setHasHorngus(false); - damage(DamageSource.player(player), 1); + damage(player.world.getDamageSources().playerAttack(player), 1); if(!player.getAbilities().creativeMode) stack.damage(1, player, p -> p.sendToolBreakStatus(hand)); return ActionResult.success(world.isClient); @@ -97,24 +101,29 @@ public ItemStack getBucketItem() { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); + } + + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } - private PlayState controller(AnimationEvent event) { + @Override + public double getTick(Object o) { + return 0; + } + + private PlayState controller(AnimationState state) { if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.dongfish.flop", true)); + state.getController().setAnimation(flopAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.dongfish.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } - @Override - public AnimationFactory getFactory() { - return factory; - } - @Override public void copyDataToStack(ItemStack stack) { super.copyDataToStack(stack); diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/FryEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/FryEntity.java index cd81d9d..2992bc2 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/FryEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/FryEntity.java @@ -25,19 +25,22 @@ import net.minecraft.util.Hand; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Optional; -public class FryEntity extends FishEntity implements IAnimatable { +public class FryEntity extends FishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.fry.idle"); + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.fry.flop"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); private static final TrackedData COLOR; private static final TrackedData AGE; private static final TrackedData VARIANT; @@ -218,25 +221,29 @@ public ItemStack getBucketItem() { } @Override - public void registerControllers(AnimationData animationData) { - AnimationController controller = new AnimationController<>(this, "controller", 2, this::controller); - animationData.addAnimationController(controller); + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } - private PlayState controller(AnimationEvent event) { + @Override + public double getTick(Object o) { + return 0; + } + + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); + } + + private PlayState controller(AnimationState state) { if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.fry.flop", true)); + state.getController().setAnimation(flopAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.fry.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } - @Override - public AnimationFactory getFactory() { - return factory; - } - static { COLOR = DataTracker.registerData(FryEntity.class, TrackedDataHandlerRegistry.INTEGER); AGE = DataTracker.registerData(FryEntity.class, TrackedDataHandlerRegistry.INTEGER); diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/MahiMahiEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/MahiMahiEntity.java index a545428..ae323dc 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/MahiMahiEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/MahiMahiEntity.java @@ -12,22 +12,29 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class MahiMahiEntity extends FishEntity implements IAnimatable { +public class MahiMahiEntity extends FishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.mahi_mahi.flop"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.mahi_mahi.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public MahiMahiEntity(EntityType entityType, World world) { super(entityType, world); } + public static DefaultAttributeContainer.Builder createAttributes() { + return MobEntity.createMobAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 10); + } + @Override protected SoundEvent getFlopSound() { return AnglingSounds.ENTITY_MAHI_MAHI_FLOP; @@ -50,26 +57,27 @@ public ItemStack getBucketItem() { return new ItemStack(AnglingItems.MAHI_MAHI_BUCKET); } - public static DefaultAttributeContainer.Builder createAttributes() { - return MobEntity.createMobAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 10); + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public double getTick(Object o) { + return 0; } - private PlayState controller(AnimationEvent event) { - if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mahi_mahi.flop", true)); - }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mahi_mahi.idle", true)); - } - return PlayState.CONTINUE; + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); } - @Override - public AnimationFactory getFactory() { - return factory; + private PlayState controller(AnimationState state) { + if (!touchingWater) { + state.getController().setAnimation(flopAnimation); + } else { + state.getController().setAnimation(idleAnimation); + } + return PlayState.CONTINUE; } } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/NautilusEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/NautilusEntity.java index 63cc752..1c0753a 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/NautilusEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/NautilusEntity.java @@ -10,25 +10,28 @@ import net.minecraft.entity.passive.FishEntity; import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; -import net.minecraft.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class NautilusEntity extends FishEntity implements IAnimatable { +public class NautilusEntity extends FishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.nautilus.idle"); + private final RawAnimation movingAnimation = RawAnimation.begin().thenLoop("animation.nautilus.moving"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public NautilusEntity(EntityType entityType, World world) { super(entityType, world); @@ -57,8 +60,18 @@ public ItemStack getBucketItem() { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; + } + + @Override + public double getTick(Object o) { + return 0; + } + + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); } @Override @@ -71,20 +84,15 @@ public void tickMovement() { super.tickMovement(); } - private PlayState controller(AnimationEvent event) { - if(event.isMoving() && isTouchingWater()) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.nautilus.moving", true)); + private PlayState controller(AnimationState state) { + if(state.isMoving() && isTouchingWater()) { + state.getController().setAnimation(movingAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.nautilus.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } - @Override - public AnimationFactory getFactory() { - return factory; - } - @SuppressWarnings("deprecation") public static boolean canSpawn(EntityType type, WorldAccess world, SpawnReason reason, BlockPos pos, Random random) { int seaLevel = world.getSeaLevel(); diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/PelicanEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/PelicanEntity.java index 2006994..f61f850 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/PelicanEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/PelicanEntity.java @@ -11,7 +11,14 @@ import com.google.common.collect.ImmutableList; import com.mojang.serialization.Dynamic; import net.minecraft.block.BlockState; -import net.minecraft.entity.*; +import net.minecraft.entity.Bucketable; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityData; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityPose; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.MovementType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.brain.Activity; import net.minecraft.entity.ai.brain.Brain; import net.minecraft.entity.ai.brain.MemoryModuleState; @@ -36,33 +43,41 @@ import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; +import net.minecraft.registry.Registries; +import net.minecraft.registry.tag.TagKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundEvent; -import net.minecraft.tag.TagKey; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.Unit; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.registry.Registry; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Optional; -public class PelicanEntity extends AnimalEntity implements IAnimatable { +public class PelicanEntity extends AnimalEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation divingAnimation = RawAnimation.begin().thenLoop("animation.pelican.diving"); + private final RawAnimation swimmingAnimation = RawAnimation.begin().thenLoop("animation.pelican.swimming"); + private final RawAnimation flyingAnimation = RawAnimation.begin().thenLoop("animation.pelican.flying"); + private final RawAnimation flappingAnimation = RawAnimation.begin().thenLoop("animation.pelican.flapping"); + private final RawAnimation walkingAnimation = RawAnimation.begin().thenLoop("animation.pelican.walking"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.pelican.idle"); + private final RawAnimation beakOpened = RawAnimation.begin().thenLoop("animation.pelican.beak_opened"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); protected static final ImmutableList>> SENSORS; protected static final ImmutableList> MEMORY_MODULES; @@ -82,7 +97,7 @@ public ActionResult interactMob(PlayerEntity player, Hand hand) { if(isBeakOpen() && stack.getItem() instanceof EntityBucketItem bucketItem) { bucketItem.playEmptyingSound(player, getWorld(), getBlockPos()); NbtCompound nbt = stack.getOrCreateNbt().copy(); - nbt.putString("id", Registry.ENTITY_TYPE.getId(bucketItem.entityType).toString()); + nbt.putString("id", Registries.ENTITY_TYPE.getId(bucketItem.entityType).toString()); if(nbt.contains("BucketVariantTag")) { nbt.put("Variant", nbt.get("BucketVariantTag")); nbt.remove("BucketVariantTag"); @@ -215,7 +230,7 @@ private NbtCompound initializeEntityInBeak() { TagKey> tag = random.nextInt(5) == 0 ? AnglingEntityTypeTags.UNCOMMON_ENTITIES_IN_PELICAN_BEAK : AnglingEntityTypeTags.COMMON_ENTITIES_IN_PELICAN_BEAK; EntityType type = AnglingUtil.getRandomTagValue(world, tag, random); - nbt.putString("id", Registry.ENTITY_TYPE.getId(type).toString()); + nbt.putString("id", Registries.ENTITY_TYPE.getId(type).toString()); nbt.putBoolean("FromBucket", true); if(type.isIn(AnglingEntityTypeTags.HUNTED_BY_PELICAN_WHEN_BABY)) { nbt.putInt("Age", -24000); @@ -223,11 +238,6 @@ private NbtCompound initializeEntityInBeak() { return PelicanBeakEntityInitializer.getInitializer(type).initialize(nbt, random, world); } - @Override - protected boolean hasWings() { - return !onGround; - } - @Override public boolean damage(DamageSource source, float amount) { boolean bl = super.damage(source, amount); @@ -305,7 +315,7 @@ public void travel(Vec3d movementInput) { } } - this.updateLimbs(this, false); + this.updateLimbs(false); } @Nullable @@ -314,51 +324,57 @@ public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { return null; } + + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; + } + @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 4, this::controller)); - animationData.addAnimationController(new AnimationController<>(this, "beak_controller", 2, this::beakController)); + public double getTick(Object o) { + return 0; + } + + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); + controllerRegistrar.add(new AnimationController<>(this, "beak_controller", 2, this::beakController)); } public boolean isFlying() { return getTimeOffGround() > 5; } - private PlayState controller(AnimationEvent event) { - PelicanEntity entity = event.getAnimatable(); + private PlayState controller(AnimationState state) { + PelicanEntity entity = state.getAnimatable(); if(entity.isDiving() && entity.isFlying()){ - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.pelican.diving", true)); + state.getController().setAnimation(divingAnimation); }else if(entity.isTouchingWater()) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.pelican.swimming", true)); + state.getController().setAnimation(swimmingAnimation); }else if(entity.isFlying()) { if (Math.abs(entity.getVelocity().y) > 0.05d) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.pelican.flying", true)); + state.getController().setAnimation(flyingAnimation); } else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.pelican.flapping", true)); + state.getController().setAnimation(flappingAnimation); } - }else if(event.isMoving()) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.pelican.walking", true)); + }else if(state.isMoving()) { + state.getController().setAnimation(walkingAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.pelican.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } - private PlayState beakController(AnimationEvent event) { - PelicanEntity entity = event.getAnimatable(); + private PlayState beakController(AnimationState state) { + PelicanEntity entity = state.getAnimatable(); if(entity.isBeakOpen()) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.pelican.beak_opened", true)); + state.getController().setAnimation(beakOpened); return PlayState.CONTINUE; } - event.getController().clearAnimationCache(); + state.getController().forceAnimationReset(); return PlayState.STOP; } - @Override - public AnimationFactory getFactory() { - return factory; - } - @Override protected Brain.Profile createBrainProfile() { return Brain.createProfile(MEMORY_MODULES, SENSORS); diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/RoeBlockEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/RoeBlockEntity.java index 41aa82a..7652651 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/RoeBlockEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/RoeBlockEntity.java @@ -16,11 +16,11 @@ import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.Registries; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; -import net.minecraft.util.registry.Registry; import net.minecraft.world.BlockRenderView; import org.jetbrains.annotations.Nullable; @@ -53,7 +53,7 @@ public void setColors(int primaryColor, int secondaryColor) { } public void setEntityType(EntityType entityType) { - this.entityType = Registry.ENTITY_TYPE.getId(entityType).toString(); + this.entityType = Registries.ENTITY_TYPE.getId(entityType).toString(); } public Optional> getEntityType() { diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEggsBlockEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEggsBlockEntity.java index 0030e0d..845b926 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEggsBlockEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEggsBlockEntity.java @@ -17,9 +17,9 @@ import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.tag.TagKey; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; -import net.minecraft.tag.TagKey; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; import net.minecraft.world.BlockRenderView; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEntity.java index 5b878cd..e01349e 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/SeaSlugEntity.java @@ -7,7 +7,11 @@ import com.eightsidedsquare.angling.core.AnglingItems; import com.eightsidedsquare.angling.core.AnglingSounds; import com.eightsidedsquare.angling.core.AnglingUtil; -import net.minecraft.entity.*; +import net.minecraft.entity.Bucketable; +import net.minecraft.entity.EntityData; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.MovementType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.goal.EscapeDangerGoal; import net.minecraft.entity.ai.goal.LookAroundGoal; import net.minecraft.entity.ai.goal.LookAtEntityGoal; @@ -35,15 +39,16 @@ import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class SeaSlugEntity extends WaterCreatureEntity implements IAnimatable, Bucketable { +public class SeaSlugEntity extends WaterCreatureEntity implements Bucketable, GeoAnimatable { private static final TrackedData PATTERN = DataTracker.registerData(SeaSlugEntity.class, SeaSlugPattern.TRACKED_DATA_HANDLER); private static final TrackedData BASE_COLOR = DataTracker.registerData(SeaSlugEntity.class, SeaSlugColor.TRACKED_DATA_HANDLER); @@ -54,8 +59,10 @@ public class SeaSlugEntity extends WaterCreatureEntity implements IAnimatable, B private static final TrackedData MATE_DATA = DataTracker.registerData(SeaSlugEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND); private static final TrackedData LOVE_TICKS = DataTracker.registerData(SeaSlugEntity.class, TrackedDataHandlerRegistry.INTEGER); private static final TrackedData LOVE_COOLDOWN = DataTracker.registerData(SeaSlugEntity.class, TrackedDataHandlerRegistry.INTEGER); + private final RawAnimation ambientAnimation = RawAnimation.begin().thenLoop("animation.sea_slug.ambient"); + private final RawAnimation movingAnimation = RawAnimation.begin().thenLoop("animation.sea_slug.moving"); - AnimationFactory factory = new AnimationFactory(this); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public SeaSlugEntity(EntityType entityType, World world) { super(entityType, world); @@ -244,22 +251,32 @@ public void readCustomDataFromNbt(NbtCompound nbt) { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "ambient_controller", 0, this::ambientController)); - animationData.addAnimationController(new AnimationController<>(this, "controller", 0, this::controller)); + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } - private PlayState ambientController(AnimationEvent event) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.sea_slug.ambient", true)); + @Override + public double getTick(Object o) { + return 0; + } + + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "ambient_controller", 0, this::ambientController)); + controllerRegistrar.add(new AnimationController<>(this, "controller", 0, this::controller)); + } + + private PlayState ambientController(AnimationState event) { + event.getController().setAnimation(ambientAnimation); return PlayState.CONTINUE; } - private PlayState controller(AnimationEvent event) { + private PlayState controller(AnimationState event) { if(new Vec3d(getVelocity().getX(), 0, getVelocity().getZ()).length() > 0.005d) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.sea_slug.moving", true)); + event.getController().setAnimation(movingAnimation); return PlayState.CONTINUE; } - event.getController().clearAnimationCache(); + event.getController().forceAnimationReset(); return PlayState.STOP; } @@ -292,11 +309,6 @@ protected void mobTick() { super.mobTick(); } - @Override - public AnimationFactory getFactory() { - return factory; - } - @Override public boolean isFromBucket() { return dataTracker.get(FROM_BUCKET); diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/SeahorseEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/SeahorseEntity.java index 5601db1..df702bc 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/SeahorseEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/SeahorseEntity.java @@ -14,17 +14,20 @@ import net.minecraft.world.World; import net.minecraft.world.WorldView; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class SeahorseEntity extends FishEntity implements IAnimatable { +public class SeahorseEntity extends FishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.seahorse.flop"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.seahorse.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public SeahorseEntity(EntityType entityType, World world) { super(entityType, world); @@ -59,24 +62,29 @@ public ItemStack getBucketItem() { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public double getTick(Object o) { + return 0; } - private PlayState controller(AnimationEvent event) { + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); + } + + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; + } + + private PlayState controller(AnimationState state) { if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.seahorse.flop", true)); + state.getController().setAnimation(flopAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.seahorse.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } - @Override - public AnimationFactory getFactory() { - return factory; - } - static class MoveToKelpGoal extends MoveToTargetPosGoal { public MoveToKelpGoal(SeahorseEntity mob) { diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/StarfishBlockEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/StarfishBlockEntity.java index f88c537..afcfffc 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/StarfishBlockEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/StarfishBlockEntity.java @@ -14,19 +14,22 @@ import net.minecraft.util.math.Vec3i; import net.minecraft.world.BlockRenderView; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; import java.awt.*; -public class StarfishBlockEntity extends BlockEntity implements IAnimatable { +public class StarfishBlockEntity extends BlockEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation deadAnimation = RawAnimation.begin().thenLoop("animation.starfish.dead"); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.starfish.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); private double randomRotation; private int color; private boolean rainbow; @@ -43,15 +46,25 @@ public StarfishBlockEntity(BlockPos pos, BlockState state) { } @Override - public void registerControllers(AnimationData data) { - data.addAnimationController(new AnimationController<>(this, "controller", 0, this::controller)); + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 0, this::controller)); } - private PlayState controller(AnimationEvent event) { + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; + } + + @Override + public double getTick(Object o) { + return 0; + } + + private PlayState controller(AnimationState state) { if(((StarfishBlock) getCachedState().getBlock()).isDead()) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.starfish.dead", true)); + state.getController().setAnimation(deadAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.starfish.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } @@ -143,9 +156,4 @@ public Vec3i getRotation() { case DOWN -> new Vec3i(180, 180, 0); }; } - - @Override - public AnimationFactory getFactory() { - return factory; - } } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/SunfishEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/SunfishEntity.java index ccccf8e..90b1155 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/SunfishEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/SunfishEntity.java @@ -19,19 +19,22 @@ import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Objects; -public class SunfishEntity extends SchoolingFishEntity implements IAnimatable { +public class SunfishEntity extends SchoolingFishEntity implements GeoAnimatable { - AnimationFactory factory = new AnimationFactory(this); + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.sunfish.idle"); + private final RawAnimation flopAnimation = RawAnimation.begin().thenLoop("animation.sunfish.flop"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); private static final TrackedData VARIANT; @@ -117,21 +120,27 @@ public void readCustomDataFromNbt(NbtCompound nbt) { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 2, this::controller)); + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } - private PlayState controller(AnimationEvent event) { + @Override + public double getTick(Object o) { + return 0; + } + + @Override + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); + } + + private PlayState controller(AnimationState state) { if(!touchingWater) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.sunfish.flop", true)); + state.getController().setAnimation(flopAnimation); }else { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.sunfish.idle", true)); + state.getController().setAnimation(idleAnimation); } return PlayState.CONTINUE; } - @Override - public AnimationFactory getFactory() { - return factory; - } } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinBlockEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinBlockEntity.java index 4839099..3765ea7 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinBlockEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinBlockEntity.java @@ -7,23 +7,26 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; -import net.minecraft.network.Packet; import net.minecraft.network.listener.ClientPlayPacketListener; +import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animatable.instance.InstancedAnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.Animation; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; -public class UrchinBlockEntity extends BlockEntity implements IAnimatable { +public class UrchinBlockEntity extends BlockEntity implements GeoAnimatable { private ItemStack hat = ItemStack.EMPTY; - AnimationFactory factory = new AnimationFactory(this); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public UrchinBlockEntity(BlockPos pos, BlockState state) { super(AnglingEntities.URCHIN, pos, state); @@ -64,18 +67,24 @@ public NbtCompound toInitialChunkDataNbt() { return createNbt(); } + + private PlayState controller(AnimationState state) { + state.getController().setAnimation(RawAnimation.begin().then("animation.urchin.idle", Animation.LoopType.LOOP)); + return PlayState.CONTINUE; + } + @Override - public void registerControllers(AnimationData data) { - data.addAnimationController(new AnimationController<>(this, "controller", 0, this::controller)); + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 0, this::controller)); } - private PlayState controller(AnimationEvent event) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.urchin.idle", true)); - return PlayState.CONTINUE; + @Override + public AnimatableInstanceCache getAnimatableInstanceCache() { + return null; } @Override - public AnimationFactory getFactory() { - return factory; + public double getTick(Object o) { + return 0; } } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinEntity.java b/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinEntity.java index 521e56b..b4545c8 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinEntity.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/UrchinEntity.java @@ -25,17 +25,19 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import software.bernie.geckolib3.core.IAnimatable; -import software.bernie.geckolib3.core.PlayState; -import software.bernie.geckolib3.core.builder.AnimationBuilder; -import software.bernie.geckolib3.core.controller.AnimationController; -import software.bernie.geckolib3.core.event.predicate.AnimationEvent; -import software.bernie.geckolib3.core.manager.AnimationData; -import software.bernie.geckolib3.core.manager.AnimationFactory; - -public class UrchinEntity extends WaterCreatureEntity implements IAnimatable, Bucketable { - - AnimationFactory factory = new AnimationFactory(this); +import software.bernie.geckolib.core.animatable.GeoAnimatable; +import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.core.animation.AnimationController; +import software.bernie.geckolib.core.animation.AnimationState; +import software.bernie.geckolib.core.animation.RawAnimation; +import software.bernie.geckolib.core.object.PlayState; +import software.bernie.geckolib.util.GeckoLibUtil; + +public class UrchinEntity extends WaterCreatureEntity implements GeoAnimatable, Bucketable { + + private final RawAnimation idleAnimation = RawAnimation.begin().thenLoop("animation.urchin.idle"); + AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); private static final TrackedData FROM_BUCKET = DataTracker.registerData(UrchinEntity.class, TrackedDataHandlerRegistry.BOOLEAN); public UrchinEntity(EntityType entityType, World world) { @@ -92,20 +94,24 @@ protected SoundEvent getDeathSound() { } @Override - public void registerControllers(AnimationData animationData) { - animationData.addAnimationController(new AnimationController<>(this, "controller", 0, this::controller)); + public AnimatableInstanceCache getAnimatableInstanceCache() { + return animatableInstanceCache; } - private PlayState controller(AnimationEvent event) { - event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.urchin.idle", true)); - return PlayState.CONTINUE; + @Override + public double getTick(Object o) { + return 0; } @Override - public AnimationFactory getFactory() { - return factory; + public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) { + controllerRegistrar.add(new AnimationController<>(this, "controller", 2, this::controller)); } + private PlayState controller(AnimationState state) { + state.getController().setAnimation(idleAnimation); + return PlayState.CONTINUE; + } @Override public boolean isFromBucket() { return dataTracker.get(FROM_BUCKET); diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/EatAlgaeGoal.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/EatAlgaeGoal.java index cd23aa1..f9a256f 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/EatAlgaeGoal.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/EatAlgaeGoal.java @@ -5,7 +5,7 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.ai.goal.MoveToTargetPosGoal; import net.minecraft.entity.mob.PathAwareEntity; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldView; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/GoToWaterGoal.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/GoToWaterGoal.java index a25d973..c608bf0 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/GoToWaterGoal.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/GoToWaterGoal.java @@ -2,7 +2,7 @@ import net.minecraft.entity.ai.goal.MoveToTargetPosGoal; import net.minecraft.entity.mob.PathAwareEntity; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldView; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanAttackTask.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanAttackTask.java index 4fb50b9..aa81897 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanAttackTask.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanAttackTask.java @@ -6,10 +6,11 @@ import net.minecraft.entity.ai.brain.MemoryModuleState; import net.minecraft.entity.ai.brain.MemoryModuleType; import net.minecraft.entity.ai.brain.task.LookTargetUtil; +import net.minecraft.entity.ai.brain.task.MultiTickTask; import net.minecraft.entity.ai.brain.task.Task; import net.minecraft.server.world.ServerWorld; -public class PelicanAttackTask extends Task { +public class PelicanAttackTask extends MultiTickTask { private final long interval; private Phase phase; private int catchingTicks; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanBrain.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanBrain.java index 371c0f9..29b113e 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanBrain.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanBrain.java @@ -33,6 +33,7 @@ public static Brain create(Brain brain) { } private static void addCoreActivities(Brain brain) { + /* brain.setTaskList(Activity.CORE, 0, ImmutableList.of( new StayAboveWaterTask(0.8F), new WalkTask(2.5F), @@ -40,9 +41,11 @@ private static void addCoreActivities(Brain brain) { new WanderAroundTask(), new UpdateAttackTargetTask<>(entity -> entity.getBrain().getOptionalMemory(MemoryModuleType.NEAREST_ATTACKABLE)) )); + */ } private static void addIdleActivities(Brain brain) { + /* brain.setTaskList(Activity.IDLE, ImmutableList.of( Pair.of(0, new UpdateAttackTargetTask<>(entity -> entity.getBrain().getOptionalMemory(MemoryModuleType.NEAREST_ATTACKABLE))), Pair.of(1, new PelicanTradeTask()), @@ -53,17 +56,23 @@ private static void addIdleActivities(Brain brain) { Pair.of(new ConditionalTask<>(Entity::isOnGround, new WaitTask(5, 20)), 2), Pair.of(new ConditionalTask<>(PelicanEntity::isFlying, new NoPenaltyStrollTask(1f)), 2)))) )); + + */ } private static void addFightActivities(Brain brain) { + /* brain.setTaskList(Activity.FIGHT,0, ImmutableList.of( new ForgetAttackTargetTask<>(), new RangedApproachTask(entity -> 1f), new PelicanAttackTask(5) ), MemoryModuleType.ATTACK_TARGET); + + */ } private static void addSoarActivities(Brain brain) { + /* brain.setTaskList(Activity.RIDE, ImmutableList.of( Pair.of(0, new UpdateAttackTargetTask<>(entity -> entity.getBrain().getOptionalMemory(MemoryModuleType.NEAREST_ATTACKABLE))), Pair.of(1, new PelicanEatTask()), @@ -72,6 +81,8 @@ private static void addSoarActivities(Brain brain) { Pair.of(AnglingMemoryModuleTypes.SOARING_COOLDOWN, MemoryModuleState.VALUE_ABSENT), Pair.of(AnglingMemoryModuleTypes.CAN_TRADE, MemoryModuleState.VALUE_ABSENT)) ); + + */ } public static void updateActivities(PelicanEntity entity) { diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanEatTask.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanEatTask.java index ed18ae1..a66d7ee 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanEatTask.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanEatTask.java @@ -4,11 +4,11 @@ import com.eightsidedsquare.angling.core.ai.AnglingMemoryModuleTypes; import com.google.common.collect.ImmutableMap; import net.minecraft.entity.ai.brain.MemoryModuleState; -import net.minecraft.entity.ai.brain.task.Task; +import net.minecraft.entity.ai.brain.task.MultiTickTask; import net.minecraft.nbt.NbtCompound; import net.minecraft.server.world.ServerWorld; -public class PelicanEatTask extends Task { +public class PelicanEatTask extends MultiTickTask { public PelicanEatTask() { super(ImmutableMap.of(AnglingMemoryModuleTypes.HAS_TRADED, MemoryModuleState.VALUE_PRESENT)); } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanSoarTask.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanSoarTask.java index 8c33a59..3b6aab7 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanSoarTask.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanSoarTask.java @@ -6,14 +6,14 @@ import net.minecraft.entity.ai.brain.MemoryModuleState; import net.minecraft.entity.ai.brain.MemoryModuleType; import net.minecraft.entity.ai.brain.WalkTarget; -import net.minecraft.entity.ai.brain.task.Task; +import net.minecraft.entity.ai.brain.task.MultiTickTask; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.server.world.ServerWorld; -import net.minecraft.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.Heightmap; -public class PelicanSoarTask extends Task { +public class PelicanSoarTask extends MultiTickTask { public PelicanSoarTask() { super(ImmutableMap.of( AnglingMemoryModuleTypes.SOARING_COOLDOWN, MemoryModuleState.VALUE_ABSENT, @@ -30,9 +30,9 @@ protected boolean shouldRun(ServerWorld world, PelicanEntity entity) { protected void run(ServerWorld world, PelicanEntity entity, long time) { Vec3d pos = entity.raycast(16, 0, false).getPos(); int topY = world.getTopY(Heightmap.Type.WORLD_SURFACE, (int) pos.x, (int) pos.z); - boolean isWater = world.getFluidState(new BlockPos(pos.x, topY - 1, pos.z)).isIn(FluidTags.WATER); + boolean isWater = world.getFluidState(new BlockPos((int) pos.x, topY - 1, (int) pos.z)).isIn(FluidTags.WATER); int y = topY + (isWater ? entity.getRandom().nextBetween(3, 8) : entity.getRandom().nextBetween(5, 25)); - BlockPos blockPos = new BlockPos(pos.x, y, pos.z); + BlockPos blockPos = new BlockPos((int) pos.x, y, (int) pos.z); if(world.getBlockState(blockPos).isAir()) { entity.getBrain().remember(MemoryModuleType.WALK_TARGET, new WalkTarget(blockPos, 1.5f, 1)); } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanTradeTask.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanTradeTask.java index a31c771..377da1c 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanTradeTask.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/PelicanTradeTask.java @@ -6,12 +6,12 @@ import net.minecraft.entity.ai.brain.MemoryModuleState; import net.minecraft.entity.ai.brain.MemoryModuleType; import net.minecraft.entity.ai.brain.task.LookTargetUtil; -import net.minecraft.entity.ai.brain.task.Task; +import net.minecraft.entity.ai.brain.task.MultiTickTask; import net.minecraft.server.world.ServerWorld; import java.util.stream.Stream; -public class PelicanTradeTask extends Task { +public class PelicanTradeTask extends MultiTickTask { public PelicanTradeTask() { super(ImmutableMap.of( MemoryModuleType.WALK_TARGET, MemoryModuleState.VALUE_ABSENT, diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/SeaSlugLayEggsGoal.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/SeaSlugLayEggsGoal.java index 603ae7a..d945122 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/SeaSlugLayEggsGoal.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/SeaSlugLayEggsGoal.java @@ -10,8 +10,8 @@ import net.minecraft.entity.mob.PathAwareEntity; import net.minecraft.fluid.Fluids; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/WanderAroundWaterGoal.java b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/WanderAroundWaterGoal.java index 7c17211..5625f32 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/ai/WanderAroundWaterGoal.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/ai/WanderAroundWaterGoal.java @@ -2,7 +2,7 @@ import net.minecraft.entity.ai.goal.WanderAroundGoal; import net.minecraft.entity.mob.PathAwareEntity; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import org.jetbrains.annotations.Nullable; @@ -25,7 +25,7 @@ public boolean canStart() { @Override protected Vec3d getWanderTarget() { Vec3d target = super.getWanderTarget(); - if(target != null && entity.world.getFluidState(new BlockPos(target.x, target.y, target.z)).isIn(FluidTags.WATER)) + if(target != null && entity.world.getFluidState(BlockPos.ofFloored(target.x, target.y, target.z)).isIn(FluidTags.WATER)) return target; return null; } diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/util/CrabVariant.java b/src/main/java/com/eightsidedsquare/angling/common/entity/util/CrabVariant.java index 7966b01..20f1969 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/util/CrabVariant.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/util/CrabVariant.java @@ -5,9 +5,9 @@ import net.fabricmc.fabric.api.event.registry.RegistryAttribute; import net.minecraft.entity.data.TrackedDataHandler; import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.Registry; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; import java.util.LinkedHashMap; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/util/PelicanBeakEntityInitializer.java b/src/main/java/com/eightsidedsquare/angling/common/entity/util/PelicanBeakEntityInitializer.java index c0ad40e..1e0ce84 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/util/PelicanBeakEntityInitializer.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/util/PelicanBeakEntityInitializer.java @@ -9,10 +9,10 @@ import net.minecraft.entity.passive.TropicalFishEntity; import net.minecraft.item.SpawnEggItem; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; import net.minecraft.util.Util; import net.minecraft.util.math.random.Random; -import net.minecraft.util.registry.Registry; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; @@ -50,7 +50,7 @@ public NbtCompound initialize(NbtCompound nbt, Random random, World world) { public NbtCompound initialize(NbtCompound nbt, Random random, World world) { int variant = random.nextInt(5) == 0 ? (random.nextInt(2) | random.nextInt(6) << 8 | random.nextInt(15) << 16 | random.nextInt(15) << 24) - : Util.getRandom(TropicalFishEntity.COMMON_VARIANTS, random); + : TropicalFishEntity.COMMON_VARIANTS.indexOf(Util.getRandom(TropicalFishEntity.COMMON_VARIANTS.toArray(), random)); nbt.putInt("Variant", variant); return nbt; } @@ -65,7 +65,7 @@ public NbtCompound initialize(NbtCompound nbt, Random random, World world) { registerInitializer(EntityType.FROG, new PelicanBeakEntityInitializer() { @Override public NbtCompound initialize(NbtCompound nbt, Random random, World world) { - Identifier variant = Registry.FROG_VARIANT.getId(Util.getRandom(Registry.FROG_VARIANT.stream().toList(), random)); + Identifier variant = Registries.FROG_VARIANT.getId(Util.getRandom(Registries.FROG_VARIANT.stream().toList(), random)); if(variant != null) nbt.putString("variant", variant.toString()); return nbt; @@ -93,7 +93,7 @@ public NbtCompound initialize(NbtCompound nbt, Random random, World world) { @Override public NbtCompound initialize(NbtCompound nbt, Random random, World world) { EntityType growUpTo = AnglingUtil.getRandomTagValue(world, AnglingEntityTypeTags.SPAWNING_FISH, random); - nbt.putString("GrowUpTo", Registry.ENTITY_TYPE.getId(growUpTo).toString()); + nbt.putString("GrowUpTo", Registries.ENTITY_TYPE.getId(growUpTo).toString()); NbtCompound variant = new NbtCompound(); if(!growUpTo.equals(AnglingEntities.FRY)) getInitializer(growUpTo).initialize(variant, random, world); diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugColor.java b/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugColor.java index f589ce8..5559769 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugColor.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugColor.java @@ -4,9 +4,9 @@ import net.fabricmc.fabric.api.event.registry.RegistryAttribute; import net.minecraft.entity.data.TrackedDataHandler; import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.Registry; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import java.util.LinkedHashMap; import java.util.Map; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugPattern.java b/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugPattern.java index 59b120f..c391048 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugPattern.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/util/SeaSlugPattern.java @@ -4,9 +4,9 @@ import net.fabricmc.fabric.api.event.registry.RegistryAttribute; import net.minecraft.entity.data.TrackedDataHandler; import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.Registry; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.Nullable; import java.util.LinkedHashMap; diff --git a/src/main/java/com/eightsidedsquare/angling/common/entity/util/SunfishVariant.java b/src/main/java/com/eightsidedsquare/angling/common/entity/util/SunfishVariant.java index ec4db5e..cce22df 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/entity/util/SunfishVariant.java +++ b/src/main/java/com/eightsidedsquare/angling/common/entity/util/SunfishVariant.java @@ -4,9 +4,9 @@ import net.fabricmc.fabric.api.event.registry.RegistryAttribute; import net.minecraft.entity.data.TrackedDataHandler; import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.Registry; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import java.util.LinkedHashMap; import java.util.Map; diff --git a/src/main/java/com/eightsidedsquare/angling/common/feature/NoisePatchFeature.java b/src/main/java/com/eightsidedsquare/angling/common/feature/NoisePatchFeature.java index a733849..54a7bc1 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/feature/NoisePatchFeature.java +++ b/src/main/java/com/eightsidedsquare/angling/common/feature/NoisePatchFeature.java @@ -4,12 +4,14 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.intprovider.UniformIntProvider; import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; import net.minecraft.util.math.random.Random; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.util.FeatureContext; import net.minecraft.world.gen.stateprovider.BlockStateProvider; +import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; public class NoisePatchFeature extends Feature { @@ -17,6 +19,7 @@ public NoisePatchFeature(Codec configCodec) { super(configCodec); } + @Override @SuppressWarnings("deprecation") public boolean generate(FeatureContext ctx) { @@ -38,7 +41,7 @@ public boolean generate(FeatureContext ctx) { BlockPos blockPos = pos.add(x, 0, z); if(value > threshold) { - BlockState state = blockStateProvider.getBlockState(random, blockPos); + BlockState state = blockStateProvider.get(random, blockPos); if(state.canPlaceAt(world, blockPos)) world.setBlockState(blockPos, state, Block.NOTIFY_LISTENERS); } diff --git a/src/main/java/com/eightsidedsquare/angling/common/feature/WaterAdjacentPatchFeature.java b/src/main/java/com/eightsidedsquare/angling/common/feature/WaterAdjacentPatchFeature.java index e603574..cdbc0d5 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/feature/WaterAdjacentPatchFeature.java +++ b/src/main/java/com/eightsidedsquare/angling/common/feature/WaterAdjacentPatchFeature.java @@ -1,7 +1,7 @@ package com.eightsidedsquare.angling.common.feature; import com.mojang.serialization.Codec; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.StructureWorldAccess; diff --git a/src/main/java/com/eightsidedsquare/angling/common/feature/WaterloggablePatchFeature.java b/src/main/java/com/eightsidedsquare/angling/common/feature/WaterloggablePatchFeature.java index 11ceedc..6778110 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/feature/WaterloggablePatchFeature.java +++ b/src/main/java/com/eightsidedsquare/angling/common/feature/WaterloggablePatchFeature.java @@ -5,8 +5,8 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.fluid.Fluids; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; import net.minecraft.world.Heightmap; @@ -33,7 +33,7 @@ public boolean generate(FeatureContext ctx) { int dz = random.nextInt(range) - random.nextInt(range); int y = structureWorldAccess.getTopY(Heightmap.Type.OCEAN_FLOOR, blockPos.getX() + dx, blockPos.getZ() + dz); BlockPos blockPos2 = new BlockPos(blockPos.getX() + dx, y, blockPos.getZ() + dz); - BlockState state = ctx.getConfig().toPlace().getBlockState(random, blockPos2); + BlockState state = ctx.getConfig().toPlace().get(random, blockPos2); if (state.canPlaceAt(structureWorldAccess, blockPos2) && !structureWorldAccess.getBlockState(blockPos2.up()).isOf(Blocks.TALL_SEAGRASS) && !structureWorldAccess.getBlockState(blockPos2.down()).isIn(BlockTags.ICE)) { diff --git a/src/main/java/com/eightsidedsquare/angling/common/feature/WormyBlockFeature.java b/src/main/java/com/eightsidedsquare/angling/common/feature/WormyBlockFeature.java index 3bd4b57..86edf66 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/feature/WormyBlockFeature.java +++ b/src/main/java/com/eightsidedsquare/angling/common/feature/WormyBlockFeature.java @@ -6,7 +6,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.tag.BlockTags; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.random.Random; diff --git a/src/main/java/com/eightsidedsquare/angling/common/item/RoeBlockItem.java b/src/main/java/com/eightsidedsquare/angling/common/item/RoeBlockItem.java index 699bd97..1ad6c29 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/item/RoeBlockItem.java +++ b/src/main/java/com/eightsidedsquare/angling/common/item/RoeBlockItem.java @@ -11,11 +11,11 @@ import net.minecraft.item.SpawnEggItem; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; +import net.minecraft.registry.Registries; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.registry.Registry; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; @@ -33,15 +33,15 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List too super.appendTooltip(stack, world, tooltip, context); NbtCompound nbt = getBlockEntityNbt(stack); if(nbt != null && nbt.contains("EntityType", NbtElement.STRING_TYPE)) { - String key = Registry.ENTITY_TYPE.get(Identifier.tryParse(nbt.getString("EntityType"))).getTranslationKey(); + String key = Registries.ENTITY_TYPE.get(Identifier.tryParse(nbt.getString("EntityType"))).getTranslationKey(); tooltip.add(Text.translatable(key).formatted(Formatting.GRAY)); } } - @Override +/* public void appendStacks(ItemGroup group, DefaultedList stacks) { if(this.isIn(group)) { - Registry.ENTITY_TYPE.stream() + Registries.ENTITY_TYPE.stream() .filter(type -> type.isIn(AnglingEntityTypeTags.SPAWNING_FISH)) .map(SpawnEggItem::forEntity) .filter(Objects::nonNull) @@ -50,10 +50,11 @@ public void appendStacks(ItemGroup group, DefaultedList stacks) { NbtCompound nbt = new NbtCompound(); nbt.putInt("PrimaryColor", egg.getColor(0)); nbt.putInt("SecondaryColor", egg.getColor(0)); - nbt.putString("EntityType", Registry.ENTITY_TYPE.getId(egg.getEntityType(null)).toString()); + nbt.putString("EntityType", Registries.ENTITY_TYPE.getId(egg.getEntityType(null)).toString()); setBlockEntityNbt(stack, AnglingEntities.ROE, nbt); stacks.add(stack); }); } } + */ } diff --git a/src/main/java/com/eightsidedsquare/angling/common/item/UrchinBucketItem.java b/src/main/java/com/eightsidedsquare/angling/common/item/UrchinBucketItem.java index 5e6e0e5..76edee8 100644 --- a/src/main/java/com/eightsidedsquare/angling/common/item/UrchinBucketItem.java +++ b/src/main/java/com/eightsidedsquare/angling/common/item/UrchinBucketItem.java @@ -23,7 +23,7 @@ public UrchinBucketItem(Settings settings) { protected boolean postPlacement(BlockPos pos, World world, @Nullable PlayerEntity player, ItemStack stack, BlockState state) { if(player != null && !player.isCreative() && !player.giveItemStack(new ItemStack(Items.BUCKET))) player.dropItem(new ItemStack(Items.BUCKET), true); - world.createAndScheduleFluidTick(pos, world.getFluidState(pos).getFluid(), 1); + world.scheduleFluidTick(pos, world.getFluidState(pos).getFluid(), 1); if(world.getDimension().ultrawarm()) world.setBlockState(pos, state.with(Properties.WATERLOGGED, false)); return super.postPlacement(pos, world, player, stack, state); diff --git a/src/main/java/com/eightsidedsquare/angling/config/AnglingConfig.java b/src/main/java/com/eightsidedsquare/angling/config/AnglingConfig.java new file mode 100644 index 0000000..139bcc3 --- /dev/null +++ b/src/main/java/com/eightsidedsquare/angling/config/AnglingConfig.java @@ -0,0 +1,11 @@ +package com.eightsidedsquare.angling.config; + +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; + +@Config(name = "angling") +public class AnglingConfig implements ConfigData { + @ConfigEntry.Category("client") + public boolean hideWaterBehindGlass = true; +} diff --git a/src/main/java/com/eightsidedsquare/angling/config/ModMenuIntegration.java b/src/main/java/com/eightsidedsquare/angling/config/ModMenuIntegration.java new file mode 100644 index 0000000..7d14ba7 --- /dev/null +++ b/src/main/java/com/eightsidedsquare/angling/config/ModMenuIntegration.java @@ -0,0 +1,13 @@ +package com.eightsidedsquare.angling.config; + +import com.eightsidedsquare.angling.config.AnglingConfig; +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import me.shedaniel.autoconfig.AutoConfig; + +public class ModMenuIntegration implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> AutoConfig.getConfigScreen(AnglingConfig.class, parent).get(); + } +} diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingBlocks.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingBlocks.java index 768e402..17ed62b 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingBlocks.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingBlocks.java @@ -1,13 +1,31 @@ package com.eightsidedsquare.angling.core; -import com.eightsidedsquare.angling.common.block.*; -import net.minecraft.block.*; +import com.eightsidedsquare.angling.common.block.AlgaeBlock; +import com.eightsidedsquare.angling.common.block.AnemoneBlock; +import com.eightsidedsquare.angling.common.block.ClamBlock; +import com.eightsidedsquare.angling.common.block.OystersBlock; +import com.eightsidedsquare.angling.common.block.PapyrusBlock; +import com.eightsidedsquare.angling.common.block.RoeBlock; +import com.eightsidedsquare.angling.common.block.SeaSlugEggsBlock; +import com.eightsidedsquare.angling.common.block.StarfishBlock; +import com.eightsidedsquare.angling.common.block.UrchinBlock; +import com.eightsidedsquare.angling.common.block.WaterFloatingPlant; +import com.eightsidedsquare.angling.common.block.WormyDirtBlock; +import com.eightsidedsquare.angling.common.block.WormyMudBlock; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.block.MapColor; +import net.minecraft.block.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import java.util.LinkedHashMap; import java.util.Map; @@ -19,31 +37,34 @@ public class AnglingBlocks { private static final Map ITEMS = new LinkedHashMap<>(); public static final Block ROE = create("roe", new RoeBlock(AbstractBlock.Settings.of(Material.FROGSPAWN, MapColor.ORANGE).noCollision().nonOpaque().breakInstantly().sounds(BlockSoundGroup.FROGSPAWN)), null); - public static final Block SEA_SLUG_EGGS = create("sea_slug_eggs", new SeaSlugEggsBlock(AbstractBlock.Settings.copy(ROE).offsetType(AbstractBlock.OffsetType.XZ).dynamicBounds()), null); + public static final Block SEA_SLUG_EGGS = create("sea_slug_eggs", new SeaSlugEggsBlock(AbstractBlock.Settings.copy(ROE).offset(AbstractBlock.OffsetType.XZ).dynamicBounds()), null); public static final Block DUCKWEED = create("duckweed", new WaterFloatingPlant(AbstractBlock.Settings.of(Material.REPLACEABLE_PLANT, MapColor.LIME).breakInstantly().nonOpaque().noCollision().sounds(BlockSoundGroup.WET_GRASS)), null); - public static final Block ALGAE = create("algae", new AlgaeBlock(AbstractBlock.Settings.of(Material.REPLACEABLE_PLANT, MapColor.GREEN).sounds(BlockSoundGroup.FROGSPAWN).noCollision().nonOpaque().strength(0.1f).ticksRandomly()), ItemGroup.DECORATIONS); - public static final Block WORMY_DIRT = create("wormy_dirt", new WormyDirtBlock(AbstractBlock.Settings.copy(Blocks.DIRT)), ItemGroup.BUILDING_BLOCKS); - public static final Block WORMY_MUD = create("wormy_mud", new WormyMudBlock(AbstractBlock.Settings.copy(Blocks.MUD)), ItemGroup.BUILDING_BLOCKS); - public static final Block OYSTERS = create("oysters", new OystersBlock(AbstractBlock.Settings.of(Material.SOLID_ORGANIC, MapColor.OAK_TAN).strength(0.5f).nonOpaque().sounds(AnglingSounds.SHELL_SOUND_GROUP)), ItemGroup.DECORATIONS); - public static final Block STARFISH = create("starfish", new StarfishBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.WHITE).strength(0.1f).nonOpaque().noCollision().sounds(AnglingSounds.SHELL_SOUND_GROUP).ticksRandomly(), false), ItemGroup.DECORATIONS); - public static final Block DEAD_STARFISH = create("dead_starfish", new StarfishBlock(AbstractBlock.Settings.copy(STARFISH), true), ItemGroup.DECORATIONS); - public static final Block CLAM = create("clam", new ClamBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.WHITE).sounds(AnglingSounds.SHELL_SOUND_GROUP).offsetType(AbstractBlock.OffsetType.XZ).strength(0.05f).nonOpaque()), ItemGroup.DECORATIONS); - public static final Block ANEMONE = create("anemone", new AnemoneBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.WHITE).strength(0.1f).nonOpaque().noCollision().sounds(BlockSoundGroup.SLIME).ticksRandomly()), ItemGroup.DECORATIONS); + public static final Block ALGAE = create("algae", new AlgaeBlock(AbstractBlock.Settings.of(Material.REPLACEABLE_PLANT, MapColor.GREEN).sounds(BlockSoundGroup.FROGSPAWN).noCollision().nonOpaque().strength(0.1f).ticksRandomly()), ItemGroups.SPAWN_EGGS); + public static final Block WORMY_DIRT = create("wormy_dirt", new WormyDirtBlock(AbstractBlock.Settings.copy(Blocks.DIRT)), ItemGroups.BUILDING_BLOCKS); + public static final Block WORMY_MUD = create("wormy_mud", new WormyMudBlock(AbstractBlock.Settings.copy(Blocks.MUD)), ItemGroups.BUILDING_BLOCKS); + public static final Block OYSTERS = create("oysters", new OystersBlock(AbstractBlock.Settings.of(Material.SOLID_ORGANIC, MapColor.OAK_TAN).strength(0.5f).nonOpaque().sounds(AnglingSounds.SHELL_SOUND_GROUP)), ItemGroups.SPAWN_EGGS); + public static final Block STARFISH = create("starfish", new StarfishBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.WHITE).strength(0.1f).nonOpaque().noCollision().sounds(AnglingSounds.SHELL_SOUND_GROUP).ticksRandomly(), false), ItemGroups.SPAWN_EGGS); + public static final Block DEAD_STARFISH = create("dead_starfish", new StarfishBlock(AbstractBlock.Settings.copy(STARFISH), true), ItemGroups.SPAWN_EGGS); + public static final Block CLAM = create("clam", new ClamBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.WHITE).sounds(AnglingSounds.SHELL_SOUND_GROUP).offset(AbstractBlock.OffsetType.XZ).strength(0.05f).nonOpaque()), ItemGroups.SPAWN_EGGS); + public static final Block ANEMONE = create("anemone", new AnemoneBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.WHITE).strength(0.1f).nonOpaque().noCollision().sounds(BlockSoundGroup.SLIME).ticksRandomly()), ItemGroups.SPAWN_EGGS); public static final Block URCHIN = create("urchin", new UrchinBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.TERRACOTTA_BLUE).strength(0.1f).nonOpaque().noCollision().sounds(AnglingSounds.SHELL_SOUND_GROUP)), null); public static final Block SARGASSUM = create("sargassum", new WaterFloatingPlant(AbstractBlock.Settings.of(Material.REPLACEABLE_PLANT, MapColor.YELLOW).breakInstantly().nonOpaque().noCollision().sounds(BlockSoundGroup.WET_GRASS)), null); - public static final Block PAPYRUS = create("papyrus", new PapyrusBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.GREEN).strength(0).breakInstantly().nonOpaque().noCollision().sounds(BlockSoundGroup.AZALEA).ticksRandomly().offsetType(AbstractBlock.OffsetType.XZ).dynamicBounds()), ItemGroup.DECORATIONS); + public static final Block PAPYRUS = create("papyrus", new PapyrusBlock(AbstractBlock.Settings.of(Material.UNDERWATER_PLANT, MapColor.GREEN).strength(0).breakInstantly().nonOpaque().noCollision().sounds(BlockSoundGroup.AZALEA).ticksRandomly().offset(AbstractBlock.OffsetType.XZ).dynamicBounds()), ItemGroups.SPAWN_EGGS); private static T create(String name, T block, ItemGroup itemGroup) { - BLOCKS.put(block, new Identifier(MOD_ID, name)); if (itemGroup != null) { - ITEMS.put(new BlockItem(block, new Item.Settings().group(itemGroup)), BLOCKS.get(block)); + BlockItem blockItem = new BlockItem(block, new Item.Settings()); + ITEMS.put(blockItem, BLOCKS.get(block)); + ItemGroupEvents.modifyEntriesEvent(itemGroup).register(entries -> { + entries.add(blockItem); + }); } return block; } public static void init() { - BLOCKS.keySet().forEach(block -> Registry.register(Registry.BLOCK, BLOCKS.get(block), block)); - ITEMS.keySet().forEach(item -> Registry.register(Registry.ITEM, ITEMS.get(item), item)); + BLOCKS.keySet().forEach(block -> Registry.register(Registries.BLOCK, BLOCKS.get(block), block)); + ITEMS.keySet().forEach(item -> Registry.register(Registries.ITEM, ITEMS.get(item), item)); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingDataGenerator.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingDataGenerator.java new file mode 100644 index 0000000..8bcde2e --- /dev/null +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingDataGenerator.java @@ -0,0 +1,21 @@ +package com.eightsidedsquare.angling.core; + +import com.eightsidedsquare.angling.core.world.AnglingConfiguredFeatures; +import com.eightsidedsquare.angling.core.world.AnglingPlacedFeatures; +import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.minecraft.registry.RegistryBuilder; +import net.minecraft.registry.RegistryKeys; + +public class AnglingDataGenerator implements DataGeneratorEntrypoint { + @Override + public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { + + } + + @Override + public void buildRegistry(RegistryBuilder registryBuilder) { + registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, AnglingPlacedFeatures::bootstrap); + registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, AnglingConfiguredFeatures::bootstrap); + } +} diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingEntities.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingEntities.java index 66eab06..fcd682b 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingEntities.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingEntities.java @@ -13,8 +13,9 @@ import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.WaterCreatureEntity; import net.minecraft.entity.passive.FishEntity; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import net.minecraft.world.Heightmap; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; @@ -22,7 +23,7 @@ public class AnglingEntities { public static final BlockEntityType ROE = Registry.register( - Registry.BLOCK_ENTITY_TYPE, + Registries.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "roe"), FabricBlockEntityTypeBuilder .create(RoeBlockEntity::new) @@ -31,7 +32,7 @@ public class AnglingEntities { ); public static final BlockEntityType STARFISH = Registry.register( - Registry.BLOCK_ENTITY_TYPE, + Registries.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "starfish"), FabricBlockEntityTypeBuilder .create(StarfishBlockEntity::new) @@ -40,7 +41,7 @@ public class AnglingEntities { ); public static final BlockEntityType SEA_SLUG_EGGS = Registry.register( - Registry.BLOCK_ENTITY_TYPE, + Registries.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "sea_slug_eggs"), FabricBlockEntityTypeBuilder .create(SeaSlugEggsBlockEntity::new) @@ -49,7 +50,7 @@ public class AnglingEntities { ); public static final BlockEntityType ANEMONE = Registry.register( - Registry.BLOCK_ENTITY_TYPE, + Registries.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "anemone"), FabricBlockEntityTypeBuilder .create(AnemoneBlockEntity::new) @@ -58,7 +59,7 @@ public class AnglingEntities { ); public static final BlockEntityType URCHIN = Registry.register( - Registry.BLOCK_ENTITY_TYPE, + Registries.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "urchin"), FabricBlockEntityTypeBuilder .create(UrchinBlockEntity::new) @@ -67,7 +68,7 @@ public class AnglingEntities { ); public static final EntityType FRY = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "fry"), FabricEntityTypeBuilder.createMob() .entityFactory(FryEntity::new) @@ -79,7 +80,7 @@ public class AnglingEntities { ); public static final EntityType SUNFISH = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "sunfish"), FabricEntityTypeBuilder.createMob() .entityFactory(SunfishEntity::new) @@ -91,7 +92,7 @@ public class AnglingEntities { ); public static final EntityType PELICAN = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "pelican"), FabricEntityTypeBuilder.createMob() .entityFactory(PelicanEntity::new) @@ -103,7 +104,7 @@ public class AnglingEntities { ); public static final EntityType NAUTILUS = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "nautilus"), FabricEntityTypeBuilder.createMob() .entityFactory(NautilusEntity::new) @@ -115,7 +116,7 @@ public class AnglingEntities { ); public static final EntityType SEA_SLUG = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "sea_slug"), FabricEntityTypeBuilder.createMob() .entityFactory(SeaSlugEntity::new) @@ -127,7 +128,7 @@ public class AnglingEntities { ); public static final EntityType CRAB = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "crab"), FabricEntityTypeBuilder.createMob() .entityFactory(CrabEntity::new) @@ -139,7 +140,7 @@ public class AnglingEntities { ); public static final EntityType DONGFISH = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "dongfish"), FabricEntityTypeBuilder.createMob() .entityFactory(DongfishEntity::new) @@ -151,7 +152,7 @@ public class AnglingEntities { ); public static final EntityType CATFISH = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "catfish"), FabricEntityTypeBuilder.createMob() .entityFactory(CatfishEntity::new) @@ -163,7 +164,7 @@ public class AnglingEntities { ); public static final EntityType SEAHORSE = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "seahorse"), FabricEntityTypeBuilder.createMob() .entityFactory(SeahorseEntity::new) @@ -175,7 +176,7 @@ public class AnglingEntities { ); public static final EntityType BUBBLE_EYE = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "bubble_eye"), FabricEntityTypeBuilder.createMob() .entityFactory(BubbleEyeEntity::new) @@ -187,7 +188,7 @@ public class AnglingEntities { ); public static final EntityType ANOMALOCARIS = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "anomalocaris"), FabricEntityTypeBuilder.createMob() .entityFactory(AnomalocarisEntity::new) @@ -199,7 +200,7 @@ public class AnglingEntities { ); public static final EntityType ANGLERFISH = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "anglerfish"), FabricEntityTypeBuilder.createMob() .entityFactory(AnglerfishEntity::new) @@ -211,7 +212,7 @@ public class AnglingEntities { ); public static final EntityType MAHI_MAHI = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, new Identifier(MOD_ID, "mahi_mahi"), FabricEntityTypeBuilder.createMob() .entityFactory(MahiMahiEntity::new) diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingItems.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingItems.java index 70eaa45..afe86f8 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingItems.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingItems.java @@ -3,14 +3,16 @@ import com.eightsidedsquare.angling.common.item.RoeBlockItem; import com.eightsidedsquare.angling.common.item.UrchinBucketItem; import com.eightsidedsquare.angling.common.item.WormItem; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.MobEntity; import net.minecraft.fluid.Fluids; import net.minecraft.item.*; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import java.util.LinkedHashMap; import java.util.Map; @@ -35,10 +37,10 @@ public class AnglingItems { public static final Item ANOMALOCARIS_SPAWN_EGG = createSpawnEgg("anomalocaris", AnglingEntities.ANOMALOCARIS, 0xebb595, 0x333333); public static final Item ANGLERFISH_SPAWN_EGG = createSpawnEgg("anglerfish", AnglingEntities.ANGLERFISH, 0x58251c, 0xd9fffc); public static final Item MAHI_MAHI_SPAWN_EGG = createSpawnEgg("mahi_mahi", AnglingEntities.MAHI_MAHI, 0xb2b729, 0x4f8f2f); - public static final Item ROE = create("roe", new RoeBlockItem(AnglingBlocks.ROE, new Item.Settings().group(ItemGroup.MISC).maxCount(1))); - public static final Item SEA_SLUG_EGGS = create("sea_slug_eggs", new BlockItem(AnglingBlocks.SEA_SLUG_EGGS, new Item.Settings().group(ItemGroup.MISC).maxCount(1))); - public static final Item DUCKWEED = create("duckweed", new PlaceableOnWaterItem(AnglingBlocks.DUCKWEED, new Item.Settings().group(ItemGroup.DECORATIONS))); - public static final Item SARGASSUM = create("sargassum", new PlaceableOnWaterItem(AnglingBlocks.SARGASSUM, new Item.Settings().group(ItemGroup.DECORATIONS))); + public static final Item ROE = create("roe", new RoeBlockItem(AnglingBlocks.ROE, new Item.Settings().maxCount(1)), ItemGroups.NATURAL); + public static final Item SEA_SLUG_EGGS = create("sea_slug_eggs", new BlockItem(AnglingBlocks.SEA_SLUG_EGGS, new Item.Settings().maxCount(1)), ItemGroups.NATURAL); + public static final Item DUCKWEED = create("duckweed", new PlaceableOnWaterItem(AnglingBlocks.DUCKWEED, new Item.Settings()), ItemGroups.NATURAL); + public static final Item SARGASSUM = create("sargassum", new PlaceableOnWaterItem(AnglingBlocks.SARGASSUM, new Item.Settings()), ItemGroups.NATURAL); public static final Item SUNFISH_BUCKET = createBucket("sunfish", AnglingEntities.SUNFISH); public static final Item NAUTILUS_BUCKET = createBucket("nautilus", AnglingEntities.NAUTILUS); public static final Item FRY_BUCKET = createBucket("fry", AnglingEntities.FRY); @@ -51,14 +53,14 @@ public class AnglingItems { public static final Item ANOMALOCARIS_BUCKET = createBucket("anomalocaris", AnglingEntities.ANOMALOCARIS); public static final Item ANGLERFISH_BUCKET = createBucket("anglerfish", AnglingEntities.ANGLERFISH); public static final Item MAHI_MAHI_BUCKET = createBucket("mahi_mahi", AnglingEntities.MAHI_MAHI); - public static final Item URCHIN_BUCKET = create("urchin_bucket", new UrchinBucketItem(new Item.Settings().group(ItemGroup.MISC).maxCount(1))); - public static final Item WORM = create("worm", new WormItem(new Item.Settings().group(ItemGroup.MISC))); - public static final Item SUNFISH = create("sunfish", new Item(new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.2f).build()))); - public static final Item FRIED_SUNFISH = create("fried_sunfish", new Item(new Item.Settings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(6).saturationModifier(0.9f).build()))); + public static final Item URCHIN_BUCKET = create("urchin_bucket", new UrchinBucketItem(new Item.Settings().maxCount(1)), ItemGroups.TOOLS); + public static final Item WORM = create("worm", new WormItem(new Item.Settings()), ItemGroups.NATURAL); + public static final Item SUNFISH = create("sunfish", new Item(new Item.Settings().food(new FoodComponent.Builder().hunger(2).saturationModifier(0.2f).build())), ItemGroups.FOOD_AND_DRINK); + public static final Item FRIED_SUNFISH = create("fried_sunfish", new Item(new Item.Settings().food(new FoodComponent.Builder().hunger(6).saturationModifier(0.9f).build())), ItemGroups.FOOD_AND_DRINK); public static void init() { - ITEMS.keySet().forEach(item -> Registry.register(Registry.ITEM, ITEMS.get(item), item)); + ITEMS.keySet().forEach(item -> Registry.register(Registries.ITEM, ITEMS.get(item), item)); registerCompostable(DUCKWEED, 0.3f); registerCompostable(SARGASSUM, 0.3f); registerCompostable(WORM, 1f); @@ -67,17 +69,22 @@ public static void init() { } - private static T create(String name, T item) { + private static T create(String name, T item, ItemGroup group) { ITEMS.put(item, new Identifier(MOD_ID, name)); + + ItemGroupEvents.modifyEntriesEvent(group).register(entries -> { + entries.add(item); + }); + return item; } private static Item createBucket(String name, EntityType type) { - return create(name + "_bucket", new EntityBucketItem(type, Fluids.WATER, SoundEvents.ITEM_BUCKET_EMPTY_FISH, new Item.Settings().group(ItemGroup.MISC).maxCount(1))); + return create(name + "_bucket", new EntityBucketItem(type, Fluids.WATER, SoundEvents.ITEM_BUCKET_EMPTY_FISH, new Item.Settings().maxCount(1)), ItemGroups.TOOLS); } private static Item createSpawnEgg(String name, EntityType type, int primary, int secondary) { - return create(name + "_spawn_egg", new SpawnEggItem(type, primary, secondary, new Item.Settings().group(ItemGroup.MISC))); + return create(name + "_spawn_egg", new SpawnEggItem(type, primary, secondary, new Item.Settings()), ItemGroups.SPAWN_EGGS); } private static void registerCompostable(T item, float chance){ diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingMixinPlugin.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingMixinPlugin.java index 6fb2c80..edb63bf 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingMixinPlugin.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingMixinPlugin.java @@ -21,7 +21,7 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if(mixinClassName.toLowerCase().contains("sodium")) { + if (mixinClassName.toLowerCase().contains("sodium")) { return FabricLoader.getInstance().isModLoaded("sodium"); } return true; diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingMod.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingMod.java index de27244..c9438d5 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingMod.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingMod.java @@ -1,33 +1,44 @@ package com.eightsidedsquare.angling.core; -import com.eightsidedsquare.angling.common.entity.util.*; +import com.eightsidedsquare.angling.common.entity.util.CrabVariant; +import com.eightsidedsquare.angling.common.entity.util.FishVariantInheritance; +import com.eightsidedsquare.angling.common.entity.util.PelicanBeakEntityInitializer; +import com.eightsidedsquare.angling.common.entity.util.SeaSlugColor; +import com.eightsidedsquare.angling.common.entity.util.SeaSlugPattern; +import com.eightsidedsquare.angling.common.entity.util.SunfishVariant; import com.eightsidedsquare.angling.common.world.PelicanSpawner; +import com.eightsidedsquare.angling.config.AnglingConfig; import com.eightsidedsquare.angling.core.world.AnglingPlacedFeatures; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; -import software.bernie.geckolib3.GeckoLib; +import software.bernie.geckolib.GeckoLib; public class AnglingMod implements ModInitializer { - public static final String MOD_ID = "angling"; + public static final String MOD_ID = "angling"; + public static AnglingConfig CONFIG; - @Override - public void onInitialize() { - GeckoLib.initialize(); - AnglingBlocks.init(); - AnglingItems.init(); - AnglingSounds.init(); - AnglingEntities.init(); - SunfishVariant.init(); - SeaSlugPattern.init(); - SeaSlugColor.init(); - CrabVariant.init(); - AnglingCriteria.init(); - AnglingPlacedFeatures.init(); - AnglingParticles.init(); - FishVariantInheritance.init(); - PelicanBeakEntityInitializer.init(); + @Override + public void onInitialize() { + GeckoLib.initialize(); + AnglingBlocks.init(); + AnglingItems.init(); + AnglingSounds.init(); + AnglingEntities.init(); + SunfishVariant.init(); + SeaSlugPattern.init(); + SeaSlugColor.init(); + CrabVariant.init(); + AnglingCriteria.init(); + AnglingParticles.init(); + FishVariantInheritance.init(); + PelicanBeakEntityInitializer.init(); - PelicanSpawner spawner = new PelicanSpawner(); - ServerTickEvents.END_WORLD_TICK.register(world -> spawner.spawn(world, world.getServer().isMonsterSpawningEnabled(), world.getServer().shouldSpawnAnimals())); - } + PelicanSpawner spawner = new PelicanSpawner(); + ServerTickEvents.END_WORLD_TICK.register(world -> spawner.spawn(world, world.getServer().isMonsterSpawningEnabled(), world.getServer().shouldSpawnAnimals())); + + AutoConfig.register(AnglingConfig.class, JanksonConfigSerializer::new); + CONFIG = AutoConfig.getConfigHolder(AnglingConfig.class).getConfig(); + } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingParticles.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingParticles.java index 2059003..15027f6 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingParticles.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingParticles.java @@ -2,15 +2,16 @@ import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; import net.minecraft.particle.DefaultParticleType; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; public class AnglingParticles { - public static DefaultParticleType ALGAE = Registry.register(Registry.PARTICLE_TYPE, new Identifier(MOD_ID, "algae"), FabricParticleTypes.simple(true)); - public static DefaultParticleType WORM = Registry.register(Registry.PARTICLE_TYPE, new Identifier(MOD_ID, "worm"), FabricParticleTypes.simple(true)); + public static DefaultParticleType ALGAE = Registry.register(Registries.PARTICLE_TYPE, new Identifier(MOD_ID, "algae"), FabricParticleTypes.simple(true)); + public static DefaultParticleType WORM = Registry.register(Registries.PARTICLE_TYPE, new Identifier(MOD_ID, "worm"), FabricParticleTypes.simple(true)); public static void init() { diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingSounds.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingSounds.java index 60a9678..05c2716 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingSounds.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingSounds.java @@ -1,10 +1,11 @@ package com.eightsidedsquare.angling.core; import com.google.common.collect.Lists; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import java.util.List; @@ -64,11 +65,11 @@ public class AnglingSounds { public static final BlockSoundGroup SHELL_SOUND_GROUP = new BlockSoundGroup(1, 1.25f, BLOCK_SHELL_BREAK, BLOCK_SHELL_STEP, BLOCK_SHELL_PLACE, BLOCK_SHELL_HIT, BLOCK_SHELL_FALL); public static void init() { - SOUNDS.forEach(sound -> Registry.register(Registry.SOUND_EVENT, sound.getId(), sound)); + SOUNDS.forEach(sound -> Registry.register(Registries.SOUND_EVENT, sound.getId(), sound)); } private static SoundEvent create(String id) { - SoundEvent soundEvent = new SoundEvent(new Identifier(MOD_ID, id)); + SoundEvent soundEvent = SoundEvent.of(new Identifier(MOD_ID, id)); SOUNDS.add(soundEvent); return soundEvent; } diff --git a/src/main/java/com/eightsidedsquare/angling/core/AnglingUtil.java b/src/main/java/com/eightsidedsquare/angling/core/AnglingUtil.java index 1936335..9e49eec 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/AnglingUtil.java +++ b/src/main/java/com/eightsidedsquare/angling/core/AnglingUtil.java @@ -7,11 +7,11 @@ import net.minecraft.entity.EntityType; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.Registries; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Util; import net.minecraft.util.math.random.Random; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; import net.minecraft.world.World; import java.util.List; @@ -30,7 +30,7 @@ public static T getRandomTagValue(World world, TagKey tagKey, Random rand public static NbtCompound entityToNbt(Entity entity, boolean stripData) { NbtCompound nbt = entity.writeNbt(new NbtCompound()); - nbt.putString("id", Registry.ENTITY_TYPE.getId(entity.getType()).toString()); + nbt.putString("id", Registries.ENTITY_TYPE.getId(entity.getType()).toString()); if(stripData){ stripEntityNbt(nbt); } diff --git a/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingMemoryModuleTypes.java b/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingMemoryModuleTypes.java index 450041e..56667ba 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingMemoryModuleTypes.java +++ b/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingMemoryModuleTypes.java @@ -2,9 +2,10 @@ import com.mojang.serialization.Codec; import net.minecraft.entity.ai.brain.MemoryModuleType; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; import net.minecraft.util.Unit; -import net.minecraft.util.registry.Registry; import java.util.Optional; @@ -17,6 +18,6 @@ public class AnglingMemoryModuleTypes { public static final MemoryModuleType HAS_TRADED = register("has_traded", Codec.unit(Unit.INSTANCE)); private static MemoryModuleType register(String id, Codec codec) { - return Registry.register(Registry.MEMORY_MODULE_TYPE, new Identifier(MOD_ID, id), new MemoryModuleType<>(Optional.of(codec))); + return Registry.register(Registries.MEMORY_MODULE_TYPE, new Identifier(MOD_ID, id), new MemoryModuleType<>(Optional.of(codec))); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingSensorTypes.java b/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingSensorTypes.java index c194295..89a3b60 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingSensorTypes.java +++ b/src/main/java/com/eightsidedsquare/angling/core/ai/AnglingSensorTypes.java @@ -3,8 +3,9 @@ import com.eightsidedsquare.angling.common.entity.ai.PelicanAttackablesSensor; import net.minecraft.entity.ai.brain.sensor.Sensor; import net.minecraft.entity.ai.brain.sensor.SensorType; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import java.util.function.Supplier; @@ -15,6 +16,6 @@ public class AnglingSensorTypes { public static final SensorType PELICAN_ATTACKABLES = register("pelican_attackables", PelicanAttackablesSensor::new); private static > SensorType register(String id, Supplier factory) { - return Registry.register(Registry.SENSOR_TYPE, new Identifier(MOD_ID, id), new SensorType<>(factory)); + return Registry.register(Registries.SENSOR_TYPE, new Identifier(MOD_ID, id), new SensorType<>(factory)); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBiomeTags.java b/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBiomeTags.java index 30bcb40..9ec0c93 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBiomeTags.java +++ b/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBiomeTags.java @@ -1,34 +1,32 @@ package com.eightsidedsquare.angling.core.tags; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; -import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; - public class AnglingBiomeTags { - public static final TagKey SUNFISH_SPAWN_IN = create("sunfish_spawn_in"); - public static final TagKey NAUTILUS_SPAWN_IN = create("nautilus_spawn_in"); - public static final TagKey SEA_SLUG_SPAWN_IN = create("sea_slug_spawn_in"); - public static final TagKey CATFISH_SPAWN_IN = create("catfish_spawn_in"); - public static final TagKey SEAHORSE_SPAWN_IN = create("seahorse_spawn_in"); - public static final TagKey BUBBLE_EYE_SPAWN_IN = create("bubble_eye_spawn_in"); - public static final TagKey ANOMALOCARIS_SPAWN_IN = create("anomalocaris_spawn_in"); - public static final TagKey ANGLERFISH_SPAWN_IN = create("anglerfish_spawn_in"); - public static final TagKey MAHI_MAHI_SPAWN_IN = create("mahi_mahi_spawn_in"); - public static final TagKey CRAB_SPAWN_IN = create("crab_spawn_in"); - public static final TagKey DUNGENESS_CRAB_BIOMES = create("dungeness_crab_biomes"); - public static final TagKey GHOST_CRAB_BIOMES = create("ghost_crab_biomes"); - public static final TagKey BLUE_CLAW_CRAB_BIOMES = create("blue_claw_crab_biomes"); - public static final TagKey OYSTER_REEF_BIOMES = create("oyster_reef_biomes"); - public static final TagKey CLAMS_BIOMES = create("clams_biomes"); - public static final TagKey DUCKWEED_BIOMES = create("duckweed_biomes"); - public static final TagKey SARGASSUM_BIOMES = create("sargassum_biomes"); - public static final TagKey PAPYRUS_BIOMES = create("papyrus_biomes"); + public static final TagKey SUNFISH_SPAWN_IN = of("sunfish_spawn_in"); + public static final TagKey NAUTILUS_SPAWN_IN = of("nautilus_spawn_in"); + public static final TagKey SEA_SLUG_SPAWN_IN = of("sea_slug_spawn_in"); + public static final TagKey CATFISH_SPAWN_IN = of("catfish_spawn_in"); + public static final TagKey SEAHORSE_SPAWN_IN = of("seahorse_spawn_in"); + public static final TagKey BUBBLE_EYE_SPAWN_IN = of("bubble_eye_spawn_in"); + public static final TagKey ANOMALOCARIS_SPAWN_IN = of("anomalocaris_spawn_in"); + public static final TagKey ANGLERFISH_SPAWN_IN = of("anglerfish_spawn_in"); + public static final TagKey MAHI_MAHI_SPAWN_IN = of("mahi_mahi_spawn_in"); + public static final TagKey CRAB_SPAWN_IN = of("crab_spawn_in"); + public static final TagKey DUNGENESS_CRAB_BIOMES = of("dungeness_crab_biomes"); + public static final TagKey GHOST_CRAB_BIOMES = of("ghost_crab_biomes"); + public static final TagKey BLUE_CLAW_CRAB_BIOMES = of("blue_claw_crab_biomes"); + public static final TagKey OYSTER_REEF_BIOMES = of("oyster_reef_biomes"); + public static final TagKey CLAMS_BIOMES = of("clams_biomes"); + public static final TagKey DUCKWEED_BIOMES = of("duckweed_biomes"); + public static final TagKey SARGASSUM_BIOMES = of("sargassum_biomes"); + public static final TagKey PAPYRUS_BIOMES = of("papyrus_biomes"); - private static TagKey create(String id) { - return TagKey.of(Registry.BIOME_KEY, new Identifier(MOD_ID, id)); + private static TagKey of(String id) { + return TagKey.of(RegistryKeys.BIOME, new Identifier(id)); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBlockTags.java b/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBlockTags.java index 0c976c8..1e2c861 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBlockTags.java +++ b/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingBlockTags.java @@ -1,20 +1,20 @@ package com.eightsidedsquare.angling.core.tags; import net.minecraft.block.Block; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; public class AnglingBlockTags { - public static final TagKey FILTER_FEEDERS = create("filter_feeders"); - public static final TagKey STARFISH_FOOD = create("starfish_food"); - public static final TagKey CRAB_SPAWNABLE_ON = create("crab_spawnable_on"); + public static final TagKey FILTER_FEEDERS = of("filter_feeders"); + public static final TagKey STARFISH_FOOD = of("starfish_food"); + public static final TagKey CRAB_SPAWNABLE_ON = of("crab_spawnable_on"); - private static TagKey create(String id) { - return TagKey.of(Registry.BLOCK_KEY, new Identifier(MOD_ID, id)); + private static TagKey of(String id) { + return TagKey.of(RegistryKeys.BLOCK, new Identifier(MOD_ID, id)); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingEntityTypeTags.java b/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingEntityTypeTags.java index cac441e..8f7ddbf 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingEntityTypeTags.java +++ b/src/main/java/com/eightsidedsquare/angling/core/tags/AnglingEntityTypeTags.java @@ -1,21 +1,21 @@ package com.eightsidedsquare.angling.core.tags; import net.minecraft.entity.EntityType; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; public class AnglingEntityTypeTags { - public static final TagKey> SPAWNING_FISH = create("spawning_fish"); - public static final TagKey> COMMON_ENTITIES_IN_PELICAN_BEAK = create("common_entities_in_pelican_beak"); - public static final TagKey> UNCOMMON_ENTITIES_IN_PELICAN_BEAK = create("uncommon_entities_in_pelican_beak"); - public static final TagKey> HUNTED_BY_PELICAN = create("hunted_by_pelican"); - public static final TagKey> HUNTED_BY_PELICAN_WHEN_BABY = create("hunted_by_pelican_when_baby"); + public static final TagKey> SPAWNING_FISH = of("spawning_fish"); + public static final TagKey> COMMON_ENTITIES_IN_PELICAN_BEAK = of("common_entities_in_pelican_beak"); + public static final TagKey> UNCOMMON_ENTITIES_IN_PELICAN_BEAK = of("uncommon_entities_in_pelican_beak"); + public static final TagKey> HUNTED_BY_PELICAN = of("hunted_by_pelican"); + public static final TagKey> HUNTED_BY_PELICAN_WHEN_BABY = of("hunted_by_pelican_when_baby"); - private static TagKey> create(String id) { - return TagKey.of(Registry.ENTITY_TYPE_KEY, new Identifier(MOD_ID, id)); + private static TagKey> of(String id) { + return TagKey.of(RegistryKeys.ENTITY_TYPE, new Identifier(MOD_ID, id)); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/world/AnglingConfiguredFeatures.java b/src/main/java/com/eightsidedsquare/angling/core/world/AnglingConfiguredFeatures.java index 43716d3..ee697e5 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/world/AnglingConfiguredFeatures.java +++ b/src/main/java/com/eightsidedsquare/angling/core/world/AnglingConfiguredFeatures.java @@ -3,19 +3,30 @@ import com.eightsidedsquare.angling.common.feature.NoisePatchFeatureConfig; import com.eightsidedsquare.angling.core.AnglingBlocks; import net.minecraft.block.BlockState; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryKey; import net.minecraft.state.property.Properties; import net.minecraft.util.collection.DataPool; import net.minecraft.util.math.Direction; import net.minecraft.util.math.intprovider.UniformIntProvider; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.world.gen.feature.*; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.ConfiguredFeatures; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.PlacedFeatures; +import net.minecraft.world.gen.feature.RandomPatchFeatureConfig; +import net.minecraft.world.gen.feature.SimpleBlockFeatureConfig; import net.minecraft.world.gen.stateprovider.BlockStateProvider; import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; -import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; - -public class AnglingConfiguredFeatures { +public class AnglingConfiguredFeatures { + public static final RegistryKey> PATCH_DUCKWEED = ConfiguredFeatures.of("patch_duckweed"); + public static final RegistryKey> PATCH_SARGASSUM = ConfiguredFeatures.of("patch_sargassum"); + public static final RegistryKey> OYSTER_REEF = ConfiguredFeatures.of("oyster_reef"); + public static final RegistryKey> CLAMS = ConfiguredFeatures.of("clams"); + public static final RegistryKey> WORMY_BLOCK = ConfiguredFeatures.of("wormy_block"); + public static final RegistryKey> PATCH_PAPYRUS = ConfiguredFeatures.of("patch_papyrus"); private static final WeightedBlockStateProvider PAPYRUS_BLOCK_STATE_PROVIDER = new WeightedBlockStateProvider( DataPool.builder() .add(AnglingBlocks.PAPYRUS.getDefaultState().with(Properties.AGE_2, 0), 1) @@ -23,50 +34,22 @@ public class AnglingConfiguredFeatures { .add(AnglingBlocks.PAPYRUS.getDefaultState().with(Properties.AGE_2, 2), 3).build() ); - public static final RegistryEntry> OYSTER_REEF = - register("oyster_reef", AnglingFeatures.WATERLOGGABLE_PATCH, - new SimpleBlockFeatureConfig(BlockStateProvider.of(AnglingBlocks.OYSTERS))); - - public static final RegistryEntry> CLAMS = - register("clams", AnglingFeatures.WATERLOGGABLE_PATCH, - new SimpleBlockFeatureConfig( - new WeightedBlockStateProvider(DataPool.builder() - .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH), 1) - .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.EAST), 1) - .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.SOUTH), 1) - .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.WEST), 1) - .build()))); - - public static final RegistryEntry> WORMY_BLOCK = - register("wormy_block", AnglingFeatures.WORMY_BLOCK, new DefaultFeatureConfig()); - - public static final RegistryEntry> PATCH_SARGASSUM = - register("patch_sargassum", AnglingFeatures.NOISE_PATCH, new NoisePatchFeatureConfig( - BlockStateProvider.of(AnglingBlocks.SARGASSUM), - -3, - 2d, - 0.25d, - UniformIntProvider.create(8, 16) - )); - - public static final RegistryEntry> PATCH_DUCKWEED = - register("patch_duckweed", AnglingFeatures.NOISE_PATCH, new NoisePatchFeatureConfig( - BlockStateProvider.of(AnglingBlocks.DUCKWEED), - -2, - 2d, - 0.35d, - UniformIntProvider.create(6, 12) - )); - - public static final RegistryEntry> PATCH_PAPYRUS = - register("patch_papyrus", AnglingFeatures.WATER_ADJACENT_PATCH, new RandomPatchFeatureConfig( - 64, - 6, - 2, - PlacedFeatures.createEntry(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(PAPYRUS_BLOCK_STATE_PROVIDER)) - )); - - public static > RegistryEntry> register(String id, F feature, FC config) { - return ConfiguredFeatures.register(MOD_ID + ":" + id, feature, config); + public static void bootstrap(Registerable> featureRegisterable) { + ConfiguredFeatures.register(featureRegisterable, PATCH_DUCKWEED, AnglingFeatures.NOISE_PATCH, new NoisePatchFeatureConfig(BlockStateProvider.of(AnglingBlocks.SARGASSUM), -3, 2d, 0.25d, UniformIntProvider.create(8, 16))); + ConfiguredFeatures.register(featureRegisterable, PATCH_SARGASSUM, AnglingFeatures.NOISE_PATCH, new NoisePatchFeatureConfig(BlockStateProvider.of(AnglingBlocks.SARGASSUM), -3, 2d, 0.25d, UniformIntProvider.create(8, 16))); + ConfiguredFeatures.register(featureRegisterable, OYSTER_REEF, AnglingFeatures.WATERLOGGABLE_PATCH, new SimpleBlockFeatureConfig(BlockStateProvider.of(AnglingBlocks.OYSTERS))); + ConfiguredFeatures.register(featureRegisterable, CLAMS, AnglingFeatures.WATERLOGGABLE_PATCH, new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(DataPool.builder() + .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH), 1) + .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.EAST), 1) + .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.SOUTH), 1) + .add(AnglingBlocks.CLAM.getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.WEST), 1) + .build()))); + ConfiguredFeatures.register(featureRegisterable, WORMY_BLOCK, AnglingFeatures.WORMY_BLOCK, new DefaultFeatureConfig()); + ConfiguredFeatures.register(featureRegisterable, PATCH_PAPYRUS, AnglingFeatures.WATER_ADJACENT_PATCH, new RandomPatchFeatureConfig( + 64, + 6, + 2, + PlacedFeatures.createEntry(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(PAPYRUS_BLOCK_STATE_PROVIDER)) + )); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/world/AnglingFeatures.java b/src/main/java/com/eightsidedsquare/angling/core/world/AnglingFeatures.java index db22da7..174c938 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/world/AnglingFeatures.java +++ b/src/main/java/com/eightsidedsquare/angling/core/world/AnglingFeatures.java @@ -1,8 +1,9 @@ package com.eightsidedsquare.angling.core.world; import com.eightsidedsquare.angling.common.feature.*; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import net.minecraft.world.gen.feature.*; import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; @@ -15,6 +16,6 @@ public class AnglingFeatures { public static final Feature WATER_ADJACENT_PATCH = register("water_adjacent_patch", new WaterAdjacentPatchFeature(RandomPatchFeatureConfig.CODEC)); private static > F register(String name, F feature) { - return Registry.register(Registry.FEATURE, new Identifier(MOD_ID, name), feature); + return Registry.register(Registries.FEATURE, new Identifier(MOD_ID, name), feature); } } diff --git a/src/main/java/com/eightsidedsquare/angling/core/world/AnglingPlacedFeatures.java b/src/main/java/com/eightsidedsquare/angling/core/world/AnglingPlacedFeatures.java index 6a0153d..bca7c0d 100644 --- a/src/main/java/com/eightsidedsquare/angling/core/world/AnglingPlacedFeatures.java +++ b/src/main/java/com/eightsidedsquare/angling/core/world/AnglingPlacedFeatures.java @@ -1,79 +1,74 @@ package com.eightsidedsquare.angling.core.world; -import com.eightsidedsquare.angling.core.tags.AnglingBiomeTags; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.minecraft.tag.BiomeTags; -import net.minecraft.tag.TagKey; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.GenerationStep; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.world.gen.feature.PlacedFeatures; -import net.minecraft.world.gen.placementmodifier.*; - -import java.util.List; - -import static com.eightsidedsquare.angling.core.AnglingMod.MOD_ID; +import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier; +import net.minecraft.world.gen.placementmodifier.RarityFilterPlacementModifier; +import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier; public class AnglingPlacedFeatures { - public static final RegistryEntry PATCH_DUCKWEED = register("patch_duckweed", - AnglingConfiguredFeatures.PATCH_DUCKWEED, - List.of(RarityFilterPlacementModifier.of(3), - SquarePlacementModifier.of(), - PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, - BiomePlacementModifier.of())); + public static final RegistryKey PATCH_DUCKWEED = PlacedFeatures.of("patch_duckweed"); + public static final RegistryKey PATCH_SARGASSUM = PlacedFeatures.of("patch_sargassum"); + public static final RegistryKey OYSTER_REEF = PlacedFeatures.of("oyster_reef"); + public static final RegistryKey CLAMS = PlacedFeatures.of("clams"); + public static final RegistryKey WORMY_BLOCK = PlacedFeatures.of("wormy_block"); + public static final RegistryKey PATCH_PAPYRUS = PlacedFeatures.of("patch_papyrus"); - public static final RegistryEntry PATCH_SARGASSUM = register("patch_sargassum", - AnglingConfiguredFeatures.PATCH_SARGASSUM, - List.of(RarityFilterPlacementModifier.of(70), - SquarePlacementModifier.of(), - PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, - BiomePlacementModifier.of())); + public static void bootstrap(Registerable featureRegisterable) { + RegistryEntryLookup> registryEntryLookup = featureRegisterable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); + RegistryEntry.Reference> patchDuckweedEntry = registryEntryLookup.getOrThrow(AnglingConfiguredFeatures.PATCH_DUCKWEED); + RegistryEntry.Reference> patchSargassumEntry = registryEntryLookup.getOrThrow(AnglingConfiguredFeatures.PATCH_SARGASSUM); + RegistryEntry.Reference> oysterReefEntry = registryEntryLookup.getOrThrow(AnglingConfiguredFeatures.OYSTER_REEF); + RegistryEntry.Reference> clamsEntry = registryEntryLookup.getOrThrow(AnglingConfiguredFeatures.CLAMS); + RegistryEntry.Reference> wormyBlockEntry = registryEntryLookup.getOrThrow(AnglingConfiguredFeatures.WORMY_BLOCK); + RegistryEntry.Reference> patchPapyrusEntry = registryEntryLookup.getOrThrow(AnglingConfiguredFeatures.PATCH_PAPYRUS); - public static final RegistryEntry OYSTER_REEF = register("oyster_reef", - AnglingConfiguredFeatures.OYSTER_REEF, - List.of(RarityFilterPlacementModifier.of(14), - SquarePlacementModifier.of(), - PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP, - BiomePlacementModifier.of())); + PlacedFeatures.register(featureRegisterable, PATCH_DUCKWEED, patchDuckweedEntry, + RarityFilterPlacementModifier.of(3), + SquarePlacementModifier.of(), + PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.of() + ); - public static final RegistryEntry CLAMS = register("clams", - AnglingConfiguredFeatures.CLAMS, - List.of(RarityFilterPlacementModifier.of(12), - SquarePlacementModifier.of(), - PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP, - BiomePlacementModifier.of())); + PlacedFeatures.register(featureRegisterable, PATCH_SARGASSUM, patchSargassumEntry, + RarityFilterPlacementModifier.of(70), + SquarePlacementModifier.of(), + PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.of() + ); - public static final RegistryEntry WORMY_BLOCK = register("wormy_block", - AnglingConfiguredFeatures.WORMY_BLOCK, - List.of(CountPlacementModifier.of(2), - SquarePlacementModifier.of(), - PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP, - BiomePlacementModifier.of())); + PlacedFeatures.register(featureRegisterable, OYSTER_REEF, oysterReefEntry, + RarityFilterPlacementModifier.of(14), + SquarePlacementModifier.of(), + PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.of() + ); - public static final RegistryEntry PATCH_PAPYRUS = register("patch_papyrus", - AnglingConfiguredFeatures.PATCH_PAPYRUS, - List.of(CountPlacementModifier.of(2), - SquarePlacementModifier.of(), - PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP, - BiomePlacementModifier.of())); + PlacedFeatures.register(featureRegisterable, CLAMS, clamsEntry, + RarityFilterPlacementModifier.of(12), + SquarePlacementModifier.of(), + PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.of() + ); - public static RegistryEntry register(String id, RegistryEntry> registryEntry, List modifiers) { - return PlacedFeatures.register(MOD_ID + ":" + id, registryEntry, modifiers); - } - - private static void addFeature(RegistryEntry featureEntry, GenerationStep.Feature step, TagKey tag) { - featureEntry.getKey().ifPresent(key -> - BiomeModifications.addFeature(ctx -> ctx.getBiomeRegistryEntry().isIn(tag), step, key)); - } + PlacedFeatures.register(featureRegisterable, WORMY_BLOCK, wormyBlockEntry, + RarityFilterPlacementModifier.of(2), + SquarePlacementModifier.of(), + PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.of() + ); - public static void init() { - addFeature(OYSTER_REEF, GenerationStep.Feature.VEGETAL_DECORATION, AnglingBiomeTags.OYSTER_REEF_BIOMES); - addFeature(CLAMS, GenerationStep.Feature.VEGETAL_DECORATION, AnglingBiomeTags.CLAMS_BIOMES); - addFeature(PATCH_DUCKWEED, GenerationStep.Feature.VEGETAL_DECORATION, AnglingBiomeTags.DUCKWEED_BIOMES); - addFeature(PATCH_SARGASSUM, GenerationStep.Feature.VEGETAL_DECORATION, AnglingBiomeTags.SARGASSUM_BIOMES); - addFeature(PATCH_PAPYRUS, GenerationStep.Feature.VEGETAL_DECORATION, AnglingBiomeTags.PAPYRUS_BIOMES); - addFeature(WORMY_BLOCK, GenerationStep.Feature.UNDERGROUND_ORES, BiomeTags.IS_OVERWORLD); + PlacedFeatures.register(featureRegisterable, PATCH_PAPYRUS, patchPapyrusEntry, + RarityFilterPlacementModifier.of(2), + SquarePlacementModifier.of(), + PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.of() + ); } } diff --git a/src/main/java/com/eightsidedsquare/angling/mixin/CoralFeatureMixin.java b/src/main/java/com/eightsidedsquare/angling/mixin/CoralFeatureMixin.java index 3460736..b266b3a 100644 --- a/src/main/java/com/eightsidedsquare/angling/mixin/CoralFeatureMixin.java +++ b/src/main/java/com/eightsidedsquare/angling/mixin/CoralFeatureMixin.java @@ -6,8 +6,8 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.FacingBlock; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.random.Random; diff --git a/src/main/java/com/eightsidedsquare/angling/mixin/FluidRendererMixin.java b/src/main/java/com/eightsidedsquare/angling/mixin/FluidRendererMixin.java index 3ed142e..c0f94a3 100644 --- a/src/main/java/com/eightsidedsquare/angling/mixin/FluidRendererMixin.java +++ b/src/main/java/com/eightsidedsquare/angling/mixin/FluidRendererMixin.java @@ -1,10 +1,11 @@ package com.eightsidedsquare.angling.mixin; +import com.eightsidedsquare.angling.core.AnglingMod; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBlockTags; import net.minecraft.block.BlockState; import net.minecraft.client.render.block.FluidRenderer; import net.minecraft.fluid.FluidState; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockRenderView; @@ -18,7 +19,7 @@ public abstract class FluidRendererMixin { @Inject(method = "shouldRenderSide", at = @At("HEAD"), cancellable = true) private static void shouldRenderSide(BlockRenderView world, BlockPos pos, FluidState fluidState, BlockState blockState, Direction direction, FluidState neighborFluidState, CallbackInfoReturnable cir) { - if(fluidState.isIn(FluidTags.WATER)) { + if(AnglingMod.CONFIG.hideWaterBehindGlass && fluidState.isIn(FluidTags.WATER)) { if(world.getBlockState(pos.offset(direction)).isIn(ConventionalBlockTags.GLASS_BLOCKS)) { cir.setReturnValue(false); } diff --git a/src/main/java/com/eightsidedsquare/angling/mixin/integration/SodiumFluidRendererMixin.java b/src/main/java/com/eightsidedsquare/angling/mixin/integration/SodiumFluidRendererMixin.java index d870917..6d08954 100644 --- a/src/main/java/com/eightsidedsquare/angling/mixin/integration/SodiumFluidRendererMixin.java +++ b/src/main/java/com/eightsidedsquare/angling/mixin/integration/SodiumFluidRendererMixin.java @@ -1,10 +1,11 @@ package com.eightsidedsquare.angling.mixin.integration; -import me.jellysquid.mods.sodium.client.render.pipeline.FluidRenderer; +import com.eightsidedsquare.angling.core.AnglingMod; +import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.FluidRenderer; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBlockTags; import net.minecraft.block.BlockState; import net.minecraft.fluid.Fluid; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockRenderView; @@ -18,14 +19,16 @@ @Mixin(value = FluidRenderer.class, remap = false) public abstract class SodiumFluidRendererMixin { - @Shadow @Final private BlockPos.Mutable scratchPos; + @Shadow + @Final + private BlockPos.Mutable scratchPos; @Inject(method = "isFluidOccluded", at = @At("RETURN"), cancellable = true) private void isFluidOccluded(BlockRenderView world, int x, int y, int z, Direction dir, Fluid fluid, CallbackInfoReturnable cir) { - if(!cir.getReturnValue()) { + if (AnglingMod.CONFIG.hideWaterBehindGlass && !cir.getReturnValue()) { BlockState state = world.getBlockState(new BlockPos(scratchPos).offset(dir.getOpposite())); BlockState sideState = world.getBlockState(scratchPos); - if(state.getFluidState().isIn(FluidTags.WATER) && sideState.isIn(ConventionalBlockTags.GLASS_BLOCKS)) { + if (state.getFluidState().isIn(FluidTags.WATER) && sideState.isIn(ConventionalBlockTags.GLASS_BLOCKS)) { cir.setReturnValue(true); } } diff --git a/src/main/resources/assets/angling/lang/en_us.json b/src/main/resources/assets/angling/lang/en_us.json index 45766ac..6a355d4 100644 --- a/src/main/resources/assets/angling/lang/en_us.json +++ b/src/main/resources/assets/angling/lang/en_us.json @@ -141,5 +141,7 @@ "advancements.husbandry.traded_with_pelican.title": "Paying the Bill", "advancements.husbandry.traded_with_pelican.description": "Trade the Fish inside a Pelican's Beak for another Fish", "advancements.husbandry.look_at_nautilus.title": "Cephalopod Activities", - "advancements.husbandry.look_at_nautilus.description": "Observe a Nautilus" + "advancements.husbandry.look_at_nautilus.description": "Observe a Nautilus", + "text.autoconfig.angling.title": "Angling Config", + "text.autoconfig.angling.option.hideWaterBehindGlass": "Hide Water Behind Glass" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 56df9ca..3d95a37 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -8,7 +8,8 @@ "authors": [ "EightSidedSquare", "Diansu", - "Sillvia" + "Sillvia", + "byquanton" ], "contact": { "homepage": "https://eightsidedsquare.com/" @@ -30,6 +31,12 @@ ], "preLaunch": [ "com.eightsidedsquare.angling.core.AnglingPreLaunch" + ], + "modmenu": [ + "com.eightsidedsquare.angling.config.ModMenuIntegration" + ], + "fabric-datagen": [ + "com.eightsidedsquare.angling.core.AnglingDataGenerator" ] }, "mixins": [ @@ -40,8 +47,9 @@ "depends": { "fabricloader": ">=0.14.6", "fabric": "*", - "minecraft": "~1.19", - "java": ">=17" + "minecraft": "1.19.4", + "java": ">=17", + "cloth-config2": ">=8.0.0" }, "custom": { "cardinal-components": [ @@ -49,5 +57,6 @@ ] }, "suggests": { + "modmenu": ">=4.0.0" } }