Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public CanteenCharcoalRecipe(ResourceLocation group, NonNullList<Ingredient> inp
@Nonnull
public ItemStack getCraftingResult(@Nonnull InventoryCrafting invcraft)
{
//return output.copy();
ItemStack output = super.getCraftingResult(invcraft);

if(!output.isEmpty())
Expand All @@ -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
Expand All @@ -70,4 +69,4 @@ public IRecipe parse(JsonContext context, JsonObject json)
result);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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


Expand Down