parent
1a851d1708
commit
42afb3528c
1 changed files with 24 additions and 6 deletions
|
@ -33,6 +33,7 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
@ -154,8 +155,13 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
|
||||||
if (hitState.getBlock() instanceof FluidDrainable) {
|
if (hitState.getBlock() instanceof FluidDrainable) {
|
||||||
Fluid drainFluid = ((FluidDrainable)hitState.getBlock()).tryDrainFluid(world, hitPos, hitState);
|
Fluid drainFluid = ((FluidDrainable)hitState.getBlock()).tryDrainFluid(world, hitPos, hitState);
|
||||||
if(drainFluid != Fluids.EMPTY){
|
if(drainFluid != Fluids.EMPTY){
|
||||||
|
if (stack.getCount() == 1) {
|
||||||
|
stack = getCellWithFluid(drainFluid, 1);
|
||||||
|
} else {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
insertOrDropStack(player, getCellWithFluid(drainFluid, 1));
|
insertOrDropStack(player, getCellWithFluid(drainFluid, 1));
|
||||||
|
}
|
||||||
|
|
||||||
playEmptyingSound(player, world, hitPos, drainFluid);
|
playEmptyingSound(player, world, hitPos, drainFluid);
|
||||||
return TypedActionResult.success(stack);
|
return TypedActionResult.success(stack);
|
||||||
}
|
}
|
||||||
|
@ -164,10 +170,22 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
|
||||||
} else {
|
} else {
|
||||||
BlockState placeState = world.getBlockState(placePos);
|
BlockState placeState = world.getBlockState(placePos);
|
||||||
if(placeState.canBucketPlace(containedFluid)){
|
if(placeState.canBucketPlace(containedFluid)){
|
||||||
|
if (world.dimension.doesWaterVaporize() && containedFluid.matches(FluidTags.WATER)) {
|
||||||
|
world.playSound(player, placePos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
|
||||||
|
for(int l = 0; l < 8; ++l) {
|
||||||
|
world.addParticle(ParticleTypes.LARGE_SMOKE, (double)placePos.getX() + Math.random(), (double)placePos.getY() + Math.random(), (double)placePos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
world.setBlockState(placePos, containedFluid.getDefaultState().getBlockState());
|
world.setBlockState(placePos, containedFluid.getDefaultState().getBlockState());
|
||||||
|
playEmptyingSound(player, world, placePos, containedFluid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stack.getCount() == 1) {
|
||||||
|
stack = getEmpty();
|
||||||
|
} else {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
insertOrDropStack(player, getEmpty());
|
insertOrDropStack(player, getEmpty());
|
||||||
playEmptyingSound(player, world, placePos, containedFluid);
|
}
|
||||||
|
|
||||||
return TypedActionResult.success(stack);
|
return TypedActionResult.success(stack);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue