diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 341000c0..d08fffc4 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -14,30 +14,30 @@ jobs: with: fetch-depth: 0 fetch-tags: true - - name: Set up JDK 21 - uses: actions/setup-java@v3 - with: - java-version: '21' - distribution: 'oracle' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - name: Publish - run: ./gradlew publish - env: - MAVEN_USER: ${{ secrets.MAVEN_USER }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - BUILD_NUMBER: ${{ github.run_number }} - - name: CurseForge Publish - run: ./gradlew curseforge -PcurseApiKey=${CURSE_API_KEY} - env: - CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} - BUILD_NUMBER: ${{ github.run_number }} - continue-on-error: true - - name: Modrinth Publish - run: ./gradlew modrinth -PmodrinthToken=${MODRINTH_TOKEN} - env: - MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} - BUILD_NUMBER: ${{ github.run_number }} - continue-on-error: true +# - name: Set up JDK 21 +# uses: actions/setup-java@v3 +# with: +# java-version: '21' +# distribution: 'oracle' +# server-id: github # Value of the distributionManagement/repository/id field of the pom.xml +# settings-path: ${{ github.workspace }} # location for the settings.xml file +# - name: Setup Gradle +# uses: gradle/gradle-build-action@v2 +# - name: Publish +# run: ./gradlew publish +# env: +# MAVEN_USER: ${{ secrets.MAVEN_USER }} +# MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} +# BUILD_NUMBER: ${{ github.run_number }} +# - name: CurseForge Publish +# run: ./gradlew curseforge -PcurseApiKey=${CURSE_API_KEY} +# env: +# CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} +# BUILD_NUMBER: ${{ github.run_number }} +# continue-on-error: true +# - name: Modrinth Publish +# run: ./gradlew modrinth -PmodrinthToken=${MODRINTH_TOKEN} +# env: +# MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} +# BUILD_NUMBER: ${{ github.run_number }} +# continue-on-error: true diff --git a/build.gradle b/build.gradle index e4017d37..570a0718 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,15 @@ ext { } } +allprojects { + // Allow 400 errors. + gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xmaxerrs" << "400" + } + } +} + subprojects { apply plugin: 'java' apply plugin: 'idea' diff --git a/common/src/main/java/toughasnails/api/crafting/TANRecipeBookCategories.java b/common/src/main/java/toughasnails/api/crafting/TANRecipeBookCategories.java new file mode 100644 index 00000000..25c8baef --- /dev/null +++ b/common/src/main/java/toughasnails/api/crafting/TANRecipeBookCategories.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2024, the Glitchfiend Team. + * All rights reserved. + ******************************************************************************/ +package toughasnails.api.crafting; + +import net.minecraft.world.item.crafting.RecipeBookCategory; + +public class TANRecipeBookCategories +{ + public static RecipeBookCategory WATER_PURIFYING; +} diff --git a/common/src/main/java/toughasnails/api/crafting/TANRecipeSerializers.java b/common/src/main/java/toughasnails/api/crafting/TANRecipeSerializers.java index cff61c42..12f42ed7 100644 --- a/common/src/main/java/toughasnails/api/crafting/TANRecipeSerializers.java +++ b/common/src/main/java/toughasnails/api/crafting/TANRecipeSerializers.java @@ -4,9 +4,11 @@ ******************************************************************************/ package toughasnails.api.crafting; +import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.SingleRecipeInput; public class TANRecipeSerializers { - public static RecipeSerializer WATER_PURIFYING; + public static RecipeSerializer> WATER_PURIFYING; } diff --git a/common/src/main/java/toughasnails/api/crafting/TANRecipeTypes.java b/common/src/main/java/toughasnails/api/crafting/TANRecipeTypes.java index a35615b2..aebf49ea 100644 --- a/common/src/main/java/toughasnails/api/crafting/TANRecipeTypes.java +++ b/common/src/main/java/toughasnails/api/crafting/TANRecipeTypes.java @@ -4,9 +4,11 @@ ******************************************************************************/ package toughasnails.api.crafting; +import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SingleRecipeInput; public class TANRecipeTypes { - public static RecipeType WATER_PURIFYING; + public static RecipeType> WATER_PURIFYING; } diff --git a/common/src/main/java/toughasnails/block/RainCollectorBlock.java b/common/src/main/java/toughasnails/block/RainCollectorBlock.java index 84b8b7ec..4d4c6da3 100644 --- a/common/src/main/java/toughasnails/block/RainCollectorBlock.java +++ b/common/src/main/java/toughasnails/block/RainCollectorBlock.java @@ -11,7 +11,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -48,10 +47,10 @@ public VoxelShape getShape(BlockState p_151964_, BlockGetter p_151965_, BlockPos } @Override - protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) + protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { if (stack.isEmpty() || stack.getItem() != Items.GLASS_BOTTLE) - return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + return InteractionResult.PASS; int waterLevel = state.getValue(LEVEL); @@ -72,7 +71,7 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev this.setWaterLevel(worldIn, pos, state, waterLevel - 1); } - return ItemInteractionResult.sidedSuccess(worldIn.isClientSide); + return InteractionResult.SUCCESS; } public void setWaterLevel(Level world, BlockPos pos, BlockState state, int level) diff --git a/common/src/main/java/toughasnails/block/ThermoregulatorBlock.java b/common/src/main/java/toughasnails/block/ThermoregulatorBlock.java index c19aefc5..bb7814ac 100644 --- a/common/src/main/java/toughasnails/block/ThermoregulatorBlock.java +++ b/common/src/main/java/toughasnails/block/ThermoregulatorBlock.java @@ -24,7 +24,8 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.redstone.Orientation; import net.minecraft.world.phys.BlockHitResult; import toughasnails.api.blockentity.TANBlockEntityTypes; import toughasnails.api.particle.TANParticles; @@ -36,7 +37,7 @@ public class ThermoregulatorBlock extends BaseEntityBlock { public static final MapCodec CODEC = simpleCodec(WaterPurifierBlock::new); - public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; + public static final EnumProperty FACING = HorizontalDirectionalBlock.FACING; public static final BooleanProperty COOLING = BooleanProperty.create("cooling"); public static final BooleanProperty HEATING = BooleanProperty.create("heating"); public static final BooleanProperty ENABLED = BlockStateProperties.ENABLED; @@ -133,7 +134,7 @@ public void onPlace(BlockState state, Level level, BlockPos $$2, BlockState $$3, } @Override - public void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, BlockPos neighborPos, boolean movedByPiston) + public void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, Orientation orientation, boolean movedByPiston) { this.checkPoweredState(level, pos, state); } diff --git a/common/src/main/java/toughasnails/block/WaterPurifierBlock.java b/common/src/main/java/toughasnails/block/WaterPurifierBlock.java index 931819f4..e207644e 100644 --- a/common/src/main/java/toughasnails/block/WaterPurifierBlock.java +++ b/common/src/main/java/toughasnails/block/WaterPurifierBlock.java @@ -26,7 +26,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.phys.BlockHitResult; import toughasnails.api.blockentity.TANBlockEntityTypes; import toughasnails.block.entity.WaterPurifierBlockEntity; @@ -36,7 +36,7 @@ public class WaterPurifierBlock extends BaseEntityBlock { public static final MapCodec CODEC = simpleCodec(WaterPurifierBlock::new); - public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; + public static final EnumProperty FACING = HorizontalDirectionalBlock.FACING; public static final BooleanProperty PURIFYING = BooleanProperty.create("filtering"); public WaterPurifierBlock(Properties builderIn) diff --git a/common/src/main/java/toughasnails/block/entity/ThermoregulatorBlockEntity.java b/common/src/main/java/toughasnails/block/entity/ThermoregulatorBlockEntity.java index d33b47a0..68102ac1 100644 --- a/common/src/main/java/toughasnails/block/entity/ThermoregulatorBlockEntity.java +++ b/common/src/main/java/toughasnails/block/entity/ThermoregulatorBlockEntity.java @@ -185,8 +185,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Therm if (fuel.isEmpty()) { - Item remainingItem = fuelItem.getCraftingRemainingItem(); - blockEntity.items.set(SLOT_COOLING, remainingItem == null ? ItemStack.EMPTY : new ItemStack(remainingItem)); + blockEntity.items.set(SLOT_COOLING, fuelItem.getCraftingRemainder()); } } } @@ -204,8 +203,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Therm if (fuel.isEmpty()) { - Item remainingItem = fuelItem.getCraftingRemainingItem(); - blockEntity.items.set(SLOT_HEATING, remainingItem == null ? ItemStack.EMPTY : new ItemStack(remainingItem)); + blockEntity.items.set(SLOT_HEATING, fuelItem.getCraftingRemainder()); } } } diff --git a/common/src/main/java/toughasnails/block/entity/WaterPurifierBlockEntity.java b/common/src/main/java/toughasnails/block/entity/WaterPurifierBlockEntity.java index adfb3219..04a87c20 100644 --- a/common/src/main/java/toughasnails/block/entity/WaterPurifierBlockEntity.java +++ b/common/src/main/java/toughasnails/block/entity/WaterPurifierBlockEntity.java @@ -9,6 +9,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.util.Mth; @@ -21,17 +22,14 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.item.crafting.SingleRecipeInput; +import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BaseContainerBlockEntity; import net.minecraft.world.level.block.state.BlockState; import toughasnails.api.blockentity.TANBlockEntityTypes; import toughasnails.api.crafting.TANRecipeTypes; import toughasnails.block.WaterPurifierBlock; -import toughasnails.container.WaterPurifierContainer; +import toughasnails.container.WaterPurifierMenu; import toughasnails.crafting.WaterPurifierRecipe; import javax.annotation.Nullable; @@ -60,6 +58,8 @@ public class WaterPurifierBlockEntity extends BaseContainerBlockEntity implement /** The total time needed to complete purification. */ private int purifyTotalTime; + private final RecipeManager.CachedCheck> quickCheck; + protected final ContainerData dataAccess = new ContainerData() { @Override @@ -108,6 +108,7 @@ public int getCount() public WaterPurifierBlockEntity(BlockPos pos, BlockState state) { super(TANBlockEntityTypes.WATER_PURIFIER, pos, state); + this.quickCheck = RecipeManager.createCheck(TANRecipeTypes.WATER_PURIFYING); } @Override @@ -146,7 +147,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Water ItemStack filterStack = blockEntity.items.get(1); boolean hasFilter = !filterStack.isEmpty(); if (blockEntity.isFiltering() || hasFilter && !blockEntity.items.get(0).isEmpty()) { - RecipeHolder recipe = blockEntity.level.getRecipeManager().getRecipeFor((RecipeType) TANRecipeTypes.WATER_PURIFYING, new SingleRecipeInput(blockEntity.items.get(0)), blockEntity.level).orElse(null); + RecipeHolder> recipe = blockEntity.quickCheck.getRecipeFor(new SingleRecipeInput(blockEntity.items.get(0)), (ServerLevel)level).orElse(null); if (recipe != null) { @@ -164,8 +165,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Water filterStack.shrink(1); if (filterStack.isEmpty()) { - Item remainingItem = filter.getCraftingRemainingItem(); - blockEntity.items.set(1, remainingItem == null ? ItemStack.EMPTY : new ItemStack(remainingItem)); + blockEntity.items.set(1, filter.getCraftingRemainder()); } } } @@ -202,7 +202,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Water @Override protected AbstractContainerMenu createMenu(int id, Inventory player) { - return new WaterPurifierContainer(id, player, this, this.dataAccess); + return new WaterPurifierMenu(id, player, this, this.dataAccess); } @Override @@ -342,11 +342,12 @@ public boolean isFiltering() return this.filterTimeRemaining > 0; } - protected boolean canFilter(@Nullable Recipe recipe) + protected boolean canFilter(@Nullable Recipe recipe) { if (!this.items.get(0).isEmpty() && recipe != null) { - ItemStack recipeResult = recipe.getResultItem(this.level.registryAccess()); + ItemStack input = this.items.get(0); + ItemStack recipeResult = recipe.assemble(new SingleRecipeInput(input), this.level.registryAccess()); // Invalid recipe result if (recipeResult.isEmpty()) @@ -377,15 +378,16 @@ protected boolean canFilter(@Nullable Recipe recipe) /** Get the time taken for an input item to be purified. */ protected int getTotalPurifyTime() { - return this.level.getRecipeManager().getRecipeFor((RecipeType) TANRecipeTypes.WATER_PURIFYING, new SingleRecipeInput(this.items.get(0)), this.level).map(r -> r.value().getPurifyTime()).orElse(200); + SingleRecipeInput singlerecipeinput = new SingleRecipeInput(this.items.get(0)); + return this.quickCheck.getRecipeFor(singlerecipeinput, (ServerLevel)this.level).map(p_379263_ -> ((WaterPurifierRecipe)p_379263_.value()).getPurifyTime()).orElse(200); } - private void filter(@Nullable Recipe recipe) + private void filter(@Nullable Recipe recipe) { if (recipe != null && this.canFilter(recipe)) { ItemStack input = this.items.get(0); - ItemStack recipeResult = recipe.getResultItem(this.level.registryAccess()); + ItemStack recipeResult = recipe.assemble(new SingleRecipeInput(input), this.level.registryAccess()); ItemStack currentResult = this.items.get(2); // Update the result stuck diff --git a/common/src/main/java/toughasnails/client/gui/ThermoregulatorScreen.java b/common/src/main/java/toughasnails/client/gui/ThermoregulatorScreen.java index 981dd8d3..bd9d6243 100644 --- a/common/src/main/java/toughasnails/client/gui/ThermoregulatorScreen.java +++ b/common/src/main/java/toughasnails/client/gui/ThermoregulatorScreen.java @@ -6,12 +6,12 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import toughasnails.api.TANAPI; import toughasnails.container.ThermoregulatorContainer; -import toughasnails.container.WaterPurifierContainer; public class ThermoregulatorScreen extends AbstractContainerScreen { @@ -42,18 +42,18 @@ protected void renderBg(GuiGraphics gui, float partialTicks, int mouseX, int mou { int leftPos = this.leftPos; int topPos = this.topPos; - gui.blit(TEXTURE, leftPos, topPos, 0, 0, this.imageWidth, this.imageHeight); + gui.blit(RenderType::guiTextured, TEXTURE, leftPos, topPos, 0, 0, this.imageWidth, this.imageHeight, 256, 256); if (this.menu.isCooling()) { int progress = this.menu.getCoolingFuelProgress(); - gui.blit(TEXTURE, leftPos + 44 + 1, topPos + 25 + 13 - progress, 176, 13 - progress, 14, progress + 1); + gui.blit(RenderType::guiTextured, TEXTURE, leftPos + 44 + 1, topPos + 25 + 13 - progress, 176, 13 - progress, 14, progress + 1, 256, 256); } if (this.menu.isHeating()) { int progress = this.menu.getHeatingFuelProgress(); - gui.blit(TEXTURE, leftPos + 116 + 1, topPos + 25 + 13 - progress, 176, 27 - progress, 14, progress + 1); + gui.blit(RenderType::guiTextured, TEXTURE, leftPos + 116 + 1, topPos + 25 + 13 - progress, 176, 27 - progress, 14, progress + 1, 256, 256); } } } diff --git a/common/src/main/java/toughasnails/client/gui/WaterPurifierScreen.java b/common/src/main/java/toughasnails/client/gui/WaterPurifierScreen.java index 45a06176..d0b2b3e4 100644 --- a/common/src/main/java/toughasnails/client/gui/WaterPurifierScreen.java +++ b/common/src/main/java/toughasnails/client/gui/WaterPurifierScreen.java @@ -6,17 +6,18 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import toughasnails.api.TANAPI; -import toughasnails.container.WaterPurifierContainer; +import toughasnails.container.WaterPurifierMenu; -public class WaterPurifierScreen extends AbstractContainerScreen +public class WaterPurifierScreen extends AbstractContainerScreen { private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(TANAPI.MOD_ID, "textures/gui/container/water_purifier.png"); - public WaterPurifierScreen(WaterPurifierContainer screenContainer, Inventory inv, Component titleIn) + public WaterPurifierScreen(WaterPurifierMenu screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); } @@ -41,7 +42,7 @@ protected void renderBg(GuiGraphics gui, float partialTicks, int mouseX, int mou { int leftPos = this.leftPos; int topPos = this.topPos; - gui.blit(TEXTURE, leftPos, topPos, 0, 0, this.imageWidth, this.imageHeight); + gui.blit(RenderType::guiTextured, TEXTURE, leftPos, topPos, 0, 0, this.imageWidth, this.imageHeight, 256, 256); if (this.menu.isFiltering()) { @@ -49,10 +50,10 @@ protected void renderBg(GuiGraphics gui, float partialTicks, int mouseX, int mou // NOTE: This is moved over right by 1 compared to the furnace // stack, x, y, u, v, width, height - gui.blit(TEXTURE, leftPos + 56 + 1, topPos + 36 + 13 - filterProgress, 176, 13 - filterProgress, 14, filterProgress + 1); + gui.blit(RenderType::guiTextured, TEXTURE, leftPos + 56 + 1, topPos + 36 + 13 - filterProgress, 176, 13 - filterProgress, 14, filterProgress + 1, 256, 256); } int purifyProgress = this.menu.getPurifyProgress(); - gui.blit(TEXTURE, leftPos + 79, topPos + 34, 176, 14, purifyProgress + 1, 16); + gui.blit(RenderType::guiTextured, TEXTURE, leftPos + 79, topPos + 34, 176, 14, purifyProgress + 1, 16, 256, 256); } } diff --git a/common/src/main/java/toughasnails/client/handler/TooltipHandler.java b/common/src/main/java/toughasnails/client/handler/TooltipHandler.java index 4b31d60f..821ee05e 100644 --- a/common/src/main/java/toughasnails/client/handler/TooltipHandler.java +++ b/common/src/main/java/toughasnails/client/handler/TooltipHandler.java @@ -12,14 +12,14 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.client.renderer.RenderType; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.armortrim.ArmorTrim; -import net.minecraft.world.item.armortrim.TrimMaterial; -import net.minecraft.world.item.armortrim.TrimMaterials; +import net.minecraft.world.item.equipment.trim.TrimMaterial; +import net.minecraft.world.item.equipment.trim.TrimMaterials; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import toughasnails.init.ModConfig; @@ -115,7 +115,7 @@ private ThirstClientTooltipComponent(int amount) } @Override - public int getHeight() + public int getHeight(Font font) { return 9; } @@ -127,7 +127,7 @@ public int getWidth(Font font) } @Override - public void renderImage(Font font, int x, int y, GuiGraphics gui) + public void renderImage(Font font, int x, int y, int width, int height, GuiGraphics gui) { gui.pose().pushPose(); @@ -142,11 +142,11 @@ public void renderImage(Font font, int x, int y, GuiGraphics gui) // Draw a full droplet if (this.amount > dropletHalf) { - gui.blit(ThirstOverlayRenderer.OVERLAY, startX, startY, 0, 41, 8, 8, 256, 256); + gui.blit(RenderType::guiTextured, ThirstOverlayRenderer.OVERLAY, startX, startY, 0, 41, 8, 8, 256, 256); } else if (this.amount == dropletHalf) // Draw a half droplet { - gui.blit(ThirstOverlayRenderer.OVERLAY, startX, startY, 8, 41, 8, 8, 256, 256); + gui.blit(RenderType::guiTextured, ThirstOverlayRenderer.OVERLAY, startX, startY, 8, 41, 8, 8, 256, 256); } } diff --git a/common/src/main/java/toughasnails/container/WaterPurifierFilterSlot.java b/common/src/main/java/toughasnails/container/WaterPurifierFilterSlot.java index b412a9e5..0a1a2b42 100644 --- a/common/src/main/java/toughasnails/container/WaterPurifierFilterSlot.java +++ b/common/src/main/java/toughasnails/container/WaterPurifierFilterSlot.java @@ -10,9 +10,9 @@ public class WaterPurifierFilterSlot extends Slot { - private final WaterPurifierContainer menu; + private final WaterPurifierMenu menu; - public WaterPurifierFilterSlot(WaterPurifierContainer container, Container inventory, int index, int xPosition, int yPosition) + public WaterPurifierFilterSlot(WaterPurifierMenu container, Container inventory, int index, int xPosition, int yPosition) { super(inventory, index, xPosition, yPosition); this.menu = container; diff --git a/common/src/main/java/toughasnails/container/WaterPurifierContainer.java b/common/src/main/java/toughasnails/container/WaterPurifierMenu.java similarity index 89% rename from common/src/main/java/toughasnails/container/WaterPurifierContainer.java rename to common/src/main/java/toughasnails/container/WaterPurifierMenu.java index 92cb55df..bf4a94b7 100644 --- a/common/src/main/java/toughasnails/container/WaterPurifierContainer.java +++ b/common/src/main/java/toughasnails/container/WaterPurifierMenu.java @@ -4,6 +4,7 @@ ******************************************************************************/ package toughasnails.container; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; @@ -13,31 +14,32 @@ import net.minecraft.world.inventory.SimpleContainerData; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.item.crafting.SingleRecipeInput; +import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import toughasnails.api.crafting.TANRecipeTypes; import toughasnails.api.container.TANContainerTypes; import toughasnails.block.entity.WaterPurifierBlockEntity; import toughasnails.crafting.WaterPurifierRecipe; -public class WaterPurifierContainer extends AbstractContainerMenu +public class WaterPurifierMenu extends AbstractContainerMenu { private final Container container; private final ContainerData data; private final Level level; + private final RecipeManager.CachedCheck> quickCheck; - public WaterPurifierContainer(int id, Inventory playerInventory) + public WaterPurifierMenu(int id, Inventory playerInventory) { this(id, playerInventory, new SimpleContainer(3), new SimpleContainerData(4)); } - public WaterPurifierContainer(int id, Inventory playerInventory, Container container, ContainerData data) + public WaterPurifierMenu(int id, Inventory playerInventory, Container container, ContainerData data) { super(TANContainerTypes.WATER_PURIFIER, id); this.container = container; this.data = data; this.level = playerInventory.player.level(); + this.quickCheck = RecipeManager.createCheck(TANRecipeTypes.WATER_PURIFYING); // Add input item slot this.addSlot(new Slot(container, 0, 56, 17)); @@ -147,7 +149,7 @@ else if (!this.moveItemStackTo(slotItem, 3, 39, false)) // Move from purifier to protected boolean canPurify(ItemStack stack) { - return this.level.getRecipeManager().getRecipeFor((RecipeType)TANRecipeTypes.WATER_PURIFYING, new SingleRecipeInput(stack), this.level).isPresent(); + return this.quickCheck.getRecipeFor(new SingleRecipeInput(stack), (ServerLevel)this.level).isPresent(); } protected boolean isFilter(ItemStack stack) diff --git a/common/src/main/java/toughasnails/core/ToughAsNails.java b/common/src/main/java/toughasnails/core/ToughAsNails.java index 5ba1f022..47176d6f 100644 --- a/common/src/main/java/toughasnails/core/ToughAsNails.java +++ b/common/src/main/java/toughasnails/core/ToughAsNails.java @@ -57,6 +57,7 @@ private static void addRegistrars() regHelper.addRegistrar(Registries.BLOCK_ENTITY_TYPE, ModBlockEntities::registerBlockEntities); regHelper.addRegistrar(Registries.RECIPE_SERIALIZER, ModCrafting::registerRecipeSerializers); regHelper.addRegistrar(Registries.RECIPE_TYPE, ModCrafting::registerRecipeTypes); + regHelper.addRegistrar(Registries.RECIPE_BOOK_CATEGORY, ModCrafting::registerRecipeBookCategories); regHelper.addRegistrar(Registries.MOB_EFFECT, ModPotions::registerEffects); regHelper.addRegistrar(Registries.POTION, ModPotions::registerPotions); regHelper.addRegistrar(Registries.CREATIVE_MODE_TAB, ModCreativeTab::registerCreativeTabs); diff --git a/common/src/main/java/toughasnails/crafting/WaterPurifierRecipe.java b/common/src/main/java/toughasnails/crafting/WaterPurifierRecipe.java index dac35e4e..6d7910bf 100644 --- a/common/src/main/java/toughasnails/crafting/WaterPurifierRecipe.java +++ b/common/src/main/java/toughasnails/crafting/WaterPurifierRecipe.java @@ -14,19 +14,21 @@ import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.item.crafting.SingleRecipeInput; +import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; +import toughasnails.api.crafting.TANRecipeBookCategories; import toughasnails.api.crafting.TANRecipeSerializers; import toughasnails.api.crafting.TANRecipeTypes; +import javax.annotation.Nullable; + public class WaterPurifierRecipe implements Recipe { protected final ItemStack input; protected final ItemStack result; protected final int purifyTime; + @Nullable + private PlacementInfo placementInfo; public WaterPurifierRecipe(ItemStack input, ItemStack result, int purifyTime) { @@ -51,26 +53,35 @@ public ItemStack assemble(SingleRecipeInput var1, HolderLookup.Provider var2) return this.result.copy(); } + protected ItemStack result() + { + return this.result; + } + @Override - public boolean canCraftInDimensions(int width, int height) + public PlacementInfo placementInfo() { - return true; + if (this.placementInfo == null) { + this.placementInfo = PlacementInfo.create(Ingredient.of(this.input.getItem())); + } + + return this.placementInfo; } @Override - public ItemStack getResultItem(HolderLookup.Provider lookup) + public RecipeBookCategory recipeBookCategory() { - return this.result; + return TANRecipeBookCategories.WATER_PURIFYING; } @Override - public RecipeSerializer getSerializer() + public RecipeSerializer> getSerializer() { return TANRecipeSerializers.WATER_PURIFYING; } @Override - public RecipeType getType() + public RecipeType> getType() { return TANRecipeTypes.WATER_PURIFYING; } diff --git a/common/src/main/java/toughasnails/init/ModArmorMaterials.java b/common/src/main/java/toughasnails/init/ModArmorMaterials.java index 962d4024..b7aa2443 100644 --- a/common/src/main/java/toughasnails/init/ModArmorMaterials.java +++ b/common/src/main/java/toughasnails/init/ModArmorMaterials.java @@ -1,41 +1,28 @@ package toughasnails.init; import net.minecraft.Util; -import net.minecraft.core.Holder; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.crafting.Ingredient; -import toughasnails.core.ToughAsNails; +import net.minecraft.world.item.equipment.ArmorMaterial; +import net.minecraft.world.item.equipment.ArmorType; import java.util.EnumMap; -import java.util.List; -import java.util.function.Supplier; public class ModArmorMaterials { - public static Holder WOOL = register("wool", Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> { - map.put(ArmorItem.Type.BOOTS, 1); - map.put(ArmorItem.Type.LEGGINGS, 1); - map.put(ArmorItem.Type.CHESTPLATE, 1); - map.put(ArmorItem.Type.HELMET, 1); - }), 1, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> Ingredient.of(ItemTags.WOOL), true); + public static final ArmorMaterial WOOL = new ArmorMaterial(5, Util.make(new EnumMap<>(ArmorType.class), map -> { + map.put(ArmorType.BOOTS, 1); + map.put(ArmorType.LEGGINGS, 1); + map.put(ArmorType.CHESTPLATE, 1); + map.put(ArmorType.HELMET, 1); + }), 1, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, ItemTags.WOOL, ModEquipmentModels.WOOL); - public static Holder LEAF = register("leaf", Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> { - map.put(ArmorItem.Type.BOOTS, 1); - map.put(ArmorItem.Type.LEGGINGS, 1); - map.put(ArmorItem.Type.CHESTPLATE, 1); - map.put(ArmorItem.Type.HELMET, 1); - }), 1, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> Ingredient.of(ItemTags.LEAVES), true); - - private static Holder register(String name, EnumMap map, int enchantmentValue, Holder equipSound, float toughness, float knockbackResistance, Supplier repairIngredient, boolean dyeable) - { - List layers = List.of(new ArmorMaterial.Layer(ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, name), "", dyeable)); - return Registry.registerForHolder(BuiltInRegistries.ARMOR_MATERIAL, ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, name), new ArmorMaterial(map, enchantmentValue, equipSound, repairIngredient, layers, toughness, knockbackResistance)); - } + public static ArmorMaterial LEAF = new ArmorMaterial(5, Util.make(new EnumMap<>(ArmorType.class), (map) -> { + map.put(ArmorType.BOOTS, 1); + map.put(ArmorType.LEGGINGS, 1); + map.put(ArmorType.CHESTPLATE, 1); + map.put(ArmorType.HELMET, 1); + }), 1, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, ItemTags.LEAVES, ModEquipmentModels.LEAF); } diff --git a/common/src/main/java/toughasnails/init/ModBlockEntities.java b/common/src/main/java/toughasnails/init/ModBlockEntities.java index 691dba38..530f0fe0 100644 --- a/common/src/main/java/toughasnails/init/ModBlockEntities.java +++ b/common/src/main/java/toughasnails/init/ModBlockEntities.java @@ -4,36 +4,34 @@ ******************************************************************************/ package toughasnails.init; -import com.mojang.datafixers.types.Type; -import glitchcore.event.RegistryEvent; -import net.minecraft.Util; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.datafix.fixes.References; -import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import toughasnails.api.TANAPI; import toughasnails.api.block.TANBlocks; import toughasnails.api.blockentity.TANBlockEntityTypes; import toughasnails.block.entity.TemperatureGaugeBlockEntity; import toughasnails.block.entity.ThermoregulatorBlockEntity; import toughasnails.block.entity.WaterPurifierBlockEntity; +import toughasnails.core.ToughAsNails; +import java.util.Set; import java.util.function.BiConsumer; public class ModBlockEntities { public static void registerBlockEntities(BiConsumer> func) { - TANBlockEntityTypes.WATER_PURIFIER = register(func, "water_purifier", BlockEntityType.Builder.of(WaterPurifierBlockEntity::new, TANBlocks.WATER_PURIFIER)); - TANBlockEntityTypes.TEMPERATURE_GAUGE = register(func, "temperature_gauge", BlockEntityType.Builder.of(TemperatureGaugeBlockEntity::new, TANBlocks.TEMPERATURE_GAUGE)); - TANBlockEntityTypes.THERMOREGULATOR = register(func, "thermoregulator", BlockEntityType.Builder.of(ThermoregulatorBlockEntity::new, TANBlocks.THERMOREGULATOR)); + TANBlockEntityTypes.WATER_PURIFIER = register(func, "water_purifier", WaterPurifierBlockEntity::new, Set.of(TANBlocks.WATER_PURIFIER)); + TANBlockEntityTypes.TEMPERATURE_GAUGE = register(func, "temperature_gauge", TemperatureGaugeBlockEntity::new, Set.of(TANBlocks.TEMPERATURE_GAUGE)); + TANBlockEntityTypes.THERMOREGULATOR = register(func, "thermoregulator", ThermoregulatorBlockEntity::new, Set.of(TANBlocks.THERMOREGULATOR)); } - private static BlockEntityType register(BiConsumer> func, String name, BlockEntityType.Builder builder) + + private static BlockEntityType register(BiConsumer> func, String name, BlockEntityType.BlockEntitySupplier supplier, Set blocks) { - var type = builder.build(Util.fetchChoiceType(References.BLOCK_ENTITY, name)); - func.accept(ResourceLocation.fromNamespaceAndPath(TANAPI.MOD_ID, name), type); + var type = new BlockEntityType(supplier, blocks); + func.accept(ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, name), type); return type; } } diff --git a/common/src/main/java/toughasnails/init/ModBlocks.java b/common/src/main/java/toughasnails/init/ModBlocks.java index 9e846829..1e488130 100644 --- a/common/src/main/java/toughasnails/init/ModBlocks.java +++ b/common/src/main/java/toughasnails/init/ModBlocks.java @@ -4,6 +4,8 @@ ******************************************************************************/ package toughasnails.init; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.CaveVines; @@ -17,23 +19,36 @@ import toughasnails.block.TemperatureGaugeBlock; import toughasnails.block.ThermoregulatorBlock; import toughasnails.block.WaterPurifierBlock; +import toughasnails.core.ToughAsNails; import java.util.function.BiConsumer; +import java.util.function.Function; public class ModBlocks { public static void registerBlocks(BiConsumer func) { - TANBlocks.THERMOREGULATOR = register(func, "thermoregulator", new ThermoregulatorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.5F).lightLevel(ThermoregulatorBlock.lightLevel(6)))); - TANBlocks.TEMPERATURE_GAUGE = register(func, "temperature_gauge", new TemperatureGaugeBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(1.0F))); - TANBlocks.RAIN_COLLECTOR = register(func, "rain_collector", new RainCollectorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).instrument(NoteBlockInstrument.BASS).strength(2.5F).sound(SoundType.WOOD).noOcclusion())); - TANBlocks.WATER_PURIFIER = register(func, "water_purifier", new WaterPurifierBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).requiresCorrectToolForDrops().strength(2.5F).sound(SoundType.WOOD).noOcclusion())); + TANBlocks.THERMOREGULATOR = register(func, "thermoregulator", ThermoregulatorBlock::new, BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.5F).lightLevel(ThermoregulatorBlock.lightLevel(6))); + TANBlocks.TEMPERATURE_GAUGE = register(func, "temperature_gauge", TemperatureGaugeBlock::new, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).requiresCorrectToolForDrops().strength(1.0F)); + TANBlocks.RAIN_COLLECTOR = register(func, "rain_collector", RainCollectorBlock::new, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).instrument(NoteBlockInstrument.BASS).strength(2.5F).sound(SoundType.WOOD).noOcclusion()); + TANBlocks.WATER_PURIFIER = register(func, "water_purifier", WaterPurifierBlock::new, BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).requiresCorrectToolForDrops().strength(2.5F).sound(SoundType.WOOD).noOcclusion()); } - private static Block register(BiConsumer func, String name, Block block) + private static Block register(BiConsumer func, ResourceKey key, Function factory, BlockBehaviour.Properties properties) { - func.accept(ResourceLocation.fromNamespaceAndPath(TANAPI.MOD_ID, name), block); + Block block = factory.apply(properties.setId(key)); + func.accept(key.location(), block); return block; } + + private static Block register(BiConsumer func, String name, Function factory, BlockBehaviour.Properties properties) + { + return register(func, blockId(name), factory, properties); + } + + private static ResourceKey blockId(String name) + { + return ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, name)); + } } diff --git a/common/src/main/java/toughasnails/init/ModCompatibility.java b/common/src/main/java/toughasnails/init/ModCompatibility.java index f186ae02..70087403 100644 --- a/common/src/main/java/toughasnails/init/ModCompatibility.java +++ b/common/src/main/java/toughasnails/init/ModCompatibility.java @@ -31,7 +31,7 @@ public static void init() public static boolean coldEnoughToSnowSeasonal(Level level, Holder biome, BlockPos pos) { - return SeasonHooks.coldEnoughToSnowSeasonal(level, biome, pos); + return SeasonHooks.coldEnoughToSnowSeasonal(level, pos, level.getSeaLevel()); } private static TemperatureLevel seasonModifier(Level level, BlockPos pos, TemperatureLevel current) diff --git a/common/src/main/java/toughasnails/init/ModContainerTypes.java b/common/src/main/java/toughasnails/init/ModContainerTypes.java index 47ae5509..2ad44186 100644 --- a/common/src/main/java/toughasnails/init/ModContainerTypes.java +++ b/common/src/main/java/toughasnails/init/ModContainerTypes.java @@ -15,7 +15,7 @@ import toughasnails.client.gui.ThermoregulatorScreen; import toughasnails.client.gui.WaterPurifierScreen; import toughasnails.container.ThermoregulatorContainer; -import toughasnails.container.WaterPurifierContainer; +import toughasnails.container.WaterPurifierMenu; import java.util.function.BiConsumer; @@ -23,12 +23,12 @@ public class ModContainerTypes { public static void registerContainers(BiConsumer> func) { - TANContainerTypes.WATER_PURIFIER = register(func, "water_purifier", WaterPurifierContainer::new); + TANContainerTypes.WATER_PURIFIER = register(func, "water_purifier", WaterPurifierMenu::new); TANContainerTypes.THERMOREGULATOR = register(func, "thermoregulator", ThermoregulatorContainer::new); if (Environment.isClient()) { - MenuScreens.register((MenuType) TANContainerTypes.WATER_PURIFIER, WaterPurifierScreen::new); + MenuScreens.register((MenuType) TANContainerTypes.WATER_PURIFIER, WaterPurifierScreen::new); MenuScreens.register((MenuType) TANContainerTypes.THERMOREGULATOR, ThermoregulatorScreen::new); } } diff --git a/common/src/main/java/toughasnails/init/ModCrafting.java b/common/src/main/java/toughasnails/init/ModCrafting.java index 14007d1d..755400a5 100644 --- a/common/src/main/java/toughasnails/init/ModCrafting.java +++ b/common/src/main/java/toughasnails/init/ModCrafting.java @@ -5,17 +5,11 @@ package toughasnails.init; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.alchemy.Potion; -import net.minecraft.world.item.alchemy.PotionBrewing; -import net.minecraft.world.item.alchemy.Potions; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.*; import toughasnails.api.TANAPI; +import toughasnails.api.crafting.TANRecipeBookCategories; import toughasnails.api.crafting.TANRecipeSerializers; import toughasnails.api.crafting.TANRecipeTypes; -import toughasnails.api.potion.TANPotions; import toughasnails.crafting.WaterPurifierRecipe; import java.util.function.BiConsumer; @@ -24,12 +18,12 @@ public class ModCrafting { public static void registerRecipeSerializers(BiConsumer> func) { - TANRecipeSerializers.WATER_PURIFYING = registerSerializer(func, "water_purifying", new WaterPurifierRecipe.Serializer()); + TANRecipeSerializers.WATER_PURIFYING = (RecipeSerializer>) registerSerializer(func, "water_purifying", new WaterPurifierRecipe.Serializer()); } public static void registerRecipeTypes(BiConsumer> func) { - TANRecipeTypes.WATER_PURIFYING = registerRecipe(func, "water_purifying", new RecipeType() + TANRecipeTypes.WATER_PURIFYING = (RecipeType>) registerRecipe(func, "water_purifying", new RecipeType() { @Override public String toString() @@ -39,15 +33,26 @@ public String toString() }); } + public static void registerRecipeBookCategories(BiConsumer func) + { + TANRecipeBookCategories.WATER_PURIFYING = registerRecipeBookCategory(func, "water_purifying", new RecipeBookCategory()); + } + private static RecipeSerializer registerSerializer(BiConsumer> func, String name, RecipeSerializer serializer) { func.accept(ResourceLocation.fromNamespaceAndPath(TANAPI.MOD_ID, name), serializer); return serializer; } - private static RecipeType registerRecipe(BiConsumer> func, String name, RecipeType type) + private static RecipeType registerRecipe(BiConsumer> func, String name, RecipeType type) { func.accept(ResourceLocation.fromNamespaceAndPath(TANAPI.MOD_ID, name), type); return type; } + + private static RecipeBookCategory registerRecipeBookCategory(BiConsumer func, String name, RecipeBookCategory category) + { + func.accept(ResourceLocation.fromNamespaceAndPath(TANAPI.MOD_ID, name), category); + return category; + } } diff --git a/common/src/main/java/toughasnails/init/ModEquipmentModels.java b/common/src/main/java/toughasnails/init/ModEquipmentModels.java new file mode 100644 index 00000000..29b20936 --- /dev/null +++ b/common/src/main/java/toughasnails/init/ModEquipmentModels.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright 2024, the Glitchfiend Team. + * All rights reserved. + ******************************************************************************/ +package toughasnails.init; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.equipment.EquipmentModel; +import toughasnails.core.ToughAsNails; + +import java.util.function.BiConsumer; + +public class ModEquipmentModels +{ + public static final ResourceLocation LEAF = ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, "leaf"); + public static final ResourceLocation WOOL = ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, "wool"); + + public static void bootstrap(BiConsumer p_371586_) + { + p_371586_.accept(LEAF, onlyHumanoid("leaf")); + p_371586_.accept(WOOL, onlyHumanoid("wool")); + } + + private static EquipmentModel onlyHumanoid(String name) + { + return EquipmentModel.builder().addHumanoidLayers(ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, name)).build(); + } +} diff --git a/common/src/main/java/toughasnails/init/ModItems.java b/common/src/main/java/toughasnails/init/ModItems.java index 7c3b28c2..557eea0d 100644 --- a/common/src/main/java/toughasnails/init/ModItems.java +++ b/common/src/main/java/toughasnails/init/ModItems.java @@ -5,86 +5,96 @@ package toughasnails.init; import glitchcore.util.Environment; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.Consumables; +import net.minecraft.world.item.equipment.ArmorType; +import net.minecraft.world.level.block.Block; import toughasnails.api.TANAPI; import toughasnails.api.block.TANBlocks; import toughasnails.api.item.TANItems; +import toughasnails.core.ToughAsNails; import toughasnails.item.*; import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; public class ModItems { public static void registerItems(BiConsumer func) { // Block Items - TANItems.THERMOREGULATOR = register(func, "thermoregulator", new BlockItem(TANBlocks.THERMOREGULATOR, new Item.Properties())); - TANItems.TEMPERATURE_GAUGE = register(func, "temperature_gauge", new BlockItem(TANBlocks.TEMPERATURE_GAUGE, new Item.Properties())); - TANItems.RAIN_COLLECTOR = register(func, "rain_collector", new BlockItem(TANBlocks.RAIN_COLLECTOR, new Item.Properties())); - TANItems.WATER_PURIFIER = register(func, "water_purifier", new BlockItem(TANBlocks.WATER_PURIFIER, new Item.Properties())); + TANItems.THERMOREGULATOR = registerBlock(func, TANBlocks.THERMOREGULATOR); + TANItems.TEMPERATURE_GAUGE = registerBlock(func, TANBlocks.TEMPERATURE_GAUGE); + TANItems.RAIN_COLLECTOR = registerBlock(func, TANBlocks.RAIN_COLLECTOR); + TANItems.WATER_PURIFIER = registerBlock(func, TANBlocks.WATER_PURIFIER); // Items - TANItems.THERMOMETER = register(func, "thermometer", new Item(new Item.Properties().stacksTo(1))); - - TANItems.LEAF_HELMET = register(func, "leaf_helmet", new LeafArmorItem(ModArmorMaterials.LEAF, ArmorItem.Type.HELMET, (new Item.Properties().stacksTo(1)))); - TANItems.LEAF_CHESTPLATE = register(func, "leaf_chestplate", new LeafArmorItem(ModArmorMaterials.LEAF, ArmorItem.Type.CHESTPLATE, (new Item.Properties().stacksTo(1)))); - TANItems.LEAF_LEGGINGS = register(func, "leaf_leggings", new LeafArmorItem(ModArmorMaterials.LEAF, ArmorItem.Type.LEGGINGS, (new Item.Properties().stacksTo(1)))); - TANItems.LEAF_BOOTS = register(func, "leaf_boots", new LeafArmorItem(ModArmorMaterials.LEAF, ArmorItem.Type.BOOTS, (new Item.Properties().stacksTo(1)))); - - TANItems.WOOL_HELMET = register(func, "wool_helmet", new WoolArmorItem(ModArmorMaterials.WOOL, ArmorItem.Type.HELMET, (new Item.Properties().stacksTo(1)))); - TANItems.WOOL_CHESTPLATE = register(func, "wool_chestplate", new WoolArmorItem(ModArmorMaterials.WOOL, ArmorItem.Type.CHESTPLATE, (new Item.Properties().stacksTo(1)))); - TANItems.WOOL_LEGGINGS = register(func, "wool_leggings", new WoolArmorItem(ModArmorMaterials.WOOL, ArmorItem.Type.LEGGINGS, (new Item.Properties().stacksTo(1)))); - TANItems.WOOL_BOOTS = register(func, "wool_boots", new WoolArmorItem(ModArmorMaterials.WOOL, ArmorItem.Type.BOOTS, (new Item.Properties().stacksTo(1)))); - - TANItems.ICE_CREAM = register(func, "ice_cream", new StackableBowlFoodItem(new Item.Properties().stacksTo(16).food(new FoodProperties.Builder().nutrition(0).saturationModifier(0.0F).alwaysEdible().build()))); - TANItems.CHARC_0S = register(func, "charc_os", new StackableBowlFoodItem(new Item.Properties().stacksTo(16).food(new FoodProperties.Builder().nutrition(0).saturationModifier(0.0F).alwaysEdible().build()))); - - TANItems.EMPTY_LEATHER_CANTEEN = register(func, "empty_leather_canteen", new EmptyCanteenItem(0, (new Item.Properties()).stacksTo(1))); - TANItems.LEATHER_DIRTY_WATER_CANTEEN = register(func, "leather_dirty_water_canteen", new FilledCanteenItem(0, (new Item.Properties()).durability(5))); - TANItems.LEATHER_WATER_CANTEEN = register(func, "leather_water_canteen", new FilledCanteenItem(0, (new Item.Properties()).durability(5))); - TANItems.LEATHER_PURIFIED_WATER_CANTEEN = register(func, "leather_purified_water_canteen", new FilledCanteenItem(0, (new Item.Properties()).durability(5))); - - TANItems.EMPTY_COPPER_CANTEEN = register(func, "empty_copper_canteen", new EmptyCanteenItem(1, (new Item.Properties()).stacksTo(1))); - TANItems.COPPER_DIRTY_WATER_CANTEEN = register(func, "copper_dirty_water_canteen", new FilledCanteenItem(1, (new Item.Properties()).durability(6))); - TANItems.COPPER_WATER_CANTEEN = register(func, "copper_water_canteen", new FilledCanteenItem(1, (new Item.Properties()).durability(6))); - TANItems.COPPER_PURIFIED_WATER_CANTEEN = register(func, "copper_purified_water_canteen", new FilledCanteenItem(1, (new Item.Properties()).durability(6))); - - TANItems.EMPTY_IRON_CANTEEN = register(func, "empty_iron_canteen", new EmptyCanteenItem(2, (new Item.Properties()).stacksTo(1))); - TANItems.IRON_DIRTY_WATER_CANTEEN = register(func, "iron_dirty_water_canteen", new FilledCanteenItem(2, (new Item.Properties()).durability(7))); - TANItems.IRON_WATER_CANTEEN = register(func, "iron_water_canteen", new FilledCanteenItem(2, (new Item.Properties()).durability(7))); - TANItems.IRON_PURIFIED_WATER_CANTEEN = register(func, "iron_purified_water_canteen", new FilledCanteenItem(2, (new Item.Properties()).durability(7))); - - TANItems.EMPTY_GOLD_CANTEEN = register(func, "empty_gold_canteen", new EmptyCanteenItem(3, (new Item.Properties()).stacksTo(1))); - TANItems.GOLD_DIRTY_WATER_CANTEEN = register(func, "gold_dirty_water_canteen", new FilledCanteenItem(3, (new Item.Properties()).durability(10))); - TANItems.GOLD_WATER_CANTEEN = register(func, "gold_water_canteen", new FilledCanteenItem(3, (new Item.Properties()).durability(10))); - TANItems.GOLD_PURIFIED_WATER_CANTEEN = register(func, "gold_purified_water_canteen", new FilledCanteenItem(3, (new Item.Properties()).durability(10))); - - TANItems.EMPTY_DIAMOND_CANTEEN = register(func, "empty_diamond_canteen", new EmptyCanteenItem(4, (new Item.Properties()).stacksTo(1))); - TANItems.DIAMOND_DIRTY_WATER_CANTEEN = register(func, "diamond_dirty_water_canteen", new FilledCanteenItem(4, (new Item.Properties()).durability(15))); - TANItems.DIAMOND_WATER_CANTEEN = register(func, "diamond_water_canteen", new FilledCanteenItem(4, (new Item.Properties()).durability(15))); - TANItems.DIAMOND_PURIFIED_WATER_CANTEEN = register(func, "diamond_purified_water_canteen", new FilledCanteenItem(4, (new Item.Properties()).durability(15))); - - TANItems.EMPTY_NETHERITE_CANTEEN = register(func, "empty_netherite_canteen", new EmptyCanteenItem(5, (new Item.Properties()).stacksTo(1))); - TANItems.NETHERITE_DIRTY_WATER_CANTEEN = register(func, "netherite_dirty_water_canteen", new FilledCanteenItem(5, (new Item.Properties()).durability(25))); - TANItems.NETHERITE_WATER_CANTEEN = register(func, "netherite_water_canteen", new FilledCanteenItem(5, (new Item.Properties()).durability(25))); - TANItems.NETHERITE_PURIFIED_WATER_CANTEEN = register(func, "netherite_purified_water_canteen", new FilledCanteenItem(5, (new Item.Properties()).durability(25))); - - TANItems.DIRTY_WATER_BOTTLE = register(func, "dirty_water_bottle", new DirtyWaterBottleItem((new Item.Properties()).stacksTo(1))); - TANItems.PURIFIED_WATER_BOTTLE = register(func, "purified_water_bottle", new PurifiedWaterBottleItem((new Item.Properties()).stacksTo(1))); - - TANItems.APPLE_JUICE = register(func, "apple_juice", new JuiceItem((new Item.Properties()).stacksTo(16))); - TANItems.CACTUS_JUICE = register(func, "cactus_juice", new JuiceItem((new Item.Properties()).stacksTo(16))); - TANItems.CHORUS_FRUIT_JUICE = register(func, "chorus_fruit_juice", new JuiceItem((new Item.Properties()).stacksTo(16))); - TANItems.GLOW_BERRY_JUICE = register(func, "glow_berry_juice", new JuiceItem((new Item.Properties()).stacksTo(16))); - TANItems.MELON_JUICE = register(func, "melon_juice", new JuiceItem((new Item.Properties()).stacksTo(16))); - TANItems.PUMPKIN_JUICE = register(func, "pumpkin_juice", new JuiceItem((new Item.Properties()).stacksTo(16))); - TANItems.SWEET_BERRY_JUICE = register(func, "sweet_berry_juice", new JuiceItem((new Item.Properties()).stacksTo(16))); - - TANItems.TAN_ICON = register(func, "tan_icon", new Item(new Item.Properties())); + TANItems.THERMOMETER = registerItem(func, "thermometer", Item::new, new Item.Properties().stacksTo(1)); + + TANItems.LEAF_HELMET = registerItem(func, "leaf_helmet", p -> new LeafArmorItem(ModArmorMaterials.LEAF, ArmorType.HELMET, p), new Item.Properties().stacksTo(1)); + TANItems.LEAF_CHESTPLATE = registerItem(func, "leaf_chestplate", p -> new LeafArmorItem(ModArmorMaterials.LEAF, ArmorType.CHESTPLATE, p), new Item.Properties().stacksTo(1)); + TANItems.LEAF_LEGGINGS = registerItem(func, "leaf_leggings", p -> new LeafArmorItem(ModArmorMaterials.LEAF, ArmorType.LEGGINGS, p), new Item.Properties().stacksTo(1)); + TANItems.LEAF_BOOTS = registerItem(func, "leaf_boots", p -> new LeafArmorItem(ModArmorMaterials.LEAF, ArmorType.BOOTS, p), new Item.Properties().stacksTo(1)); + + TANItems.WOOL_HELMET = registerItem(func, "wool_helmet", p -> new WoolArmorItem(ModArmorMaterials.WOOL, ArmorType.HELMET, p), new Item.Properties().stacksTo(1)); + TANItems.WOOL_CHESTPLATE = registerItem(func, "wool_chestplate", p -> new WoolArmorItem(ModArmorMaterials.WOOL, ArmorType.CHESTPLATE, p), new Item.Properties().stacksTo(1)); + TANItems.WOOL_LEGGINGS = registerItem(func, "wool_leggings", p -> new WoolArmorItem(ModArmorMaterials.WOOL, ArmorType.LEGGINGS, p), new Item.Properties().stacksTo(1)); + TANItems.WOOL_BOOTS = registerItem(func, "wool_boots", p -> new WoolArmorItem(ModArmorMaterials.WOOL, ArmorType.BOOTS, p), new Item.Properties().stacksTo(1)); + + TANItems.ICE_CREAM = registerItem(func, "ice_cream", StackableBowlFoodItem::new, new Item.Properties().stacksTo(16).component(DataComponents.CONSUMABLE, Consumables.DEFAULT_FOOD).usingConvertsTo(Items.BOWL).food(new FoodProperties.Builder().nutrition(0).saturationModifier(0.0F).alwaysEdible().build())); + TANItems.CHARC_0S = registerItem(func, "charc_os", StackableBowlFoodItem::new, new Item.Properties().stacksTo(16).component(DataComponents.CONSUMABLE, Consumables.DEFAULT_FOOD).usingConvertsTo(Items.BOWL).food(new FoodProperties.Builder().nutrition(0).saturationModifier(0.0F).alwaysEdible().build())); + + TANItems.EMPTY_LEATHER_CANTEEN = registerItem(func, "empty_leather_canteen", p -> new EmptyCanteenItem(0, p), new Item.Properties().enchantable(1).stacksTo(1)); + TANItems.LEATHER_DIRTY_WATER_CANTEEN = registerItem(func, "leather_dirty_water_canteen", p -> new FilledCanteenItem(0, p), new Item.Properties().durability(5)); + TANItems.LEATHER_WATER_CANTEEN = registerItem(func, "leather_water_canteen", p -> new FilledCanteenItem(0, p), new Item.Properties().durability(5)); + TANItems.LEATHER_PURIFIED_WATER_CANTEEN = registerItem(func, "leather_purified_water_canteen", p -> new FilledCanteenItem(0, p), new Item.Properties().durability(5)); + + TANItems.EMPTY_COPPER_CANTEEN = registerItem(func, "empty_copper_canteen", p -> new EmptyCanteenItem(1, p), new Item.Properties().enchantable(1).stacksTo(1)); + TANItems.COPPER_DIRTY_WATER_CANTEEN = registerItem(func, "copper_dirty_water_canteen", p -> new FilledCanteenItem(1, p), new Item.Properties().durability(6)); + TANItems.COPPER_WATER_CANTEEN = registerItem(func, "copper_water_canteen", p -> new FilledCanteenItem(1, p), new Item.Properties().durability(6)); + TANItems.COPPER_PURIFIED_WATER_CANTEEN = registerItem(func, "copper_purified_water_canteen", p -> new FilledCanteenItem(1, p), new Item.Properties().durability(6)); + + TANItems.EMPTY_IRON_CANTEEN = registerItem(func, "empty_iron_canteen", p -> new EmptyCanteenItem(2, p), new Item.Properties().enchantable(1).stacksTo(1)); + TANItems.IRON_DIRTY_WATER_CANTEEN = registerItem(func, "iron_dirty_water_canteen", p -> new FilledCanteenItem(2, p), new Item.Properties().durability(7)); + TANItems.IRON_WATER_CANTEEN = registerItem(func, "iron_water_canteen", p -> new FilledCanteenItem(2, p), new Item.Properties().durability(7)); + TANItems.IRON_PURIFIED_WATER_CANTEEN = registerItem(func, "iron_purified_water_canteen", p -> new FilledCanteenItem(2, p), new Item.Properties().durability(7)); + + TANItems.EMPTY_GOLD_CANTEEN = registerItem(func, "empty_gold_canteen", p -> new EmptyCanteenItem(3, p), new Item.Properties().enchantable(1).stacksTo(1)); + TANItems.GOLD_DIRTY_WATER_CANTEEN = registerItem(func, "gold_dirty_water_canteen", p -> new FilledCanteenItem(3, p), new Item.Properties().durability(10)); + TANItems.GOLD_WATER_CANTEEN = registerItem(func, "gold_water_canteen", p -> new FilledCanteenItem(3, p), new Item.Properties().durability(10)); + TANItems.GOLD_PURIFIED_WATER_CANTEEN = registerItem(func, "gold_purified_water_canteen", p -> new FilledCanteenItem(3, p), new Item.Properties().durability(10)); + + TANItems.EMPTY_DIAMOND_CANTEEN = registerItem(func, "empty_diamond_canteen", p -> new EmptyCanteenItem(4, p), new Item.Properties().enchantable(1).stacksTo(1)); + TANItems.DIAMOND_DIRTY_WATER_CANTEEN = registerItem(func, "diamond_dirty_water_canteen", p -> new FilledCanteenItem(4, p), new Item.Properties().durability(15)); + TANItems.DIAMOND_WATER_CANTEEN = registerItem(func, "diamond_water_canteen", p -> new FilledCanteenItem(4, p), new Item.Properties().durability(15)); + TANItems.DIAMOND_PURIFIED_WATER_CANTEEN = registerItem(func, "diamond_purified_water_canteen", p -> new FilledCanteenItem(4, p), new Item.Properties().durability(15)); + + TANItems.EMPTY_NETHERITE_CANTEEN = registerItem(func, "empty_netherite_canteen", p -> new EmptyCanteenItem(5, p), new Item.Properties().enchantable(1).stacksTo(1)); + TANItems.NETHERITE_DIRTY_WATER_CANTEEN = registerItem(func, "netherite_dirty_water_canteen", p -> new FilledCanteenItem(5, p), new Item.Properties().durability(25)); + TANItems.NETHERITE_WATER_CANTEEN = registerItem(func, "netherite_water_canteen", p -> new FilledCanteenItem(5, p), new Item.Properties().durability(25)); + TANItems.NETHERITE_PURIFIED_WATER_CANTEEN = registerItem(func, "netherite_purified_water_canteen", p -> new FilledCanteenItem(5, p), new Item.Properties().durability(25)); + + TANItems.DIRTY_WATER_BOTTLE = registerItem(func, "dirty_water_bottle", DirtyWaterBottleItem::new, new Item.Properties().stacksTo(1)); + TANItems.PURIFIED_WATER_BOTTLE = registerItem(func, "purified_water_bottle", PurifiedWaterBottleItem::new, new Item.Properties().stacksTo(1)); + + TANItems.APPLE_JUICE = registerItem(func, "apple_juice", JuiceItem::new, new Item.Properties().stacksTo(16)); + TANItems.CACTUS_JUICE = registerItem(func, "cactus_juice", JuiceItem::new, new Item.Properties().stacksTo(16)); + TANItems.CHORUS_FRUIT_JUICE = registerItem(func, "chorus_fruit_juice", JuiceItem::new, new Item.Properties().stacksTo(16)); + TANItems.GLOW_BERRY_JUICE = registerItem(func, "glow_berry_juice", JuiceItem::new, new Item.Properties().stacksTo(16)); + TANItems.MELON_JUICE = registerItem(func, "melon_juice", JuiceItem::new, new Item.Properties().stacksTo(16)); + TANItems.PUMPKIN_JUICE = registerItem(func, "pumpkin_juice", JuiceItem::new, new Item.Properties().stacksTo(16)); + TANItems.SWEET_BERRY_JUICE = registerItem(func, "sweet_berry_juice", JuiceItem::new, new Item.Properties().stacksTo(16)); + + TANItems.TAN_ICON = registerItem(func, "tan_icon", Item::new, new Item.Properties()); if (Environment.isClient()) { @@ -92,9 +102,46 @@ public static void registerItems(BiConsumer func) } } - private static Item register(BiConsumer func, String name, Item item) + public static Item registerBlock(BiConsumer func, Block block) { - func.accept(ResourceLocation.fromNamespaceAndPath(TANAPI.MOD_ID, name), item); + return registerBlock(func, block, BlockItem::new); + } + + public static Item registerBlock(BiConsumer func, Block block, BiFunction factory) + { + return registerBlock(func, block, factory, new Item.Properties()); + } + + public static Item registerBlock(BiConsumer func, Block block, BiFunction factory, Item.Properties properties) + { + return registerItem(func, blockIdToItemId(block.builtInRegistryHolder().key()), p_370785_ -> factory.apply(block, p_370785_), properties.useBlockDescriptionPrefix() + ); + } + + private static Item registerItem(BiConsumer func, ResourceKey key, Function factory, Item.Properties properties) + { + Item item = factory.apply(properties.setId(key)); + func.accept(key.location(), item); return item; } + + private static Item registerItem(BiConsumer func, String name, Function factory, Item.Properties properties) + { + return registerItem(func, itemId(name), factory, properties); + } + + private static Item registerItem(BiConsumer func, String name, Item.Properties properties) + { + return registerItem(func, itemId(name), Item::new, properties); + } + + private static ResourceKey blockIdToItemId(ResourceKey key) + { + return ResourceKey.create(Registries.ITEM, key.location()); + } + + private static ResourceKey itemId(String name) + { + return ResourceKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(ToughAsNails.MOD_ID, name)); + } } diff --git a/common/src/main/java/toughasnails/init/ModPotions.java b/common/src/main/java/toughasnails/init/ModPotions.java index 2e1214f8..bc26ea65 100644 --- a/common/src/main/java/toughasnails/init/ModPotions.java +++ b/common/src/main/java/toughasnails/init/ModPotions.java @@ -5,6 +5,7 @@ package toughasnails.init; import net.minecraft.core.Holder; +import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; @@ -38,8 +39,8 @@ public static void registerEffects(BiConsumer func) public static void registerPotions(BiConsumer func) { - TANPotions.ICE_RESISTANCE = registerPotion(func, "ice_resistance", new Potion(new MobEffectInstance(TANEffects.ICE_RESISTANCE, 3600))); - TANPotions.LONG_ICE_RESISTANCE = registerPotion(func, "long_ice_resistance", new Potion(new MobEffectInstance(TANEffects.ICE_RESISTANCE, 9600))); + TANPotions.ICE_RESISTANCE = registerPotion(func, "ice_resistance", new Potion("ice_resistance", new MobEffectInstance(TANEffects.ICE_RESISTANCE, 3600))); + TANPotions.LONG_ICE_RESISTANCE = registerPotion(func, "long_ice_resistance", new Potion("long_ice_resistance", new MobEffectInstance(TANEffects.ICE_RESISTANCE, 9600))); } private static Holder registerEffect(BiConsumer func, String name, MobEffect effect) @@ -47,7 +48,7 @@ private static Holder registerEffect(BiConsumer key = ResourceKey.create(Registries.MOB_EFFECT, location); func.accept(location, effect); - return BuiltInRegistries.MOB_EFFECT.getHolder(key).orElseThrow(); + return BuiltInRegistries.MOB_EFFECT.get(key).orElseThrow(); } private static Holder registerPotion(BiConsumer func, String name, Potion potion) @@ -55,6 +56,6 @@ private static Holder registerPotion(BiConsumer key = ResourceKey.create(Registries.POTION, location); func.accept(location, potion); - return BuiltInRegistries.POTION.getHolder(key).orElseThrow(); + return BuiltInRegistries.POTION.get(key).orElseThrow(); } } diff --git a/common/src/main/java/toughasnails/init/ModTags.java b/common/src/main/java/toughasnails/init/ModTags.java index f7e8a0be..649eb513 100644 --- a/common/src/main/java/toughasnails/init/ModTags.java +++ b/common/src/main/java/toughasnails/init/ModTags.java @@ -6,8 +6,7 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.armortrim.ArmorTrim; -import net.minecraft.world.item.armortrim.TrimMaterial; +import net.minecraft.world.item.equipment.trim.TrimMaterial; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import toughasnails.api.TANAPI; diff --git a/common/src/main/java/toughasnails/init/ModVillages.java b/common/src/main/java/toughasnails/init/ModVillages.java index 9d790663..9cdc2884 100644 --- a/common/src/main/java/toughasnails/init/ModVillages.java +++ b/common/src/main/java/toughasnails/init/ModVillages.java @@ -127,8 +127,8 @@ public static void addWanderingVillagerTrades(WandererTradesEvent event) public static void addBuildings(RegistryAccess registryAccess) { - Registry templatePools = registryAccess.registry(Registries.TEMPLATE_POOL).get(); - Registry processorLists = registryAccess.registry(Registries.PROCESSOR_LIST).get(); + Registry templatePools = registryAccess.lookupOrThrow(Registries.TEMPLATE_POOL); + Registry processorLists = registryAccess.lookupOrThrow(Registries.PROCESSOR_LIST); addBuildingToPool(templatePools, processorLists, ResourceLocation.parse("minecraft:village/desert/houses"), ToughAsNails.MOD_ID + ":village/desert/houses/desert_climatologist_1", 1); addBuildingToPool(templatePools, processorLists, ResourceLocation.parse("minecraft:village/savanna/houses"), ToughAsNails.MOD_ID + ":village/savanna/houses/savanna_climatologist_1", 2); @@ -204,21 +204,20 @@ private static Int2ObjectMap toIntMap(ImmutableMap public static void addBuildingToPool(Registry templatePoolRegistry, Registry processorListRegistry, ResourceLocation poolRL, String nbtPieceRL, int weight) { - StructureTemplatePool pool = templatePoolRegistry.get(poolRL); - if (pool == null) return; + templatePoolRegistry.get(poolRL).ifPresent(pool -> { + ResourceLocation emptyProcessor = ResourceLocation.fromNamespaceAndPath("minecraft", "empty"); + Holder processorHolder = processorListRegistry.getOrThrow(ResourceKey.create(Registries.PROCESSOR_LIST, emptyProcessor)); - ResourceLocation emptyProcessor = ResourceLocation.fromNamespaceAndPath("minecraft", "empty"); - Holder processorHolder = processorListRegistry.getHolderOrThrow(ResourceKey.create(Registries.PROCESSOR_LIST, emptyProcessor)); + SinglePoolElement piece = SinglePoolElement.single(nbtPieceRL, processorHolder).apply(StructureTemplatePool.Projection.RIGID); - SinglePoolElement piece = SinglePoolElement.single(nbtPieceRL, processorHolder).apply(StructureTemplatePool.Projection.RIGID); - - for (int i = 0; i < weight; i++) { - pool.templates.add(piece); - } + for (int i = 0; i < weight; i++) { + pool.value().templates.add(piece); + } - List> listOfPieceEntries = new ArrayList<>(pool.rawTemplates); - listOfPieceEntries.add(new Pair<>(piece, weight)); - pool.rawTemplates = listOfPieceEntries; + List> listOfPieceEntries = new ArrayList<>(pool.value().rawTemplates); + listOfPieceEntries.add(new Pair<>(piece, weight)); + pool.value().rawTemplates = listOfPieceEntries; + }); } private static PoiType register(BiConsumer func, ResourceKey key, Set states, int maxTickets, int validRange) @@ -260,7 +259,7 @@ private static Set getBlockStates(Block block) private static void registerBlockStates(ResourceKey key, Set states) { - var holder = BuiltInRegistries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(key); + var holder = BuiltInRegistries.POINT_OF_INTEREST_TYPE.getOrThrow(key); states.forEach(state -> { if (!PoiTypes.hasPoi(state)) PoiTypes.registerBlockStates(holder, Set.of(state)); }); diff --git a/common/src/main/java/toughasnails/item/DrinkItem.java b/common/src/main/java/toughasnails/item/DrinkItem.java index f20b6ac8..23fcaf67 100644 --- a/common/src/main/java/toughasnails/item/DrinkItem.java +++ b/common/src/main/java/toughasnails/item/DrinkItem.java @@ -8,7 +8,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.Stats; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; @@ -60,20 +60,20 @@ public int getUseDuration(ItemStack stack, LivingEntity entity) } @Override - public UseAnim getUseAnimation(ItemStack stack) + public ItemUseAnimation getUseAnimation(ItemStack stack) { - return UseAnim.DRINK; + return ItemUseAnimation.DRINK; } @Override - public InteractionResultHolder use(Level world, Player player, InteractionHand hand) + public InteractionResult use(Level world, Player player, InteractionHand hand) { if (ThirstHelper.canDrink(player, this.canAlwaysDrink())) { return ItemUtils.startUsingInstantly(world, player, hand); } - return InteractionResultHolder.fail(player.getItemInHand(hand)); + return InteractionResult.FAIL; } public abstract boolean canAlwaysDrink(); diff --git a/common/src/main/java/toughasnails/item/EmptyCanteenItem.java b/common/src/main/java/toughasnails/item/EmptyCanteenItem.java index 11c28981..57cc4c35 100644 --- a/common/src/main/java/toughasnails/item/EmptyCanteenItem.java +++ b/common/src/main/java/toughasnails/item/EmptyCanteenItem.java @@ -12,7 +12,7 @@ import net.minecraft.stats.Stats; import net.minecraft.tags.FluidTags; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -46,12 +46,12 @@ public EmptyCanteenItem(int tier, Properties properties) } @Override - public InteractionResultHolder use(@NotNull Level level, Player player, @NotNull InteractionHand hand) + public InteractionResult use(@NotNull Level level, Player player, @NotNull InteractionHand hand) { return this.fillCanteen(level, player, player.getItemInHand(hand)); } - protected InteractionResultHolder fillCanteen(Level level, Player player, ItemStack stack) + protected InteractionResult fillCanteen(Level level, Player player, ItemStack stack) { HitResult rayTraceResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY); @@ -72,7 +72,7 @@ protected InteractionResultHolder fillCanteen(Level level, Player pla { level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F); ((RainCollectorBlock) TANBlocks.RAIN_COLLECTOR).setWaterLevel(level, pos, state, waterLevel - 1); - return InteractionResultHolder.success(this.replaceCanteen(stack, player, new ItemStack(getPurifiedWaterCanteen()))); + return InteractionResult.SUCCESS.heldItemTransformedTo(this.replaceCanteen(stack, player, new ItemStack(getPurifiedWaterCanteen()))); } } else if (state.getBlock() == Blocks.WATER_CAULDRON) @@ -84,7 +84,7 @@ else if (state.getBlock() == Blocks.WATER_CAULDRON) { level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F); LayeredCauldronBlock.lowerFillLevel(state, level, pos); - return InteractionResultHolder.success(this.replaceCanteen(stack, player, new ItemStack(getWaterCanteen()))); + return InteractionResult.SUCCESS.heldItemTransformedTo(this.replaceCanteen(stack, player, new ItemStack(getWaterCanteen()))); } } else if (level.getFluidState(pos).is(FluidTags.WATER)) @@ -98,8 +98,8 @@ else if (level.getFluidState(pos).is(FluidTags.WATER)) Holder biome = player.level().getBiome(player.blockPosition()); Item canteenItem; - var enchantmentRegistry = level.registryAccess().registryOrThrow(Registries.ENCHANTMENT); - if (EnchantmentHelper.getItemEnchantmentLevel(enchantmentRegistry.getHolderOrThrow(TANEnchantments.WATER_CLEANSING), stack) > 0 || biome.is(ModTags.Biomes.PURIFIED_WATER_BIOMES)) + var enchantmentRegistry = level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT); + if (EnchantmentHelper.getItemEnchantmentLevel(enchantmentRegistry.getOrThrow(TANEnchantments.WATER_CLEANSING), stack) > 0 || biome.is(ModTags.Biomes.PURIFIED_WATER_BIOMES)) { canteenItem = getPurifiedWaterCanteen(); } @@ -112,18 +112,12 @@ else if (biome.is(ModTags.Biomes.DIRTY_WATER_BIOMES)) canteenItem = getWaterCanteen(); } - return InteractionResultHolder.sidedSuccess(this.replaceCanteen(stack, player, new ItemStack(canteenItem)), level.isClientSide()); + return InteractionResult.SUCCESS.heldItemTransformedTo(this.replaceCanteen(stack, player, new ItemStack(canteenItem))); } } } - return InteractionResultHolder.pass(stack); - } - - @Override - public boolean isEnchantable(ItemStack stack) - { - return true; + return InteractionResult.PASS; } protected ItemStack replaceCanteen(ItemStack oldStack, Player player, ItemStack newStack) diff --git a/common/src/main/java/toughasnails/item/FilledCanteenItem.java b/common/src/main/java/toughasnails/item/FilledCanteenItem.java index 49b55e61..62381105 100644 --- a/common/src/main/java/toughasnails/item/FilledCanteenItem.java +++ b/common/src/main/java/toughasnails/item/FilledCanteenItem.java @@ -8,15 +8,14 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.Stats; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemUseAnimation; import net.minecraft.world.item.ItemUtils; -import net.minecraft.world.item.UseAnim; -import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.Level; import toughasnails.api.item.TANItems; import toughasnails.api.thirst.ThirstHelper; @@ -46,12 +45,12 @@ public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, } @Override - public InteractionResultHolder use(Level level, Player player, InteractionHand hand) + public InteractionResult use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - InteractionResultHolder result; + InteractionResult result; - if ((result = this.fillCanteen(level, player, stack)).getResult().consumesAction()) + if ((result = this.fillCanteen(level, player, stack)).consumesAction()) { return result; } @@ -61,7 +60,7 @@ public InteractionResultHolder use(Level level, Player player, Intera return ItemUtils.startUsingInstantly(level, player, hand); } - return InteractionResultHolder.fail(stack); + return InteractionResult.FAIL; } @Override @@ -99,9 +98,9 @@ public int getUseDuration(ItemStack stack, LivingEntity entity) } @Override - public UseAnim getUseAnimation(ItemStack stack) + public ItemUseAnimation getUseAnimation(ItemStack stack) { - return UseAnim.DRINK; + return ItemUseAnimation.DRINK; } public boolean canAlwaysDrink() diff --git a/common/src/main/java/toughasnails/item/LeafArmorItem.java b/common/src/main/java/toughasnails/item/LeafArmorItem.java index 6637f389..e11c2c77 100644 --- a/common/src/main/java/toughasnails/item/LeafArmorItem.java +++ b/common/src/main/java/toughasnails/item/LeafArmorItem.java @@ -5,19 +5,19 @@ package toughasnails.item; import net.minecraft.client.renderer.BiomeColors; -import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponents; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.DyedItemColor; +import net.minecraft.world.item.equipment.ArmorMaterial; +import net.minecraft.world.item.equipment.ArmorType; import net.minecraft.world.level.Level; import toughasnails.api.item.TANItems; public class LeafArmorItem extends ArmorItem { - public LeafArmorItem(Holder $$0, Type $$1, Properties $$2) { + public LeafArmorItem(ArmorMaterial $$0, ArmorType $$1, Properties $$2) { super($$0, $$1, $$2); } diff --git a/common/src/main/java/toughasnails/item/WoolArmorItem.java b/common/src/main/java/toughasnails/item/WoolArmorItem.java index 7fe0756e..1199d147 100644 --- a/common/src/main/java/toughasnails/item/WoolArmorItem.java +++ b/common/src/main/java/toughasnails/item/WoolArmorItem.java @@ -4,16 +4,16 @@ ******************************************************************************/ package toughasnails.item; -import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponents; import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.DyedItemColor; +import net.minecraft.world.item.equipment.ArmorMaterial; +import net.minecraft.world.item.equipment.ArmorType; public class WoolArmorItem extends ArmorItem { - public WoolArmorItem(Holder $$0, Type $$1, Properties $$2) + public WoolArmorItem(ArmorMaterial $$0, ArmorType $$1, Properties $$2) { super($$0, $$1, $$2); } diff --git a/common/src/main/java/toughasnails/mixin/MixinFoodData.java b/common/src/main/java/toughasnails/mixin/MixinFoodData.java index 77d74389..321ecda9 100644 --- a/common/src/main/java/toughasnails/mixin/MixinFoodData.java +++ b/common/src/main/java/toughasnails/mixin/MixinFoodData.java @@ -4,6 +4,7 @@ ******************************************************************************/ package toughasnails.mixin; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.food.FoodData; import org.spongepowered.asm.mixin.Mixin; @@ -16,7 +17,7 @@ public abstract class MixinFoodData { @Inject(method="tick", at=@At(value="HEAD"), cancellable = true) - public void onTick(Player player, CallbackInfo ci) + public void onTick(ServerPlayer player, CallbackInfo ci) { ThirstHooks.doFoodDataTick((FoodData)(Object)this, player); ci.cancel(); diff --git a/common/src/main/java/toughasnails/mixin/MixinItem.java b/common/src/main/java/toughasnails/mixin/MixinItem.java deleted file mode 100644 index 5ab987cf..00000000 --- a/common/src/main/java/toughasnails/mixin/MixinItem.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright 2023, the Glitchfiend Team. - * All rights reserved. - ******************************************************************************/ -package toughasnails.mixin; - -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import toughasnails.init.ModTags; - -@Mixin(Item.class) -public class MixinItem -{ - @Redirect(method="use", at=@At(value = "INVOKE", target="Lnet/minecraft/world/entity/player/Player;canEat(Z)Z")) - public boolean onUse(Player player, boolean canAlwaysEat, Level level, Player player2, InteractionHand hand) - { - ItemStack stack = player.getItemInHand(hand); - return stack.is(ModTags.Items.HEATING_CONSUMED_ITEMS) || stack.is(ModTags.Items.COOLING_CONSUMED_ITEMS) || player.canEat(canAlwaysEat); - } -} diff --git a/common/src/main/java/toughasnails/potion/ThirstEffect.java b/common/src/main/java/toughasnails/potion/ThirstEffect.java index 09eefc78..b9930fa8 100644 --- a/common/src/main/java/toughasnails/potion/ThirstEffect.java +++ b/common/src/main/java/toughasnails/potion/ThirstEffect.java @@ -4,6 +4,7 @@ ******************************************************************************/ package toughasnails.potion; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.effect.MobEffect; @@ -19,7 +20,7 @@ public ThirstEffect(MobEffectCategory type, int color) } @Override - public boolean applyEffectTick(LivingEntity entity, int amplifier) + public boolean applyEffectTick(ServerLevel level, LivingEntity entity, int amplifier) { if (entity instanceof Player) { diff --git a/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java b/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java index 84a1ff38..2451dae8 100644 --- a/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java +++ b/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java @@ -12,10 +12,8 @@ import net.minecraft.tags.FluidTags; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.item.armortrim.ArmorTrim; -import net.minecraft.world.item.armortrim.TrimMaterial; -import net.minecraft.world.item.armortrim.TrimMaterials; import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.equipment.trim.TrimMaterials; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.state.BlockState; @@ -327,10 +325,10 @@ protected static TemperatureLevel armorModifier(Player player, TemperatureLevel else if (armorAdjTemp == TemperatureLevel.ICY && current != TemperatureLevel.ICY) current = armorAdjTemp.increment(1); else current = armorAdjTemp; - var enchantmentRegistry = player.registryAccess().registryOrThrow(Registries.ENCHANTMENT); + var enchantmentRegistry = player.registryAccess().lookupOrThrow(Registries.ENCHANTMENT); // Armor enchantments - if (EnchantmentHelper.getEnchantmentLevel(enchantmentRegistry.getHolderOrThrow(TANEnchantments.THERMAL_TUNING), player) > 0) + if (EnchantmentHelper.getEnchantmentLevel(enchantmentRegistry.getOrThrow(TANEnchantments.THERMAL_TUNING), player) > 0) current = TemperatureLevel.NEUTRAL; return current; @@ -358,7 +356,7 @@ private static boolean isExposedToRain(Level level, BlockPos pos) private static boolean coldEnoughToSnow(Level level, Holder biome, BlockPos pos) { - return biome.value().coldEnoughToSnow(pos); + return biome.value().coldEnoughToSnow(pos, level.getSeaLevel()); } public static TemperatureLevel modifyTemperatureByThermoregulators(Level level, Set thermoregulators, BlockPos checkPos, TemperatureLevel current) diff --git a/common/src/main/java/toughasnails/temperature/TemperatureHooksClient.java b/common/src/main/java/toughasnails/temperature/TemperatureHooksClient.java index a23b63c7..1ae23743 100644 --- a/common/src/main/java/toughasnails/temperature/TemperatureHooksClient.java +++ b/common/src/main/java/toughasnails/temperature/TemperatureHooksClient.java @@ -9,6 +9,7 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; import toughasnails.api.temperature.TemperatureHelper; import toughasnails.init.ModConfig; @@ -32,11 +33,11 @@ public static void heartBlit(GuiGraphics gui, Gui.HeartType heartType, int x, in // Normal hearts if (heartType == Gui.HeartType.NORMAL && TemperatureHelper.isFullyHyperthermic(player)) { - gui.blitSprite(getOverheatedHeartSprite(isHardcore, isHalf, isBlinking), x, y, 9, 9); + gui.blitSprite(RenderType::guiTextured, getOverheatedHeartSprite(isHardcore, isHalf, isBlinking), x, y, 9, 9); } else { - gui.blitSprite(heartType.getSprite(isHardcore, isHalf, isBlinking), x, y, 9, 9); + gui.blitSprite(RenderType::guiTextured, heartType.getSprite(isHardcore, isHalf, isBlinking), x, y, 9, 9); } } diff --git a/common/src/main/java/toughasnails/temperature/TemperatureOverlayRenderer.java b/common/src/main/java/toughasnails/temperature/TemperatureOverlayRenderer.java index 4875979b..ce549f17 100644 --- a/common/src/main/java/toughasnails/temperature/TemperatureOverlayRenderer.java +++ b/common/src/main/java/toughasnails/temperature/TemperatureOverlayRenderer.java @@ -10,6 +10,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import toughasnails.api.TANAPI; @@ -131,12 +132,12 @@ private static void drawTemperature(GuiGraphics gui, int width, int height, Temp if (flashCounter > updateCounter) v += 16; - gui.blit(OVERLAY, left, top, iconIndex, v, 16, 16); + gui.blit(RenderType::guiTextured, OVERLAY, left, top, iconIndex, v, 16, 16, 256, 256); // Draw the arrow if (arrowDirection != null) { - gui.blit(OVERLAY, left, top, arrowDirection.getU(15 - (int)(arrowCounter - updateCounter)), arrowDirection.getV(), 16, 16); + gui.blit(RenderType::guiTextured, OVERLAY, left, top, arrowDirection.getU(15 - (int)(arrowCounter - updateCounter)), arrowDirection.getV(), 16, 16, 256, 256); } } diff --git a/common/src/main/java/toughasnails/thirst/ThirstHandler.java b/common/src/main/java/toughasnails/thirst/ThirstHandler.java index 714ba04b..03c4d3a1 100644 --- a/common/src/main/java/toughasnails/thirst/ThirstHandler.java +++ b/common/src/main/java/toughasnails/thirst/ThirstHandler.java @@ -10,6 +10,7 @@ import glitchcore.event.player.PlayerInteractEvent; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -17,7 +18,7 @@ import net.minecraft.tags.FluidTags; import net.minecraft.world.Difficulty; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -95,7 +96,7 @@ else if (difficulty != Difficulty.PEACEFUL) } // Increment thirst if on peaceful mode - if (difficulty == Difficulty.PEACEFUL && player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) + if (difficulty == Difficulty.PEACEFUL && ((ServerLevel)player.level()).getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (thirst.isThirsty() && player.tickCount % 10 == 0) { @@ -215,7 +216,7 @@ else if (biome.is(ModTags.Biomes.PURIFIED_WATER_BIOMES)) ItemStack replacementStack = ItemUtils.createFilledResult(stack, player, filledStack); // Cancel the event, we've taken responsibility for bottle filling - event.setCancelResult(InteractionResultHolder.sidedSuccess(replacementStack, level.isClientSide())); + event.setCancelResult(InteractionResult.SUCCESS.heldItemTransformedTo(replacementStack)); event.setCancelled(true); } @@ -264,7 +265,7 @@ private static void tryDrinkWaterInWorld(Player player) { inWorldDrinkTimer = IN_WORLD_DRINK_COOLDOWN; ModPackets.HANDLER.sendToServer(new DrinkInWorldPacket(pos)); - player.playSound(SoundEvents.GENERIC_DRINK, 0.5f, 1.0f); + player.playSound(SoundEvents.GENERIC_DRINK.value(), 0.5f, 1.0f); player.swing(InteractionHand.MAIN_HAND); } } diff --git a/common/src/main/java/toughasnails/thirst/ThirstHooks.java b/common/src/main/java/toughasnails/thirst/ThirstHooks.java index d524c97c..c0a4f169 100644 --- a/common/src/main/java/toughasnails/thirst/ThirstHooks.java +++ b/common/src/main/java/toughasnails/thirst/ThirstHooks.java @@ -1,5 +1,6 @@ package toughasnails.thirst; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Difficulty; import net.minecraft.world.entity.player.Player; import net.minecraft.world.food.FoodData; @@ -23,13 +24,11 @@ public static void onCauseFoodExhaustion(Player player, float exhaustion) } } - public static void doFoodDataTick(FoodData data, Player player) + public static void doFoodDataTick(FoodData data, ServerPlayer player) { Difficulty difficulty = player.level().getDifficulty(); IThirst thirst = ThirstHelper.getThirst(player); - data.lastFoodLevel = data.foodLevel; - if (data.exhaustionLevel > 4.0F) { data.exhaustionLevel -= 4.0F; @@ -44,7 +43,7 @@ else if (difficulty != Difficulty.PEACEFUL) } } - boolean naturalRegen = player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); + boolean naturalRegen = player.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); if (naturalRegen && data.saturationLevel > 0.0F && player.isHurt() && data.foodLevel >= 20 && (!ModConfig.thirst.thirstPreventHealthRegen || (thirst.getHydration() > 0.0F && thirst.getThirst() >= 20))) { diff --git a/common/src/main/java/toughasnails/thirst/ThirstOverlayRenderer.java b/common/src/main/java/toughasnails/thirst/ThirstOverlayRenderer.java index ae49d168..0eae1ad2 100644 --- a/common/src/main/java/toughasnails/thirst/ThirstOverlayRenderer.java +++ b/common/src/main/java/toughasnails/thirst/ThirstOverlayRenderer.java @@ -9,6 +9,7 @@ import glitchcore.util.GuiUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; @@ -89,16 +90,16 @@ public static void drawThirst(GuiGraphics guiGraphics, int screenWidth, int rowT } // Draw the background of each thirst droplet - guiGraphics.blit(OVERLAY, startX, startY, backgroundU, 32, 9, 9); + guiGraphics.blit(RenderType::guiTextured, OVERLAY, startX, startY, backgroundU, 32, 9, 9, 256, 256); // Draw a full droplet if (thirstLevel > dropletHalf) { - guiGraphics.blit(OVERLAY, startX, startY, (iconIndex + 4) * 9, 32, 9, 9); + guiGraphics.blit(RenderType::guiTextured, OVERLAY, startX, startY, (iconIndex + 4) * 9, 32, 9, 9, 256, 256); } else if (thirstLevel == dropletHalf) // Draw a half droplet { - guiGraphics.blit(OVERLAY, startX, startY, (iconIndex + 5) * 9, 32, 9, 9); + guiGraphics.blit(RenderType::guiTextured, OVERLAY, startX, startY, (iconIndex + 5) * 9, 32, 9, 9, 256, 256); } } } diff --git a/common/src/main/resources/toughasnails.accesswidener b/common/src/main/resources/toughasnails.accesswidener index c55d45bc..e6ba8d25 100644 --- a/common/src/main/resources/toughasnails.accesswidener +++ b/common/src/main/resources/toughasnails.accesswidener @@ -38,4 +38,6 @@ accessible method net/minecraft/world/damagesource/DamageSources source (Lnet/mi accessible field net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool rawTemplates Ljava/util/List; mutable field net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool rawTemplates Ljava/util/List; accessible field net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool templates Lit/unimi/dsi/fastutil/objects/ObjectArrayList; -accessible method net/minecraft/world/entity/ai/village/poi/PoiTypes registerBlockStates (Lnet/minecraft/core/Holder;Ljava/util/Set;)V \ No newline at end of file +accessible method net/minecraft/world/entity/ai/village/poi/PoiTypes registerBlockStates (Lnet/minecraft/core/Holder;Ljava/util/Set;)V + +accessible method net/minecraft/world/level/block/entity/BlockEntityType (Lnet/minecraft/world/level/block/entity/BlockEntityType$BlockEntitySupplier;Ljava/util/Set;)V \ No newline at end of file diff --git a/common/src/main/resources/toughasnails.mixins.json b/common/src/main/resources/toughasnails.mixins.json index aa4ccdfe..73851e25 100644 --- a/common/src/main/resources/toughasnails.mixins.json +++ b/common/src/main/resources/toughasnails.mixins.json @@ -5,7 +5,6 @@ "refmap": "toughasnails.refmap.json", "mixins": [ "MixinFoodData", - "MixinItem", "MixinLivingEntity", "MixinPlayer", "MixinPotionBrewing", diff --git a/fabric/build.gradle b/fabric/build.gradle index f31e8880..913909d1 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id "fabric-loom" version "1.6-SNAPSHOT" + id "fabric-loom" version "1.8-SNAPSHOT" id "com.matthewprenger.cursegradle" version "1.4.0" } diff --git a/forge/build.gradle b/forge/build.gradle index 24157743..8f416d67 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -7,10 +7,10 @@ plugins { base.archivesName.set("${mod_name}-forge") mixin { - add sourceSets.main, "${mod_id}.refmap.json" + config("${mod_id}.mixins.json") + config("${mod_id}.forge.mixins.json") } - // As of 1.20.6 Forge no longer has reobf tasks. This has broken mixins adding configs correctly into the manifest file // See: https://github.com/SpongePowered/MixinGradle/blob/f800b26d2b180d98d9aa9355e5b3086d71218508/src/main/groovy/org/spongepowered/asm/gradle/plugins/MixinExtension.groovy#L184 // Instead, we will do it ourselves. diff --git a/forge/src/main/java/toughasnails/forge/datagen/DataGenerationHandler.java b/forge/src/main/java/toughasnails/forge/datagen/DataGenerationHandler.java index ff63298c..68e6710a 100644 --- a/forge/src/main/java/toughasnails/forge/datagen/DataGenerationHandler.java +++ b/forge/src/main/java/toughasnails/forge/datagen/DataGenerationHandler.java @@ -23,6 +23,7 @@ import toughasnails.forge.datagen.loot.TANLootTableProvider; import toughasnails.forge.datagen.provider.*; import toughasnails.init.ModEnchantments; +import toughasnails.init.ModEquipmentModels; import java.util.HashSet; import java.util.Set; @@ -32,7 +33,8 @@ public class DataGenerationHandler { private static final RegistrySetBuilder REG_BUILDER = new RegistrySetBuilder() .add(Registries.DAMAGE_TYPE, ModDamageTypes::bootstrap) - .add(Registries.ENCHANTMENT, ModEnchantments::bootstrap); + .add(Registries.ENCHANTMENT, ModEnchantments::bootstrap) + .add(Registries.MODEL, ModEquipmentModels::bootstrap); @SubscribeEvent public static void onGatherData(GatherDataEvent event) diff --git a/forge/src/main/resources/META-INF/accesstransformer.cfg b/forge/src/main/resources/META-INF/accesstransformer.cfg index 17eb6e6f..557ca38f 100644 --- a/forge/src/main/resources/META-INF/accesstransformer.cfg +++ b/forge/src/main/resources/META-INF/accesstransformer.cfg @@ -18,4 +18,6 @@ public net.minecraft.client.gui.Gui f_279580_ #GUI_ICONS_LOCATION # Villages public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210559_ #rawTemplates public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210560_ #templates -public net.minecraft.world.entity.ai.village.poi.PoiTypes m_246216_(Lnet/minecraft/core/Holder;Ljava/util/Set;)V #registerBlockStates \ No newline at end of file +public net.minecraft.world.entity.ai.village.poi.PoiTypes m_246216_(Lnet/minecraft/core/Holder;Ljava/util/Set;)V #registerBlockStates + +public net.minecraft.world.level.block.entity.BlockEntityType (Lnet/minecraft/world/level/block/entity/BlockEntityType$BlockEntitySupplier;Ljava/util/Set;)V \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 32bf7ec2..532ab2bb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,21 +3,21 @@ group=com.github.glitchfiend release_channel=beta # Common -minecraft_version=1.21.1 +minecraft_version=1.21.3 # Forge -forge_version=52.0.8 -forge_version_range=[52.0.8,) -forge_loader_version_range=[52,) +forge_version=53.0.25 +forge_version_range=[53.0.25,) +forge_loader_version_range=[53,) # NeoForge -neoforge_version=21.1.23 -neoforge_version_range=[21.1,) +neoforge_version=21.3.57 +neoforge_version_range=[21.3,) neoforge_loader_version_range=[1,) # Fabric -fabric_version=0.102.1+1.21.1 -fabric_loader_version=0.16.2 +fabric_version=0.110.0+1.21.3 +fabric_loader_version=0.16.9 # Mod options mod_id=toughasnails @@ -40,5 +40,5 @@ org.gradle.daemon=false # Dependencies nightconfig_version=3.6.7 -glitchcore_version=2.1.0.0 -serene_seasons_version=10.1.0.0 +glitchcore_version=2.2.0.4 +serene_seasons_version=10.2.0.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138..9355b415 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 8a1d1d43..ba5a0ffc 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -1,6 +1,6 @@ plugins { - id "net.neoforged.gradle.userdev" version "7.0.142" - id "net.neoforged.gradle.mixin" version "7.0.142" + id "net.neoforged.gradle.userdev" version "7.+" + id "net.neoforged.gradle.mixin" version "7.+" id "com.matthewprenger.cursegradle" version "1.4.0" } diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg index 8dfb8027..54ef8026 100644 --- a/neoforge/src/main/resources/META-INF/accesstransformer.cfg +++ b/neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -22,3 +22,5 @@ public net.minecraft.client.gui.screens.MenuScreens register(Lnet/minecraft/worl public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool rawTemplates public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool templates public net.minecraft.world.entity.ai.village.poi.PoiTypes registerBlockStates(Lnet/minecraft/core/Holder;Ljava/util/Set;)V + +public net.minecraft.world.level.block.entity.BlockEntityType (Lnet/minecraft/world/level/block/entity/BlockEntityType$BlockEntitySupplier;Ljava/util/Set;)V