Skip to content

Commit

Permalink
Fixes #471: TFC alcohols and waters can be bottled into vanilla water…
Browse files Browse the repository at this point in the history
…. (Squashed from PR, closes #530)
  • Loading branch information
Lysergid authored and alcatrazEscapee committed Nov 23, 2019
1 parent 7ddf53d commit ea1a244
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
@@ -0,0 +1,48 @@
/*
* Work under Copyright. Licensed under the EUPL.
* See the project README.md and LICENSE.txt for more information.
*/

package net.dries007.tfc.objects.items;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemGlassBottle;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;

import net.dries007.tfc.objects.fluids.FluidsTFC;

/**
* todo: as per comment in ItemsTFC, turn this into a proper fluid handler item?
*/
@ParametersAreNonnullByDefault
public class ItemGlassBottleTFC extends ItemGlassBottle
{
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
RayTraceResult result = rayTrace(worldIn, playerIn, true);

//noinspection ConstantConditions
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK)
{
IBlockState targetState = worldIn.getBlockState(result.getBlockPos());
if (targetState.getMaterial() == Material.WATER && targetState.getBlock() != Blocks.WATER && targetState.getBlock() != FluidsTFC.FRESH_WATER.get().getBlock())
{
return new ActionResult<>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
}
}
return super.onItemRightClick(worldIn, playerIn, handIn);
}
}
4 changes: 3 additions & 1 deletion src/main/java/net/dries007/tfc/objects/items/ItemsTFC.java
Expand Up @@ -9,6 +9,7 @@
import com.google.common.collect.ImmutableList.Builder;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSnow;
Expand Down Expand Up @@ -316,7 +317,8 @@ public static void registerVanillaOverrides(RegistryEvent.Register<Item> event)
TerraFirmaCraft.getLog().info("The below warnings about unintended overrides are normal. The override is intended. ;)");
event.getRegistry().registerAll(
new ItemSnow(Blocks.SNOW_LAYER).setRegistryName("minecraft", "snow_layer"),
new ItemBlockTorch(Blocks.TORCH).setRegistryName("minecraft", "torch")
new ItemBlockTorch(Blocks.TORCH).setRegistryName("minecraft", "torch"),
new ItemGlassBottleTFC().setRegistryName(Items.GLASS_BOTTLE.getRegistryName()).setTranslationKey("glassBottle")
);
}

Expand Down
Expand Up @@ -177,7 +177,6 @@ public final class InteractionManager
}
return EnumActionResult.FAIL;
});

}

@SubscribeEvent(priority = EventPriority.LOWEST)
Expand Down

0 comments on commit ea1a244

Please sign in to comment.