diff --git a/gradle.properties b/gradle.properties index a9d03066..34eb1049 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,8 +5,8 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=1.16.1 - yarn_mappings=1.16.1+build.1 - loader_version=0.8.8+build.202 + yarn_mappings=1.16.1+build.19 + loader_version=0.8.9+build.203 # Mod Properties mod_version = 1.4.1+v200701 diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 3cd4747f..59d2d4cf 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -568,6 +568,13 @@ public class CarpetSettings @Rule(desc = "Coral structures will grow with bonemeal from coral plants", category = FEATURE) public static boolean renewableCoral = false; + @Rule( + desc = "Nether basalt generator without soul sand below ", + extra = " .. will convert into blackstone instead", + category = FEATURE + ) + public static boolean renewableBlackstone = false; + @Rule(desc = "fixes block placement rotation issue when player rotates quickly while placing blocks", category = BUGFIX) public static boolean placementRotationFix = false; diff --git a/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java b/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java new file mode 100644 index 00000000..e3b620d8 --- /dev/null +++ b/src/main/java/carpet/mixins/FluidBlock_renewableBlackstoneMixin.java @@ -0,0 +1,47 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FluidBlock; +import net.minecraft.fluid.FlowableFluid; +import net.minecraft.tag.FluidTags; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(FluidBlock.class) +public abstract class FluidBlock_renewableBlackstoneMixin +{ + @Shadow @Final protected FlowableFluid fluid; + + @Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos); + + @Inject(method = "receiveNeighborFluids", at = @At("TAIL"), cancellable = true) + private void receiveFluidToBlackstone(World world, BlockPos pos, BlockState state, CallbackInfoReturnable cir) + { + if (CarpetSettings.renewableBlackstone) + { + if (fluid.isIn(FluidTags.LAVA)) { + for(Direction direction : Direction.values()) + { + if (direction != Direction.DOWN) { + BlockPos blockPos = pos.offset(direction); + if (world.getBlockState(blockPos).isOf(Blocks.BLUE_ICE)) { + world.setBlockState(pos, Blocks.BLACKSTONE.getDefaultState()); + playExtinguishSound(world, pos); + cir.setReturnValue(false); + } + } + } + } + } + } +} diff --git a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java index 6311ec45..03bb1f38 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java @@ -63,7 +63,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec */ // Cancel a while statement - @Redirect(method = "method_29741", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z")) + @Redirect(method = "runServer", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z")) private boolean cancelRunLoop(MinecraftServer server) { return false; @@ -72,7 +72,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec // Replaced the above cancelled while statement with this one // could possibly just inject that mspt selection at the beginning of the loop, but then adding all mspt's to // replace 50L will be a hassle - @Inject(method = "method_29741", at = @At(value = "INVOKE", shift = At.Shift.AFTER, + @Inject(method = "runServer", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V")) private void modifiedRunLoop(CallbackInfo ci) { diff --git a/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java b/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java index 7ae91e62..ff32165b 100644 --- a/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java +++ b/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java @@ -33,14 +33,14 @@ public class PortalForcer_portalSuffocationMixin @Redirect(method = "usePortal", at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/Entity;positAfterTeleport(DDD)V" + target = "Lnet/minecraft/entity/Entity;refreshPositionAfterTeleport(DDD)V" )) private void alternativeSetPositionAndAngles(Entity entity, double d, double e, double f) { if (CarpetSettings.portalSuffocationFix && CarpetSettings.fixedPosition != null) - entity.positAfterTeleport(CarpetSettings.fixedPosition.x, CarpetSettings.fixedPosition.y, CarpetSettings.fixedPosition.z); + entity.refreshPositionAfterTeleport(CarpetSettings.fixedPosition.x, CarpetSettings.fixedPosition.y, CarpetSettings.fixedPosition.z); else - entity.positAfterTeleport(d, e, f); + entity.refreshPositionAfterTeleport(d, e, f); } diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index 4a63d9e1..bec0c120 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -25,7 +25,7 @@ public class WorldTools if (region == null) return false; return region.hasChunk(chpos); } - Path regionPath = new File(((MinecraftServerInterface )world.getServer()).getCMSession().method_27424(world.getRegistryKey()), "region").toPath(); + Path regionPath = new File(((MinecraftServerInterface )world.getServer()).getCMSession().getWorldDirectory(world.getRegistryKey()), "region").toPath(); Path regionFilePath = regionPath.resolve(currentRegionName); File regionFile = regionFilePath.toFile(); if (!regionFile.exists()) diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 20746e15..e9bb8afd 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -31,7 +31,7 @@ import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.mob.MobEntityWithAi; +import net.minecraft.entity.mob.PathAwareEntity; import net.minecraft.entity.passive.PassiveEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag; @@ -281,7 +281,7 @@ public class EntityValue extends Value put("home", (e, a) -> { if (e instanceof MobEntity) { - return (((MobEntity) e).getPositionTargetRange () > 0)?new BlockValue(null, (ServerWorld) e.getEntityWorld(), ((MobEntityWithAi) e).getPositionTarget()):Value.FALSE; + return (((MobEntity) e).getPositionTargetRange () > 0)?new BlockValue(null, (ServerWorld) e.getEntityWorld(), ((PathAwareEntity) e).getPositionTarget()):Value.FALSE; } return Value.NULL; }); @@ -807,9 +807,9 @@ public class EntityValue extends Value } }); put("home", (e, v) -> { - if (!(e instanceof MobEntityWithAi)) + if (!(e instanceof PathAwareEntity)) return; - MobEntityWithAi ec = (MobEntityWithAi)e; + PathAwareEntity ec = (PathAwareEntity)e; if (v == null) throw new InternalExpressionException("'home' requires at least one position argument, and optional distance, or null to cancel"); if (v instanceof NullValue) diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 8383aec0..cd719e7f 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -9,7 +9,7 @@ import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.TargetFinder; import net.minecraft.entity.ai.goal.WanderAroundGoal; import net.minecraft.entity.ai.pathing.NavigationType; -import net.minecraft.entity.mob.MobEntityWithAi; +import net.minecraft.entity.mob.PathAwareEntity; import net.minecraft.entity.mob.ZombifiedPiglinEntity; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.text.BaseText; @@ -222,7 +222,7 @@ public class BlockInfo private static BaseText wander_chances(BlockPos pos, World worldIn) { - MobEntityWithAi creature = new ZombifiedPiglinEntity(EntityType.ZOMBIFIED_PIGLIN, worldIn); + PathAwareEntity creature = new ZombifiedPiglinEntity(EntityType.ZOMBIFIED_PIGLIN, worldIn); creature.initialize(worldIn, worldIn.getLocalDifficulty(pos), SpawnReason.NATURAL, null, null); creature.refreshPositionAndAngles(pos, 0.0F, 0.0F); WanderAroundGoal wander = new WanderAroundGoal(creature, 0.8D); diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index b60a0951..d325191e 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -79,6 +79,7 @@ "ServerWorld_onePlayerSleepingMixin", "CoralBlockMixin", "CoralFeatureMixin", + "FluidBlock_renewableBlackstoneMixin", "StructureFeatureMixin", "World_scarpetPlopMixin", "Biome_scarpetMixin",