diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerFakePlayer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerFakePlayer.java index ec3768403..bd8fd3288 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerFakePlayer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerFakePlayer.java @@ -30,6 +30,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; +import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -87,6 +88,11 @@ public class DeployerFakePlayer extends FakePlayer { return false; } + @Override + public ItemStack onFoodEaten(World world, ItemStack stack) { + return stack; + } + @SubscribeEvent public static void deployerHasEyesOnHisFeet(EntityEvent.EyeHeight event) { if (event.getEntity() instanceof DeployerFakePlayer) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerHandler.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerHandler.java index 5c6b9a069..d19f330a0 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerHandler.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerHandler.java @@ -20,6 +20,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.inventory.EquipmentSlotType; @@ -137,6 +138,14 @@ public class DeployerHandler { && stack.interactWithEntity(player, (LivingEntity) entity, hand)) success = true; } + if (!success && stack.isFood() && entity instanceof PlayerEntity) { + PlayerEntity playerEntity = (PlayerEntity) entity; + if (playerEntity.canEat(item.getFood().canEatWhenFull())) { + playerEntity.onFoodEaten(world, stack); + player.spawnedItemEffects = stack.copy(); + success = true; + } + } } // Punch entity