Search in sources :

Example 81 with SubscribeEvent

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

the class ScubaAmbienceTicker method onClientTick.

@SubscribeEvent
public static void onClientTick(ClientTickEvent event) {
    if (event.phase != Phase.START)
        return;
    Minecraft mc = Minecraft.getInstance();
    if (mc.level != null && mc.player != null) {
        Camera renderInfo = mc.getEntityRenderDispatcher().camera;
        Entity renderViewEntity = mc.getCameraEntity();
        if (renderInfo != null && renderViewEntity instanceof Player) {
            Player player = (Player) renderViewEntity;
            if (renderInfo.getFluidInCamera() == FogType.WATER && player.getItemBySlot(EquipmentSlot.CHEST).getItem() instanceof ScubaArmorItem) {
                if (ScubaData.getDepth(player) < 60) {
                    play(SHALLOW_SCUBA);
                    return;
                } else {
                    play(DEEP_SCUBA);
                    return;
                }
            }
        }
    }
    stop();
}
Also used : Entity(net.minecraft.world.entity.Entity) Player(net.minecraft.world.entity.player.Player) Camera(net.minecraft.client.Camera) ScubaArmorItem(net.tropicraft.core.common.item.scuba.ScubaArmorItem) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 82 with SubscribeEvent

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

the class HugePlantBlockHighlight method onHighlightBlock.

@SubscribeEvent
public static void onHighlightBlock(DrawSelectionEvent.HighlightBlock event) {
    ClientLevel world = CLIENT.level;
    if (world == null)
        return;
    BlockPos pos = event.getTarget().getBlockPos();
    BlockState state = world.getBlockState(pos);
    if (state.getBlock() instanceof HugePlantBlock) {
        renderHugePlantHighlight(event, world, pos, state);
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) ClientLevel(net.minecraft.client.multiplayer.ClientLevel) BlockPos(net.minecraft.core.BlockPos) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 83 with SubscribeEvent

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

the class TropicraftBiomes method onBiomeLoad.

@SubscribeEvent
public static void onBiomeLoad(BiomeLoadingEvent event) {
    ResourceLocation name = event.getName();
    if (name != null && name.getNamespace().equals(Constants.MODID)) {
        return;
    }
    Biome.BiomeCategory category = event.getCategory();
    Biome.Precipitation precipitation = event.getClimate().precipitation;
    if (precipitation == Biome.Precipitation.SNOW) {
        return;
    }
    BiomeGenerationSettingsBuilder generation = event.getGeneration();
    if (category == Biome.BiomeCategory.BEACH) {
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, TropicraftFeatures.NORMAL_PALM_TREE.get().configured(NoneFeatureConfiguration.INSTANCE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).decorated(FeatureDecorator.COUNT_EXTRA.configured(new FrequencyWithExtraChanceDecoratorConfiguration(0, 0.08F, 1))));
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, TropicraftFeatures.CURVED_PALM_TREE.get().configured(NoneFeatureConfiguration.INSTANCE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).decorated(FeatureDecorator.COUNT_EXTRA.configured(new FrequencyWithExtraChanceDecoratorConfiguration(0, 0.08F, 1))));
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, TropicraftFeatures.LARGE_PALM_TREE.get().configured(NoneFeatureConfiguration.INSTANCE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).decorated(FeatureDecorator.COUNT_EXTRA.configured(new FrequencyWithExtraChanceDecoratorConfiguration(0, 0.08F, 1))));
    } else if (category == Biome.BiomeCategory.JUNGLE) {
        SimpleStateProvider state = new SimpleStateProvider(TropicraftBlocks.PINEAPPLE.get().defaultBlockState());
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(new RandomPatchConfiguration.GrassConfigurationBuilder(state, new DoublePlantPlacer()).tries(6).canReplace().build()).decorated(Features.Decorators.HEIGHTMAP_DOUBLE_SQUARE));
    }
}
Also used : SimpleStateProvider(net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider) Biome(net.minecraft.world.level.biome.Biome) FrequencyWithExtraChanceDecoratorConfiguration(net.minecraft.world.level.levelgen.placement.FrequencyWithExtraChanceDecoratorConfiguration) ResourceLocation(net.minecraft.resources.ResourceLocation) DoublePlantPlacer(net.minecraft.world.level.levelgen.feature.blockplacers.DoublePlantPlacer) BiomeGenerationSettingsBuilder(net.minecraftforge.common.world.BiomeGenerationSettingsBuilder) RandomPatchConfiguration(net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 84 with SubscribeEvent

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

the class VolcanoGenerator method onServerStarting.

@SubscribeEvent
public static void onServerStarting(FMLServerStartingEvent event) {
    // we don't really have a structure but we fake it
    CommandDispatcher<CommandSourceStack> dispatcher = event.getServer().getCommands().getDispatcher();
    LiteralArgumentBuilder<CommandSourceStack> locate = Commands.literal("locate").requires(source -> source.hasPermission(2));
    dispatcher.register(locate.then(Commands.literal(Constants.MODID + ":volcano").executes(ctx -> {
        CommandSourceStack source = ctx.getSource();
        BlockPos pos = new BlockPos(source.getPosition());
        BlockPos volcanoPos = getVolcanoNear(source.getLevel(), pos.getX() >> 4, pos.getZ() >> 4, 100);
        if (volcanoPos == null) {
            throw new SimpleCommandExceptionType(new TranslatableComponent("commands.locate.failed")).create();
        } else {
            return LocateCommand.showLocateResult(source, "Volcano", pos, volcanoPos, "commands.locate.success");
        }
    })));
}
Also used : TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) BlockPos(net.minecraft.core.BlockPos) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandSourceStack(net.minecraft.commands.CommandSourceStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 85 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project MC-Prefab by Brian-Wuest.

the class ModEventHandler method AnvilUpdate.

@SubscribeEvent
public static void AnvilUpdate(AnvilUpdateEvent event) {
    ItemStack rightItem = event.getRight();
    ItemStack leftItem = event.getLeft();
    Item tripleCompressedStone = ModRegistry.TripleCompressedStoneItem.get();
    ItemBulldozer bulldozer = ModRegistry.Bulldozer.get();
    if (rightItem.getItem() == tripleCompressedStone || leftItem.getItem() == tripleCompressedStone) {
        if (rightItem.getItem() == bulldozer || leftItem.getItem() == bulldozer) {
            event.setCost(4);
            ItemStack outputStack = new ItemStack(bulldozer);
            bulldozer.setPoweredValue(outputStack, true);
            outputStack.setDamageValue(0);
            event.setOutput(outputStack);
        }
    }
}
Also used : Item(net.minecraft.world.item.Item) ItemStack(net.minecraft.world.item.ItemStack) ItemBulldozer(com.wuest.prefab.structures.items.ItemBulldozer) 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