- Fix extractor couldn't drop items when it attaches to a moving blcoks (#317)

This commit is contained in:
Snownee 2020-05-17 17:56:32 +08:00
parent f662a1c805
commit 3544b981ee

View file

@ -35,18 +35,18 @@ public class ExtractorMovementBehaviour extends MovementBehaviour {
ItemStack filter = getFilter(context); ItemStack filter = getFilter(context);
int amount = getFilterAmount(context); int amount = getFilterAmount(context);
ItemStack dropped = ItemHelper.extract(context.contraption.inventory, ItemStack dropped = ItemHelper.extract(context.contraption.inventory,
stack -> FilterItem.test(context.world, stack, filter), amount == 0 ? -1 : amount, false); stack -> FilterItem.test(context.world, stack, filter), amount == 0 ? 64 : amount, false);
if (dropped.isEmpty()) if (dropped.isEmpty())
return; return;
if (world.isRemote) if (world.isRemote)
return; return;
Vec3d entityPos = VecHelper.getCenterOf(pos).add(0, -0.5f, 0); Vec3d entityPos = context.position;
Entity entityIn = null; Entity entityIn = null;
Direction facing = AttachedLogisticalBlock.getBlockFacing(context.state); Direction facing = AttachedLogisticalBlock.getBlockFacing(context.state);
if (facing == Direction.DOWN) if (facing != Direction.DOWN)
entityPos = entityPos.add(0, .5, 0); entityPos = entityPos.add(0, -0.5f, 0);
entityIn = new ItemEntity(world, entityPos.x, entityPos.y, entityPos.z, dropped); entityIn = new ItemEntity(world, entityPos.x, entityPos.y, entityPos.z, dropped);
entityIn.setMotion(Vec3d.ZERO); entityIn.setMotion(Vec3d.ZERO);