Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port to 1.19.2 #40

Open
wants to merge 1 commit into
base: 1.18
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '0.12.+'
id 'maven-publish'
}

Expand All @@ -25,7 +25,7 @@ dependencies {
//Parchment
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.18.2:2022.05.02@zip")
parchment("org.parchmentmc.data:parchment-1.19.2:2022.09.18@zip")
}
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx1G
minecraft_version=1.18.2
loader_version=0.14.5
mod_version = 1.0.1
minecraft_version = 1.19.2
loader_version = 0.14.9
mod_version = 1.1.1-1.19.2
maven_group = net.zestyblaze
archives_base_name = nomadbooks-1.18
fabric_version=0.51.1+1.18.2
archives_base_name = nomadbooks
fabric_version = 0.61.0+1.19.2
73 changes: 37 additions & 36 deletions src/main/java/net/zestyblaze/nomadbooks/NomadBooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.Util;
import net.minecraft.core.Registry;
Expand All @@ -17,6 +16,8 @@
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootPool.Builder;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.SetNbtFunction;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
Expand Down Expand Up @@ -71,67 +72,67 @@ public void onInitialize() {
CREATIVE_NOMAD_BOOK = registerItem(new NomadBookItem(new FabricItemSettings().maxCount(1).group(CreativeModeTab.TAB_MISC).rarity(Rarity.RARE).fireproof()), "creative_nomad_book");

UniformGenerator lootTableRange = UniformGenerator.between(0, 1);
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, supplier, setter) -> {
if (DUNGEON_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(lootTableRange)
.withEntry(LootItem.lootTableItem(GRASS_PAGE).build());
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(lootTableRange)
.add(LootItem.lootTableItem(GRASS_PAGE));

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
if (MINESHAFT_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(lootTableRange)
.withEntry(LootItem.lootTableItem(GRASS_PAGE).build());
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(lootTableRange)
.add(LootItem.lootTableItem(GRASS_PAGE));

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
if (TEMPLE_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(lootTableRange)
.withEntry(LootItem.lootTableItem(GRASS_PAGE).build());
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(lootTableRange)
.add(LootItem.lootTableItem(GRASS_PAGE));

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
if (TREASURE_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(lootTableRange)
.withEntry(LootItem.lootTableItem(GRASS_PAGE).build());
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(lootTableRange)
.add(LootItem.lootTableItem(GRASS_PAGE));

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
if (OUTPOST_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(lootTableRange)
.withEntry(LootItem.lootTableItem(GRASS_PAGE).build());
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(lootTableRange)
.add(LootItem.lootTableItem(GRASS_PAGE));

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
if (CARTOGRAPHER_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(lootTableRange)
.withEntry(LootItem.lootTableItem(GRASS_PAGE).build());
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(lootTableRange)
.add(LootItem.lootTableItem(GRASS_PAGE));

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
if (STRONGHOLD_LIBRARY_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(UniformGenerator.between(0, 3))
.withEntry(LootItem.lootTableItem(GRASS_PAGE).build());
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(UniformGenerator.between(0, 3))
.add(LootItem.lootTableItem(GRASS_PAGE));

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
if (BONUS_CHEST_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.rolls(ConstantValue.exactly(1))
.withEntry(LootItem.lootTableItem(NOMAD_BOOK).build())
.withFunction(SetNbtFunction.setTag(Util.make(new CompoundTag(), (compoundTag) -> compoundTag.put(MODID, Util.make(new CompoundTag(), child -> {
LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(NOMAD_BOOK))
.apply(SetNbtFunction.setTag(Util.make(new CompoundTag(), (compoundTag) -> compoundTag.put(MODID, Util.make(new CompoundTag(), child -> {
child.putInt("Height", 1);
child.putInt("Width", 3);
child.putString("Structure", NomadBookItem.defaultStructurePath);
})))).build());

supplier.withPool(poolBuilder.build());
supplier.withPool(poolBuilder);
}
});

Expand Down
37 changes: 18 additions & 19 deletions src/main/java/net/zestyblaze/nomadbooks/item/NomadBookItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.nbt.*;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
Expand All @@ -26,9 +25,9 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
import net.minecraft.world.level.material.Material;
import net.zestyblaze.nomadbooks.NomadBooks;
import net.zestyblaze.nomadbooks.block.NomadMushroomBlock;
Expand Down Expand Up @@ -79,7 +78,7 @@ public InteractionResult useOn(UseOnContext context) {
BlockPos p = pos.offset(new BlockPos(x, y, z));
BlockState bs = context.getLevel().getBlockState(p);
if (!(isBlockReplaceable(bs) || isBlockUnderwaterReplaceable(bs) && tags.getList("Upgrades", NbtType.STRING).contains(StringTag.valueOf("aquatic_membrane")))) {
Objects.requireNonNull(context.getPlayer()).displayClientMessage(new TranslatableComponent("error.nomadbooks.no_space"), true);
Objects.requireNonNull(context.getPlayer()).displayClientMessage(Component.translatable("error.nomadbooks.no_space"), true);
return InteractionResult.FAIL;
}
}
Expand Down Expand Up @@ -114,7 +113,7 @@ public InteractionResult useOn(UseOnContext context) {
BlockPos p = pos.offset(new BlockPos(x, -1, z));
BlockState bs = context.getLevel().getBlockState(p);
if (isBlockReplaceable(bs)) {
Objects.requireNonNull(context.getPlayer()).displayClientMessage(new TranslatableComponent("error.nomadbooks.invalid_surface"), true);
Objects.requireNonNull(context.getPlayer()).displayClientMessage(Component.translatable("error.nomadbooks.invalid_surface"), true);
return InteractionResult.FAIL;
}
}
Expand Down Expand Up @@ -189,10 +188,10 @@ public InteractionResultHolder<ItemStack> use(@NotNull Level world, Player user,
if (user.isShiftKeyDown()) {
// switch boundaries display on or off
if (tags.getBoolean("DisplayBoundaries")) {
user.displayClientMessage(new TranslatableComponent("info.nomadbooks.display_boundaries_off"), true);
user.displayClientMessage(Component.translatable("info.nomadbooks.display_boundaries_off"), true);
tags.putBoolean("DisplayBoundaries", false);
} else {
user.displayClientMessage(new TranslatableComponent("info.nomadbooks.display_boundaries_on"), true);
user.displayClientMessage(Component.translatable("info.nomadbooks.display_boundaries_on"), true);
tags.putBoolean("DisplayBoundaries", true);
}

Expand All @@ -215,12 +214,12 @@ public InteractionResultHolder<ItemStack> use(@NotNull Level world, Player user,
}
world.playSound(null, pos.getX() + width / 2 + 0.5, pos.getY(), pos.getZ() + width / 2 + 0.5, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 1f);
} else {
user.displayClientMessage(new TranslatableComponent("error.nomadbooks.camp_too_far"), true);
user.displayClientMessage(Component.translatable("error.nomadbooks.camp_too_far"), true);
}
return InteractionResultHolder.success(itemStack);
}
} else {
user.displayClientMessage(new TranslatableComponent("error.nomadbooks.different_dimension"), true);
user.displayClientMessage(Component.translatable("error.nomadbooks.different_dimension"), true);
return InteractionResultHolder.success(itemStack);
}

Expand All @@ -232,7 +231,7 @@ public InteractionResultHolder<ItemStack> use(@NotNull Level world, Player user,

if (!world.isClientSide) {
ServerLevel serverLevel = (ServerLevel) world;
StructureManager structureManager = serverLevel.getStructureManager();
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();

// free beds so they don't redeploy as occupied
for (int x = 0; x < width; x++) {
Expand All @@ -251,14 +250,14 @@ public InteractionResultHolder<ItemStack> use(@NotNull Level world, Player user,
// save structure
StructureTemplate structure;
try {
structure = structureManager.getOrCreate(new ResourceLocation(structurePath));
structure = structureTemplateManager.getOrCreate(new ResourceLocation(structurePath));
} catch (ResourceLocationException var8) {
return InteractionResultHolder.success(itemStack);
}

structure.fillFromWorld(world, pos.offset(new BlockPos(0, 0, 0)), new BlockPos(width, height, width), true, Blocks.STRUCTURE_VOID);
structure.setAuthor(user.getScoreboardName());
structureManager.save(new ResourceLocation(structurePath));
structureTemplateManager.save(new ResourceLocation(structurePath));

// clear block entities
for (int x = 0; x < width; x++) {
Expand Down Expand Up @@ -362,14 +361,14 @@ public void appendHoverText(ItemStack stack, Level world, List<Component> toolti
// height, width and upgrades
int height = tags.getInt("Height");
int width = tags.getInt("Width");
tooltip.add(new TranslatableComponent("item.nomadbooks.nomad_book.tooltip.height", height).setStyle(Style.EMPTY.withColor(ChatFormatting.GRAY)));
tooltip.add(new TranslatableComponent("item.nomadbooks.nomad_book.tooltip.width", width).setStyle(Style.EMPTY.withColor(ChatFormatting.GRAY)));
tooltip.add(Component.translatable("item.nomadbooks.nomad_book.tooltip.height", height).setStyle(Style.EMPTY.withColor(ChatFormatting.GRAY)));
tooltip.add(Component.translatable("item.nomadbooks.nomad_book.tooltip.width", width).setStyle(Style.EMPTY.withColor(ChatFormatting.GRAY)));
ListTag upgrades = tags.getList("Upgrades", NbtType.STRING);
upgrades.forEach(tag -> tooltip.add(new TranslatableComponent("upgrade.nomadbooks."+tag.getAsString()).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_AQUA))));
upgrades.forEach(tag -> tooltip.add(Component.translatable("upgrade.nomadbooks."+tag.getAsString()).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_AQUA))));

// if inked, show progress
if (tags.getBoolean("Inked")) {
tooltip.add(new TranslatableComponent("item.nomadbooks.nomad_book.tooltip.itinerant_ink", tags.getInt("InkProgress"), tags.getInt("InkGoal")).setStyle(Style.EMPTY.withColor(ChatFormatting.BLUE)));
tooltip.add(Component.translatable("item.nomadbooks.nomad_book.tooltip.itinerant_ink", tags.getInt("InkProgress"), tags.getInt("InkGoal")).setStyle(Style.EMPTY.withColor(ChatFormatting.BLUE)));
}
// camp coordinates if deployed
if (stack.getOrCreateTag().getFloat(NomadBooks.MODID+":deployed") == 1.0f) {
Expand All @@ -379,16 +378,16 @@ public void appendHoverText(ItemStack stack, Level world, List<Component> toolti
Optional<ResourceKey<Level>> dimension = Level.RESOURCE_KEY_CODEC.parse(NbtOps.INSTANCE, tags.get("Dimension")).result();

if (dimension.isPresent() && dimension.get() == world.dimension()) {
tooltip.add(new TranslatableComponent("item.nomadbooks.nomad_book.tooltip.position", pos.getX()+", "+pos.getY()+", "+pos.getZ()).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_GRAY)));
tooltip.add(Component.translatable("item.nomadbooks.nomad_book.tooltip.position", pos.getX()+", "+pos.getY()+", "+pos.getZ()).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_GRAY)));
} else {
tooltip.add(new TranslatableComponent("item.nomadbooks.nomad_book.tooltip.position", pos.getX()+", "+pos.getY()+", "+pos.getZ()).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_GRAY).applyFormats(ChatFormatting.OBFUSCATED)));
tooltip.add(Component.translatable("item.nomadbooks.nomad_book.tooltip.position", pos.getX()+", "+pos.getY()+", "+pos.getZ()).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_GRAY).applyFormats(ChatFormatting.OBFUSCATED)));
}
// tooltip.add(new TranslatableComponent("item.nomadbooks.nomad_book.tooltip.dimension", dimension).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_GRAY)));
// tooltip.add(Component.translatable("item.nomadbooks.nomad_book.tooltip.dimension", dimension).setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_GRAY)));
}
// displaying boundaries
if (stack.getItem() instanceof NomadBookItem) {
if (tags.getBoolean("DisplayBoundaries")) {
tooltip.add(new TranslatableComponent("item.nomadbooks.nomad_book.tooltip.boundaries_display").setStyle(Style.EMPTY.withColor(ChatFormatting.GREEN).withItalic(true)));
tooltip.add(Component.translatable("item.nomadbooks.nomad_book.tooltip.boundaries_display").setStyle(Style.EMPTY.withColor(ChatFormatting.GREEN).withItalic(true)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.zestyblaze.nomadbooks.NomadBooks;
import net.zestyblaze.nomadbooks.client.NomadBooksClient;
import net.zestyblaze.nomadbooks.item.NomadBookItem;
Expand All @@ -20,8 +21,8 @@

@Mixin(LocalPlayer.class)
public abstract class LocalPlayerMixin extends AbstractClientPlayer {
public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) {
super(clientLevel, gameProfile);
public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile, ProfilePublicKey profilePublicKey) {
super(clientLevel, gameProfile, profilePublicKey);
}

@Inject(method = "tick", at = @At("HEAD"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import net.minecraft.nbt.StringTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.zestyblaze.nomadbooks.NomadBooks;
Expand All @@ -33,11 +33,11 @@ public abstract class ServerPlayerMixin extends Player {

@Shadow public abstract void displayClientMessage(@NotNull Component chatComponent, boolean actionBar);

public ServerPlayerMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile) {
super(level, blockPos, f, gameProfile);
public ServerPlayerMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile, ProfilePublicKey profilePublicKey) {
super(level, blockPos, f, gameProfile, profilePublicKey);
}

@Inject(method = "doTick", at = @At(value = "FIELD", target = "Lnet/minecraft/advancements/CriteriaTriggers;LOCATION:Lnet/minecraft/advancements/critereon/LocationTrigger;"))
@Inject(method = "doTick", at = @At(value = "FIELD", target = "Lnet/minecraft/advancements/CriteriaTriggers;LOCATION:Lnet/minecraft/advancements/critereon/PlayerTrigger;"))
private void enterBiome(CallbackInfo info) {
for(int i = 0; i < this.getInventory().getContainerSize(); ++i) {
ItemStack itemStack = this.getInventory().getItem(i);
Expand Down Expand Up @@ -69,7 +69,7 @@ private void enterBiome(CallbackInfo info) {
tags.put("CampPos", NbtUtils.writeBlockPos(pos));
// show a chat message to the player
this.playNotifySound(SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 0.1f, 0.75f);
this.displayClientMessage(new TranslatableComponent("info.nomadbooks.itinerant_ink_done", tags.getInt("Width")).setStyle(Style.EMPTY.withColor(ChatFormatting.BLUE)), false);
this.displayClientMessage(Component.translatable("info.nomadbooks.itinerant_ink_done", tags.getInt("Width")).setStyle(Style.EMPTY.withColor(ChatFormatting.BLUE)), false);
} else {
visitedBiomes.add(biome);
tags.put("VisitedBiomes", visitedBiomes);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"depends": {
"fabricloader": ">=0.12.12",
"fabric": "*",
"minecraft": "1.18.x",
"minecraft": "1.19.2",
"java": ">=17"
}
}