Make cells drainable again (#1246)
* FIx unused import * Make cells drainable again * Fix deprecated warning
This commit is contained in:
parent
c401f116aa
commit
df808760ad
2 changed files with 20 additions and 2 deletions
|
@ -42,7 +42,6 @@ import techreborn.Core;
|
||||||
import techreborn.api.reactor.FusionReactorRecipe;
|
import techreborn.api.reactor.FusionReactorRecipe;
|
||||||
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
||||||
import techreborn.api.recipe.machines.*;
|
import techreborn.api.recipe.machines.*;
|
||||||
import techreborn.blocks.BlockMachineFrames;
|
|
||||||
import techreborn.blocks.BlockOre;
|
import techreborn.blocks.BlockOre;
|
||||||
import techreborn.compat.CompatManager;
|
import techreborn.compat.CompatManager;
|
||||||
import techreborn.config.ConfigTechReborn;
|
import techreborn.config.ConfigTechReborn;
|
||||||
|
|
|
@ -45,7 +45,9 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fluids.FluidUtil;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
|
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||||
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
|
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
@ -109,7 +111,7 @@ public class DynamicCell extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (block instanceof BlockStaticLiquid) {
|
} else if (block instanceof BlockStaticLiquid) {
|
||||||
Fluid fluid = block.getMaterial(state) == Material.LAVA ? FluidRegistry.LAVA : FluidRegistry.WATER;
|
Fluid fluid = state.getMaterial() == Material.LAVA ? FluidRegistry.LAVA : FluidRegistry.WATER;
|
||||||
|
|
||||||
if (tryAddCellToInventory(playerIn, stack, fluid)) {
|
if (tryAddCellToInventory(playerIn, stack, fluid)) {
|
||||||
if (fluid != FluidRegistry.WATER)
|
if (fluid != FluidRegistry.WATER)
|
||||||
|
@ -117,6 +119,23 @@ public class DynamicCell extends Item {
|
||||||
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
|
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ItemStack usedCell = stack.copy();
|
||||||
|
usedCell.setCount(1);
|
||||||
|
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(usedCell);
|
||||||
|
if (fluidHandler != null) {
|
||||||
|
FluidStack fluid = fluidHandler.drain(DynamicCell.CAPACITY, false);
|
||||||
|
if (fluid != null){
|
||||||
|
if(FluidUtil.tryPlaceFluid(playerIn, worldIn, pos.offset(result.sideHit), fluidHandler, fluid)){
|
||||||
|
stack.shrink(1);
|
||||||
|
playerIn.inventory.addItemStackToInventory(getEmptyCell(1));
|
||||||
|
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
|
||||||
|
}
|
||||||
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
}
|
||||||
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
}
|
||||||
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue