当前位置: 首页>>代码示例>>Java>>正文


Java MinecraftForge类代码示例

本文整理汇总了Java中net.minecraftforge.common.MinecraftForge的典型用法代码示例。如果您正苦于以下问题:Java MinecraftForge类的具体用法?Java MinecraftForge怎么用?Java MinecraftForge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MinecraftForge类属于net.minecraftforge.common包,在下文中一共展示了MinecraftForge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@EventHandler
public void init(FMLInitializationEvent evt) {
	INSTANCE.registerMessage(LobbyPlayerOpenedGuiPacketHandler.class, LobbyPlayerOpenedGuiPacket.class, 0,
			Side.SERVER);

	INSTANCE.registerMessage(LobbyBeginGamePacketHandler.class, LobbyBeginGamePacket.class, 1, Side.SERVER);
	INSTANCE.registerMessage(PacketSyncPlayerPropertiesClientHandler.class, PacketSyncPlayerPropertiesClient.class,
			2, Side.CLIENT);
	INSTANCE.registerMessage(PacketSyncPlayerPropertiesServerHandler.class, PacketSyncPlayerPropertiesServer.class,
			3, Side.SERVER);

	INSTANCE.registerMessage(PacketSyncTileEntityServerHandler.class, PacketSyncTileEntityServer.class, 4,
			Side.SERVER);
	INSTANCE.registerMessage(PacketSyncTileEntityClientHandler.class, PacketSyncTileEntityClient.class, 5,
			Side.CLIENT);

	NetworkRegistry.INSTANCE.registerGuiHandler(PAYDAY.instance, new MGuiHandler());
	GameRegistry.registerBlock(lobbyBlock, "Lobby");
	GameRegistry.registerTileEntity(LobbyTileEntity.class, "lobby_tile_entity");

	FMLCommonHandler.instance().bus().register(eventHandler);
	MinecraftForge.EVENT_BUS.register(eventHandler);
}
 
开发者ID:TominoCZ,项目名称:PAYDAY,代码行数:24,代码来源:PAYDAY.java

示例2: preInit

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent pre) {
    logger = pre.getModLog();
    logger.debug("FirstAid starting");
    creativeTab = new CreativeTabs(FirstAid.MODID) {
        @Nonnull
        @Override
        public ItemStack getTabIconItem() {
            return new ItemStack(FirstAidItems.BANDAGE);
        }
    };

    MinecraftForge.EVENT_BUS.register(EventHandler.class);
    FirstAidItems.init();
    proxy.init();
    //Setup API
    RegistryManager.setupRegistries();
    checkEarlyExit();
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:20,代码来源:FirstAid.java

示例3: fireCreateEventAndReplace

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
public void fireCreateEventAndReplace(Biome biome)
{
    // Copy any configuration from us to the real instance.
    wrapped.bigMushroomsPerChunk = bigMushroomsPerChunk;
    wrapped.cactiPerChunk = cactiPerChunk;
    wrapped.clayPerChunk = clayPerChunk;
    wrapped.deadBushPerChunk = deadBushPerChunk;
    wrapped.flowersPerChunk = flowersPerChunk;
    wrapped.generateLakes = generateLakes;
    wrapped.grassPerChunk = grassPerChunk;
    wrapped.mushroomsPerChunk = mushroomsPerChunk;
    wrapped.reedsPerChunk = reedsPerChunk;
    wrapped.sandPerChunk = sandPerChunk;
    wrapped.sandPerChunk2 = sandPerChunk2;
    wrapped.treesPerChunk = treesPerChunk;
    wrapped.waterlilyPerChunk = waterlilyPerChunk;

    BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    biome.theBiomeDecorator = event.getNewBiomeDecorator();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:DeferredBiomeDecorator.java

示例4: coralPassGenerate

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
public void coralPassGenerate(World worldIn, Random rand, Biome biome, BlockPos pos)
{
	if (!BiomeDictionary.areSimilar(biome, Biomes.OCEAN))
	{
		return;
	}
	
	int x = rand.nextInt(16) + 8;
	int z = rand.nextInt(16) + 8;
	BlockPos at = worldIn.getHeight(pos.add(x, 0, z));
	EventGenCoral event = new EventGenCoral(worldIn, at, rand, genCoral);
	if (MinecraftForge.TERRAIN_GEN_BUS.post(event))
	{
		return;
	}
	
	event.generator.generate(worldIn, rand, at);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:19,代码来源:ExPBiomeDecorator.java

示例5: cropsPassGenerate

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
public void cropsPassGenerate(World worldIn, Random rand, Biome biome, BlockPos pos)
{
	if (!(biome instanceof ExPBiome))
	{
		return;
	}
	
	int x = rand.nextInt(16) + 8;
	int z = rand.nextInt(16) + 8;
	BlockPos at = worldIn.getHeight(pos.add(x, 0, z));
	
	WorldGenerator cropsGen = new CropGenerator((ExPBiome) biome);
	EventGenVegetation event = new EventGenVegetation(worldIn, at, rand, cropsGen, Type.WILD_CROP);
	if (MinecraftForge.TERRAIN_GEN_BUS.post(event))
	{
		return;
	}
	
	event.generator.generate(worldIn, rand, at);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:21,代码来源:ExPBiomeDecorator.java

示例6: onCollideWithPlayer

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@Override
public void onCollideWithPlayer(EntityPlayer player)
{
	if (!this.worldObj.isRemote)
	{
		NBTTagCompound nbt = new NBTTagCompound();
		this.writeToNBT(nbt);

		boolean inground = nbt.hasKey("inGround") && nbt.getByte("inGround") == 1;
		if(inground)
		{
			boolean flag = this.canBePickedUp == 1 || (this.canBePickedUp == 2 && player.capabilities.isCreativeMode);

			EntityItem ei = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(this.pickupItem, 1, 0));

			if (this.canBePickedUp == 1)
			{
				EntityItemPickupEvent event = new EntityItemPickupEvent(player, ei);

				if (MinecraftForge.EVENT_BUS.post(event))
					return;
			}

			ItemStack itemstack = ei.getEntityItem();
			if (itemstack.stackSize <= 0)
				flag = true;
			else if (this.canBePickedUp == 1 && !player.inventory.addItemStackToInventory(itemstack))
				flag = false;

			if (flag)
			{
				this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
				player.onItemPickup(this, 1);
				this.setDead();
			}
		}
	}
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:39,代码来源:EntityProjectileHardStone.java

示例7: init

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{		
	FMLInterModComms.sendRuntimeMessage(MODID, "VersionChecker", "addVersionCheck", VERSION_LINK);
	
	instance = this;		
	proxy.init();
       
       EventHandler eventHandler = new EventHandler();
       MinecraftForge.EVENT_BUS.register(eventHandler);
	
       if(FMLCommonHandler.instance().getEffectiveSide().isClient())
           FMLCommonHandler.instance().bus().register(eventHandler);
       
       //Minecraft.getMinecraft().gameSettings.showInventoryAchievementHint = false;
       Minecraft.getMinecraft().gameSettings.saveOptions();
       
       //Stop space from activating buttons, allowing it to be used for adding keyframes in the timeline.
       InputMap im = (InputMap)UIManager.get("Button.focusInputMap");
       im.put(KeyStroke.getKeyStroke("pressed SPACE"), "none");
       im.put(KeyStroke.getKeyStroke("released SPACE"), "none");
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:23,代码来源:ObsidianAnimator.java

示例8: causeDamage

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@Override
public void causeDamage(float damage)
{
	CropEvent.Damage dmgEvent = new CropEvent.Damage(this, this.getContainer().getWorld(), this.getContainer().getPos(), damage);
	if (this.isDead() || MinecraftForge.EVENT_BUS.post(dmgEvent))
	{
		return;
	}
	
	damage = dmgEvent.amount;
	this.setHealth(this.getHealth() - damage);
	if (this.isDead())
	{
		this.stats.type = EnumCrop.DEAD;
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:17,代码来源:ExPCrop.java

示例9: preInit

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@EventHandler
  public void preInit(FMLPreInitializationEvent event){
  	Util.logger = new Logger(event.getModLog());

  	// find the fields we need regardless of obs
  	OpenGuiWrapper.findFields();

  	// register event handlers
  	MinecraftForge.EVENT_BUS.register(new Registrar());
  	MinecraftForge.EVENT_BUS.register(new VersionTracker());
  	MinecraftForge.EVENT_BUS.register(PlayerWorldSyncServer.INSTANCE);

// setup networking
  	RemoteGuiNetworkManager.INSTANCE.preInit(event);

  	VersionTracker.register(new UniversalRemoteVersionProvider());

  	proxy.preInit(event);

  	// fix broken config issues
  	UniversalRemoteConfiguration.validateConfig();
  }
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:23,代码来源:UniversalRemote.java

示例10: syncCallback

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
public void syncCallback()
{
    if (chunk == null)
    {
        this.runCallbacks();
        return;
    }

    // Load Entities
    this.loader.loadEntities(this.chunkInfo.world, this.nbt.getCompoundTag("Level"), this.chunk);

    MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(this.chunk, this.nbt)); // Don't call ChunkDataEvent.Load async

    this.chunk.setLastSaveTime(provider.worldObj.getTotalWorldTime());
    this.provider.chunkGenerator.recreateStructures(this.chunk, this.chunkInfo.x, this.chunkInfo.z);

    provider.id2ChunkMap.put(ChunkPos.asLong(this.chunkInfo.x, this.chunkInfo.z), this.chunk);
    this.chunk.onChunkLoad();
    this.chunk.populateChunk(provider, provider.chunkGenerator);

    this.runCallbacks();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:ChunkIOProvider.java

示例11: onHoeUse

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
{
    UseHoeEvent event = new UseHoeEvent(player, stack, worldIn, pos);
    if (MinecraftForge.EVENT_BUS.post(event)) return -1;
    if (event.getResult() == Result.ALLOW)
    {
        stack.damageItem(1, player);
        return 1;
    }
    return 0;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:ForgeEventFactory.java

示例12: inject

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
public static void inject(ModContainer mod, ASMDataTable data, Side side)
{
    FMLLog.fine("Attempting to inject @EventBusSubscriber classes into the eventbus for %s", mod.getModId());
    Set<ASMDataTable.ASMData> targets = data.getAnnotationsFor(mod).get(Mod.EventBusSubscriber.class.getName());
    ClassLoader mcl = Loader.instance().getModClassLoader();

    for (ASMDataTable.ASMData targ : targets)
    {
        try
        {
            //noinspection unchecked
            List<ModAnnotation.EnumHolder> sidesEnum = (List<ModAnnotation.EnumHolder>)targ.getAnnotationInfo().get("value");
            EnumSet<Side> sides = DEFAULT;
            if (sidesEnum != null) {
                sides = EnumSet.noneOf(Side.class);
                for (ModAnnotation.EnumHolder h: sidesEnum) {
                    sides.add(Side.valueOf(h.getValue()));
                }
            }
            if (sides == DEFAULT || sides.contains(side)) {
                FMLLog.fine("Found @EventBusSubscriber class %s", targ.getClassName());
                Class<?> subscriptionTarget = Class.forName(targ.getClassName(), true, mcl);
                MinecraftForge.EVENT_BUS.register(subscriptionTarget);
                FMLLog.fine("Injected @EventBusSubscriber class %s", targ.getClassName());
            }
        }
        catch (Exception e)
        {
            FMLLog.log(Level.ERROR, e, "An error occurred trying to load an EventBusSubscriber %s for modid %s", targ.getClassName(), mod.getModId());
            throw new LoaderException(e);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:34,代码来源:AutomaticEventSubscriber.java

示例13: onItemRightClick

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player)
{
	ArrowNockEvent event = new ArrowNockEvent(player, is);
	MinecraftForge.EVENT_BUS.post(event);
	if (event.isCanceled())
		return event.result;

	if (player.capabilities.isCreativeMode || player.inventory.hasItem(ModItems.itemSharpStone) || player.inventory.hasItem(ModItems.itemHardStone) || player.inventory.hasItem(ModItems.itemSoftStone) )
		player.setItemInUse(is, this.getMaxItemUseDuration(is));

	return is;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:14,代码来源:ItemSlingshot.java

示例14: onWorldUpdate

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
public static void onWorldUpdate(ExPCrop crop)
{
	if (((VCSettings)(VoidApi.config.dataHolder)).recoveryMode)
	{
		return;
	}
	
	if (MinecraftForge.EVENT_BUS.post(new CropEvent.Update.Pre(crop, crop.getContainer().getWorld(), crop.getContainer().getPos())))
	{
		return;
	}
	
	Calendar prev = crop.timeKeeper;
	
	// Should not happen
	if (prev.getTime() == 0)
	{
		prev.setTime(IExPWorld.of(crop.getContainer().getWorld()).today().getTime());
	}
	else
	{
		Calendar current = IExPWorld.of(crop.getContainer().getWorld()).today();
		long ticksDelta = current.getTime() - prev.getTime();
		crop.timeKeeper = current;
		handleTimePassed(crop, ticksDelta, current);
	}
	
	if (crop.getContainer() != null && !crop.getContainer().isInvalid() && !crop.getContainer().getWorld().isAirBlock(crop.getContainer().getPos()))
	{
		MinecraftForge.EVENT_BUS.post(new CropEvent.Update.Post(crop, crop.getContainer().getWorld(), crop.getContainer().getPos()));
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:33,代码来源:CropLogic.java

示例15: shouldTrackWithThisEntry

import net.minecraftforge.common.MinecraftForge; //导入依赖的package包/类
@Override
public boolean shouldTrackWithThisEntry(IBlockAccess world, BlockPos pos, IBlockState state, TileEntity te) {
    if (te instanceof TileEntityChest) {
        TileEntityChest chest = (TileEntityChest) te;
        if (chest.adjacentChestXNeg != null || chest.adjacentChestZNeg != null) return false;
    }

    return te != null
            && !invBlackList.contains(TileEntity.getKey(te.getClass()))
            && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)
            && !MinecraftForge.EVENT_BUS.post(new InventoryTrackEvent(te));
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:13,代码来源:BlockTrackEntryInventory.java


注:本文中的net.minecraftforge.common.MinecraftForge类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。