mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-25 14:36:18 +01:00
Add deployer feeding
This commit is contained in:
parent
282445d2ac
commit
f08a574653
2 changed files with 15 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue