Skip to content

Commit

Permalink
Work towards 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Dec 5, 2024
1 parent c52ea95 commit 4951761
Show file tree
Hide file tree
Showing 52 changed files with 435 additions and 339 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Recipe<SingleRecipeInput>> WATER_PURIFYING;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Recipe<SingleRecipeInput>> WATER_PURIFYING;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +37,7 @@
public class ThermoregulatorBlock extends BaseEntityBlock
{
public static final MapCodec<WaterPurifierBlock> CODEC = simpleCodec(WaterPurifierBlock::new);
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public static final EnumProperty<Direction> 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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +36,7 @@
public class WaterPurifierBlock extends BaseEntityBlock
{
public static final MapCodec<WaterPurifierBlock> CODEC = simpleCodec(WaterPurifierBlock::new);
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public static final EnumProperty<Direction> FACING = HorizontalDirectionalBlock.FACING;
public static final BooleanProperty PURIFYING = BooleanProperty.create("filtering");

public WaterPurifierBlock(Properties builderIn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand All @@ -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());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -60,6 +58,8 @@ public class WaterPurifierBlockEntity extends BaseContainerBlockEntity implement
/** The total time needed to complete purification. */
private int purifyTotalTime;

private final RecipeManager.CachedCheck<SingleRecipeInput, ? extends Recipe<SingleRecipeInput>> quickCheck;

protected final ContainerData dataAccess = new ContainerData()
{
@Override
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<WaterPurifierRecipe>) TANRecipeTypes.WATER_PURIFYING, new SingleRecipeInput(blockEntity.items.get(0)), blockEntity.level).orElse(null);
RecipeHolder<? extends Recipe<SingleRecipeInput>> recipe = blockEntity.quickCheck.getRecipeFor(new SingleRecipeInput(blockEntity.items.get(0)), (ServerLevel)level).orElse(null);

if (recipe != null)
{
Expand All @@ -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());
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -342,11 +342,12 @@ public boolean isFiltering()
return this.filterTimeRemaining > 0;
}

protected boolean canFilter(@Nullable Recipe<?> recipe)
protected boolean canFilter(@Nullable Recipe<SingleRecipeInput> 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())
Expand Down Expand Up @@ -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<WaterPurifierRecipe>) 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<SingleRecipeInput> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ThermoregulatorContainer>
{
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<WaterPurifierContainer>
public class WaterPurifierScreen extends AbstractContainerScreen<WaterPurifierMenu>
{
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);
}
Expand All @@ -41,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.isFiltering())
{
int filterProgress = this.menu.getFilterProgress();

// 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);
}
}
Loading

0 comments on commit 4951761

Please sign in to comment.