Skip to content

Commit

Permalink
Port to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
realguyman committed Oct 28, 2024
1 parent a77a6a3 commit 6527345
Show file tree
Hide file tree
Showing 25 changed files with 222 additions and 199 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'com.modrinth.minotaur' version '2.+'
id 'maven-publish'
}
Expand Down Expand Up @@ -30,8 +30,8 @@ dependencies {

// Local dependencies
modLocalRuntime "com.terraformersmc:modmenu:${project.modmenu}"
modLocalRuntime "maven.modrinth:lithium:${project.lithium}"
modLocalRuntime "vazkii.patchouli:Patchouli:${project.patchouli}"
// modLocalRuntime "maven.modrinth:lithium:${project.lithium}"
// modLocalRuntime "vazkii.patchouli:Patchouli:${project.patchouli}"
// modLocalRuntime "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei}"
// modLocalRuntime "dev.emi:emi:${project.emi}"
}
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Required dependencies
minecraft=1.21.1
mappings=1.21.1+build.3
fabric_loader=0.16.7
fabric_api=0.106.0+1.21.1
owo_lib=0.12.15+1.21
minecraft=1.21.3
mappings=1.21.3+build.1
fabric_loader=0.16.8
fabric_api=0.107.0+1.21.3
owo_lib=0.12.16+1.21.2

# Local dependencies
modmenu=11.0.3
modmenu=12.0.0-beta.1
lithium=mc1.21.1-0.13.1
patchouli=1.21-87-FABRIC
rei=16.0.783
emi=1.1.16+1.21.1+fabric

# Project detail
mod_version=0.15.1+1.21.1
mod_version=0.15.1+1.21.3
maven_group=io.github.realguyman
archives_base_name=totally_lit
11 changes: 5 additions & 6 deletions src/main/java/io/github/realguyman/totally_lit/TotallyLit.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -207,7 +206,7 @@ private ActionResult igniteUnlitItemInHand(
return ActionResult.PASS;
}

private TypedActionResult<ItemStack> igniteUnlitItemInHandFromRaycast(
private ActionResult igniteUnlitItemInHandFromRaycast(
PlayerEntity player,
World world,
Hand hand,
Expand All @@ -219,7 +218,7 @@ private TypedActionResult<ItemStack> igniteUnlitItemInHandFromRaycast(
final ItemStack stack = player.getStackInHand(hand);

if (!world.getFluidState(pos).isIn(igniterFluids)) {
return TypedActionResult.pass(stack);
return ActionResult.PASS;
}

for (Map.Entry<Block, Block> entry : map.entrySet()) {
Expand All @@ -231,15 +230,15 @@ private TypedActionResult<ItemStack> igniteUnlitItemInHandFromRaycast(
}

if (!player.giveItemStack(new ItemStack(lit))) {
return TypedActionResult.fail(stack);
return ActionResult.FAIL;
}

stack.decrement(1);
world.playSound(null, player.getBlockPos(), SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 0.125F, world.getRandom().nextFloat() * 0.5F + 0.125F);
return TypedActionResult.success(stack, true);
return ActionResult.SUCCESS;
}

return TypedActionResult.pass(stack);
return ActionResult.PASS;
}

private ActionResult igniteUnlitBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
import io.github.realguyman.totally_lit.TotallyLit;
import io.github.realguyman.totally_lit.access.CampfireBlockEntityAccess;
import io.github.realguyman.totally_lit.registry.TagRegistry;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.block.CampfireBlock;
import net.minecraft.block.entity.CampfireBlockEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.recipe.CampfireCookingRecipe;
import net.minecraft.recipe.ServerRecipeManager;
import net.minecraft.recipe.input.SingleStackRecipeInput;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.property.Properties;
import net.minecraft.util.TypeFilter;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -50,7 +52,7 @@ private void writeTicksBurntForToNbt(NbtCompound nbt, RegistryWrapper.WrapperLoo
}

@Inject(method = "litServerTick", at = @At("RETURN"))
private static void trackTicksBurntFor(World world, BlockPos pos, BlockState state, CampfireBlockEntity campfire, CallbackInfo ci) {
private static void trackTicksBurntFor(ServerWorld world, BlockPos pos, BlockState state, CampfireBlockEntity campfire, ServerRecipeManager.MatchGetter<SingleStackRecipeInput, CampfireCookingRecipe> recipeMatchGetter, CallbackInfo ci) {
var nearbyVillagers = world.getEntitiesByType(
TypeFilter.instanceOf(VillagerEntity.class),
new Box(pos).expand(32),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.CampfireBlock;
import net.minecraft.enchantment.Enchantment;
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.registry.tag.TagKey;
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;
Expand All @@ -38,7 +36,7 @@ private BlockState litStateWhenPlaced(BlockState original) {
}

@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) {
private void ignite(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
final boolean canBeIgnited = CampfireBlock.canBeLit(state);
final boolean stackHasFireAspect = EnchantmentHelper.getEnchantments(stack).getEnchantments().contains(Enchantments.FIRE_ASPECT);

Expand All @@ -47,12 +45,12 @@ private void ignite(ItemStack stack, BlockState state, World world, BlockPos pos
}

if (!world.setBlockState(pos, state.with(CampfireBlock.LIT, true))) {
cir.setReturnValue(ItemActionResult.FAIL);
cir.setReturnValue(ActionResult.FAIL);
}

stack.damage(1, player, EquipmentSlot.values()[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(ItemActionResult.SUCCESS);
cir.setReturnValue(ActionResult.SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import net.minecraft.block.LanternBlock;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;

public class BlockRegistry {
Expand All @@ -29,15 +31,94 @@ private static Block add(String path, Block block) {
}

static {
GLOWSTONE_TORCH = add("glowstone_torch", new NoParticleTorchBlock(Settings.copy(Blocks.TORCH)));
GLOWSTONE_WALL_TORCH = add("glowstone_wall_torch", new NoParticleWallTorchBlock(Settings.copy(Blocks.TORCH).dropsLike(GLOWSTONE_TORCH)));
GLOWSTONE_LANTERN = add("glowstone_lantern", new LanternBlock(Settings.copy(Blocks.LANTERN)));
UNLIT_JACK_O_LANTERN = add("unlit_jack_o_lantern", new CarvedPumpkinBlock(Settings.copy(Blocks.JACK_O_LANTERN).luminance(state -> 0)));
UNLIT_LANTERN = add("unlit_lantern", new LanternBlock(Settings.copy(Blocks.LANTERN).luminance(state -> 0)));
UNLIT_SOUL_LANTERN = add("unlit_soul_lantern", new LanternBlock(Settings.copy(UNLIT_LANTERN)));
UNLIT_SOUL_TORCH = add("unlit_soul_torch", new NoParticleTorchBlock(Settings.copy(Blocks.TORCH).luminance(state -> 0)));
UNLIT_SOUL_WALL_TORCH = add("unlit_soul_wall_torch", new NoParticleWallTorchBlock(Settings.copy(Blocks.WALL_TORCH).luminance(state -> 0).dropsLike(UNLIT_SOUL_TORCH)));
UNLIT_TORCH = add("unlit_torch", new NoParticleTorchBlock(Settings.copy(Blocks.TORCH).luminance(state -> 0)));
UNLIT_WALL_TORCH = add("unlit_wall_torch", new NoParticleWallTorchBlock(Settings.copy(Blocks.WALL_TORCH).luminance(state -> 0).dropsLike(UNLIT_TORCH)));
GLOWSTONE_TORCH = add(
"glowstone_torch",
new NoParticleTorchBlock(
Settings.copy(Blocks.TORCH)
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "glowstone_torch")))
)
);

GLOWSTONE_WALL_TORCH = add(
"glowstone_wall_torch",
new NoParticleWallTorchBlock(
Settings.copy(Blocks.TORCH)
.lootTable(GLOWSTONE_TORCH.getLootTableKey())
.overrideTranslationKey(GLOWSTONE_TORCH.getTranslationKey())
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "glowstone_wall_torch")))
)
);

GLOWSTONE_LANTERN = add(
"glowstone_lantern",
new LanternBlock(
Settings.copy(Blocks.LANTERN)
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "glowstone_lantern")))
)
);

UNLIT_JACK_O_LANTERN = add(
"unlit_jack_o_lantern",
new CarvedPumpkinBlock(
Settings.copy(Blocks.JACK_O_LANTERN)
.luminance(state -> 0)
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "unlit_jack_o_lantern")))
)
);

UNLIT_LANTERN = add(
"unlit_lantern",
new LanternBlock(
Settings.copy(Blocks.LANTERN)
.luminance(state -> 0)
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "unlit_lantern")))
)
);

UNLIT_SOUL_LANTERN = add(
"unlit_soul_lantern",
new LanternBlock(
Settings.copy(UNLIT_LANTERN)
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "unlit_soul_lantern")))
)
);

UNLIT_SOUL_TORCH = add(
"unlit_soul_torch",
new NoParticleTorchBlock(
Settings.copy(Blocks.TORCH)
.luminance(state -> 0)
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "unlit_soul_torch")))
)
);

UNLIT_SOUL_WALL_TORCH = add(
"unlit_soul_wall_torch",
new NoParticleWallTorchBlock(
Settings.copy(Blocks.WALL_TORCH)
.luminance(state -> 0)
.lootTable(UNLIT_SOUL_TORCH.getLootTableKey())
.overrideTranslationKey(UNLIT_SOUL_TORCH.getTranslationKey())
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "unlit_soul_wall_torch")))
)
);

UNLIT_TORCH = add("unlit_torch",
new NoParticleTorchBlock(
Settings.copy(Blocks.TORCH)
.luminance(state -> 0)
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "unlit_torch")))
)
);

UNLIT_WALL_TORCH = add("unlit_wall_torch",
new NoParticleWallTorchBlock(
Settings.copy(Blocks.WALL_TORCH)
.luminance(state -> 0)
.lootTable(UNLIT_TORCH.getLootTableKey())
.overrideTranslationKey(UNLIT_TORCH.getTranslationKey())
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(TotallyLit.MOD_ID, "unlit_wall_torch")))
)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@
package io.github.realguyman.totally_lit.registry;

import io.github.realguyman.totally_lit.TotallyLit;
import net.minecraft.item.*;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.VerticallyAttachableBlockItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;

public class ItemRegistry {
public static final Item GLOWSTONE_TORCH = new VerticallyAttachableBlockItem(BlockRegistry.GLOWSTONE_TORCH, BlockRegistry.GLOWSTONE_WALL_TORCH, new Item.Settings(), Direction.DOWN);
public static final Item GLOWSTONE_LANTERN = new BlockItem(BlockRegistry.GLOWSTONE_LANTERN, new Item.Settings());
public static final Item UNLIT_JACK_O_LANTERN = new BlockItem(BlockRegistry.UNLIT_JACK_O_LANTERN, new Item.Settings());
public static final Item UNLIT_LANTERN = new BlockItem(BlockRegistry.UNLIT_LANTERN, new Item.Settings());
public static final Item UNLIT_SOUL_LANTERN = new BlockItem(BlockRegistry.UNLIT_SOUL_LANTERN, new Item.Settings());
public static final Item UNLIT_SOUL_TORCH = new VerticallyAttachableBlockItem(BlockRegistry.UNLIT_SOUL_TORCH, BlockRegistry.UNLIT_SOUL_WALL_TORCH, new Item.Settings(), Direction.DOWN);
public static final Item UNLIT_TORCH = new VerticallyAttachableBlockItem(BlockRegistry.UNLIT_TORCH, BlockRegistry.UNLIT_WALL_TORCH, new Item.Settings(), Direction.DOWN);
public static final Item GLOWSTONE_TORCH = new VerticallyAttachableBlockItem(
BlockRegistry.GLOWSTONE_TORCH,
BlockRegistry.GLOWSTONE_WALL_TORCH,
Direction.DOWN,
new Item.Settings()
.useBlockPrefixedTranslationKey()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TotallyLit.MOD_ID, "glowstone_torch")))
);

public static final Item GLOWSTONE_LANTERN = new BlockItem(
BlockRegistry.GLOWSTONE_LANTERN,
new Item.Settings()
.useBlockPrefixedTranslationKey()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TotallyLit.MOD_ID, "glowstone_lantern")))
);

public static final Item UNLIT_JACK_O_LANTERN = new BlockItem(
BlockRegistry.UNLIT_JACK_O_LANTERN,
new Item.Settings()
.useBlockPrefixedTranslationKey()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TotallyLit.MOD_ID, "unlit_jack_o_lantern")))
);

public static final Item UNLIT_LANTERN = new BlockItem(
BlockRegistry.UNLIT_LANTERN,
new Item.Settings()
.useBlockPrefixedTranslationKey()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TotallyLit.MOD_ID, "unlit_lantern")))
);

public static final Item UNLIT_SOUL_LANTERN = new BlockItem(
BlockRegistry.UNLIT_SOUL_LANTERN,
new Item.Settings()
.useBlockPrefixedTranslationKey()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TotallyLit.MOD_ID, "unlit_soul_lantern")))
);

public static final Item UNLIT_SOUL_TORCH = new VerticallyAttachableBlockItem(
BlockRegistry.UNLIT_SOUL_TORCH,
BlockRegistry.UNLIT_SOUL_WALL_TORCH,
Direction.DOWN,
new Item.Settings()
.useBlockPrefixedTranslationKey()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TotallyLit.MOD_ID, "unlit_soul_torch")))
);

public static final Item UNLIT_TORCH = new VerticallyAttachableBlockItem(
BlockRegistry.UNLIT_TORCH,
BlockRegistry.UNLIT_WALL_TORCH,
Direction.DOWN,
new Item.Settings()
.useBlockPrefixedTranslationKey()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(TotallyLit.MOD_ID, "unlit_torch")))
);

private static Item add(String path, Item item) {
return Registry.register(Registries.ITEM, Identifier.of(TotallyLit.MOD_ID, path), item);
Expand Down
Loading

0 comments on commit 6527345

Please sign in to comment.