本文整理匯總了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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
}
}
}
示例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");
}
示例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;
}
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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()));
}
}
示例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));
}