本文整理汇总了Java中net.minecraftforge.event.ForgeSubscribe类的典型用法代码示例。如果您正苦于以下问题:Java ForgeSubscribe类的具体用法?Java ForgeSubscribe怎么用?Java ForgeSubscribe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ForgeSubscribe类属于net.minecraftforge.event包,在下文中一共展示了ForgeSubscribe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAttack
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onAttack(LivingAttackEvent event)
{
Entity source = event.source.getSourceOfDamage();
if(source != null && source instanceof EntityLiving && !event.source.isProjectile())
{
EntityLiving attacker = (EntityLiving)source;
PotionEffect affliction = attacker.getActivePotionEffect(Potion.confusion);
if(affliction != null)
{
Random rand = attacker.getRNG();
int tier = affliction.getAmplifier();
if(rand.nextInt(5) <= tier)
{
event.setCanceled(true);
}
}
}
}
示例2: fertellise
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void fertellise (BonemealEvent event)
{
World world = event.world;
EntityPlayer player = event.entityPlayer;
int x = event.X;
int y = event.Y;
int z = event.Z;
int id = event.ID;
ItemStack item = player.getHeldItem();
int meta = world.getBlockMetadata(x, y, z);
if (id == BlockListMF.sapling.blockID)
{
if (!world.isRemote)
{
if ((double)world.rand.nextFloat() < ((BlockSaplingMF)BlockListMF.sapling).getBonemealChance(meta))
{
((BlockSaplingMF)BlockListMF.sapling).markOrGrowMarked(world, x, y, z, world.rand);
}
}
event.setResult(Result.ALLOW);
}
}
示例3: onEntityJoinWorld
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
if(event.entity instanceof EntityArrow)
{
EntityArrow arrow = (EntityArrow)event.entity;
if(arrow.shootingEntity != null && arrow.shootingEntity instanceof EntityLiving)
{
EntityLiving attacker = (EntityLiving)arrow.shootingEntity;
PotionEffect affliction = attacker.getActivePotionEffect(Potion.confusion);
if(affliction != null)
{
Random rand = attacker.getRNG();
float tier = (float)affliction.getAmplifier()+1*5F;
arrow.motionX *= 1F + ((rand.nextFloat()*0.2F - 0.1F)*tier);
arrow.motionY *= 1F + ((rand.nextFloat()*0.2F - 0.1F)*tier);
arrow.motionZ *= 1F + ((rand.nextFloat()*0.2F - 0.1F)*tier);
}
}
}
}
示例4: onEntityLivingDeath
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onEntityLivingDeath( LivingDeathEvent event )
{
if( event.entity.worldObj.isRemote )
{
return;
}
if( event.entity instanceof EntityZombie )
{
EntityLivingBase living = (EntityLivingBase)event.entity;
if( (living.isChild() && r.nextInt(20) == 0) ||
(!living.isChild() && r.nextInt(100) == 0) )
{
event.entity.entityDropItem( new ItemStack( Billund.Items.orderForm, 1 ), 0.0f );
}
}
}
示例5: miniPre
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@ForgeSubscribe(priority = EventPriority.HIGHEST)
public void miniPre(RenderPlayerEvent.Pre event){
if(((EntityLivingBase) event.entity).isPotionActive(FCraftPotions.miniPot)){
GL11.glPushMatrix();
GL11.glScalef(0.2F, 0.2F, 0.2F);
//GL11.glTranslatef(0, -6.5F, 0);
if(event.entity instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer) event.entity;
player.height = 0.5F;
player.yOffset = 0.55F;
mc.thePlayer.eyeHeight = 0.02F;
player.boundingBox.setBounds(player.posX - (double)player.width/2.0F, player.posY - (double)player.yOffset + (double)player.ySize, player.posZ - (double)player.width/2.0F, player.posX + (double)player.width/2.0F, player.posY - (double)player.yOffset + (double)player.ySize + (double)player.height, player.posZ + (double)player.width/2.0F);
}
}
}
示例6: onEntityJoinWorld
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
//Only need to synchronize when the world is remote (i.e. we're on the server side)
if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer){
FCraftJobCore.get((EntityPlayer) event.entity).sync();
FCraftJobCore props = FCraftJobCore.get((EntityPlayer) event.entity);
if(event.entity.dimension==0){
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatMessageComponent.createFromText(props.getJob()+" "+event.entity.getEntityName()+" has joined the search for the grimoire."));
}else if(event.entity.dimension==-1){
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatMessageComponent.createFromText(props.getJob()+" "+event.entity.getEntityName()+" went to hell!"));
}else if(event.entity.dimension==DimensionID.WORLD_OF_BALANCE_ID){
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(ChatMessageComponent.createFromText(props.getJob()+" "+event.entity.getEntityName()+" entered the World of Balance!"));
}
FCraftJobCore playerData = FCraftJobCore.get((EntityPlayer)event.entity);
NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey((EntityPlayer)event.entity));
if(savedData != null) {
playerData.loadNBTData(savedData);
}
playerData.sync();
}
}
示例7: onLivingDrops
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onLivingDrops(LivingDropsEvent event)
{
if (event.entityLiving == null)
{
return;
}
if (event.entityLiving instanceof EntityDragon)
{
if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.source.getEntity();
if (!player.worldObj.isRemote)
{
EntityItem item = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(Registries.dragonEgg, 1, 0));
player.worldObj.spawnEntityInWorld(item);
if (!(player instanceof FakePlayer))
{
item.onCollideWithPlayer(player);
}
}
}
}
}
示例8: onEntityPlaceTE
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
@SideOnly(Side.SERVER)
public void onEntityPlaceTE (PlayerInteractEvent event) {
if (event.entityPlayer.worldObj.getChunkFromBlockCoords(event.x, event.z).chunkTileEntityMap.size() >= Apocalyptic.tePerChunk && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && (event.entityPlayer.worldObj.getBlockTileEntity(event.x, event.y, event.z) == null || event.entityPlayer.isSneaking())) {
if (event.entityLiving.getHeldItem() != null && (TileEntities.contains(event.entityLiving.getHeldItem().getItem().itemID) || ((event.entityLiving.getHeldItem().getItem().itemID < 4096) && Block.blocksList[event.entityLiving.getHeldItem().getItem().itemID].hasTileEntity()))) {
event.setCanceled(true);
event.entityPlayer.addChatMessage("\2474\u0414\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442\u043E \u043C\u0430\u043A\u0441. \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E TE \u0432 \u0447\u0430\u043D\u043A\u0435");
}
}
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && event.entityLiving.getHeldItem() != null) {
if ((event.entityLiving.getHeldItem().itemID == 1407 || event.entityLiving.getHeldItem().itemID == 223) && (event.entityPlayer.worldObj.provider.dimensionId != 0)) {
event.setCanceled(true);
event.entityPlayer.addChatMessage("\2474Невозможно установить устройство!");
}
if (event.entityLiving.getHeldItem().itemID == 2007 && event.entityLiving.getHeldItem().getItemDamage() == 2 && event.entityPlayer.worldObj.provider.dimensionId == 4) {
event.setCanceled(true);
event.entityPlayer.addChatMessage("\2474Невозможно установить устройство!");
}
}
}
示例9: onArrowLooseEvent
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onArrowLooseEvent(ArrowLooseEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack par1ItemStack = inv.getStackInSlot(inv.currentItem);
if(inv.getCurrentItem().itemID == Item.bow.itemID)
{
if(mod_Rediscovered.QuickBow)
{
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
ItemStack itemstack = player.inventory.armorInventory[2];
if (itemstack != null && itemstack.itemID == mod_Rediscovered.Quiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.LeatherQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.ChainQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.IronQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.GoldQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.DiamondQuiver.itemID)
{
event.setCanceled(true);
}
}
}
}
示例10: onPlayerJoinWorld
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onPlayerJoinWorld(EntityEvent.EntityConstructing event)
{
if (event.entity != null)
if (event.entity.worldObj != null)
if (!event.entity.worldObj.isRemote)
if (event.entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.entity;
if (player
.getExtendedProperties(R0b0tsPlayerProperties.IDENTIFIER) == null)
player.registerExtendedProperties(
R0b0tsPlayerProperties.IDENTIFIER,
new R0b0tsPlayerProperties());
}
}
示例11: onSoundLoad
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event)
{
// For each custom sound file we have defined in Sounds
for (String soundFile : soundFiles)
{
// Try to add the custom sound file to the pool of sounds
try
{
event.manager.addSound(soundFile);
}
// If we cannot add the custom sound file to the pool, log the exception
catch (Exception e)
{
FMLLog.warning("Failed loading sound file: " + soundFile);
}
}
}
示例12: handleBonemeal
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void handleBonemeal(BonemealEvent event) {
if (!Proxies.common.isSimulating(event.world))
return;
TileEntity tile = event.world.getBlockTileEntity(event.X, event.Y, event.Z);
if (tile instanceof TileSapling) {
if (((TileSapling) tile).tryGrow(true)) {
event.setResult(Result.ALLOW);
}
} else if(tile instanceof IFruitBearer) {
IFruitBearer bearer = (IFruitBearer)tile;
if(bearer.getRipeness() <= 1.0f) {
bearer.addRipeness(1.0f);
event.setResult(Result.ALLOW);
}
}
}
示例13: onPopulateChunk
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onPopulateChunk(PopulateChunkEvent.Post event) {
if (!event.world.isRemote && shopData != null && event.world.villageCollectionObj != null) {
List<ChunkCoordinates> villageCoords = new ArrayList<ChunkCoordinates>();
List<Village> villages = event.world.villageCollectionObj.getVillageList();
for (Village village : villages) {
ChunkCoordinates coords = village.getCenter();
if (isVillageVisited(coords)) {
continue;
}
spawnShop(event.world, coords.posX, coords.posZ);
shopData.visitedVillageCoords.add(village.getCenter());
shopData.setDirty(true);
}
}
}
示例14: playerUpdate
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void playerUpdate(LivingEvent.LivingUpdateEvent event) {
if (ticks > 16) {
if (event.entityLiving != null && event.entityLiving instanceof EntityPlayer) {
if (!event.entityLiving.worldObj.isRemote)
return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
String capeUrl = CapeHandler.getCapeUrl(player.username);
if (capeUrl != null && !capeUrl.equals(player.cloakUrl)) {
player.cloakUrl = capeUrl;
FMLClientHandler.instance().getClient().renderEngine.obtainImageData(player.cloakUrl, null);
}
}
ticks = 0;
}
ticks++;
}
示例15: onSound
import net.minecraftforge.event.ForgeSubscribe; //导入依赖的package包/类
@ForgeSubscribe
public void onSound(SoundLoadEvent event) {
try {
for (Sound sound : Sound.values()) {
if (!sound.isRandom()) {
event.manager.soundPoolSounds.addSound(sound.getName()+".ogg");
} else {
for (int i = 1; i <= sound.randomVariants; i++) {
event.manager.soundPoolSounds.addSound(sound.getName()+i+".ogg");
}
}
}
}
catch (Exception e) {
Dota2Items.logger.warning("Failed to register one or more sounds.");
}
}