2022-01-09 18:58:55 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.items;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
import net.minecraft.block.FlowingFluidBlock;
|
|
|
|
import net.minecraft.entity.item.ItemEntity;
|
|
|
|
import net.minecraft.fluid.Fluid;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
|
|
|
public class CanolaSeed extends ItemBase {
|
|
|
|
public boolean empowered;
|
|
|
|
public CanolaSeed(boolean empowered) {
|
|
|
|
this.empowered = empowered;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFoil(ItemStack p_77636_1_) {
|
|
|
|
return empowered;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
|
|
|
|
if (!entity.level.isClientSide) {
|
|
|
|
if (stack != null) {
|
|
|
|
BlockPos pos = entity.blockPosition();
|
|
|
|
BlockState state = entity.level.getBlockState(pos);
|
|
|
|
Block block = state.getBlock();
|
|
|
|
|
|
|
|
if (block instanceof FlowingFluidBlock && state.getFluidState().isSource()) {
|
|
|
|
Fluid fluid = ((FlowingFluidBlock) block).getFluid();
|
|
|
|
if (fluid != null && fluid == (empowered
|
2022-04-02 04:50:39 +02:00
|
|
|
? InitFluids.CRYSTALLIZED_OIL.get()
|
2022-01-09 18:58:55 +01:00
|
|
|
: InitFluids.REFINED_CANOLA_OIL.get())) {
|
|
|
|
entity.kill();
|
|
|
|
entity.level.setBlockAndUpdate(pos, (empowered
|
|
|
|
? InitFluids.EMPOWERED_OIL.getBlock()
|
2022-04-02 04:50:39 +02:00
|
|
|
: InitFluids.CRYSTALLIZED_OIL.getBlock()).defaultBlockState());
|
2022-01-09 18:58:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.onEntityItemUpdate(stack, entity);
|
|
|
|
}
|
|
|
|
}
|