cpw.mods.fml.common.eventhandler.SubscribeEvent Java Examples

The following examples show how to use cpw.mods.fml.common.eventhandler.SubscribeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void on(BlockEvent.PlaceEvent e) {
    if (e.isCanceled()) {
        if (interacts != null)
            interacts.remove(e.player);
    } else {
        if (!e.world.isRemote && isStickyJar(e.itemInHand)) {
            TileEntity parent = e.world.getTileEntity(e.x, e.y, e.z);
            if (parent instanceof TileJarFillable) {
                int metadata = e.world.getBlockMetadata(e.x, e.y, e.z);
                e.world.setBlock(e.x, e.y, e.z, RegisteredBlocks.blockStickyJar, metadata, 2);

                TileEntity tile = e.world.getTileEntity(e.x, e.y, e.z);
                if (tile instanceof TileStickyJar) {
                    Integer sideHit = interacts.get(e.player);
                    ((TileStickyJar) tile).init((TileJarFillable) parent, e.placedBlock, metadata,
                            ForgeDirection.getOrientation(sideHit == null ? 1 : sideHit).getOpposite());
                    RegisteredBlocks.blockStickyJar.onBlockPlacedBy(e.world, e.x, e.y, e.z, e.player, e.itemInHand);
                }
            }
        }
    }
}
 
Example #2
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void arrowNock(ArrowNockEvent event) {
	if (event.result == null)
		return;
	IInventory invt = event.entityPlayer.inventory;
	for (int i = 0; i < invt.getSizeInventory(); i++) {
		ItemStack stack = invt.getStackInSlot(i);
		if (stack == null || stack.stackSize <= 0)
			continue;
		if (stack.getItem() == Items.arrow)
			return;
		if (stack.getItem() == ModItems.tipped_arrow) {
			event.setCanceled(true);
			event.entityPlayer.setItemInUse(event.result, event.result.getItem().getMaxItemUseDuration(event.result));
			return;
		}
	}
}
 
Example #3
Source File: LookingGlassEventHandler.java    From LookingGlass with GNU General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent event) {
	// If no client world we're not playing. Abort.
	if (Minecraft.getMinecraft().theWorld == null) return;
	if (event.phase == TickEvent.Phase.START) {
		// Anything we need to render for the current frame should happen either during or before the main world render
		// Here we call the renderer for "live portal" renders.
		PerspectiveRenderManager.onRenderTick(printstream);
		return;
	}
	if (event.phase == TickEvent.Phase.END) {
		// We render the world views at the end of the render tick.  
		WorldViewRenderManager.onRenderTick(printstream);
		return;
	}
}
 
Example #4
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPig) {
		EntityPig pig = (EntityPig) event.entity;
		if (EtFuturum.enableBeetroot)
			pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
	} else if (event.entity instanceof EntityChicken) {
		EntityChicken chicken = (EntityChicken) event.entity;
		if (EtFuturum.enableBeetroot)
			chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
	} else if (event.entity instanceof EntityWolf) {
		EntityWolf wolf = (EntityWolf) event.entity;
		if (EtFuturum.enableRabbit)
			wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
	} else if (event.entity instanceof EntityVillager) {
		EntityVillager villager = (EntityVillager) event.entity;
		for (Object obj : villager.tasks.taskEntries) {
			EntityAITaskEntry entry = (EntityAITaskEntry) obj;
			if (entry.action instanceof EntityAIOpenDoor) {
				villager.tasks.removeTask(entry.action);
				villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
				break;
			}
		}
	}
}
 
Example #5
Source File: CustomToolTipsHandler.java    From NewHorizonsCoreMod with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onToolTip( ItemTooltipEvent pEvent )
{
  if( pEvent.entity == null ) {
    return;
  }
  CustomToolTips.ItemToolTip itt = _mCustomToolTips.FindItemToolTip( pEvent.itemStack );
  if( itt != null )
  {
      String[] tToolTips = itt.getToolTip().split("\\\\n");

    for( String tPartTip : tToolTips ) {
      pEvent.toolTip.add(tPartTip.replace("&", "ยง"));
    }
  }
}
 
Example #6
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event) {
	if (!EtFuturum.enableEnchants)
		return;
	try {
		File file = event.getPlayerFile(Reference.MOD_ID);
		if (!file.exists()) {
			file.createNewFile();
			return;
		}

		BufferedReader br = new BufferedReader(new FileReader(file));
		String line = br.readLine();
		if (line != null) {
			int seed = Integer.parseInt(line);
			ContainerEnchantment.seeds.put(event.playerUUID, seed);
			br.close();
		}
	} catch (Exception e) {
	}
}
 
Example #7
Source File: MinetweakerFurnaceFix.java    From NewHorizonsCoreMod with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onFuelBurnTime(FuelBurnTimeEvent event) {
    /*
        Minetweaker's feature to change fuel burn values is implemented through an `IFuelHandler` which is
        forcibly registered with GameRegistry as the only fuel handler. However, the vanilla Furnace code
        always checks a small hardcoded list of fuels (including a check for `material == WOOD`) before calling
        the `IFuelHandler`.

        Before checking the hardcoded list, the Furnace is patched by Forge to obey any result returned by a
        `FuelBurnTimeEvent`, allowing the event handler to override the vanilla handling.

        This event handler simply delegates the fuel value to Minetweaker's `IFuelHandler`, which will be the only
        fuel handler registered, by simply calling `GameRegistry.getFuelValue`. In turn, this fuel handler will
        delegate to this mod's `CustomFuelsHandler` if no MT script changes the fuel value for the item.
     */
    int burnTime = GameRegistry.getFuelValue(event.fuel);
    if (burnTime > 0) {
        event.burnTime = burnTime;
        event.setResult(Event.Result.ALLOW);
    }
}
 
Example #8
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
Example #9
Source File: Events.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onAttack(AttackEntityEvent event) {
    if (!cheatEnabled) {
        return;
    }
    if (!(KillAura.isActive || MobAura.isActive || ProphuntAura.isActive || Forcefield.isActive || TriggerBot.isActive || !Criticals.isActive || Wrapper.INSTANCE.player().isInWater() || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) || !Wrapper.INSTANCE.player().onGround || !Wrapper.INSTANCE.mcSettings().keyBindAttack.getIsKeyPressed() || Wrapper.INSTANCE.mc().objectMouseOver == null || Wrapper.INSTANCE.mc().objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY)) {
        event.setCanceled(true);
        Wrapper.INSTANCE.player().motionY = 0.1000000014901161;
        Wrapper.INSTANCE.player().fallDistance = 0.1f;
        Wrapper.INSTANCE.player().onGround = false;
        event.setCanceled(false);
    }
    if (event.target instanceof EntityPlayer) {
        EntityPlayer e = (EntityPlayer) event.target;
        if (SeeHealth.isActive) {
            InteropUtils.log("Health of &e" + e.getCommandSenderName() + "&f: &e" + e.getHealth(), "SeeHealth");
        }
    }
}
 
Example #10
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onBreak(BlockEvent.BreakEvent event) {
    if (!event.world.isRemote) {
        if (event.block == RegisteredBlocks.blockNodeManipulator) {
            TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
            if (te != null && te instanceof TileNodeManipulator) {
                if (((TileNodeManipulator) te).isInMultiblock())
                    ((TileNodeManipulator) te).breakMultiblock();
            }
        }
        if (event.block == RegisteredBlocks.blockStoneMachine && event.blockMetadata == 5) {
            TileAIShutdown.removeTrackedEntities(event.world, event.x, event.y, event.z);
        }
        if (event.world.provider.dimensionId == ModConfig.dimOuterId) {
            if(event.block == ConfigBlocks.blockEldritchNothing) {
                if(event.getPlayer().capabilities.isCreativeMode && MiscUtils.isANotApprovedOrMisunderstoodPersonFromMoreDoor(event.getPlayer())) return;
                event.setCanceled(true);
                event.getPlayer().addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + StatCollector.translateToLocal("gadomancy.eldritch.nobreakPortalNothing")));
            }
        }
    }
}
 
Example #11
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(PlayerInteractEvent e) {
    if (!e.world.isRemote && e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
            && isStickyJar(e.entityPlayer.getHeldItem())) {
        if (interacts == null) {
            interacts = new HashMap<EntityPlayer, Integer>();
        }
        interacts.put(e.entityPlayer, e.face);
    }

    if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
        ItemStack i = e.entityPlayer.getHeldItem();
        if (i != null && (i.getItem() instanceof ItemWandCasting)) {
            WandHandler.handleWandInteract(e.world, e.x, e.y, e.z, e.entityPlayer, i);
        }
    }
}
 
Example #12
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(ItemTooltipEvent e) {
    if (e.toolTip.size() > 0 && e.itemStack.hasTagCompound()) {
        if (e.itemStack.stackTagCompound.getBoolean("isStickyJar")) {
            e.toolTip.add(1, "\u00a7a" + StatCollector.translateToLocal("gadomancy.lore.stickyjar"));
        }
    }

    if(e.toolTip.size() > 0 && NBTHelper.hasPersistentData(e.itemStack)) {
        NBTTagCompound compound = NBTHelper.getPersistentData(e.itemStack);
        if(compound.hasKey("disguise")) {
            NBTBase base = compound.getTag("disguise");
            String lore;
            if(base instanceof NBTTagCompound) {
                ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) base);
                lore = String.format(StatCollector.translateToLocal("gadomancy.lore.disguise.item"), EnumChatFormatting.getTextWithoutFormattingCodes(stack.getDisplayName()));
            } else {
                lore = StatCollector.translateToLocal("gadomancy.lore.disguise.none");
            }
            e.toolTip.add("\u00a7a" + lore);
        }
    }
}
 
Example #13
Source File: ConnectionHandler.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent
public void connectionOpened( FMLNetworkEvent.ClientConnectedToServerEvent event )
{
    if( !event.isLocal )
    {
        SocketAddress socketAddress = event.manager.getSocketAddress();
        if( socketAddress != null && socketAddress instanceof InetSocketAddress )
        {
            InetSocketAddress internet = (InetSocketAddress)socketAddress;
            String hostString = null;
            try
            {
                Method getHostString = InetSocketAddress.class.getDeclaredMethod( "getHostString", new Class[]{} );
                getHostString.setAccessible( true );
                hostString = getHostString.invoke( internet ).toString();
            }
            catch( Exception e )
            {
                hostString = internet.getHostName();
            }
            QCraft.setCurrentServerAddress( hostString + ":" + internet.getPort() );
            return;
        }
    }
    QCraft.setCurrentServerAddress( null );
}
 
Example #14
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(ItemTooltipEvent event) {
    if(event.itemStack != null) {
        if(event.itemStack.getItem() instanceof ItemGolemPlacer
                || event.itemStack.getItem() instanceof ItemAdditionalGolemPlacer) {
            if(RegisteredGolemStuff.upgradeRunicShield.hasUpgrade(event.itemStack)) {
                event.toolTip.add("\u00a76" + StatCollector.translateToLocal("item.runic.charge") + " +" + RegisteredGolemStuff.upgradeRunicShield.getChargeLimit(event.itemStack));
            }

            AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(event.itemStack);
            if(core != null) {
                String searchStr = StatCollector.translateToLocal("item.ItemGolemCore.name");
                for(int i = 0; i < event.toolTip.size(); i++) {
                    String line = event.toolTip.get(i);
                    if(line.contains(searchStr)) {
                        int index = line.indexOf('\u00a7', searchStr.length()) + 2;
                        event.toolTip.remove(i);
                        event.toolTip.add(i, line.substring(0, index) + StatCollector.translateToLocal(core.getUnlocalizedName()));
                        break;
                    }
                }
            }
        }
    }
}
 
Example #15
Source File: EventHandlerMystcraft.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onLink(LinkEvent.LinkEventAllow event) {
    if(event.origin != null && event.origin.provider.dimensionId == ModConfig.dimOuterId) {
        event.setCanceled(true);
    }
    if(event.destination != null && event.destination.provider.dimensionId == ModConfig.dimOuterId) {
        event.setCanceled(true);
    }
}
 
Example #16
Source File: RenderEventHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void renderPost(RenderLivingEvent.Post event) {
    if(event.entity instanceof EntityPlayer) {
        EntityPlayer p = (EntityPlayer) event.entity;
        if(armor != null) {
            p.inventory.armorInventory = armor;
        }
    }
}
 
Example #17
Source File: RenderEventHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onSetArmor(RenderPlayerEvent.SetArmorModel event) {
    if(event.entityPlayer == current) {
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDepthMask(true);
    }
}
 
Example #18
Source File: RenderEventHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void renderEntityPre(RenderLivingEvent.Pre event) {
    if(event.entity instanceof EntityPlayer) {
        EntityPlayer p = (EntityPlayer) event.entity;
        if(((DataAchromatic)SyncDataHolder.getDataClient("AchromaticData")).isAchromatic((EntityPlayer) event.entity)) {
            current = p;
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F);
            GL11.glDepthMask(false);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
        }

        armor = p.inventory.armorInventory;
        p.inventory.armorInventory = new ItemStack[armor.length];
        System.arraycopy(armor, 0, p.inventory.armorInventory, 0, armor.length);

        boolean changed = false;
        for(int i = 0; i < armor.length; i++) {
            if(armor[i] != null && NBTHelper.hasPersistentData(armor[i])) {
                NBTTagCompound compound = NBTHelper.getPersistentData(armor[i]);
                if(compound.hasKey("disguise")) {
                    NBTBase base = compound.getTag("disguise");
                    if(base instanceof NBTTagCompound) {
                        p.inventory.armorInventory[i] = ItemStack.loadItemStackFromNBT((NBTTagCompound) base);
                    } else {
                        p.inventory.armorInventory[i] = null;
                    }
                    changed = true;
                }
            }
        }

        if(!changed) {
            p.inventory.armorInventory = armor;
            armor = null;
        }
    }
}
 
Example #19
Source File: RenderUtility.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Handles NOVA texture update.
 * @param event Event
 */
@SubscribeEvent
public void textureHook(TextureStitchEvent.Post event) {
	Game.render().blockTextures.forEach(this::updateTexureDimensions);
	Game.render().itemTextures.forEach(this::updateTexureDimensions);
	Game.render().entityTextures.forEach(this::updateTexureDimensions);
}
 
Example #20
Source File: IntegrationThaumicHorizions.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent e) {
    EntityPlayer player = e.entityPlayer;
    if(!e.target.worldObj.isRemote && e.target instanceof EntityGolemTH
            && player.isSneaking()) {
        e.setCanceled(true);

        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem().onLeftClickEntity(stack, player, e.target)
                && e.target.isDead) {
            CommonProxy.EVENT_HANDLER_GOLEM.on(new PlaySoundAtEntityEvent(e.target, "thaumcraft:zap", 0.5f, 1.0f));
        }
    }
}
 
Example #21
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) {
    if (event.player.worldObj.isRemote) {
        return;
    }
    handleQuit((EntityPlayerMP) event.player);
}
 
Example #22
Source File: EffectHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onRender(RenderWorldLastEvent event) {
    Tessellator tessellator = Tessellator.instance;

    FXFlow.FXFlowBase.sheduleRender(tessellator);
    Orbital.sheduleRenders(orbitals, event.partialTicks);
    FXVortex.sheduleRender(fxVortexes, tessellator, event.partialTicks);
}
 
Example #23
Source File: ClientHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
    if(event.phase.equals(TickEvent.Phase.END) && !Minecraft.getMinecraft().isGamePaused()) {
        FamiliarHandlerClient.playerTickEvent();
        ticks++;

        EffectHandler.getInstance().tick();
    }

    Queue<Runnable> actions = ((ClientProxy)Gadomancy.proxy).clientActions;
    while(actions.peek() != null) {
        actions.poll().run();
    }
}
 
Example #24
Source File: QCraftProxyCommon.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@SubscribeEvent
public void onPlayerLogin( PlayerEvent.PlayerLoggedInEvent event )
{
    EntityPlayer player = event.player;
    if( FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER )
    {
        QCraft.clearUnverifiedLuggage( player ); // Shouldn't be necessary, but can't hurt
        QCraft.requestLuggage( player );
    }
}
 
Example #25
Source File: BWAtmosphereManager.java    From bartworks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void gcAutoRegister(GalaxyRegistry.PlanetRegisterEvent event){
    CelestialBody planet = GalaxyRegistry.getRegisteredPlanets().get(event.planetName);
    for (int i = 0; i < planet.atmosphere.size(); i++) {
        if (!BWAtmosphereManager.addGCGasToWorld(planet.getDimensionID(),planet.atmosphere.get(i),i,planet.atmosphere.size()))
            BartWorksCrossmod.LOGGER.warn("Unidentified Fluid ("+planet.atmosphere.get(i)+") in the Atmosphere of: "+planet.getLocalizedName());
    }
}
 
Example #26
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@SubscribeEvent
public void teleportEvent(EnderTeleportEvent event) {
	if (EtFuturum.enableEndermite) {
		EntityLivingBase entity = event.entityLiving;
		if (entity instanceof EntityPlayerMP)
			if (entity.getRNG().nextFloat() < 0.05F && entity.worldObj.getGameRules().getGameRuleBooleanValue("doMobSpawning")) {
				EntityEndermite entityendermite = new EntityEndermite(entity.worldObj);
				entityendermite.setSpawnedByPlayer(true);
				entityendermite.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
				entity.worldObj.spawnEntityInWorld(entityendermite);
			}
	}
}
 
Example #27
Source File: EventHandlerNetwork.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void on(PlayerEvent.PlayerLoggedOutEvent e) {
    EntityPlayer player = e.player;
    DataFamiliar familiarData = SyncDataHolder.getDataServer("FamiliarData");
    if(familiarData.hasFamiliar(player)) {
        familiarData.handleUnsafeUnequip(player);
    }

    TCMazeHandler.closeSession(e.player, true);
}
 
Example #28
Source File: ForgeEventHandler.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void playerInteractEvent(PlayerInteractEvent event) {
	nova.core.event.PlayerEvent.Interact evt = new nova.core.event.PlayerEvent.Interact(
		WorldConverter.instance().toNova(event.world),
		new Vector3D(event.x, event.y, event.z),
		EntityConverter.instance().toNova(event.entityPlayer),
		nova.core.event.PlayerEvent.Interact.Action.values()[event.action.ordinal()]
	);

	Game.events().publish(evt);

	event.useBlock = Event.Result.values()[evt.useBlock.ordinal()];
	event.useItem = Event.Result.values()[evt.useItem.ordinal()];
	event.setCanceled(evt.isCanceled());
}
 
Example #29
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(EntityEvent.EntityConstructing e) {
    if(e.entity instanceof EntityGolemBase) {
        EntityGolemBase golem = (EntityGolemBase) e.entity;

        golem.registerExtendedProperties(Gadomancy.MODID, new ExtendedGolemProperties(golem));

        golem.getDataWatcher().addObject(ModConfig.golemDatawatcherId, "");
    }
}
 
Example #30
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void on(EntityJoinWorldEvent event) {
    if(!event.entity.worldObj.isRemote && event.entity instanceof EntityGolemBase) {
        EntityGolemBase golem = (EntityGolemBase) event.entity;
        ExtendedGolemProperties props = (ExtendedGolemProperties) golem.getExtendedProperties(Gadomancy.MODID);
        if(props != null) {
            props.setWrapperIfNeeded();
        }
    }

    if (event.entity instanceof EntityItem) {
        EntityItem item = (EntityItem) event.entity;
        ItemStack stack = item.getEntityItem();

        if (stack.getItem() == ConfigItems.itemGolemPlacer) {
            AdditionalGolemType type = GadomancyApi.getAdditionalGolemType(EnumGolemType.getType(stack.getItemDamage()));
            if (type != null) {
                ItemStack fakePlacer = new ItemStack(type.getPlacerItem());
                fakePlacer.setTagCompound(stack.getTagCompound());
                fakePlacer.setItemDamage(stack.getItemDamage());

                item.setEntityItemStack(fakePlacer);
            }
        }
    }

    if(!event.world.isRemote && event.entity instanceof EntityLivingBase) {
        if(((EntityLivingBase) event.entity).isPotionActive(RegisteredPotions.ACHROMATIC)) {
            ((DataAchromatic) SyncDataHolder.getDataServer("AchromaticData")).handleApplication((EntityLivingBase) event.entity);
        }
    }
}