Search in sources :

Example 66 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class MagnifyingGlassViewHandler method onPlayerRender.

@SuppressWarnings("unused")
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerRender(RenderPlayerEvent.Pre event) {
    if (this.isActive()) {
        PlayerRenderer renderer = event.getRenderer();
        PlayerModel<AbstractClientPlayerEntity> model = renderer.getEntityModel();
        Hand hand = this.getActiveHand();
        HandSide side = Minecraft.getInstance().gameSettings.mainHand;
        if ((hand == Hand.MAIN_HAND && side == HandSide.RIGHT) || (hand == Hand.OFF_HAND && side == HandSide.LEFT)) {
            model.rightArmPose = BipedModel.ArmPose.BLOCK;
            model.leftArmPose = BipedModel.ArmPose.EMPTY;
        } else if ((hand == Hand.MAIN_HAND && side == HandSide.LEFT) || (hand == Hand.OFF_HAND && side == HandSide.RIGHT)) {
            model.leftArmPose = BipedModel.ArmPose.BLOCK;
            model.rightArmPose = BipedModel.ArmPose.EMPTY;
        }
    }
}
Also used : PlayerRenderer(net.minecraft.client.renderer.entity.PlayerRenderer) HandSide(net.minecraft.util.HandSide) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) Hand(net.minecraft.util.Hand) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 67 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class BlockUpdateHandler method onBlockUpdate.

@SubscribeEvent
@SuppressWarnings("unused")
public void onBlockUpdate(BlockEvent.NeighborNotifyEvent event) {
    if (event.getWorld() instanceof ServerWorld) {
        ServerWorld world = (ServerWorld) event.getWorld();
        RegistryKey<World> dimension = world.getDimensionKey();
        this.listeners.computeIfPresent(dimension, (dim, chunkMap) -> {
            chunkMap.computeIfPresent(new ChunkPos(event.getPos()), (chunkPos, posMap) -> {
                posMap.computeIfPresent(event.getPos(), (pos, set) -> {
                    set.forEach(listener -> listener.onBlockUpdate(world, pos));
                    return set;
                });
                return posMap;
            });
            return chunkMap;
        });
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) ChunkPos(net.minecraft.util.math.ChunkPos) ServerWorld(net.minecraft.world.server.ServerWorld) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 68 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class ItemToolTipHandler method addRegistryInfo.

@SubscribeEvent
@SuppressWarnings("unused")
public void addRegistryInfo(ItemTooltipEvent event) {
    if (AgriCraft.instance.getConfig().registryTooltips()) {
        final Item item = event.getItemStack().getItem();
        addCategory(event, "Registry");
        addParameter(event, "id", item.getRegistryName());
    }
}
Also used : Item(net.minecraft.item.Item) IAgriClipperItem(com.infinityraider.agricraft.api.v1.content.items.IAgriClipperItem) IAgriJournalItem(com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem) IAgriTrowelItem(com.infinityraider.agricraft.api.v1.content.items.IAgriTrowelItem) BlockItem(net.minecraft.item.BlockItem) IAgriRakeItem(com.infinityraider.agricraft.api.v1.content.items.IAgriRakeItem) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 69 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class BlockGreenHouseAirRenderer method render.

@SubscribeEvent
@SuppressWarnings("unused")
public void render(RenderWorldLastEvent event) {
    PlayerEntity player = AgriCraft.instance.getClientPlayer();
    ItemStack stack = player.getHeldItemMainhand();
    if (stack.getItem() != AgriCraft.instance.getModItemRegistry().debugger) {
        return;
    }
    if (AgriCraft.instance.getModItemRegistry().debugger.getDebugMode(stack) instanceof DebugModeGreenHouse) {
        this.highlightGreenHouseAirBlocks(player.getEntityWorld(), player.getPosition(), event.getMatrixStack());
    }
}
Also used : DebugModeGreenHouse(com.infinityraider.agricraft.util.debug.DebugModeGreenHouse) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 70 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project AgriCraft by AgriCraft.

the class GeneAnimalAttractant method onEntitySpawned.

@SubscribeEvent
@SuppressWarnings("unused")
public void onEntitySpawned(EntityJoinWorldEvent event) {
    if (!event.getWorld().isRemote() && this.clazz.isInstance(event.getEntity())) {
        MobEntity entity = this.clazz.cast(event.getEntity());
        EatCropGoal goal = new EatCropGoal(this, entity, SPEED, COOLDOWN, this.defaultPlantIds);
        if (EntityHelper.injectGoal(entity, goal, PRIORITY)) {
            CapabilityEatCropGoal.getInstance().setCropEatGoal(entity, goal);
        }
    }
}
Also used : MobEntity(net.minecraft.entity.MobEntity) CapabilityEatCropGoal(com.infinityraider.agricraft.capability.CapabilityEatCropGoal) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)87 PlayerEntity (net.minecraft.entity.player.PlayerEntity)18 ItemStack (net.minecraft.item.ItemStack)17 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)11 ResourceLocation (net.minecraft.util.ResourceLocation)10 World (net.minecraft.world.World)8 Player (net.minecraft.world.entity.player.Player)8 BlockPos (net.minecraft.util.math.BlockPos)7 Entity (net.minecraft.world.entity.Entity)7 ItemStack (net.minecraft.world.item.ItemStack)7 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 Minecraft (net.minecraft.client.Minecraft)5 BlockPos (net.minecraft.core.BlockPos)5 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)5 Item (net.minecraft.world.item.Item)5 BlockItem (net.minecraft.item.BlockItem)4 ResourceLocation (net.minecraft.resources.ResourceLocation)4 BlockState (net.minecraft.world.level.block.state.BlockState)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4