Skip to content

Commit

Permalink
Hoppers waterlog on placement
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Dec 27, 2019
1 parent 71728ff commit 5178e28
Showing 1 changed file with 17 additions and 3 deletions.
@@ -1,15 +1,19 @@
package knightminer.inspirations.tweaks.block;

import knightminer.inspirations.tweaks.InspirationsTweaks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HopperBlock;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.tileentity.HopperTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
Expand All @@ -23,11 +27,21 @@ public DryHopperBlock(Properties props) {
super(props);
}

@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
Direction side = context.getFace().getOpposite();
Block block = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER
? InspirationsTweaks.wetHopper : InspirationsTweaks.dryHopper;
return block.getDefaultState()
.with(FACING, side.getAxis() == Axis.Y ? Direction.DOWN : side)
.with(ENABLED, true);
}

@Override
public void onReplaced(BlockState state1, @Nonnull World world, @Nonnull BlockPos pos, BlockState state2, boolean moving) {
if ( state2.getBlock() != state1.getBlock() &&
state2.getBlock() != InspirationsTweaks.dryHopper &&
state2.getBlock() != InspirationsTweaks.wetHopper
if (state2.getBlock() != state1.getBlock() &&
state2.getBlock() != InspirationsTweaks.dryHopper &&
state2.getBlock() != InspirationsTweaks.wetHopper
) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof HopperTileEntity) {
Expand Down

0 comments on commit 5178e28

Please sign in to comment.