本文将为您提供关于cpw.mods.fml.common.network.ByteBufUtils的实例源码的详细介绍,我们还将为您解释fwknop源码解析的相关知识,同时,我们还将为您提供关于cpw
本文将为您提供关于cpw.mods.fml.common.network.ByteBufUtils的实例源码的详细介绍,我们还将为您解释fwknop 源码解析的相关知识,同时,我们还将为您提供关于cpw.mods.fml.common.DummyModContainer的实例源码、cpw.mods.fml.common.event.FMLInterModComms的实例源码、cpw.mods.fml.common.FMLCommonHandler的实例源码、cpw.mods.fml.common.FMLContainer的实例源码的实用信息。
本文目录一览:- cpw.mods.fml.common.network.ByteBufUtils的实例源码(fwknop 源码解析)
- cpw.mods.fml.common.DummyModContainer的实例源码
- cpw.mods.fml.common.event.FMLInterModComms的实例源码
- cpw.mods.fml.common.FMLCommonHandler的实例源码
- cpw.mods.fml.common.FMLContainer的实例源码
cpw.mods.fml.common.network.ByteBufUtils的实例源码(fwknop 源码解析)
@Override void fromBytes(ByteBuf bytes) { int listSize = bytes.readInt(); for (int i = 0; i < listSize; i++) { String fluidName = ByteBufUtils.readUTF8String(bytes); int fluidId = bytes.readInt(); fluidIds.put(FluidRegistry.getFluid(fluidName),fluidId); } // do we have a defaults list? if (bytes.isReadable()) { for (int i = 0; i < listSize; i++) { defaultFluids.add(ByteBufUtils.readUTF8String(bytes)); } } else { FMLLog.getLogger().log(Level.INFO,"Legacy server message contains no default fluid list - there may be problems with fluids"); defaultFluids.clear(); } }
@Override public void encodePacket(ChannelHandlerContext context,ByteBuf buffer) { ByteBufUtils.writeVarInt(buffer,entityIds.size(),5); for (Map.Entry<Integer,VRPlayerData> entry : entityIds.entrySet()) { VRPlayerData data = entry.getValue(); ByteBufUtils.writeVarInt(buffer,entry.getKey(),5); buffer.writeBoolean(data.newAPI); buffer.writeBoolean(data.reverseHands); buffer.writeFloat(data.worldScale); buffer.writeBoolean(data.seated); buffer.writeByte(data.entityIds.size()); for (int id : data.entityIds) { ByteBufUtils.writeVarInt(buffer,id,5); } } }
@Override public void decodePacket(ChannelHandlerContext context,ByteBuf buffer) { int size = ByteBufUtils.readVarInt(buffer,5); entityIds = new HashMap<Integer,VRPlayerData>(size); for (int i = 0; i < size; i++) { VRPlayerData data = new VRPlayerData(); entityIds.put(ByteBufUtils.readVarInt(buffer,5),data); data.newAPI = buffer.readBoolean(); data.reverseHands = buffer.readBoolean(); data.worldScale = buffer.readFloat(); data.seated = buffer.readBoolean(); int size2 = buffer.readUnsignedByte(); for (int j = 0; j < size2; j++) { data.entityIds.add(ByteBufUtils.readVarInt(buffer,5)); } } }
@Override public void toBytes(ByteBuf buf) { ByteArrayOutputStream obj = new ByteArrayOutputStream(); try { GZIPOutputStream gzip = new GZIPOutputStream(obj); ObjectOutputStream objStream = new ObjectOutputStream(gzip); objStream.writeObject(configValues); objStream.close(); } catch (IOException e) { Throwables.propagate(e); } buf.writeShort(obj.size()); buf.writeBytes(obj.toByteArray()); ByteBufUtils.writeUTF8String(buf,modid); }
@SuppressWarnings("unchecked") @Override public void fromBytes(ByteBuf buf) { short len = buf.readShort(); byte[] compressedBody = new byte[len]; for (short i = 0; i < len; i++) compressedBody[i] = buf.readByte(); try { ObjectInputStream obj = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(compressedBody))); configValues = (Map<String,Object>) obj.readobject(); obj.close(); } catch (Exception e) { Throwables.propagate(e); } modid = ByteBufUtils.readUTF8String(buf); }
@Override public void toBytes(ByteBuf buffer) { super.toBytes(buffer); ByteBufUtils.writeVarInt(buffer,modTags.size(),2); for (Map.Entry<String,String> modTag: modTags.entrySet()) { ByteBufUtils.writeUTF8String(buffer,modTag.getKey()); ByteBufUtils.writeUTF8String(buffer,modTag.getValue()); } }
@Override public void fromBytes(ByteBuf buffer) { super.fromBytes(buffer); int modCount = ByteBufUtils.readVarInt(buffer,2); for (int i = 0; i < modCount; i++) { modTags.put(ByteBufUtils.readUTF8String(buffer),ByteBufUtils.readUTF8String(buffer)); } }
@Override public void fromBytes(ByteBuf buffer) { int length = ByteBufUtils.readVarInt(buffer,3); modIds = Maps.newHashMap(); blockSubstitutions = Sets.newHashSet(); itemSubstitutions = Sets.newHashSet(); for (int i = 0; i < length; i++) { modIds.put(ByteBufUtils.readUTF8String(buffer),ByteBufUtils.readVarInt(buffer,3)); } // we don't have any more data to read if (!buffer.isReadable()) { return; } length = ByteBufUtils.readVarInt(buffer,3); for (int i = 0; i < length; i++) { blockSubstitutions.add(ByteBufUtils.readUTF8String(buffer)); } length = ByteBufUtils.readVarInt(buffer,3); for (int i = 0; i < length; i++) { itemSubstitutions.add(ByteBufUtils.readUTF8String(buffer)); } }
@Override protected void testMessageValidity(FMLProxyPacket msg) { if (msg.payload().getByte(0) == 0 && msg.payload().readableBytes() > 2) { FMLLog.severe("The connection appears to have sent an invalid FML packet of type 0,this is likely because it think's it's talking to 1.6.4 FML"); FMLLog.info("Bad data :"); for (String l : Splitter.on('\n').split(ByteBufUtils.getContentDump(msg.payload()))) { FMLLog.info("\t%s",l); } throw new FMLNetworkException("Invalid FML packet"); } }
@Override void toBytes(ByteBuf buf) { buf.writeInt(windowId); ByteBufUtils.writeUTF8String(buf,modId); buf.writeInt(modGuiId); buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); }
@Override void fromBytes(ByteBuf buf) { windowId = buf.readInt(); modId = ByteBufUtils.readUTF8String(buf); modGuiId = buf.readInt(); x = buf.readInt(); y = buf.readInt(); z = buf.readInt(); }
@Override void fromBytes(ByteBuf dat) { super.fromBytes(dat); modId = ByteBufUtils.readUTF8String(dat); modEntityTypeId = dat.readInt(); rawX = dat.readInt(); rawY = dat.readInt(); rawZ = dat.readInt(); scaledX = rawX / 32D; scaledY = rawY / 32D; scaledZ = rawZ / 32D; scaledYaw = dat.readByte() * 360F / 256F; scaledPitch = dat.readByte() * 360F / 256F; scaledHeadYaw = dat.readByte() * 360F / 256F; try { dataWatcherList = DataWatcher.func_151508_b(new PacketBuffer(dat)); } catch (IOException e) { FMLLog.log(Level.FATAL,e,"There was a critical error decoding the datawatcher stream for a mod entity."); throw Throwables.propagate(e); } throwerId = dat.readInt(); if (throwerId != 0) { speedScaledX = dat.readInt() / 8000D; speedScaledY = dat.readInt() / 8000D; speedScaledZ = dat.readInt() / 8000D; } this.dataStream = dat; }
@Override public void fromBytes(ByteBuf buf) { NBTTagCompound data = ByteBufUtils.readTag(buf); x = data.getInteger("x"); y = data.getInteger("y"); z = data.getInteger("z"); once = data.getBoolean("once"); }
@Override public void toBytes(ByteBuf buf) { NBTTagCompound data = new NBTTagCompound(); data.setInteger("x",x); data.setInteger("y",y); data.setInteger("z",z); data.setBoolean("once",once); ByteBufUtils.writeTag(buf,data); }
@Override public void fromBytes(ByteBuf buf) { slotCount = (short) ByteBufUtils.readVarShort(buf); itemStacks = new ItemStack[slotCount]; stackSizes = new int[slotCount]; for (int i = 0; i < slotCount; i++) { itemStacks[i] = ByteBufUtils.readItemStack(buf); stackSizes[i] = ByteBufUtils.readVarInt(buf,5); if (itemStacks[i] != null) itemStacks[i].stackSize = stackSizes[i]; } }
@Override public void toBytes(final ByteBuf buf) { ByteBufUtils.writeVarShort(buf,slotCount); for (int i = 0; i < slotCount; i++) { ByteBufUtils.writeItemStack(buf,itemStacks[i]); ByteBufUtils.writeVarInt(buf,stackSizes[i],5); } }
@Override public void fromBytes(final ByteBuf buf) { windowId = ByteBufUtils.readVarInt(buf,4); slotNumber = ByteBufUtils.readVarShort(buf); if (slotNumber < 0 || slotNumber > 279) slotNumber = -999; mouseButton = ByteBufUtils.readVarInt(buf,4); modifier = ByteBufUtils.readVarInt(buf,4); itemStack = ByteBufUtils.readItemStack(buf); stackSize = ByteBufUtils.readVarInt(buf,5); if (itemStack != null) itemStack.stackSize = stackSize; transactionID = (short) ByteBufUtils.readVarShort(buf); }
@Override public void toBytes(final ByteBuf buf) { ByteBufUtils.writeVarInt(buf,windowId,4); ByteBufUtils.writeVarShort(buf,slotNumber); ByteBufUtils.writeVarInt(buf,mouseButton,4); ByteBufUtils.writeVarInt(buf,modifier,4); ByteBufUtils.writeItemStack(buf,itemStack); ByteBufUtils.writeVarInt(buf,stackSize,5); ByteBufUtils.writeVarShort(buf,transactionID); }
@Override public void fromBytes(final ByteBuf buf) { itemStack = ByteBufUtils.readItemStack(buf); slot = ByteBufUtils.readVarShort(buf); stackSize = ByteBufUtils.readVarInt(buf,5); }
@Override public void toBytes(final ByteBuf buf) { ByteBufUtils.writeItemStack(buf,itemStack); ByteBufUtils.writeVarShort(buf,slot); ByteBufUtils.writeVarInt(buf,5); }
@Override public void fromBytes(final ByteBuf buf) { windowID = ByteBufUtils.readVarInt(buf,4); transactionID = (short) ByteBufUtils.readVarShort(buf); confirmed = ByteBufUtils.readVarShort(buf) == 1; }
@Override public void toBytes(final ByteBuf buf) { ByteBufUtils.writeVarInt(buf,windowID,transactionID); ByteBufUtils.writeVarShort(buf,confirmed ? 1 : 0); }
@Override public void fromBytes(ByteBuf buf) { entityId = ByteBufUtils.readVarInt(buf,4); entitySyncDataCompound = ByteBufUtils.readTag(buf); // this class is very useful in general for writing more complex objects // DEBUG System.out.println("fromBytes"); }
@Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeVarInt(buf,entityId,4); ByteBufUtils.writeTag(buf,entitySyncDataCompound); // DEBUG System.out.println("toBytes encoded"); }
@Override public void fromBytes(ByteBuf buf) { NBTTagCompound tag = ByteBufUtils.readTag(buf); startTime = tag.getLong("startTime"); time = tag.getInteger("time"); profile = new GameProfile(UUID.fromString(tag.getString("uuid")),tag.getString("name")); }
@Override public void toBytes(ByteBuf buf) { NBTTagCompound tag = new NBTTagCompound(); tag.setLong("startTime",startTime); tag.setInteger("time",time); tag.setString("uuid",profile.getId().toString()); tag.setString("name",profile.getName()); ByteBufUtils.writeTag(buf,tag); }
@Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf,identifier); buf.writeInt(index); ByteBufUtils.writeUTF8String(buf,title); buf.writeLong(created.getTime()); ByteBufUtils.writeUTF8String(buf,author); buf.writeLong(lastModified.getTime()); ByteBufUtils.writeUTF8String(buf,lastContributor); ByteBufUtils.writeUTF8String(buf,contents); }
@Override public void toBytes(ByteBuf buf) { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("dim",world.provider.dimensionId); tag.setInteger("x",x); tag.setInteger("y",y); tag.setInteger("z",z); tag.setTag("tag",updateData); ByteBufUtils.writeTag(buf,tag); }
@Override public void fromBytes(ByteBuf buf) { NBTTagCompound tag = ByteBufUtils.readTag(buf); configName = tag.getString("configName"); config = tag.getString("config"); isRevert = tag.getBoolean("isRevert"); }
@Override public void toBytes(ByteBuf buf) { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("dim",tag); }
@Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf,Codename); buf.writeInt(Faction); buf.writeInt(Level); buf.writeInt(AP); buf.writeInt(XM); }
@Override public void writeSpawnData(ByteBuf buffer) { ByteBufUtils.writeUTF8String(buffer,UUID); ByteBufUtils.writeUTF8String(buffer,Name); ByteBufUtils.writeUTF8String(buffer,String.valueOf(Faction)); ByteBufUtils.writeUTF8String(buffer,Owner); }
@Override public void toBytes(ByteBuf buf) { super.toBytes(buf); ByteBufUtils.writeUTF8String(buf,this.node_uuid.toString()); buf.writeInt(this.getX()); buf.writeInt(this.getY()); buf.writeInt(this.getZ()); }
@Override public void encodeInto(ChannelHandlerContext ctx,ByteBuf buffer) { buffer.writeInt(this.RecordSize); buffer.writeInt(this.FoodListRef); for(int i = 0; i < this.RecordSize; ++i) { if(this.foodrecord.FoodsEaten[i] != null) ByteBufUtils.writeUTF8String(buffer,this.foodrecord.FoodsEaten[i]); } }
@Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf,this.node_uuid.toString()); buf.writeInt(this.getX()); buf.writeInt(this.getY()); buf.writeInt(this.getZ()); }
@Override public void fromBytes(ByteBuf buf) { this.grid_uuid = UUID.fromString(ByteBufUtils.readUTF8String(buf)); this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); }
@Override public void fromBytes(ByteBuf buf) { x = buf.readInt(); y = buf.readInt(); z = buf.readInt(); scripts = new ArrayList<ComputerScript>(); while (buf.readableBytes() > 1) { scripts.add(new ComputerScript(new ScriptComputer((TileEntityComputer) minecraft.getminecraft().theWorld.getTileEntity(x,y,z)),ByteBufUtils.readUTF8String(buf),ByteBufUtils.readUTF8String(buf))); } }
@Override public void fromBytes(ByteBuf buf) { super.fromBytes(buf); relX = buf.readInt(); relY = buf.readInt(); relZ = buf.readInt(); name = ByteBufUtils.readUTF8String(buf); }
public static FMLProxyPacket createPacket(int xPos,int yPos,int zPos,NBTTagCompound nbt,int dim) { // This line may look like black magic (and,well,it is),but it's actually just returning a class reference for this class. copy-paste safe. ByteBuf data = PacketHandlerBase.createDataBuffer((Class<? extends PacketHandlerBase>) new Object() {}.getClass().getEnclosingClass()); data.writeInt(dim); data.writeInt(xPos); data.writeInt(yPos); data.writeInt(zPos); ByteBufUtils.writeTag(data,nbt); return buildPacket(data); }
@Override public void handle(ByteBuf data,EntityPlayer player) { int dimension = data.readInt(); int xPos = data.readInt(); int yPos = data.readInt(); int zPos = data.readInt(); NBTTagCompound nbt = ByteBufUtils.readTag(data); WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimension); if (proxyworld == null) return; if (proxyworld.provider.dimensionId != dimension) return; if (proxyworld.blockExists(xPos,yPos,zPos)) { TileEntity tileentity = proxyworld.getTileEntity(xPos,zPos); if (tileentity != null) { tileentity.readFromNBT(nbt); } else { //Create tile entity from data tileentity = TileEntity.createAndLoadEntity(nbt); if (tileentity != null) { proxyworld.addTileEntity(tileentity); } } proxyworld.markTileEntityChunkModified(xPos,zPos,tileentity); proxyworld.setTileEntity(xPos,tileentity); proxyworld.markBlockForUpdate(xPos,zPos); } }
cpw.mods.fml.common.DummyModContainer的实例源码
private void detectOptifine() { try { Class<?> optifineConfig = Class.forName("Config",false,Loader.instance().getModClassLoader()); String optifineVersion = (String) optifineConfig.getField("VERSION").get(null); Map<String,Object> dummyOptifineMeta = ImmutableMap.<String,Object>builder().put("name","Optifine").put("version",optifineVersion).build(); ModMetadata optifineMetadata = MetadataCollection.from(getClass().getResourceAsstream("optifinemod.info"),"optifine").getMetadataForId("optifine",dummyOptifineMeta); optifineContainer = new DummyModContainer(optifineMetadata); FMLLog.info("Forge Mod Loader has detected optifine %s,enabling compatibility features",optifineContainer.getVersion()); } catch (Exception e) { optifineContainer = null; } }
/** * We must force the following load order,otherwise many things break: * - TFC * - This mod * - Anything else */ public static void doLoadOrderHaxing() { File injectedDepFile = new File(Loader.instance().getConfigDir(),"injectedDependencies.json"); JsonArray deps = new JsonArray(); JsonObject dep = new JsonObject(); dep.addProperty("type","after"); dep.addProperty("target",TFC); deps.add(dep); for (ModContainer container : Loader.instance().getModList()) { if (container instanceof DummyModContainer || container instanceof InjectedModContainer) continue; String modid = container.getModId(); if (modid.equals(MODID) || modid.equals(TFC)) continue; dep = new JsonObject(); dep.addProperty("type","before"); dep.addProperty("target",modid); deps.add(dep); } JsonArray root = new JsonArray(); JsonObject mod = new JsonObject(); mod.addProperty("modId",MODID); mod.add("deps",deps); root.add(mod); try { FileUtils.write(injectedDepFile,GSON.toJson(root)); } catch (IOException e) { throw new RuntimeException(e); } }
public EAPluginContainer(File file) { ModMetadata stub = new ModMetadata(); stub.modId = file.getName().toLowerCase(); stub.name = file.getName(); stub.version = "eaLua Compatible Plugin 1.0"; this.container = (ModContainer)new DummyModContainer(stub); }
public static void start(File coremodLocation) { LoadingFrame.setSystemLAF(); coreModLocation = coremodLocation; if (coreModLocation == null) coreModLocation = new File("./../bin/"); // Assume this is a dev environment,and that the build dir is in bin,and the test dir has the same parent as // the bin dir... ModMetadata md = new ModMetadata(); md.name = Lib.Mod.NAME; md.modId = Lib.Mod.ID; modContainer = new DummyModContainer(md) { @Override public Class<?> getCustomresourcePackClass() { return FMLFileResourcePack.class; } @Override public File getSource() { return coreModLocation; } @Override public String getModId() { return Lib.Mod.ID; } }; File fileOld = new File("./config/betterloadingscreen.cfg"); File fileNew = new File("./config/BetterLoadingScreen/config.cfg"); if (fileOld.exists()) cfg = new Configuration(fileOld); else cfg = new Configuration(fileNew); boolean useminecraft = isClient(); if (useminecraft) { String comment = "Whether or not to use minecraft's display to show the progress. This looks better,but there is a possibilty of not being "; comment += "compatible,so if you do have any strange crash reports or compatability issues,try setting this to false"; useminecraft = cfg.getBoolean("useminecraft","general",true,comment); } connectExternally = cfg.getBoolean("connectExternally","If this is true,it will conect to drone.io to get a changelog"); playSound = cfg.getBoolean("playSound","Play a sound after minecraft has finished starting up"); if (useminecraft) displayer = new minecraftdisplayerWrapper(); else if (!GraphicsEnvironment.isHeadless()) displayer = new Framedisplayer(); else displayer = new Loggingdisplayer(); displayer.open(cfg); cfg.save(); }
cpw.mods.fml.common.event.FMLInterModComms的实例源码
public static void addSmelter(int energy,final ItemStack a,final ItemStack b,final ItemStack output,final ItemStack altOutput,final int prob) { if (a == null || b == null || output == null) { return; } if (energy <= 0) { energy = 4000; } final NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("energy",energy); tag.setTag("primaryInput",(NBTBase)getItemStackNBT(a)); tag.setTag("secondaryInput",(NBTBase)getItemStackNBT(b)); tag.setTag("primaryOutput",(NBTBase)getItemStackNBT(output)); if (altOutput != null) { tag.setTag("secondaryOutput",(NBTBase)getItemStackNBT(altOutput)); tag.setInteger("secondaryChance",prob); } FMLInterModComms.sendMessage("ThermalExpansion","SmelterRecipe",tag); }
public void initializeMods() { progressBar.step("Initializing mods Phase 2"); // Mod controller should be in the initialization state here modController.distributeStateMessage(LoaderState.INITIALIZATION); progressBar.step("Initializing mods Phase 3"); modController.transition(LoaderState.POStiniTIALIZATION,false); modController.distributeStateMessage(FMLInterModComms.IMCEvent.class); ItemStackHolderInjector.INSTANCE.inject(); modController.distributeStateMessage(LoaderState.POStiniTIALIZATION); progressBar.step("Finishing up"); modController.transition(LoaderState.AVAILABLE,false); modController.distributeStateMessage(LoaderState.AVAILABLE); GameData.freezeData(); // Dump the custom registry data map,if necessary GameData.dumpRegistry(minecraftDir); FMLLog.info("Forge Mod Loader has successfully loaded %d mod%s",mods.size(),mods.size() == 1 ? "" : "s"); progressBar.step("Completing minecraft initialization"); }
@Override public void init(FMLInitializationEvent e) { super.init(e); Register.registerGlobalEntityID(EntityLaser.class,"laser"); Register.registerEntityRenderingHandler(EntityLaser.class,new RenderLaser()); Register.registerItemRenderer(RorysMod.items.rifle1,new RenderRifle()); Register.registerItemRenderer(RorysMod.items.rifle2,new RenderRifle()); Register.registerItemRenderer(RorysMod.items.rifle3,new RenderRifle()); Register.registerItemRenderer(RorysMod.items.rifle4,new RenderRifle()); Register.registerItemRenderer(RorysMod.items.rifle5,new RenderRifle()); TileEntitySpecialRenderer render = new RenderRifleTable(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRifleTable.class,render); Register.registerItemRenderer(Item.getItemFromBlock(RorysMod.blocks.upgradeTable),new ItemRender(render,new TileEntityRifleTable())); render = new RenderPoweredChest(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPoweredChest.class,render); FMLInterModComms.sendMessage("Waila","register",WailaConfig.class.getName() + ".callbackRegister"); }
public static void addPulverizerRecipe(int energy,ItemStack input,ItemStack primaryOutput,ItemStack secondaryOutput,int secondaryChance) { if (input == null || primaryOutput == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",energy); toSend.setTag("input",new NBTTagCompound()); toSend.setTag("primaryOutput",new NBTTagCompound()); if (secondaryOutput != null) { toSend.setTag("secondaryOutput",new NBTTagCompound()); } input.writetoNBT(toSend.getCompoundTag("input")); primaryOutput.writetoNBT(toSend.getCompoundTag("primaryOutput")); if (secondaryOutput != null) { secondaryOutput.writetoNBT(toSend.getCompoundTag("secondaryOutput")); toSend.setInteger("secondaryChance",secondaryChance); } boolean bool = FMLInterModComms.sendMessage("ThermalExpansion","PulverizerRecipe",toSend); if (bool) recipies++; }
public static void addSmelterRecipe(int energy,ItemStack primaryInput,ItemStack secondaryInput,int secondaryChance) { NBTTagCompound data = new NBTTagCompound(); data.setInteger("energy",energy); NBTTagCompound input1Compound = new NBTTagCompound(); primaryInput.writetoNBT(input1Compound); data.setTag("primaryInput",input1Compound); NBTTagCompound input2Compound = new NBTTagCompound(); secondaryInput.writetoNBT(input2Compound); data.setTag("secondaryInput",input2Compound); NBTTagCompound output1Compound = new NBTTagCompound(); primaryOutput.writetoNBT(output1Compound); data.setTag("primaryOutput",output1Compound); if (secondaryOutput != null) { NBTTagCompound output2Compound = new NBTTagCompound(); secondaryOutput.writetoNBT(output2Compound); data.setTag("secondaryOutput",output2Compound); data.setInteger("secondaryChance",data); if (bool) recipies++; }
private void fixEnderIO(){ //Example of how to add a recipe: NBTTagCompound root = new NBTTagCompound(); root.setString(SoulBinderRecipeManager.KEY_RECIPE_UID,"sentientEnderMK2"); root.setInteger(SoulBinderRecipeManager.KEY_required_ENERGY,100000); root.setInteger(SoulBinderRecipeManager.KEY_required_XP,10); root.setString(SoulBinderRecipeManager.KEY_SOUL_TYPES,"SpecialMobs.SpecialWitch"); ItemStack is = new ItemStack(EnderIO.itemFrankenSkull,1,FrankenSkull.ENDER_RESONATOR.ordinal()); NBTTagCompound stackRoot = new NBTTagCompound(); is.writetoNBT(stackRoot); root.setTag(SoulBinderRecipeManager.KEY_INPUT_STACK,stackRoot); is = new ItemStack(EnderIO.itemFrankenSkull,FrankenSkull.SENTIENT_ENDER.ordinal()); stackRoot = new NBTTagCompound(); is.writetoNBT(stackRoot); root.setTag(SoulBinderRecipeManager.KEY_OUTPUT_STACK,stackRoot); SoulBinderRecipeManager.getInstance().addRecipeFromNBT(root); FMLInterModComms.sendMessage("EnderIO","recipe:soulbinder",root); }
public static void register() { if (Loader.isModLoaded("VersionChecker")) { final NBTTagCompound nbt = new NBTTagCompound(); nbt.setString("curseProjectName",CURSE_PROJECT_NAME); nbt.setString("curseFilenameParser",MOD_NAME_TEMPLATE); FMLInterModComms.sendRuntimeMessage(ModpackInfo.MOD_ID,"VersionChecker","addVersionCheck",nbt); } if (Modoptions.getonlineVersionChecking()) { final VersionCheck test = new VersionCheck(); FMLCommonHandler.instance().bus().register(test); new Thread(test).start(); } }
public static void addPulverizerRecipe(int energy,int secondaryChance) { if (input == null || primaryOutput == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",energy); toSend.setTag("input",new NBTTagCompound()); toSend.setTag("primaryOutput",new NBTTagCompound()); if (secondaryOutput != null) { toSend.setTag("secondaryOutput",new NBTTagCompound()); } input.writetoNBT(toSend.getCompoundTag("input")); primaryOutput.writetoNBT(toSend.getCompoundTag("primaryOutput")); if (secondaryOutput != null) { secondaryOutput.writetoNBT(toSend.getCompoundTag("secondaryOutput")); toSend.setInteger("secondaryChance",secondaryChance); } FMLInterModComms.sendMessage("ThermalExpansion",toSend); }
public static void addSawmillRecipe(int energy,"SawmillRecipe",toSend); }
public static void addCrucibleRecipe(int energy,FluidStack output) { if (input == null || output == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",new NBTTagCompound()); toSend.setTag("output",new NBTTagCompound()); input.writetoNBT(toSend.getCompoundTag("input")); output.writetoNBT(toSend.getCompoundTag("output")); FMLInterModComms.sendMessage("ThermalExpansion","CrucibleRecipe",toSend); }
public static void addTransposerFill(int energy,ItemStack output,FluidStack fluid,boolean reversible) { if (input == null || output == null || fluid == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",new NBTTagCompound()); toSend.setTag("fluid",new NBTTagCompound()); input.writetoNBT(toSend.getCompoundTag("input")); output.writetoNBT(toSend.getCompoundTag("output")); toSend.setBoolean("reversible",reversible); fluid.writetoNBT(toSend.getCompoundTag("fluid")); FMLInterModComms.sendMessage("ThermalExpansion","TransposerFillRecipe",toSend); }
public static void addTransposerExtract(int energy,int chance,reversible); toSend.setInteger("chance",chance); fluid.writetoNBT(toSend.getCompoundTag("fluid")); FMLInterModComms.sendMessage("ThermalExpansion","TransposerExtractRecipe",toSend); }
public static void addAlloySmelterRecipe(String name,int energy,ItemStack tertiaryInput,ItemStack output) { StringBuilder toSend = new StringBuilder(); toSend.append("<recipeGroup name=\"" + Reference.MOD_ID + "\">"); toSend.append("<recipe name=\"" + name + "\" energyCost=\"" + energy + "\">"); toSend.append("<input>"); writeItemStack(toSend,primaryInput); writeItemStack(toSend,secondaryInput); writeItemStack(toSend,tertiaryInput); toSend.append("</input>"); toSend.append("<output>"); writeItemStack(toSend,output); toSend.append("</output>"); toSend.append("</recipe>"); toSend.append("</recipeGroup>"); FMLInterModComms.sendMessage("EnderIO","recipe:alloysmelter",toSend.toString()); }
@Mod.EventHandler public static void init(FMLInitializationEvent event) { if (Loader.isModLoaded("NotEnoughItems")) { try { System.out.println("Registering NEI comp."); codechicken.nei.NEIModContainer.plugins.add(new NEIToggleConfig()); } catch (Exception ignored) { } } minecraftForge.EVENT_BUS.register(new EventHandler()); proxy.registerRenderer(); FMLInterModComms.sendRuntimeMessage(ModInfo.MOD_ID,"http://mrspring.dk/mods/tb/versions.json"); FMLInterModComms.sendMessage("tb","dk.mrspring.toggle.comp.vanilla.ToggleRegistryCallback.register"); FMLInterModComms.sendMessage("Waila","dk.mrspring.toggle.comp.waila.WailaCompatibility.callbackRegister"); Recipes.register(); }
public void registerMicroMaterials() { for(int i = 0; i < 16; i++) { MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.PlasticBlock,i),BlockMicroMaterial.materialKey(MekanismBlocks.PlasticBlock,i)); MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.GlowPlasticBlock,BlockMicroMaterial.materialKey(MekanismBlocks.GlowPlasticBlock,i)); MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.SlickPlasticBlock,BlockMicroMaterial.materialKey(MekanismBlocks.SlickPlasticBlock,i)); MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.ReinforcedplasticBlock,BlockMicroMaterial.materialKey(MekanismBlocks.ReinforcedplasticBlock,i)); MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.RoadplasticBlock,BlockMicroMaterial.materialKey(MekanismBlocks.RoadplasticBlock,i)); FMLInterModComms.sendMessage("ForgeMicroblock","microMaterial",new ItemStack(MekanismBlocks.BasicBlock,i)); if(!MachineType.get(MACHINE_BLOCK_1,i).hasModel) { FMLInterModComms.sendMessage("ForgeMicroblock",new ItemStack(MekanismBlocks.MachineBlock,i)); } if(!MachineType.get(MACHINE_BLOCK_2,new ItemStack(MekanismBlocks.MachineBlock2,i)); } } FMLInterModComms.sendMessage("ForgeMicroblock",new ItemStack(MekanismBlocks.BasicBlock2,0)); FMLInterModComms.sendMessage("ForgeMicroblock",new ItemStack(MekanismBlocks.CardboardBox)); }
/** * MACHInes */ /* Furnace */ public static void addFurnaceRecipe(int energy,ItemStack output) { if (input == null || output == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",energy); toSend.setTag("input",new NBTTagCompound()); toSend.setTag("output",new NBTTagCompound()); input.writetoNBT(toSend.getCompoundTag("input")); output.writetoNBT(toSend.getCompoundTag("output")); FMLInterModComms.sendMessage("ThermalExpansion","FurnaceRecipe",toSend); }
public static void addPulverizerRecipe(int energy,toSend); }
public static void addSawmillRecipe(int energy,toSend); }
public static void addCrucibleRecipe(int energy,toSend); }
public static void addTransposerFill(int energy,toSend); }
public static void addTransposerExtract(int energy,toSend); }
private void sendMessage() { if (Loader.isModLoaded("VersionChecker")) { String changeLog = ""; for (String i : this.changelist) changeLog += "- " + i; NBTTagCompound tag = new NBTTagCompound(); tag.setString("moddisplayName",this.modname); tag.setString("oldVersion",this.currentVer); tag.setString("newVersion",this.version); tag.setString("updateUrl",this.downloadURL); tag.setBoolean("isDirectLink",this.isDirect); tag.setString("changeLog",changeLog); FMLInterModComms.sendMessage("VersionChecker","addUpdate",tag); } Logger.logInfo(String.format(translate("update.wiiemc"),this.version,this.downloadURL)); }
public void init() { WIIEMC.config.initEvent(); Logger.logInfo("Beware the flower pots...they will confuse you and ambush you..."); if (Loader.isModLoaded("EE3")) { FMLInterModComms.sendMessage("Waila","net.lomeli.wiiemc.providers.ee3.BlockEMCDataProvider.callbackRegister"); FMLInterModComms.sendMessage("Waila","net.lomeli.wiiemc.providers.ee3.EntityEMCDataProvider.callbackRegister"); FMLInterModComms.sendMessage("Waila","net.lomeli.wiiemc.providers.ee3.TileEMCDataProvider.callbackRegister"); minecraftForge.EVENT_BUS.register(new EventHandler()); } if (Loader.isModLoaded("ProjectE")) { FMLInterModComms.sendMessage("Waila","net.lomeli.wiiemc.providers.projecte.BlockEMCDataProvider.callbackRegister"); FMLInterModComms.sendMessage("Waila","net.lomeli.wiiemc.providers.projecte.EntityEMCDataProvider.callbackRegister"); FMLInterModComms.sendMessage("Waila","net.lomeli.wiiemc.providers.projecte.TileEMCDataProvider.callbackRegister"); } if (Loader.isModLoaded("simplecondenser")) Logger.logInfo("Aww...I feel all special Now..."); if (Loader.isModLoaded("EE3") && Loader.isModLoaded("ProjectE")) Logger.logError("Greedy little fella,aren't ya?"); }
@EventHandler public void handleIMC(FMLInterModComms.IMCEvent event) { // IMCHandler try { log.info("Processing IMC messages..."); IMCHandler.processIMC(event.getMessages()); log.info("IMC Messages processed."); } catch (Exception e) { log.error("=============================ERROR!============================="); log.error("Failed to process IMC Messages,printing stacktrace..."); log.error("Please report this as a bug report with the stacktrace,the minecraft log and a mod list + version to: " + issueURL); log.error("=============================ERROR!============================="); e.printstacktrace(); } }
@EventHandler public void loadComplete(FMLLoadCompleteEvent event) { // Fetching runtime messages try { log.info("Fetching runtime IMC messages..."); IMCHandler.processIMC(FMLInterModComms.fetchRuntimeMessages(this)); log.info("Fetched runtime IMC messages."); } catch (Exception e) { log.error("=============================ERROR!============================="); log.error("Failed to fetch IMC Runtime messages,the minecraft log and a mod list + version to: " + issueURL); log.error("=============================ERROR!============================="); e.printstacktrace(); } }
public static void addPulverizerRecipe(int energy,int secondaryChance) { NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",energy); toSend.setCompoundTag("input",new NBTTagCompound()); toSend.setCompoundTag("primaryOutput",new NBTTagCompound()); toSend.setCompoundTag("secondaryOutput",new NBTTagCompound()); input.writetoNBT(toSend.getCompoundTag("input")); primaryOutput.writetoNBT(toSend.getCompoundTag("primaryOutput")); secondaryOutput.writetoNBT(toSend.getCompoundTag("secondaryOutput")); toSend.setInteger("secondaryChance",secondaryChance); FMLInterModComms.sendMessage("ThermalExpansion",toSend); }
public static void addSawmillRecipe(int energy,toSend); }
public static void addTransposerExtract(int energy,boolean reversible) { NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",new NBTTagCompound()); toSend.setCompoundTag("output",new NBTTagCompound()); toSend.setCompoundTag("fluid",toSend); }
@Mod.EventHandler public void handleIMcmessage(FMLInterModComms.IMCEvent event) { for (IMcmessage message : event.getMessages()) { if ("addClassExclusion".equals(message.key) && message.isstringMessage()) { try { Class<?> clazz = Class.forName(message.getStringValue()); CommonProxy.excludedClasses.add(clazz); } catch (ClassNotFoundException e) { I18n.format("message.cartlivery.invalidExclusion",message.getSender(),message.getStringValue()); } } if ("addBuiltInLiveries".equals(message.key) && message.isstringMessage() && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { String[] liveries = message.getStringValue().split(","); log.info(I18n.format("message.cartlivery.registerBuiltIn",liveries.length,message.getSender())); for(String livery : liveries) LiveryTextureRegistry.builtInLiveries.put(livery,message.getSender()); } } }
public static void addPulverizerRecipe(int energy,toSend); }
public static void addTransposerExtract(int energy,boolean reversible) { if (input == null || output == null || fluid == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",new NBTTagCompound()); toSend.setTag("output",new NBTTagCompound()); toSend.setTag("fluid",new NBTTagCompound()); input.writetoNBT(toSend.getCompoundTag("input")); output.writetoNBT(toSend.getCompoundTag("output")); toSend.setBoolean("reversible",reversible); toSend.setInteger("chance",chance); fluid.writetoNBT(toSend.getCompoundTag("fluid")); FMLInterModComms.sendMessage("ThermalExpansion",toSend); }
@EventHandler public void init2(FMLInitializationEvent event) { NyxRecipes.init(); if (IaSFlags.flag_death_system) { minecraftForge.EVENT_BUS.register(new NyxDeathSystem()); } NyxBiomes.registerBiomes(); minecraftForge.EVENT_BUS.register(new IaSTooltipHandler()); minecraftForge.EVENT_BUS.register(new NyxEventHandlerCold()); minecraftForge.EVENT_BUS.register(new NyxBlockHandler()); minecraftForge.EVENT_BUS.register(new NyxEquipmentHandler()); GameRegistry.registerFuelHandler(new NyxFuelHandler()); // Be nice,Thaumcraft. FMLInterModComms.sendMessage("Thaumcraft","dimensionBlacklist","" + IaSFlags.dim_nyx_id + ":0"); }
public static void addTransposerFill(int energy,toSend); }
public static void addTransposerExtract(int energy,toSend); }
private void sendSimpleImcRecipe(String recipeKey,Gas gasType,ItemStack output) { NBTTagCompound msg = new NBTTagCompound(); NBTTagCompound nbtInput = new NBTTagCompound(); input.writetoNBT(nbtInput); msg.setTag("input",nbtInput); if (gasType != null) { NBTTagCompound nbtGasType = new NBTTagCompound(); gasType.write(nbtGasType); msg.setTag("gasType",nbtGasType); } NBTTagCompound nbtOutput = new NBTTagCompound(); output.writetoNBT(nbtOutput); msg.setTag("output",nbtOutput); FMLInterModComms.sendMessage(this._modID,recipeKey,msg); }
public static void addSmelterRecipe(int energy,int secondaryChance) { NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger("energy",energy); toSend.setCompoundTag("primaryInput",new NBTTagCompound()); toSend.setCompoundTag("secondaryInput",new NBTTagCompound()); toSend.setCompoundTag("primaryOutput",new NBTTagCompound()); toSend.setCompoundTag("secondaryOutput",new NBTTagCompound()); primaryInput.writetoNBT(toSend.getCompoundTag("primaryInput")); secondaryInput.writetoNBT(toSend.getCompoundTag("secondaryInput")); primaryOutput.writetoNBT(toSend.getCompoundTag("primaryOutput")); secondaryOutput.writetoNBT(toSend.getCompoundTag("secondaryOutput")); toSend.setInteger("secondaryChance",secondaryChance); FMLInterModComms.sendMessage("ThermalExpansion",toSend); }
public static void addTransposerFill(int energy,reversible); fluid.writetoNBT(toSend.getCompoundTag("fluid")); FMLInterModComms.sendMessage("ThermalExpansion",toSend); }
@EventHandler public void init(FMLInitializationEvent event) { Features.init(); NetworkRegistry.INSTANCE.registerGuiHandler(this,new ChiselGuiHandler()); addWorldgen(Features.MARBLE,ChiselBlocks.marble,Configurations.marbleAmount); addWorldgen(Features.LIMESTONE,ChiselBlocks.limestone,Configurations.limestoneAmount); addWorldgen(Features.ANDESITE,ChiselBlocks.andesite,Configurations.andesiteAmount,40,100,0.5); addWorldgen(Features.GRANITE,ChiselBlocks.granite,Configurations.graniteAmount,0.5); addWorldgen(Features.dioRITE,ChiselBlocks.diorite,Configurations.dioriteAmount,0.5); GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE,1000); EntityRegistry.registerModEntity(EntityChiselSNowman.class,"sNowman",this,80,true); proxy.init(); minecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(instance); FMLInterModComms.sendMessage("Waila","com.cricketcraft.chisel.compat.WailaCompat.register"); }
@EventHandler public void init(FMLInitializationEvent event){ log("Setting up inter-mod stuff..."); FMLInterModComms.sendMessage("Waila","net.geforcemods.securitycraft.imc.waila.WailaDataProvider.callbackRegister"); FMLInterModComms.sendMessage("LookingGlass","API","net.geforcemods.securitycraft.imc.lookingglass.LookingGlassAPIProvider.register"); if(config.checkForUpdates) { NBTTagCompound vcUpdateTag = VersionUpdateChecker.getNBTTagCompound(); if(vcUpdateTag != null) FMLInterModComms.sendRuntimeMessage(MODID,vcUpdateTag); } log("Registering mod content... (PT 2/2)"); NetworkRegistry.INSTANCE.registerGuiHandler(this,guiHandler); RegistrationHandler.registerEntities(); EnumCustomModules.refresh(); serverProxy.registerRenderThings(); }
cpw.mods.fml.common.FMLCommonHandler的实例源码
@Mod.EventHandler public void init(FMLInitializationEvent event) { Configurator.configure(new File("config/" + MODID + ".cfg")); GameRegistry.registerWorldGenerator(new Decorator(),4096); FMLCommonHandler.instance().bus().register(this); minecraftForge.EVENT_BUS.register(this); }
public static int lookupForgeRevision() { if (sForgeRevision != 0) return sForgeRevision; int revision = Integer.parseInt(System.getProperty("uranium.forgeRevision","0")); if (revision != 0) return sForgeRevision = revision; try { Properties p = new Properties(); p.load(Uranium.class .getResourceAsstream("/fmlversion.properties")); revision = Integer.parseInt(String.valueOf(p.getProperty( "fmlbuild.build.number","0"))); } catch (Exception e) { } if (revision == 0) { ULog.get().warning("Uranium: Could not parse forge revision,critical error"); FMLCommonHandler.instance().exitJava(1,false); } return sForgeRevision = revision; }
/** * Starts the Scheduler which submits our data every 30 minutes. */ private void startSubmitting() { final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags timer.scheduleAtFixedrate(new TimerTask() { @Override public void run() { // Nevertheless we want our code to run in the Bukkit main thread,so we have to use the Bukkit scheduler // Don't be afraid! The connection to the bStats server is still async,only the stats collection is sync ;) FMLCommonHandler.instance().getminecraftServerInstance().processQueue.add(new Runnable() { @Override public void run() { submitData(); } }); } },1000*60*5,1000*60*30); // Submit the data every 30 minutes,first time after 5 minutes to give other plugins enough time to start // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted! // WARNING: Just don't do it! }
@EventHandler public void init(FMLInitializationEvent evt) { INSTANCE.registerMessage(LobbyPlayerOpenedGuiPacketHandler.class,LobbyPlayerOpenedGuiPacket.class,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); }
@SubscribeEvent public void clientConnectedtoServer(FMLNetworkEvent.ServerConnectionFromClientEvent event) { if (!CreeperHost.instance.active) return; minecraftServer server = FMLCommonHandler.instance().getminecraftServerInstance(); if (server == null || server.isSinglePlayer() || discoverMode != discoverability.PUBLIC) return; INetHandlerPlayServer handler = event.handler; if (handler instanceof NetHandlerPlayServer) { EntityPlayerMP entity = ((NetHandlerPlayServer) handler).playerEntity; playersJoined.add(entity.getUniqueID()); } }
private void inviteUser(GameProfile profile) { minecraftServer server = FMLCommonHandler.instance().getminecraftServerInstance(); Gson gson = new Gson(); UserListWhitelist whitelistedplayers = server.getConfigurationManager().func_152599_k(); final ArrayList<String> tempHash = new ArrayList<String>(); String name = profile.getName().toLowerCase(); try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(whitelistedplayers.func_152706_a(name).getId().toString().getBytes(Charset.forName("UTF-8"))); tempHash.add((new HexBinaryAdapter()).marshal(hash)); } catch (NoSuchAlgorithmException e) { e.printstacktrace(); } CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass(); invite.hash = tempHash; invite.id = CreeperHostServer.updateID; Util.putWebResponse("https://api.creeper.host/serverlist/invite",gson.toJson(invite),true,true); }
private void removeUser(GameProfile profile) { minecraftServer server = FMLCommonHandler.instance().getminecraftServerInstance(); Gson gson = new Gson(); final ArrayList<String> tempHash = new ArrayList<String>(); try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(profile.getId().toString().getBytes(Charset.forName("UTF-8"))); tempHash.add((new HexBinaryAdapter()).marshal(hash)); } catch (NoSuchAlgorithmException e) { e.printstacktrace(); } CreeperHostServer.InviteClass invite = new CreeperHostServer.InviteClass(); invite.hash = tempHash; invite.id = CreeperHostServer.updateID; CreeperHostServer.logger.debug("Sending " + gson.toJson(invite) + " to revoke endpoint"); String resp = Util.putWebResponse("https://api.creeper.host/serverlist/revokeinvite",true); CreeperHostServer.logger.debug("Response from revoke endpoint " + resp); }
private void click(boolean state) { if (Wrapper.currentScreen() != null) { clickInventory(0,state); return; } if (inventoryOnly.getValue()) return; try { MouseEvent event = new MouseEvent(); int key = Wrapper.getKeyCode(Wrapper.keybindAttack()); ReflectionUtil.setField("button",event,Wrapper.convertKeyToLWJGL(key)); ReflectionUtil.setField("buttonstate",state); //calling the event for cpsMod compatibility. boolean thingy = minecraftForge.EVENT_BUS.post(event); Wrapper.keybinding_setKeybindState(key,state); if (state) Wrapper.keybinding_onTick(key); if (!thingy) FMLCommonHandler.instance().fireMouseinput(); } catch (Exception ex) { } }
public void processCommand(final ICommandSender icommandsender,final String[] astring) { final File f = new File(minecraft.getminecraft().mcDataDir,"extrautilities_localization.txt"); final Map<String,Properties> k = (Map<String,Properties>)ReflectionHelper.getPrivateValue((Class)LanguageRegistry.class,(Object)LanguageRegistry.instance(),new String[] { "modLanguageData" }); final String lang = FMLCommonHandler.instance().getCurrentLanguage(); final Properties p = k.get(lang); String t = ""; for (final Map.Entry<Object,Object> entry : p.entrySet()) { t = t + entry.getKey() + "=" + entry.getValue() + "\n"; } try { Files.write((CharSequence)t,f,Charsets.UTF_8); LogHelper.info("Dumped Language data to " + f.getAbsolutePath(),new Object[0]); } catch (Exception exception) { exception.printstacktrace(); } }
@EventHandler public void preInit(FMLPreInitializationEvent event) { FMLCommonHandler.instance().bus().register(this); //Initialise configs,converting mars.conf + asteroids.conf to planets.conf if necessary File oldMarsConf = new File(event.getModConfigurationDirectory(),"galacticraft/mars.conf"); File newPlanetsConf = new File(event.getModConfigurationDirectory(),"galacticraft/planets.conf"); boolean update = false; if (oldMarsConf.exists()) { oldMarsConf.renameto(newPlanetsConf); update = true; } new ConfigManagerMars(newPlanetsConf,update); new ConfigManagerAsteroids(new File(event.getModConfigurationDirectory(),"galacticraft/asteroids.conf")); galacticraftPlanets.commonModules.put(galacticraftPlanets.MODULE_KEY_MARS,new MarsModule()); galacticraftPlanets.commonModules.put(galacticraftPlanets.MODULE_KEY_ASTEROIDS,new AsteroidsModule()); galacticraftPlanets.proxy.preInit(event); }
@SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent event) { minecraftServer server = FMLCommonHandler.instance().getminecraftServerInstance(); //Prevent issues when clients switch to LAN servers if (server == null) return; if (event.phase == TickEvent.Phase.START) { if (AsteroidsTickHandlerServer.spaceRaceData == null) { World world = server.worldServerForDimension(0); AsteroidsTickHandlerServer.spaceRaceData = (ShortRangeTelepadHandler) world.mapStorage.loadData(ShortRangeTelepadHandler.class,ShortRangeTelepadHandler.saveDataID); if (AsteroidsTickHandlerServer.spaceRaceData == null) { AsteroidsTickHandlerServer.spaceRaceData = new ShortRangeTelepadHandler(ShortRangeTelepadHandler.saveDataID); world.mapStorage.setData(ShortRangeTelepadHandler.saveDataID,AsteroidsTickHandlerServer.spaceRaceData); } } } }
@Override protected void channelRead0(ChannelHandlerContext ctx,IPacket msg) throws Exception { INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); EntityPlayer player = galacticraftCore.proxy.getPlayerFromNetHandler(netHandler); switch (FMLCommonHandler.instance().getEffectiveSide()) { case CLIENT: msg.handleClientSide(player); break; case SERVER: msg.handleServerSide(player); break; default: break; } }
@Override protected void channelRead0(ChannelHandlerContext ctx,IPacket msg) throws Exception { INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); EntityPlayer player = VivecraftForge.proxy.getPlayerFromNetHandler(netHandler); switch (FMLCommonHandler.instance().getEffectiveSide()) { case CLIENT: msg.handleClient(player); break; case SERVER: msg.handleServer(player); break; default: VivecraftForgeLog.severe("Impossible scenario encountered! Effective side is neither server nor client!"); break; } }
@Override public void init(FMLInitializationEvent event) { super.init(event); minecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockCapacitor),new ItemRendererCapacitor()); minecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockdiode),new ItemRendererdiode()); minecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockResistor),new ItemRendererResistor()); minecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockSwitch),new ItemRendererSwitch()); minecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockInvisTess),new ItemRendererInvisTess()); //minecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockRFMeter),new ItemRendererRFMeter()); minecraftForgeClient.registerItemRenderer(RFUContent.itemmaterialTess,new ItemRendererMaterialTess()); //minecraftForgeClient.registerItemRenderer(RFUContent.itemmaterialdisplay,new ItemRendererMaterialdisplay()); minecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RFUContent.blockTransistor),new ItemRendererTransistor()); FMLCommonHandler.instance().bus().register(new KeyInputHandler()); KeyBindings.init(); }
public static String channelName(Object channelKey) { if (channelKey instanceof String) return (String) channelKey; if (channelKey instanceof ModContainer) { String s = ((ModContainer) channelKey).getModId(); if(s.length() > 20) throw new IllegalArgumentException("Mod ID ("+s+") too long for use as channel (20 chars). Use a string identifier"); return s; } ModContainer mc = FMLCommonHandler.instance().findContainerFor(channelKey); if (mc != null) return mc.getModId(); throw new IllegalArgumentException("Invalid channel: " + channelKey); }
@SuppressWarnings("deprecation") @Override public void run() { if(FMLCommonHandler.instance().findContainerFor("NotEnoughItems").getVersion().contains("$")) return;//don't run this thread in a source environment while (thread.isAlive()) { synchronized (this) { if (operation != null && System.currentTimeMillis() - opTime > limit) thread.stop(new TimeoutException("Operation took too long",operation)); } try { Thread.sleep(50); } catch (InterruptedException ie) {} } }
public void load() { super.load(); ClientPlayerAPI.register("Magic Crusade",ClientPlayerBaseMagic.class); RenderRegistry.load(); FMLCommonHandler.instance().bus().register(new KeyInputHandler()); KeyBindings.load(); GuiIngameOverlay events = new GuiIngameOverlay(minecraft); FMLCommonHandler.instance().bus().register(events); minecraftForge.EVENT_BUS.register(events); SoundEventM soundHandler = new SoundEventM(); FMLCommonHandler.instance().bus().register(soundHandler); minecraftForge.EVENT_BUS.register(soundHandler); }
@EventHandler public void preInit(FMLPreInitializationEvent event) { blockTile = new BlockTile(Material.rock).setBlockName("BlockTile").setBlockTextureName("fnafmod:tile_floor").setCreativeTab(tabFNAF); blockMultiTile = new BlockMultiTile(Material.rock).setBlockName("BlockMultiTile").setBlockTextureName("fnafmod:multi_tiled_floor").setCreativeTab(tabFNAF); GameRegistry.registerBlock(blockTile,blockTile.getUnlocalizedname().substring(5)); GameRegistry.registerBlock(blockMultiTile,blockMultiTile.getUnlocalizedname().substring(5)); System.out.println(blockTile.getUnlocalizedname().substring(5)); System.out.println(blockMultiTile.getUnlocalizedname().substring(5)); FMLCommonHandler.instance().bus().register(FNAFMod.instance); FNAF_Blocks.register(); FNAFEntities.registerEntity(); proxy.registerRenderers(); proxy.preInit(); }
public static WorldProvider createProviderFor(int dim) { try { if (dimensions.containsKey(dim)) { WorldProvider provider = providers.get(getProviderType(dim)).newInstance(); provider.setDimension(dim); return provider; } else { throw new RuntimeException(String.format("No WorldProvider bound for dimension %d",dim)); //It's going to crash anyway at this point. Might as well be informative } } catch (Exception e) { FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR,String.format("An error occured trying to create an instance of WorldProvider %d (%s)",dim,providers.get(getProviderType(dim)).getSimpleName()),e); throw new RuntimeException(e); } }
@EventHandler public void initialize(FMLInitializationEvent event) { TerraFirmaCraft.PACKET_PIPELINE.registerPacket(InitClientWorldPacket.class); FMLCommonHandler.instance().bus().register(new PlayerTracker()); minecraftForge.EVENT_BUS.register(new ChunkEventHandler()); minecraftForge.EVENT_BUS.register(new PlayerInteractionHandler()); minecraftForge.EVENT_BUS.register(new AnvilCraftingHandler()); if (Loader.isModLoaded("mineTweaker3")) { mineTweakerAPI.registerClass(ItemHeat.class); mineTweakerAPI.registerClass(Loom.class); mineTweakerAPI.registerClass(Quern.class); mineTweakerAPI.registerClass(Barrel.class); mineTweakerAPI.registerClass(Anvil.class); mineTweakerAPI.registerClass(Knapping.class); } }
@Override public void onUpdate() { if (ticksExisted == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) Packetdispatcher.packetsys.sendToAll(new EntityDebrisPacket(this)); prevPosX = posX; prevPosY = posY; prevPosZ = posZ; ++ticksExisted; motionY -= 0.04; motionX *= 0.98; motionY *= 0.98; motionZ *= 0.98; posX += motionX; posY += motionY; posZ += motionZ; if (!worldobj.isRemote && worldobj.getBlock(MathHelper.floor_double(posX),MathHelper.floor_double(posY),MathHelper.floor_double(posZ)).isOpaqueCube()) die(prevPosX,prevPosY,prevPosZ); }
@Override public void onUpdate(ItemStack item,World world,Entity entity,int par4,boolean par5) { if (item.getTagCompound() == null) item.stackTagCompound = new NBTTagCompound(); if (!item.getTagCompound().getBoolean("isReady")) { item.getTagCompound().setBoolean("isReady",true); item.getTagCompound().setInteger("mode",2); } if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; if (player.inventory.getCurrentItem() != null) { if (player.inventory.getCurrentItem().getItem() == this) { if (world.rand.nextInt(10) == 0 && !player.isInWater()) { RivalRebelsSoundplayer.playSound(player,8,0.03f); } } } } Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.CLIENT) openGui(item,entity); }
/** * 发送服务器数据到统计网页 */ private void postPlugin() throws IOException { // 服务器数据获取 final String pluginname = Uranium.name; final String tmposarch = System.getProperty("os.arch"); final Map<String,Object> data = new HashMap(); data.put("guid",guid); data.put("server_version",Bukkit.getVersion()); data.put("server_port",Bukkit.getServer().getPort()); data.put("server_tps",FMLCommonHandler.instance().getminecraftServerInstance().recentTps[1]); data.put("plugin_version",Uranium.getCurrentVersion()); data.put("players_online",Bukkit.getServer().getonlinePlayers().size()); data.put("os_name",System.getProperty("os.name")); data.put("os_arch",tmposarch.equalsIgnoreCase("amd64") ? "x86_64" : tmposarch); data.put("os_version",System.getProperty("os.version")); data.put("os_usemem",(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024); data.put("os_cores",Runtime.getRuntime().availableProcessors()); data.put("auth_mode",Bukkit.getServer().getonlineMode() ? 1 : 0); data.put("java_version",System.getProperty("java.version")); final String jsondata = "Info=" + JSONValue.toJSONString(data); final String url = String.format("http://api.yumc.pw/I/P/S/V/%s/P/%s",REVISION,URLEncoder.encode(pluginname,"UTF-8")); print("Plugin: " + pluginname + " Send Data To CityCraft Data Center"); print("Address: " + url); print("Data: " + jsondata); // 发送数据 final JSONObject result = (JSONObject) JSONValue.parse(postData(url,jsondata)); print("Plugin: " + pluginname + " Recover Data From CityCraft Data Center: " + result.get("info")); }
@Override public IMessage onMessage(final PacketSyncTileEntityServer packet,final MessageContext ctx) { // THIS IS ON SERVER new Thread() { @Override public void run() { EntityPlayerMP p = ctx.getServerHandler().playerEntity; World w = FMLCommonHandler.instance().getminecraftServerInstance().worldServers[packet.dimensionID]; LobbyTileEntity te = (LobbyTileEntity) w.getTileEntity(packet.x,packet.y,packet.z); if (te != null) { te.players = packet.players; te.lobbyHost = packet.lobbyHost; te.isGameLive = packet.isGameLive; te.check(); } w = p.worldobj; te = (LobbyTileEntity) w.getTileEntity(packet.x,packet.z); te.check(); PAYDAY.INSTANCE.sendToAll(new PacketSyncTileEntityClient(te)); // PAYDAY.INSTANCE.sendToServer(new // LobbyPlayerOpenedGuiPacket(packet.x,// packet.z));//new PacketSyncTileEntityClient(te)); } }.start(); return null; }
@Mod.EventHandler public void preInit(FMLPreInitializationEvent e) { if (!CreeperHost.instance.active) return; minecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(this); logger = e.getModLog(); }
public File getSaveFolder() { minecraftServer server = FMLCommonHandler.instance().getminecraftServerInstance(); if (server != null && !server.isSinglePlayer()) return server.getFile(""); return DimensionManager.getCurrentSaveRootDirectory(); }
public static void syncConfig() { FMLCommonHandler.instance().bus().register(KorTech.instance); final String RECIPIES = KorTech.config.CATEGORY_GENERAL + KorTech.config.CATEGORY_SPLITTER + "Recipies"; KorTech.config.addCustomCategoryComment(RECIPIES,"Enable/disable recipes"); cheapRecipe = KorTech.config.get(RECIPIES,CHEAPRECIPE_NAME,CHEAPRECIPE_DEFAULT).getBoolean(CHEAPRECIPE_DEFAULT); if(KorTech.config.hasChanged()) { KorTech.config.save(); } }
@Override public void registerEventHandlers() { super.registerEventHandlers(); ClientEventHandler eventhandler = new ClientEventHandler(); FMLCommonHandler.instance().bus().register(eventhandler); minecraftForge.EVENT_BUS.register(eventhandler); }
@EventHandler public void initialize(FMLInitializationEvent e) { // Register packets in the TFC PacketPipeline TerraFirmaCraft.PACKET_PIPELINE.registerPacket(InitClientWorldPacket.class); // Register the player tracker FMLCommonHandler.instance().bus().register(new ModplayerTracker()); // Register the tool classes proxy.registerToolClasses(); // Register Crafting Handler FMLCommonHandler.instance().bus().register(new CraftingHandler()); // Register the Chunk Load/Save Handler minecraftForge.EVENT_BUS.register(new ChunkEventHandler()); // Register all the render stuff for the client proxy.registerRenderinformation(); FluidList.registerFluidContainers(); ModRecipes.initialise(); // Register WAILA classes proxy.registerWailaClasses(); proxy.hideNEIItems(); }
@Mod.EventHandler public void init(FMLInitializationEvent event) { proxy.registerNetworkStuff(); NetworkRegistry.INSTANCE.registerGuiHandler(this,new TechnicalGuiHandler()); TechnicalItem.removeVanillaRecipes(); Recipes.init(); FMLCommonHandler.instance().bus().register(new EventListener()); radioactivityPotion = (new PotionTechnical(radioactivityPotionId,0)).setIconIndex(0,0).setpotionName("potion.radioactivityPotion"); TechnicalAchievement.init(); AchievementPage.registerachievementPage(technicalAchievementPage); }
@EventHandler public void init(FMLInitializationEvent event) { long time = System.nanoTime(); ContentRegistry.init(); FMLCommonHandler.instance().bus().register(this); NetworkRegistry.INSTANCE.registerGuiHandler(OpenSensors.instance,new GUIHandler()); logger.info("Finished init in %d ms",(System.nanoTime() - time) / 1000000); }
@Override public void init(FMLInitializationEvent event) { minecraftForge.EVENT_BUS.register(ThaumOresMod.events); FMLCommonHandler.instance().bus().register(ThaumOresMod.events); if (TOConfig.generalangryPigs) ReactionUtils.addBlockToPigangryList(TOBlocks.netherrackInfusedOre,OreDictionary.WILDCARD_VALUE); }
@Override public void registerEventHandler() { minecraftForge.EVENT_BUS.register((Object)new EventHandlerClient()); FMLCommonHandler.instance().bus().register((Object)new EventHandlerClient()); ((IReloadableResourceManager)minecraft.getminecraft().getResourceManager()).registerReloadListener((IResourceManagerReloadListener)new LiquidColorRegistry()); ((IReloadableResourceManager)minecraft.getminecraft().getResourceManager()).registerReloadListener((IResourceManagerReloadListener)new ParticleHelperClient()); ExtraUtils.handlesClientMethods = true; if (Loader.isModLoaded("ForgeMultipart")) { RenderBlockConnectedTextures.fakeRender = new FakeRenderBlocksMultiPart(); } ClientCommandHandler.instance.registerCommand((ICommand)new CommandHologram()); ClientCommandHandler.instance.registerCommand((ICommand)new CommandUUID()); KeyHandler.INSTANCE.register(); super.registerEventHandler(); }
@Override public boolean isAltSneaking() { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { return KeyHandler.getIsKeypressed(minecraft.getminecraft().gameSettings.keyBindSprint); } return super.isAltSneaking(); }
@Override protected void channelRead0(final ChannelHandlerContext ctx,final XUPacketBase msg) throws Exception { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { msg.doStuffServer(ctx); } else { msg.doStuffClient(); } }
@Override public String getUnlocalizedname(final ItemStack par1ItemStack) { if (par1ItemStack.getItemdamage() == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { final StackTraceElement[] stackTrace = new Throwable().getStackTrace(); if ("net.minecraft.item.Item".equals(stackTrace[1].getClassName())) { final long curTime = System.currentTimeMillis(); if (curTime - ItemBlockQED.prevTime > 1000L || ItemBlockQED.curRand == -1) { ItemBlockQED.curRand = ItemBlockQED.rand.nextInt(17); } ItemBlockQED.prevTime = curTime; return "tile.extrautils:qed.rand." + ItemBlockQED.curRand; } } return super.getUnlocalizedname(par1ItemStack); }
/** Starts this task by registering the tick handler */ public void start() { if (INSTANCE != this) throw new IllegalStateException("Cannot start a stopped task"); FMLCommonHandler.instance().bus().register(this); }
@EventHandler public void init( FMLInitializationEvent event ) { FMLCommonHandler.instance().bus().register( AdminlogonErrors ); FMLCommonHandler.instance().bus().register( LootGroupHandler ); minecraftForge.EVENT_BUS.register( LootGroupHandler ); NetworkRegistry.INSTANCE.registerGuiHandler( this,new GuiHandler() ); }
public static Boolean isServer() { Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.SERVER) return true; else if (side == Side.CLIENT) return false; else rmlog.warn("Server returned no side!"); return null; }
public static void initiate() { if(!loaderRegistered) { loaderRegistered = true; minecraftForge.EVENT_BUS.register(new NetworkLoader()); FMLCommonHandler.instance().bus().register(INSTANCE); } }
cpw.mods.fml.common.FMLContainer的实例源码
public static void registerChannel(FMLContainer container,Side side) { channelPair = NetworkRegistry.INSTANCE.newChannel(container,"FML",new FMLRuntimeCodec(),new HandshakeCompletionHandler()); EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NowHERE); if (side == Side.CLIENT) { addClientHandlers(); } }
public static void registerChannel(FMLContainer container,new HandshakeCompletionHandler()); EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NowHERE); if (side == Side.CLIENT) { addClientHandlers(); } }
public static void registerChannel(FMLContainer container,new HandshakeCompletionHandler()); EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NowHERE); if (side == Side.CLIENT) { addClientHandlers(); } }
关于cpw.mods.fml.common.network.ByteBufUtils的实例源码和fwknop 源码解析的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于cpw.mods.fml.common.DummyModContainer的实例源码、cpw.mods.fml.common.event.FMLInterModComms的实例源码、cpw.mods.fml.common.FMLCommonHandler的实例源码、cpw.mods.fml.common.FMLContainer的实例源码的相关信息,请在本站寻找。
本文标签: