Search in sources :

Example 36 with PlayerEntity

use of net.minecraft.entity.player.PlayerEntity in project NetherEx by LogicTechCorp.

the class RenderEventHandler method onRenderSpecificHand.

@SubscribeEvent
public static void onRenderSpecificHand(RenderHandEvent event) {
    PlayerEntity player = MINECRAFT.player;
    MatrixStack matrixStack = event.getMatrixStack();
    if (player != null && player.isPotionActive(NetherExEffects.FIRE_BURNING.get())) {
        renderFirstPersonBlueFire(matrixStack);
    }
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 37 with PlayerEntity

use of net.minecraft.entity.player.PlayerEntity in project AgriCraft by AgriCraft.

the class ItemTrowel method onItemUse.

@Nonnull
@Override
public ActionResultType onItemUse(@Nonnull ItemUseContext context) {
    World world = context.getWorld();
    BlockPos pos = context.getPos();
    ItemStack stack = context.getItem();
    PlayerEntity player = context.getPlayer();
    return AgriApi.getCrop(world, pos).map(crop -> this.tryUseOnCrop(crop, stack, player)).orElseGet(() -> this.tryPlantOnSoil(world, pos, stack, player));
}
Also used : AgriNBT(com.infinityraider.agricraft.reference.AgriNBT) InfinityItemProperty(com.infinityraider.infinitylib.item.InfinityItemProperty) IAgriCrop(com.infinityraider.agricraft.api.v1.crop.IAgriCrop) TileEntityCropSticks(com.infinityraider.agricraft.content.core.TileEntityCropSticks) NoPlant(com.infinityraider.agricraft.impl.v1.plant.NoPlant) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) CompoundNBT(net.minecraft.nbt.CompoundNBT) IAgriGrowthStage(com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage) IAgriGenome(com.infinityraider.agricraft.api.v1.genetics.IAgriGenome) ItemUseContext(net.minecraft.item.ItemUseContext) Dist(net.minecraftforge.api.distmarker.Dist) ItemStack(net.minecraft.item.ItemStack) AgriToolTips(com.infinityraider.agricraft.reference.AgriToolTips) Names(com.infinityraider.agricraft.reference.Names) ItemBase(com.infinityraider.infinitylib.item.ItemBase) IAgriTrowelItem(com.infinityraider.agricraft.api.v1.content.items.IAgriTrowelItem) BlockState(net.minecraft.block.BlockState) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) AgriCraft(com.infinityraider.agricraft.AgriCraft) IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) ImmutableSet(com.google.common.collect.ImmutableSet) AgriApi(com.infinityraider.agricraft.api.v1.AgriApi) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) World(net.minecraft.world.World) Set(java.util.Set) BlockPos(net.minecraft.util.math.BlockPos) Blocks(net.minecraft.block.Blocks) MinecraftForge(net.minecraftforge.common.MinecraftForge) AgriTabs(com.infinityraider.agricraft.content.AgriTabs) ResourceLocation(net.minecraft.util.ResourceLocation) Optional(java.util.Optional) TileEntity(net.minecraft.tileentity.TileEntity) AgriCropEvent(com.infinityraider.agricraft.api.v1.event.AgriCropEvent) ActionResultType(net.minecraft.util.ActionResultType) ClientWorld(net.minecraft.client.world.ClientWorld) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ClientWorld(net.minecraft.client.world.ClientWorld) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Nonnull(javax.annotation.Nonnull)

Example 38 with PlayerEntity

use of net.minecraft.entity.player.PlayerEntity in project AgriCraft by AgriCraft.

the class MagnifyingGlassViewHandler method checkInspectedPosition.

protected void checkInspectedPosition() {
    RayTraceResult hit = Minecraft.getInstance().objectMouseOver;
    Target target = Target.getTarget(hit);
    if (target == null) {
        this.endInspection();
        return;
    }
    if (target.isNewTarget(this.lastTarget)) {
        this.endInspection();
        MessageMagnifyingGlassObserving.sendToServer(this.getPlayer(), true);
        World world = AgriCraft.instance.getClientWorld();
        PlayerEntity player = AgriCraft.instance.getClientPlayer();
        this.inspectors.stream().filter(inspector -> target.canInspect(world, inspector, player)).findAny().ifPresent(inspector -> {
            this.lastTarget = target;
            this.inspector = inspector;
            this.lastTarget.onInspectionStart(world, inspector, player);
        });
    }
}
Also used : World(net.minecraft.world.World) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 39 with PlayerEntity

use of net.minecraft.entity.player.PlayerEntity in project AgriCraft by AgriCraft.

the class ItemSeedBag method onItemUse.

@Nonnull
@Override
public ActionResultType onItemUse(@Nonnull ItemUseContext context) {
    Contents contents = this.getContents(context.getItem());
    if (this.isActivated(context.getItem())) {
        Hand hand = context.getHand();
        PlayerEntity player = context.getPlayer();
        if (hand == Hand.OFF_HAND) {
            // From off hand: interact with main to insert / extract seeds
            if (player != null && this.attemptExtractOrInsertSeed(player, contents)) {
                return ActionResultType.SUCCESS;
            }
        } else {
            // From main hand: interact with the world to plant the seed
            if (this.attemptPlantSeed(context.getWorld(), context.getPos(), contents, player)) {
                return ActionResultType.SUCCESS;
            }
        }
    }
    return ActionResultType.PASS;
}
Also used : CapabilitySeedBagContents(com.infinityraider.agricraft.capability.CapabilitySeedBagContents) Hand(net.minecraft.util.Hand) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Nonnull(javax.annotation.Nonnull)

Example 40 with PlayerEntity

use of net.minecraft.entity.player.PlayerEntity in project AgriCraft by AgriCraft.

the class MessageCompareLight method processMessage.

@Override
protected void processMessage(NetworkEvent.Context ctx) {
    // Get world.
    final World world = AgriCraft.instance.proxy().getWorldFromDimension(this.dimId);
    // Get player.
    final PlayerEntity player = ctx.getSender();
    // Get server light data.
    final byte[] serverLightData = LightHelper.getLightData(world, this.pos);
    // Message the light data to the player.
    LightHelper.messageLightData(player, clientLightData, serverLightData);
}
Also used : World(net.minecraft.world.World) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

PlayerEntity (net.minecraft.entity.player.PlayerEntity)46 ItemStack (net.minecraft.item.ItemStack)22 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)19 World (net.minecraft.world.World)17 BlockPos (net.minecraft.util.math.BlockPos)16 CompoundNBT (net.minecraft.nbt.CompoundNBT)13 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)12 BlockState (net.minecraft.block.BlockState)10 ResourceLocation (net.minecraft.util.ResourceLocation)7 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)6 Nonnull (javax.annotation.Nonnull)6 AgriCraft (com.infinityraider.agricraft.AgriCraft)5 TileEntity (net.minecraft.tileentity.TileEntity)5 IAgriCrop (com.infinityraider.agricraft.api.v1.crop.IAgriCrop)4 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)4 AgriTabs (com.infinityraider.agricraft.content.AgriTabs)4 Names (com.infinityraider.agricraft.reference.Names)4 ItemBase (com.infinityraider.infinitylib.item.ItemBase)4 Nullable (javax.annotation.Nullable)4 Blocks (net.minecraft.block.Blocks)4