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();
}
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);
}
}
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));
}
}
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");
}
})));
}
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);
}
}
}
Aggregations