Skip to content

Commit

Permalink
Port to 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
realguyman committed May 23, 2024
1 parent ef6e6f2 commit ba171af
Show file tree
Hide file tree
Showing 36 changed files with 117 additions and 160 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -66,8 +66,8 @@ loom {
java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand All @@ -85,7 +85,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

modrinth {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -250,7 +251,7 @@ private ActionResult igniteUnlitBlock(
TagKey<Item> 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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RegistryWrapper.WrapperLookup> registryLookup) {
super(dataOutput, registryLookup);
}

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

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<init>", 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<ActionResult> 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<ItemActionResult> 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);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> cir) {
cir.setReturnValue(true);
}

@Inject(method = "randomTick", at = @At("HEAD"))
private void schedule(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Boolean> 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<BlockState> cir) {
if (!world.isClient() && AbstractCandleBlock.isLitCandle(state)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> cir) {
cir.setReturnValue(true);
}

@Inject(method = "randomTick", at = @At("HEAD"))
private void schedule(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> 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<BlockState> cir) {
if (!world.isClient() && TotallyLit.JACK_O_LANTERN_MAP.containsKey(state.getBlock())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Boolean> cir) {
cir.setReturnValue(true);
}

@Inject(method = "randomTick", at = @At("HEAD"))
private void schedule(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> 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)) {
Expand Down
Loading

0 comments on commit ba171af

Please sign in to comment.