From ba171af8f00cf10039e13fc39c37bb33b060a0ea Mon Sep 17 00:00:00 2001 From: realguyman Date: Wed, 22 May 2024 22:08:22 -0800 Subject: [PATCH] Port to 1.20.5 --- build.gradle | 10 +++---- gradle.properties | 14 +++++----- .../realguyman/totally_lit/TotallyLit.java | 5 ++-- .../datagen/BlockLootTableDatagen.java | 7 +++-- ...RainMixin.java => AbstractBlockMixin.java} | 8 +++++- ...xin.java => CampfireBlockEntityMixin.java} | 7 ++--- ...tionMixin.java => CampfireBlockMixin.java} | 26 +++++++------------ .../campfire/CanExtinguishInRainMixin.java | 21 --------------- ...duleMixin.java => AbstractBlockMixin.java} | 10 +++++-- ...dCanScheduleMixin.java => BlockMixin.java} | 17 +----------- ...duleMixin.java => AbstractBlockMixin.java} | 10 +++++-- ...dCanScheduleMixin.java => BlockMixin.java} | 16 +----------- ...duleMixin.java => AbstractBlockMixin.java} | 12 ++++++--- ...dCanScheduleMixin.java => BlockMixin.java} | 16 +----------- ...duleMixin.java => AbstractBlockMixin.java} | 10 +++++-- ...dCanScheduleMixin.java => BlockMixin.java} | 16 +----------- .../assets/totally_lit/lang/en_us.json | 5 ++++ .../data/minecraft/recipes/soul_torch.json | 2 +- .../data/minecraft/recipes/torch.json | 2 +- .../recipes/glowstone_lantern.json | 2 +- .../totally_lit/recipes/glowstone_torch.json | 2 +- .../recipes/lantern_from_igniters.json | 2 +- .../recipes/soul_lantern_from_igniters.json | 2 +- .../recipes/soul_torch_from_campfire.json | 4 ++- .../recipes/torch_from_campfire.json | 4 ++- .../recipes/unlit_jack_o_lantern.json | 2 +- .../totally_lit/recipes/unlit_lantern.json | 2 +- .../unlit_lantern_from_water_bucket.json | 2 +- .../recipes/unlit_soul_lantern.json | 2 +- .../unlit_soul_lantern_from_water_bucket.json | 2 +- .../totally_lit/recipes/unlit_soul_torch.json | 2 +- .../unlit_soul_torch_from_water_bucket.json | 2 +- .../data/totally_lit/recipes/unlit_torch.json | 2 +- .../unlit_torch_from_water_bucket.json | 2 +- src/main/resources/fabric.mod.json | 4 +-- src/main/resources/totally_lit.mixins.json | 25 +++++++++--------- 36 files changed, 117 insertions(+), 160 deletions(-) rename src/main/java/io/github/realguyman/totally_lit/mixin/campfire/{ExtinguishInRainMixin.java => AbstractBlockMixin.java} (88%) rename src/main/java/io/github/realguyman/totally_lit/mixin/campfire/{TrackTicksBurntForMixin.java => CampfireBlockEntityMixin.java} (88%) rename src/main/java/io/github/realguyman/totally_lit/mixin/campfire/{DefaultStateAndIgnitionMixin.java => CampfireBlockMixin.java} (63%) delete mode 100644 src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CanExtinguishInRainMixin.java rename src/main/java/io/github/realguyman/totally_lit/mixin/candle/{ScheduleMixin.java => AbstractBlockMixin.java} (84%) rename src/main/java/io/github/realguyman/totally_lit/mixin/candle/{ClearAndCanScheduleMixin.java => BlockMixin.java} (59%) rename src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/{ScheduleMixin.java => AbstractBlockMixin.java} (85%) rename src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/{ClearAndCanScheduleMixin.java => BlockMixin.java} (61%) rename src/main/java/io/github/realguyman/totally_lit/mixin/lantern/{ScheduleMixin.java => AbstractBlockMixin.java} (85%) rename src/main/java/io/github/realguyman/totally_lit/mixin/lantern/{ClearAndCanScheduleMixin.java => BlockMixin.java} (76%) rename src/main/java/io/github/realguyman/totally_lit/mixin/torch/{ScheduleMixin.java => AbstractBlockMixin.java} (85%) rename src/main/java/io/github/realguyman/totally_lit/mixin/torch/{ClearAndCanScheduleMixin.java => BlockMixin.java} (62%) diff --git a/build.gradle b/build.gradle index 5800a94..2ead905 100644 --- a/build.gradle +++ b/build.gradle @@ -31,8 +31,8 @@ dependencies { // Local dependencies modLocalRuntime "com.terraformersmc:modmenu:${project.mod_menu}" - modLocalRuntime "maven.modrinth:lithium:${project.lithium}" - modLocalRuntime "dev.lambdaurora:lambdynamiclights:${project.lambdynamiclights}" +// modLocalRuntime "maven.modrinth:lithium:${project.lithium}" +// modLocalRuntime "dev.lambdaurora:lambdynamiclights:${project.lambdynamiclights}" // modLocalRuntime "vazkii.patchouli:Patchouli:${project.patchouli}" // modLocalRuntime "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei}" // modLocalRuntime "dev.emi:emi:${project.emi}" @@ -66,8 +66,8 @@ loom { java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { @@ -85,7 +85,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } modrinth { diff --git a/gradle.properties b/gradle.properties index 085e7b2..a97a255 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ org.gradle.jvmargs=-Xmx1G # Required dependencies -minecraft=1.20.4 -mappings=1.20.4+build.3 -fabric_loader=0.15.9 -fabric_api=0.96.11+1.20.4 -owo_lib=0.12.6+1.20.3 +minecraft=1.20.5 +mappings=1.20.5+build.1 +fabric_loader=0.15.11 +fabric_api=0.97.8+1.20.5 +owo_lib=0.12.8+1.20.5 # Local dependencies -mod_menu=9.0.0 +mod_menu=10.0.0-beta.1 lithium=mc1.20.4-0.12.1 lambdynamiclights=2.3.4+1.20.4-local patchouli=1.20.1-83-FABRIC @@ -16,6 +16,6 @@ rei=13.0.678 emi=1.0.24+1.20.2+fabric # Project details -mod_version=0.13.6+1.20.4 +mod_version=0.14.0+1.20.5 maven_group=io.github.realguyman archives_base_name=totally_lit diff --git a/src/main/java/io/github/realguyman/totally_lit/TotallyLit.java b/src/main/java/io/github/realguyman/totally_lit/TotallyLit.java index f2e767f..e45fe27 100644 --- a/src/main/java/io/github/realguyman/totally_lit/TotallyLit.java +++ b/src/main/java/io/github/realguyman/totally_lit/TotallyLit.java @@ -14,6 +14,7 @@ import net.minecraft.block.BlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.item.Item; @@ -250,7 +251,7 @@ private ActionResult igniteUnlitBlock( TagKey igniters ) { final ItemStack stack = player.getStackInHand(hand); - final boolean stackHasFireAspect = EnchantmentHelper.get(stack).containsKey(Enchantments.FIRE_ASPECT); + final boolean stackHasFireAspect = EnchantmentHelper.getEnchantments(stack).getEnchantments().contains(Enchantments.FIRE_ASPECT); if ((!stack.isIn(igniters) && !stackHasFireAspect) || player.isSneaking()) { return ActionResult.PASS; @@ -271,7 +272,7 @@ private ActionResult igniteUnlitBlock( return ActionResult.FAIL; } - stack.damage(1, player, playerInScope -> playerInScope.sendToolBreakStatus(hand)); + stack.damage(1, player, EquipmentSlot.fromTypeIndex(EquipmentSlot.Type.HAND, hand.ordinal())); world.playSound(null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 0.125F, world.getRandom().nextFloat() * 0.5F + 0.125F); return ActionResult.SUCCESS; } diff --git a/src/main/java/io/github/realguyman/totally_lit/datagen/BlockLootTableDatagen.java b/src/main/java/io/github/realguyman/totally_lit/datagen/BlockLootTableDatagen.java index c938adc..c04a674 100644 --- a/src/main/java/io/github/realguyman/totally_lit/datagen/BlockLootTableDatagen.java +++ b/src/main/java/io/github/realguyman/totally_lit/datagen/BlockLootTableDatagen.java @@ -4,10 +4,13 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; import net.minecraft.block.Block; +import net.minecraft.registry.RegistryWrapper; + +import java.util.concurrent.CompletableFuture; public class BlockLootTableDatagen extends FabricBlockLootTableProvider { - public BlockLootTableDatagen(FabricDataOutput dataOutput) { - super(dataOutput); + public BlockLootTableDatagen(FabricDataOutput dataOutput, CompletableFuture registryLookup) { + super(dataOutput, registryLookup); } @Override diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/ExtinguishInRainMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/AbstractBlockMixin.java similarity index 88% rename from src/main/java/io/github/realguyman/totally_lit/mixin/campfire/ExtinguishInRainMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/campfire/AbstractBlockMixin.java index 0e9ca85..3893f41 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/ExtinguishInRainMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/AbstractBlockMixin.java @@ -21,9 +21,15 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractBlock.class) -public abstract class ExtinguishInRainMixin { +public abstract class AbstractBlockMixin { + @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) + private void hasRandomTicks(BlockState state, CallbackInfoReturnable cir) { + cir.setReturnValue(true); + } + @Inject(method = "randomTick", at = @At("HEAD")) private void extinguish(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { if (state.isIn(BlockTags.CAMPFIRES)) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/TrackTicksBurntForMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CampfireBlockEntityMixin.java similarity index 88% rename from src/main/java/io/github/realguyman/totally_lit/mixin/campfire/TrackTicksBurntForMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CampfireBlockEntityMixin.java index a3f1150..e734768 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/TrackTicksBurntForMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CampfireBlockEntityMixin.java @@ -9,6 +9,7 @@ import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.predicate.entity.EntityPredicates; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.state.property.Properties; @@ -23,7 +24,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(CampfireBlockEntity.class) -public abstract class TrackTicksBurntForMixin implements CampfireBlockEntityAccess { +public abstract class CampfireBlockEntityMixin implements CampfireBlockEntityAccess { @Unique private int ticksBurntFor = 0; @@ -36,14 +37,14 @@ public abstract class TrackTicksBurntForMixin implements CampfireBlockEntityAcce } @Inject(method = "readNbt", at = @At("RETURN")) - private void readBurnDurationFromNbt(NbtCompound nbt, CallbackInfo ci) { + private void readBurnDurationFromNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup, CallbackInfo ci) { if (nbt.contains("ticksBurntFor")) { ticksBurntFor = nbt.getInt("ticksBurntFor"); } } @Inject(method = "writeNbt", at = @At("RETURN")) - private void writeTicksBurntForToNbt(NbtCompound nbt, CallbackInfo ci) { + private void writeTicksBurntForToNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup, CallbackInfo ci) { nbt.putInt("ticksBurntFor", ticksBurntFor); } diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/DefaultStateAndIgnitionMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CampfireBlockMixin.java similarity index 63% rename from src/main/java/io/github/realguyman/totally_lit/mixin/campfire/DefaultStateAndIgnitionMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CampfireBlockMixin.java index 661ac91..828ba5f 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/DefaultStateAndIgnitionMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CampfireBlockMixin.java @@ -8,55 +8,49 @@ import net.minecraft.block.CampfireBlock; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.stat.Stats; -import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.ItemActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(CampfireBlock.class) -public abstract class DefaultStateAndIgnitionMixin extends BlockWithEntity { - protected DefaultStateAndIgnitionMixin(Settings settings) { +public abstract class CampfireBlockMixin extends BlockWithEntity { + protected CampfireBlockMixin(Settings settings) { super(settings); } - @Inject(method = "", at = @At("RETURN")) - private void litStateWhenInitialized(boolean emitsParticles, int fireDamage, Settings settings, CallbackInfo ci) { - setDefaultState(getDefaultState().with(CampfireBlock.LIT, TotallyLit.CONFIG.campfires.defaultLitStateWhenPlaced())); - } - @ModifyReturnValue(method = "getPlacementState", at = @At("RETURN")) private BlockState litStateWhenPlaced(BlockState original) { return original.with(CampfireBlock.LIT, TotallyLit.CONFIG.campfires.defaultLitStateWhenPlaced()); } - @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) - private void ignite(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { - final ItemStack stack = player.getStackInHand(hand); + @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) + private void ignite(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { final boolean canBeIgnited = CampfireBlock.canBeLit(state); - final boolean stackHasFireAspect = EnchantmentHelper.get(stack).containsKey(Enchantments.FIRE_ASPECT); + final boolean stackHasFireAspect = EnchantmentHelper.getEnchantments(stack).getEnchantments().contains(Enchantments.FIRE_ASPECT); if ((!stack.isIn(TagRegistry.CAMPFIRE_IGNITER_ITEMS) && !stackHasFireAspect) || !canBeIgnited) { return; } if (!world.setBlockState(pos, state.with(CampfireBlock.LIT, true))) { - cir.setReturnValue(ActionResult.FAIL); + cir.setReturnValue(ItemActionResult.FAIL); } - stack.damage(1, player, playerInScope -> playerInScope.sendToolBreakStatus(hand)); + stack.damage(1, player, EquipmentSlot.fromTypeIndex(EquipmentSlot.Type.HAND, hand.ordinal())); world.playSound(null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 0.125F, world.getRandom().nextFloat() * 0.5F + 0.125F); player.incrementStat(Stats.INTERACT_WITH_CAMPFIRE); - cir.setReturnValue(ActionResult.SUCCESS); + cir.setReturnValue(ItemActionResult.SUCCESS); } } diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CanExtinguishInRainMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CanExtinguishInRainMixin.java deleted file mode 100644 index 35d4e73..0000000 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/campfire/CanExtinguishInRainMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.realguyman.totally_lit.mixin.campfire; - -import io.github.realguyman.totally_lit.TotallyLit; -import net.minecraft.block.*; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(Block.class) -public abstract class CanExtinguishInRainMixin { - @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) - private void canExtinguish(BlockState state, CallbackInfoReturnable cir) { - final boolean isLitCampfire = CampfireBlock.isLitCampfire(state); - final boolean canExtinguishInRain = TotallyLit.CONFIG.campfires.extinguishInRainChance() > 0F; - - if (isLitCampfire && canExtinguishInRain) { - cir.setReturnValue(true); - } - } -} diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/candle/ScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/candle/AbstractBlockMixin.java similarity index 84% rename from src/main/java/io/github/realguyman/totally_lit/mixin/candle/ScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/candle/AbstractBlockMixin.java index 0a976de..7cec5f0 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/candle/ScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/candle/AbstractBlockMixin.java @@ -16,10 +16,16 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractBlock.class) -public abstract class ScheduleMixin { - @Shadow public abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random); +public abstract class AbstractBlockMixin { + @Shadow protected abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random); + + @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) + private void canSchedule(BlockState state, CallbackInfoReturnable cir) { + cir.setReturnValue(true); + } @Inject(method = "randomTick", at = @At("HEAD")) private void schedule(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/candle/ClearAndCanScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/candle/BlockMixin.java similarity index 59% rename from src/main/java/io/github/realguyman/totally_lit/mixin/candle/ClearAndCanScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/candle/BlockMixin.java index e98c157..d64dda7 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/candle/ClearAndCanScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/candle/BlockMixin.java @@ -1,6 +1,5 @@ package io.github.realguyman.totally_lit.mixin.candle; -import io.github.realguyman.totally_lit.TotallyLit; import net.minecraft.block.*; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -13,21 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Block.class) -public abstract class ClearAndCanScheduleMixin { - @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) - private void canSchedule(BlockState state, CallbackInfoReturnable cir) { - if (!AbstractCandleBlock.isLitCandle(state)) { - return; - } - - boolean extinguishOverTime = TotallyLit.CONFIG.candles.extinguishOverTime(); - boolean extinguishInRain = TotallyLit.CONFIG.candles.extinguishInRainChance() > 0F; - - if (extinguishOverTime || extinguishInRain) { - cir.setReturnValue(true); - } - } - +public abstract class BlockMixin { @Inject(method = "onBreak", at = @At("HEAD")) private void clearNextScheduledExtinguish(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfoReturnable cir) { if (!world.isClient() && AbstractCandleBlock.isLitCandle(state)) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/ScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/AbstractBlockMixin.java similarity index 85% rename from src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/ScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/AbstractBlockMixin.java index 8214aa7..cdaba74 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/ScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/AbstractBlockMixin.java @@ -17,10 +17,16 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractBlock.class) -public abstract class ScheduleMixin { - @Shadow public abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, net.minecraft.util.math.random.Random random); +public abstract class AbstractBlockMixin { + @Shadow protected abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, net.minecraft.util.math.random.Random random); + + @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) + private void canSchedule(BlockState state, CallbackInfoReturnable cir) { + cir.setReturnValue(true); + } @Inject(method = "randomTick", at = @At("HEAD")) private void schedule(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/ClearAndCanScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/BlockMixin.java similarity index 61% rename from src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/ClearAndCanScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/BlockMixin.java index 99c40cf..8f9124c 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/ClearAndCanScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/jack_o_lantern/BlockMixin.java @@ -13,21 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Block.class) -public abstract class ClearAndCanScheduleMixin { - @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) - private void canSchedule(BlockState state, CallbackInfoReturnable cir) { - if (!TotallyLit.JACK_O_LANTERN_MAP.containsKey(state.getBlock())) { - return; - } - - final boolean canExtinguishOverTime = TotallyLit.CONFIG.jackOLanterns.extinguishOverTime(); - final boolean canExtinguishInRain = TotallyLit.CONFIG.jackOLanterns.extinguishInRainChance() > 0F; - - if (canExtinguishOverTime || canExtinguishInRain) { - cir.setReturnValue(true); - } - } - +public abstract class BlockMixin { @Inject(method = "onBreak", at = @At("HEAD")) private void clearNextScheduledExtinguish(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfoReturnable cir) { if (!world.isClient() && TotallyLit.JACK_O_LANTERN_MAP.containsKey(state.getBlock())) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/ScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/AbstractBlockMixin.java similarity index 85% rename from src/main/java/io/github/realguyman/totally_lit/mixin/lantern/ScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/lantern/AbstractBlockMixin.java index 1763c56..cd892ba 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/ScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/AbstractBlockMixin.java @@ -3,10 +3,8 @@ import io.github.realguyman.totally_lit.TotallyLit; import io.github.realguyman.totally_lit.registry.TagRegistry; import net.minecraft.block.*; -import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.predicate.entity.EntityPredicates; -import net.minecraft.registry.tag.EntityTypeTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -20,10 +18,16 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractBlock.class) -public abstract class ScheduleMixin { - @Shadow public abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, net.minecraft.util.math.random.Random random); +public abstract class AbstractBlockMixin { + @Shadow protected abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, net.minecraft.util.math.random.Random random); + + @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) + private void canSchedule(BlockState state, CallbackInfoReturnable cir) { + cir.setReturnValue(true); + } @Inject(method = "randomTick", at = @At("HEAD")) private void schedule(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/ClearAndCanScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/BlockMixin.java similarity index 76% rename from src/main/java/io/github/realguyman/totally_lit/mixin/lantern/ClearAndCanScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/lantern/BlockMixin.java index cdc9616..def30df 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/ClearAndCanScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/lantern/BlockMixin.java @@ -21,21 +21,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Block.class) -public abstract class ClearAndCanScheduleMixin { - @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) - private void canSchedule(BlockState state, CallbackInfoReturnable cir) { - if (!TotallyLit.LANTERN_MAP.containsKey(state.getBlock())) { - return; - } - - final boolean canExtinguishInRain = TotallyLit.CONFIG.lanterns.extinguishInRainChance() > 0F; - final boolean canExtinguishOverTime = TotallyLit.CONFIG.lanterns.extinguishOverTime(); - - if (canExtinguishOverTime || canExtinguishInRain) { - cir.setReturnValue(true); - } - } - +public abstract class BlockMixin { @Inject(method = "onPlaced", at = @At("HEAD")) private void extinguishWhenPlacedInWater(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack, CallbackInfo ci) { if (world.isClient() || !state.contains(Properties.WATERLOGGED) || !state.get(Properties.WATERLOGGED)) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/torch/ScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/torch/AbstractBlockMixin.java similarity index 85% rename from src/main/java/io/github/realguyman/totally_lit/mixin/torch/ScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/torch/AbstractBlockMixin.java index 1aea343..2b9eafd 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/torch/ScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/torch/AbstractBlockMixin.java @@ -18,10 +18,16 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractBlock.class) -public abstract class ScheduleMixin { - @Shadow public abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, net.minecraft.util.math.random.Random random); +public abstract class AbstractBlockMixin { + @Shadow protected abstract void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, net.minecraft.util.math.random.Random random); + + @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) + private void canSchedule(BlockState state, CallbackInfoReturnable cir) { + cir.setReturnValue(true); + } @Inject(method = "randomTick", at = @At("HEAD")) private void schedule(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { diff --git a/src/main/java/io/github/realguyman/totally_lit/mixin/torch/ClearAndCanScheduleMixin.java b/src/main/java/io/github/realguyman/totally_lit/mixin/torch/BlockMixin.java similarity index 62% rename from src/main/java/io/github/realguyman/totally_lit/mixin/torch/ClearAndCanScheduleMixin.java rename to src/main/java/io/github/realguyman/totally_lit/mixin/torch/BlockMixin.java index af70bd3..f40891b 100644 --- a/src/main/java/io/github/realguyman/totally_lit/mixin/torch/ClearAndCanScheduleMixin.java +++ b/src/main/java/io/github/realguyman/totally_lit/mixin/torch/BlockMixin.java @@ -14,21 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Block.class) -public abstract class ClearAndCanScheduleMixin { - @Inject(method = "hasRandomTicks", at = @At("HEAD"), cancellable = true) - private void canSchedule(BlockState state, CallbackInfoReturnable cir) { - if (!TotallyLit.TORCH_MAP.containsKey(state.getBlock())) { - return; - } - - final boolean canExtinguishOverTime = TotallyLit.CONFIG.torches.extinguishOverTime(); - final boolean canExtinguishInRain = TotallyLit.CONFIG.torches.extinguishInRainChance() > 0F; - - if (canExtinguishOverTime || canExtinguishInRain) { - cir.setReturnValue(true); - } - } - +public abstract class BlockMixin { @Inject(method = "onBreak", at = @At("HEAD")) private void clearNextScheduledExtinguish(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfoReturnable cir) { if (!world.isClient() && TotallyLit.TORCH_MAP.containsKey(state.getBlock())) { diff --git a/src/main/resources/assets/totally_lit/lang/en_us.json b/src/main/resources/assets/totally_lit/lang/en_us.json index 5be74e6..9014672 100644 --- a/src/main/resources/assets/totally_lit/lang/en_us.json +++ b/src/main/resources/assets/totally_lit/lang/en_us.json @@ -6,6 +6,11 @@ "block.totally_lit.unlit_soul_lantern": "Unlit Soul Lantern", "block.totally_lit.unlit_soul_torch": "Unlit Soul Torch", "block.totally_lit.unlit_torch": "Unlit Torch", + "tag.item.totally_lit.campfire_igniters": "Campfire Igniters", + "tag.item.totally_lit.jack_o_lantern_igniters": "Jack O'lantern Igniters", + "tag.item.totally_lit.lantern_igniters": "Lantern Igniters", + "tag.item.totally_lit.torch_igniters": "Torch Igniters", + "tag.item.totally_lit.soul_fire_variants": "Soul Fire Variants", "text.config.totally_lit.category.campfires": "Campfires", "text.config.totally_lit.category.candles": "Candles", "text.config.totally_lit.category.jackOLanterns": "Jack O' Lanterns", diff --git a/src/main/resources/data/minecraft/recipes/soul_torch.json b/src/main/resources/data/minecraft/recipes/soul_torch.json index 8f463f3..1beaf7b 100644 --- a/src/main/resources/data/minecraft/recipes/soul_torch.json +++ b/src/main/resources/data/minecraft/recipes/soul_torch.json @@ -11,7 +11,7 @@ ] ], "result": { - "item": "minecraft:soul_torch" + "id": "minecraft:soul_torch" }, "owo:remainders": { "minecraft:torch": "minecraft:torch", diff --git a/src/main/resources/data/minecraft/recipes/torch.json b/src/main/resources/data/minecraft/recipes/torch.json index 642a018..15e5f38 100644 --- a/src/main/resources/data/minecraft/recipes/torch.json +++ b/src/main/resources/data/minecraft/recipes/torch.json @@ -11,7 +11,7 @@ ] ], "result": { - "item": "minecraft:torch" + "id": "minecraft:torch" }, "owo:remainders": { "minecraft:torch": "minecraft:torch", diff --git a/src/main/resources/data/totally_lit/recipes/glowstone_lantern.json b/src/main/resources/data/totally_lit/recipes/glowstone_lantern.json index c066356..db48ac8 100644 --- a/src/main/resources/data/totally_lit/recipes/glowstone_lantern.json +++ b/src/main/resources/data/totally_lit/recipes/glowstone_lantern.json @@ -18,6 +18,6 @@ ] }, "result": { - "item": "totally_lit:glowstone_lantern" + "id": "totally_lit:glowstone_lantern" } } diff --git a/src/main/resources/data/totally_lit/recipes/glowstone_torch.json b/src/main/resources/data/totally_lit/recipes/glowstone_torch.json index 2e3041d..2fa286e 100644 --- a/src/main/resources/data/totally_lit/recipes/glowstone_torch.json +++ b/src/main/resources/data/totally_lit/recipes/glowstone_torch.json @@ -15,7 +15,7 @@ } }, "result": { - "item": "totally_lit:glowstone_torch", + "id": "totally_lit:glowstone_torch", "count": 4 } } diff --git a/src/main/resources/data/totally_lit/recipes/lantern_from_igniters.json b/src/main/resources/data/totally_lit/recipes/lantern_from_igniters.json index 0a3ff36..bd8f1a2 100644 --- a/src/main/resources/data/totally_lit/recipes/lantern_from_igniters.json +++ b/src/main/resources/data/totally_lit/recipes/lantern_from_igniters.json @@ -11,7 +11,7 @@ ] ], "result": { - "item": "minecraft:lantern" + "id": "minecraft:lantern" }, "owo:remainders": { "minecraft:torch": "minecraft:torch", diff --git a/src/main/resources/data/totally_lit/recipes/soul_lantern_from_igniters.json b/src/main/resources/data/totally_lit/recipes/soul_lantern_from_igniters.json index a209cfb..1820b88 100644 --- a/src/main/resources/data/totally_lit/recipes/soul_lantern_from_igniters.json +++ b/src/main/resources/data/totally_lit/recipes/soul_lantern_from_igniters.json @@ -11,7 +11,7 @@ ] ], "result": { - "item": "minecraft:soul_lantern" + "id": "minecraft:soul_lantern" }, "owo:remainders": { "minecraft:torch": "minecraft:torch", diff --git a/src/main/resources/data/totally_lit/recipes/soul_torch_from_campfire.json b/src/main/resources/data/totally_lit/recipes/soul_torch_from_campfire.json index f2e2a38..2915d13 100644 --- a/src/main/resources/data/totally_lit/recipes/soul_torch_from_campfire.json +++ b/src/main/resources/data/totally_lit/recipes/soul_torch_from_campfire.json @@ -3,6 +3,8 @@ "ingredient": { "item": "totally_lit:unlit_soul_torch" }, - "result": "minecraft:soul_torch", + "result": { + "id": "minecraft:soul_torch" + }, "experience": 0 } diff --git a/src/main/resources/data/totally_lit/recipes/torch_from_campfire.json b/src/main/resources/data/totally_lit/recipes/torch_from_campfire.json index aa433da..b19d3c7 100644 --- a/src/main/resources/data/totally_lit/recipes/torch_from_campfire.json +++ b/src/main/resources/data/totally_lit/recipes/torch_from_campfire.json @@ -3,6 +3,8 @@ "ingredient": { "item": "totally_lit:unlit_torch" }, - "result": "minecraft:torch", + "result": { + "id": "minecraft:torch" + }, "experience": 0 } diff --git a/src/main/resources/data/totally_lit/recipes/unlit_jack_o_lantern.json b/src/main/resources/data/totally_lit/recipes/unlit_jack_o_lantern.json index 2842188..b17c4ec 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_jack_o_lantern.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_jack_o_lantern.json @@ -14,6 +14,6 @@ "B" ], "result": { - "item": "totally_lit:unlit_jack_o_lantern" + "id": "totally_lit:unlit_jack_o_lantern" } } \ No newline at end of file diff --git a/src/main/resources/data/totally_lit/recipes/unlit_lantern.json b/src/main/resources/data/totally_lit/recipes/unlit_lantern.json index 4b7a260..add9b93 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_lantern.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_lantern.json @@ -18,6 +18,6 @@ ] }, "result": { - "item": "totally_lit:unlit_lantern" + "id": "totally_lit:unlit_lantern" } } diff --git a/src/main/resources/data/totally_lit/recipes/unlit_lantern_from_water_bucket.json b/src/main/resources/data/totally_lit/recipes/unlit_lantern_from_water_bucket.json index a523128..e6cf289 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_lantern_from_water_bucket.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_lantern_from_water_bucket.json @@ -9,7 +9,7 @@ } ], "result": { - "item": "totally_lit:unlit_lantern" + "id": "totally_lit:unlit_lantern" }, "owo:remainders": { "minecraft:water_bucket": "minecraft:water_bucket" diff --git a/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern.json b/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern.json index 2d5be52..ee4cb6b 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern.json @@ -18,6 +18,6 @@ ] }, "result": { - "item": "totally_lit:unlit_soul_lantern" + "id": "totally_lit:unlit_soul_lantern" } } diff --git a/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern_from_water_bucket.json b/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern_from_water_bucket.json index 3514fad..653cc04 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern_from_water_bucket.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_soul_lantern_from_water_bucket.json @@ -9,7 +9,7 @@ } ], "result": { - "item": "totally_lit:unlit_soul_lantern" + "id": "totally_lit:unlit_soul_lantern" }, "owo:remainders": { "minecraft:water_bucket": "minecraft:water_bucket" diff --git a/src/main/resources/data/totally_lit/recipes/unlit_soul_torch.json b/src/main/resources/data/totally_lit/recipes/unlit_soul_torch.json index fb3f451..26caaaa 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_soul_torch.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_soul_torch.json @@ -21,7 +21,7 @@ ] }, "result": { - "item": "totally_lit:unlit_soul_torch", + "id": "totally_lit:unlit_soul_torch", "count": 4 } } diff --git a/src/main/resources/data/totally_lit/recipes/unlit_soul_torch_from_water_bucket.json b/src/main/resources/data/totally_lit/recipes/unlit_soul_torch_from_water_bucket.json index 1f36aac..8148a7c 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_soul_torch_from_water_bucket.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_soul_torch_from_water_bucket.json @@ -9,7 +9,7 @@ } ], "result": { - "item": "totally_lit:unlit_soul_torch" + "id": "totally_lit:unlit_soul_torch" }, "owo:remainders": { "minecraft:water_bucket": "minecraft:water_bucket" diff --git a/src/main/resources/data/totally_lit/recipes/unlit_torch.json b/src/main/resources/data/totally_lit/recipes/unlit_torch.json index 5770a2f..89037f2 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_torch.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_torch.json @@ -15,7 +15,7 @@ } }, "result": { - "item": "totally_lit:unlit_torch", + "id": "totally_lit:unlit_torch", "count": 4 } } diff --git a/src/main/resources/data/totally_lit/recipes/unlit_torch_from_water_bucket.json b/src/main/resources/data/totally_lit/recipes/unlit_torch_from_water_bucket.json index 83717ee..41205d0 100644 --- a/src/main/resources/data/totally_lit/recipes/unlit_torch_from_water_bucket.json +++ b/src/main/resources/data/totally_lit/recipes/unlit_torch_from_water_bucket.json @@ -9,7 +9,7 @@ } ], "result": { - "item": "totally_lit:unlit_torch" + "id": "totally_lit:unlit_torch" }, "owo:remainders": { "minecraft:water_bucket": "minecraft:water_bucket" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ca1f99e..d058db0 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,8 +20,8 @@ "issues": "https://github.com/realguyman/totally_lit/issues" }, "depends": { - "java": ">=17", - "minecraft": "1.20.4", + "java": ">=21", + "minecraft": "1.20.5", "fabricloader": ">=0.15.0", "fabric-api": "*", "owo-lib": ">=0.12.0" diff --git a/src/main/resources/totally_lit.mixins.json b/src/main/resources/totally_lit.mixins.json index 97473cf..79eca1d 100644 --- a/src/main/resources/totally_lit.mixins.json +++ b/src/main/resources/totally_lit.mixins.json @@ -2,24 +2,23 @@ "required": true, "minVersion": "0.8", "package": "io.github.realguyman.totally_lit.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [ "DamageFlintAndSteelItemInRecipeMixin", "ItemEntityMixin", "ItemMixin", "PotionEntityMixin", - "campfire.CanExtinguishInRainMixin", - "campfire.DefaultStateAndIgnitionMixin", - "campfire.ExtinguishInRainMixin", - "campfire.TrackTicksBurntForMixin", - "candle.ClearAndCanScheduleMixin", - "candle.ScheduleMixin", - "jack_o_lantern.ScheduleMixin", - "jack_o_lantern.ClearAndCanScheduleMixin", - "lantern.ClearAndCanScheduleMixin", - "lantern.ScheduleMixin", - "torch.ClearAndCanScheduleMixin", - "torch.ScheduleMixin" + "campfire.CampfireBlockMixin", + "campfire.AbstractBlockMixin", + "campfire.CampfireBlockEntityMixin", + "candle.BlockMixin", + "candle.AbstractBlockMixin", + "jack_o_lantern.AbstractBlockMixin", + "jack_o_lantern.BlockMixin", + "lantern.BlockMixin", + "lantern.AbstractBlockMixin", + "torch.BlockMixin", + "torch.AbstractBlockMixin" ], "injectors": { "defaultRequire": 1