當前位置: 首頁>>代碼示例>>Java>>正文


Java Event類代碼示例

本文整理匯總了Java中net.minecraftforge.fml.common.eventhandler.Event的典型用法代碼示例。如果您正苦於以下問題:Java Event類的具體用法?Java Event怎麽用?Java Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Event類屬於net.minecraftforge.fml.common.eventhandler包,在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendChanges

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
private void sendChanges()
{
    EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
    if (player == null)
        return;

    // Send any changes requested over the wire to the server:
    double x = this.setX ? this.x : 0;
    double y = this.setY ? this.y : 0;
    double z = this.setZ ? this.z : 0;
    float yaw = this.setYaw ? this.rotationYaw : 0;
    float pitch = this.setPitch ? this.rotationPitch : 0;

    if (this.setX || this.setY || this.setZ || this.setYaw || this.setPitch)
    {
        MalmoMod.network.sendToServer(new TeleportMessage(x, y, z, yaw, pitch, this.setX, this.setY, this.setZ, this.setYaw, this.setPitch));
        if (this.setYaw || this.setPitch)
        {
            // Send a message that the ContinuousMovementCommands can pick up on:
            Event event = new CommandForWheeledRobotNavigationImplementation.ResetPitchAndYawEvent(this.setYaw, this.rotationYaw, this.setPitch, this.rotationPitch);
            MinecraftForge.EVENT_BUS.post(event);
        }
        this.setX = this.setY = this.setZ = this.setYaw = this.setPitch = false;
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:26,代碼來源:AbsoluteMovementCommandsImplementation.java

示例2: onEvent

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
public void onEvent(Event event) {
    ISensorSetting sensor = SensorHandler.getInstance().getSensorFromPath(sensorSetting);
    if (sensor != null && sensor instanceof IEventSensorSetting && getPressure() > PneumaticValues.MIN_PRESSURE_UNIVERSAL_SENSOR) {
        int newRedstoneStrength = ((IEventSensorSetting) sensor).emitRedstoneOnEvent(event, this, getRange(), sensorGuiText);
        if (newRedstoneStrength != 0) eventTimer = ((IEventSensorSetting) sensor).getRedstonePulseLength();
        if (invertedRedstone) newRedstoneStrength = 15 - newRedstoneStrength;
        if (eventTimer > 0 && ThirdPartyManager.computerCraftLoaded) {
            if (event instanceof PlayerInteractEvent) {
                PlayerInteractEvent e = (PlayerInteractEvent) event;
                notifyComputers(newRedstoneStrength, e.getPos().getX(), e.getPos().getY(), e.getPos().getZ());
            } else {
                notifyComputers(newRedstoneStrength);
            }
        }
        if (newRedstoneStrength != redstoneStrength) {
            redstoneStrength = newRedstoneStrength;
            updateNeighbours();
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:21,代碼來源:TileEntityUniversalSensor.java

示例3: getPlayer

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
public static EntityPlayer getPlayer(Event event)
{
	if(event instanceof LivingEvent && ((LivingEvent)event).getEntity() instanceof EntityPlayer)
		return (EntityPlayer)((LivingEvent)event).getEntity();
	if(event instanceof RenderGameOverlayEvent || event instanceof RenderWorldLastEvent || event instanceof ClientTickEvent)
		return HarshenCastle.proxy.getPlayer();
	if(event instanceof PlayerTickEvent)
		return ((PlayerTickEvent)event).player;
	if(event instanceof PlayerEvent)
		return ((PlayerEvent)event).player;
	if(event instanceof net.minecraftforge.event.entity.player.PlayerEvent)
		return ((net.minecraftforge.event.entity.player.PlayerEvent)event).getEntityPlayer();
	if(event instanceof PlayerPunchedEvent)
		return ((PlayerPunchedEvent)event).attacker;
	if(event instanceof LivingDropsEvent && isSourceFromPlayer(((LivingDropsEvent)event).getSource()))
		return getPlayerFromSource(((LivingDropsEvent)event).getSource());
	return null;
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:19,代碼來源:HarshenUtils.java

示例4: onEntityJoinWorld

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    int i = 0;
    for (SpawnRule rule : RulesManager.rules) {
        if (rule.isOnJoin() && rule.match(event)) {
            Event.Result result = rule.getResult();
            if (debug) {
                InControl.logger.log(Level.INFO, "Join Rule " + i + ": "+ result
                        + " entity: " + event.getEntity().getName()
                        + " y: " + event.getEntity().getPosition().getY());
            }
            if (result != Event.Result.DENY) {
                rule.action(event);
            } else {
                event.setCanceled(true);
            }
            return;
        }
        i++;
    }
}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:22,代碼來源:ForgeEventHandlers.java

示例5: onEntitySpawnEvent

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
    int i = 0;
    for (SpawnRule rule : RulesManager.rules) {
        if (rule.match(event)) {
            Event.Result result = rule.getResult();
            if (debug) {
                InControl.logger.log(Level.INFO, "Rule " + i + ": "+ result
                        + " entity: " + event.getEntity().getName()
                        + " y: " + event.getY()
                        + " biome: " + event.getWorld().getBiome(new BlockPos(event.getX(), event.getY(), event.getZ())).getBiomeName());
            }
            event.setResult(result);
            if (result != Event.Result.DENY) {
                rule.action(event);
            }
            return;
        }
        i++;
    }
}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:22,代碼來源:ForgeEventHandlers.java

示例6: onSummonAidEvent

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public void onSummonAidEvent(ZombieEvent.SummonAidEvent event) {
    int i = 0;
    for (SummonAidRule rule : RulesManager.summonAidRules) {
        if (rule.match(event)) {
            Event.Result result = rule.getResult();
            if (debug) {
                InControl.logger.log(Level.INFO, "SummonAid " + i + ": "+ result
                        + " entity: " + event.getEntity().getName()
                        + " y: " + event.getY()
                        + " biome: " + event.getWorld().getBiome(new BlockPos(event.getX(), event.getY(), event.getZ())).getBiomeName());
            }
            event.setResult(result);
            if (result != Event.Result.DENY) {
                rule.action(event);
            }
            return;
        }
        i++;
    }

}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:23,代碼來源:ForgeEventHandlers.java

示例7: onUseHoe

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public static void onUseHoe(UseHoeEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();

    if (block == GenesisBlocks.HUMUS || block == GenesisBlocks.HUMUS_PATH) {
        world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);

        if (!world.isRemote) {
            IBlockState farmland = GenesisBlocks.HUMUS_FARMLAND.getDefaultState();
            world.setBlockState(pos, farmland, WorldFlags.UPDATE_BLOCK_AND_CLIENT_AND_RERENDER_ON_MAIN);
        }

        event.setResult(Event.Result.ALLOW);
    }
}
 
開發者ID:Boethie,項目名稱:Genesis,代碼行數:20,代碼來源:GenesisEventHandler.java

示例8: onPlayerClickBlock

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public void onPlayerClickBlock(PlayerInteractEvent.RightClickBlock event) {

	if (event.getEntityPlayer() == null || !event.getEntityPlayer().isSneaking()) {
		return;
	}
	
	if (event.getItemStack().getItem() == ModItems.hammer && !event.getEntityPlayer().getCooldownTracker().hasCooldown(ModItems.hammer)) {

		if (!event.getWorld().isRemote) {
			BlockPos pos = event.getPos().offset(event.getFace());
			event.getWorld().createExplosion(event.getEntityPlayer(), pos.getX() + 0.5, pos.getY() + 0.5,
					pos.getZ() + 0.5, 3, false);
		}

		event.getEntityPlayer().swingArm(event.getHand());
		event.getEntityPlayer().setActiveHand(event.getHand());
		event.getEntityPlayer().getCooldownTracker().setCooldown(ModItems.hammer, 200);
		ModItems.hammer.setDamage(event.getItemStack(), ModItems.hammer.getDamage(event.getItemStack()) - 10);
		
		event.setCancellationResult(EnumActionResult.SUCCESS);
		event.setResult(Event.Result.ALLOW);
		event.setCanceled(true);
	}

}
 
開發者ID:the-realest-stu,項目名稱:Adventurers-Toolbox,代碼行數:27,代碼來源:HammerHandler.java

示例9: onPlayerPickup

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
public void onPlayerPickup(EntityItemPickupEvent e, ItemStack stack) {
    applyNetwork(stack, n -> {
        if (RSAddons.INSTANCE.config.networkBagUsesEnergy && stack.getItemDamage() != ItemNetworkBag.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RSAddons.INSTANCE.config.networkBagUsage) {
            return;
        }

        if (!n.getSecurityManager().hasPermission(Permission.INSERT, e.getEntityPlayer())) {
            return;
        }

        if (n.insertItem(e.getItem().getItem(), e.getItem().getItem().getCount(), true) == null) {
            e.setResult(Event.Result.ALLOW);
            e.setCanceled(true);

            n.insertItem(e.getItem().getItem(), e.getItem().getItem().getCount(), false);

            e.getItem().setDead();

            if (RSAddons.INSTANCE.config.networkBagUsesEnergy && stack.getItemDamage() != ItemNetworkBag.TYPE_CREATIVE) {
                stack.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy(RSAddons.INSTANCE.config.networkBagUsage, false);
            }
        }
    }, error -> {
        // NO OP
    });
}
 
開發者ID:raoulvdberge,項目名稱:refinedstorageaddons,代碼行數:27,代碼來源:ItemNetworkBag.java

示例10: canCreateFluidSource

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public static void canCreateFluidSource(BlockEvent.CreateFluidSourceEvent event)
{
    if (event.getResult() != Event.Result.DEFAULT)
        return;

    if (applyModifiers(event))
        return;

    Block block = event.getState().getBlock();

    if (block instanceof CSBlock)
    {
        ContentBlockBase content = ((CSBlock) block).getContent();
        if (content instanceof ContentBlockFluid)
        {
            ContentBlockFluid fluid = (ContentBlockFluid) content;
            event.setResult(fluid.canCreateSource ? Event.Result.ALLOW : Event.Result.DENY);
        }
    }
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:22,代碼來源:EventHandler.java

示例11: applyModifiers

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
private static boolean applyModifiers(BlockEvent.CreateFluidSourceEvent event)
{
    Block block = event.getState().getBlock();

    for (FluidModifier modifier : FluidModifier.getModifiers())
    {
        if (block.getRegistryName() != null && block.getRegistryName().equals(modifier.block))
        {
            if (modifier.canCreateSource != null)
            {
                event.setResult(modifier.canCreateSource ? Event.Result.ALLOW : Event.Result.DENY);
                return true;
            }
        }
    }

    return false;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:19,代碼來源:EventHandler.java

示例12: decorate

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void decorate(DecorateBiomeEvent.Decorate event) {
	World world = event.getWorld();
	Biome biome = world.getBiomeGenForCoords(event.getPos());
	Random rand = event.getRand();

	if ((biome == Biomes.PLAINS || biome == Biomes.ICE_PLAINS || biome == Biomes.MUTATED_PLAINS || biome == Biomes.EXTREME_HILLS_WITH_TREES || biome == Biomes.MUTATED_EXTREME_HILLS_WITH_TREES) && event.getType() == DecorateBiomeEvent.Decorate.EventType.TREE) {
		if (rand.nextDouble() > 0.1) return;
		int x = rand.nextInt(16) + 8;
		int y = rand.nextInt(16) + 8;

		TintedTreeGenerator gen = new TintedTreeGenerator();

		gen.generateTree(rand, world, world.getHeight(event.getPos().add(x, 0, y)));

		event.setResult(Event.Result.DENY);
	}
}
 
開發者ID:yolp900,項目名稱:ItsJustaCharm1.10.2Dead,代碼行數:19,代碼來源:EventTintedTreeGenerator.java

示例13: onCheckSpawn

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public void onCheckSpawn(LivingSpawnEvent.CheckSpawn event) {
    double distanceMin = Double.MAX_VALUE;

    for (int i = -31; i <= 32; ++i) {
        for (int j = -31; j <= 32; ++j) {
            for (int k = -31; k <= 32; ++k) {
                BlockPos pos = new BlockPos(event.getX() + i, event.getY() + j, event.getZ() + k);
                IBlockState state = event.getWorld().getBlockState(pos);
                if (state.getBlock() instanceof BlockSourceLight && state.getValue(IWTechBlocks.WORKING)) {
                    distanceMin = Math.min(distanceMin, MathHelper.sqrt_double(i * i + j * j + k * k));
                }
            }
        }
    }

    if (event.getWorld().rand.nextDouble() * 32.0D > distanceMin) {
        event.setResult(Event.Result.DENY);
    }
}
 
開發者ID:InfinityStudio,項目名稱:InspiringWorld,代碼行數:21,代碼來源:BlockSourceLight.java

示例14: sendChanges

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
private void sendChanges()
{
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if (player == null)
        return;

    // Send any changes requested over the wire to the server:
    double x = this.setX ? this.x : 0;
    double y = this.setY ? this.y : 0;
    double z = this.setZ ? this.z : 0;
    float yaw = this.setYaw ? this.rotationYaw : 0;
    float pitch = this.setPitch ? this.rotationPitch : 0;

    if (this.setX || this.setY || this.setZ || this.setYaw || this.setPitch)
    {
        MalmoMod.network.sendToServer(new TeleportMessage(x, y, z, yaw, pitch, this.setX, this.setY, this.setZ, this.setYaw, this.setPitch));
        if (this.setYaw || this.setPitch)
        {
            // Send a message that the ContinuousMovementCommands can pick up on:
            Event event = new CommandForWheeledRobotNavigationImplementation.ResetPitchAndYawEvent(this.setYaw, this.rotationYaw, this.setPitch, this.rotationPitch);
            MinecraftForge.EVENT_BUS.post(event);
        }
        this.setX = this.setY = this.setZ = this.setYaw = this.setPitch = false;
    }
}
 
開發者ID:Microsoft,項目名稱:malmo,代碼行數:26,代碼來源:AbsoluteMovementCommandsImplementation.java

示例15: onEntityCheckSpawn

import net.minecraftforge.fml.common.eventhandler.Event; //導入依賴的package包/類
@SubscribeEvent
public void onEntityCheckSpawn(LivingSpawnEvent.CheckSpawn event)
{
	if(event.getResult() == Event.Result.ALLOW) return;
	if(TorchmasterConfig.MegaTorchAllowVanillaSpawners && event.isSpawner()) return;

	if(TorchMasterMod.MegaTorchFilterRegistry.containsEntity(event.getEntity()))
	{
		if(TorchRegistry.getMegaTorchRegistry().isInRangeOfTorch(event.getWorld(), event.getEntity().getPosition()))
		{
			event.setResult(Event.Result.DENY);
		}
	}
	else if(TorchMasterMod.DreadLampFilterRegistry.containsEntity(event.getEntity()))
	{
		if(TorchRegistry.getDreadLampRegistry().isInRangeOfTorch(event.getWorld(), event.getEntity().getPosition()))
		{
			event.setResult(Event.Result.DENY);
		}
	}
}
 
開發者ID:Xalcon,項目名稱:TorchMaster,代碼行數:22,代碼來源:EventHandlerServer.java


注:本文中的net.minecraftforge.fml.common.eventhandler.Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。