Fluid buckets place fluid from dispenser (#3161). Thanks to WaffleDevs
* Fluid buckets place fluid from dispenser * Remove unused imports & variables. * Rename emptyCell to emptyBucket
This commit is contained in:
parent
5045566a98
commit
e57f7a444e
1 changed files with 24 additions and 0 deletions
|
@ -34,6 +34,7 @@ import net.minecraft.fluid.FlowableFluid;
|
|||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.BlockPointer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
@ -41,6 +42,7 @@ import net.minecraft.util.math.Position;
|
|||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.fluid.RebornBucketItem;
|
||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -121,5 +123,27 @@ public class TRDispenserBehavior {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (ModFluids fluid : ModFluids.values()) {
|
||||
DispenserBlock.registerBehavior(fluid, new ItemDispenserBehavior() {
|
||||
public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
|
||||
RebornBucketItem bucket = (RebornBucketItem) stack.getItem();
|
||||
BlockPos blockPos = pointer.getPos().offset(pointer.getBlockState().get(DispenserBlock.FACING));
|
||||
|
||||
if (bucket.placeFluid(null, pointer.getWorld(), blockPos, null)) {
|
||||
ItemStack emptyBucket = new ItemStack(Items.BUCKET);
|
||||
if (stack.getCount() == 1) {
|
||||
stack = emptyBucket;
|
||||
} else {
|
||||
stack.decrement(1);
|
||||
if (((DispenserBlockEntity) pointer.getBlockEntity()).addToFirstFreeSlot(emptyBucket) < 0) {
|
||||
this.dispense(pointer, emptyBucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue