diff --git a/src/main/java/com/charles445/simpledifficulty/item/ItemCanteen.java b/src/main/java/com/charles445/simpledifficulty/item/ItemCanteen.java index 3b6a99d..517a8ae 100644 --- a/src/main/java/com/charles445/simpledifficulty/item/ItemCanteen.java +++ b/src/main/java/com/charles445/simpledifficulty/item/ItemCanteen.java @@ -333,7 +333,8 @@ public boolean tryAddDose(ItemStack stack, ThirstEnum thirstEnum) { protected boolean formatCanteen(ItemStack stack, ThirstEnum thirstEnum) { if (thirstEnum != getThirstEnum(stack)) { - // When changing water type, keep existing doses but change the type. This prevents losing all water when switching types + // When changing water type, keep existing doses but change the type + // This prevents losing all water when switching types int currentDoses = getDoses(stack); setTypeTag(stack, thirstEnum); setDosesInternal(stack, currentDoses); diff --git a/src/main/java/com/charles445/simpledifficulty/register/crafting/CanteenCharcoalRecipe.java b/src/main/java/com/charles445/simpledifficulty/register/crafting/CanteenCharcoalRecipe.java index 4b7ea2b..c687e01 100644 --- a/src/main/java/com/charles445/simpledifficulty/register/crafting/CanteenCharcoalRecipe.java +++ b/src/main/java/com/charles445/simpledifficulty/register/crafting/CanteenCharcoalRecipe.java @@ -30,7 +30,6 @@ public CanteenCharcoalRecipe(ResourceLocation group, NonNullList inp @Nonnull public ItemStack getCraftingResult(@Nonnull InventoryCrafting invcraft) { - //return output.copy(); ItemStack output = super.getCraftingResult(invcraft); if(!output.isEmpty()) @@ -41,14 +40,14 @@ public ItemStack getCraftingResult(@Nonnull InventoryCrafting invcraft) if(!ingredient.isEmpty() && (ingredient.getItem() == SDItems.canteen || ingredient.getItem() == SDItems.ironCanteen)) { IItemCanteen canteen = (ItemCanteen)ingredient.getItem(); - canteen.setDoses(output, ThirstEnum.NORMAL, canteen.getDoses(ingredient)); + // Charcoal filter purifies water, so set to PURIFIED + canteen.setDoses(output, ThirstEnum.PURIFIED, canteen.getDoses(ingredient)); break; } } } return output; - } public static class Factory implements IRecipeFactory @@ -70,4 +69,4 @@ public IRecipe parse(JsonContext context, JsonObject json) result); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java index cb73a06..f18c67d 100644 --- a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java +++ b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java @@ -13,8 +13,10 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.biome.Biome; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -128,29 +130,58 @@ public ThirstEnumBlockPos traceWater(EntityPlayer player) return null; //Hit a block - Block traceBlock = player.getEntityWorld().getBlockState(trace.getBlockPos()).getBlock(); + BlockPos blockPos = trace.getBlockPos(); + Block traceBlock = player.getEntityWorld().getBlockState(blockPos).getBlock(); + if(traceBlock == Blocks.WATER) { - return new ThirstEnumBlockPos(ThirstEnum.NORMAL, trace.getBlockPos()); + // Check if the water is in an ocean biome - if so, it's salt water + Biome biome = player.getEntityWorld().getBiome(blockPos); + if (isOceanBiome(biome)) { + return new ThirstEnumBlockPos(ThirstEnum.SALT, blockPos); + } + return new ThirstEnumBlockPos(ThirstEnum.NORMAL, blockPos); } else if(traceBlock == SDFluids.blockPurifiedWater) { - return new ThirstEnumBlockPos(ThirstEnum.PURIFIED, trace.getBlockPos()); + return new ThirstEnumBlockPos(ThirstEnum.PURIFIED, blockPos); } else if(traceBlock == SDFluids.blockSaltWater) { - return new ThirstEnumBlockPos(ThirstEnum.SALT, trace.getBlockPos()); + return new ThirstEnumBlockPos(ThirstEnum.SALT, blockPos); } // Optimized lookup using HashSet instead of array iteration String blockRegistryName = traceBlock.getRegistryName().toString(); if(RIVER_BLOCKS_SET.contains(blockRegistryName)) { - return new ThirstEnumBlockPos(ThirstEnum.NORMAL, trace.getBlockPos()); + return new ThirstEnumBlockPos(ThirstEnum.NORMAL, blockPos); } return null; } + // Helper method to check if a biome is an ocean biome + private boolean isOceanBiome(Biome biome) { + if (biome == null) { + return false; + } + + // Check biome category/name for ocean types + String biomeName = biome.getRegistryName() != null ? biome.getRegistryName().toString() : ""; + + // Vanilla ocean biomes + return biomeName.contains("ocean") || + biomeName.equals("minecraft:frozen_ocean") || + biomeName.equals("minecraft:deep_ocean") || + biomeName.equals("minecraft:frozen_ocean") || + biomeName.equals("minecraft:cold_ocean") || + biomeName.equals("minecraft:deep_cold_ocean") || + biomeName.equals("minecraft:lukewarm_ocean") || + biomeName.equals("minecraft:deep_lukewarm_ocean") || + biomeName.equals("minecraft:warm_ocean") || + biomeName.equals("minecraft:deep_warm_ocean"); + } + // Removed riverBlocks array - now using RIVER_BLOCKS_SET for O(1) lookups