@SubscribeEvent public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event ) { if( AEConfig.instance() .isFeatureEnabled( AEFeature.SPATIAL_IO ) && event.getObject() == DimensionManager.getWorld( AEConfig.instance().getStorageDimensionID() ) ) { event.addCapability( new ResourceLocation( "appliedenergistics2:spatial_dimension_manager" ), new SpatialDimensionManager( event.getObject() ) ); } }
/** * Requires to start up from external from here * * drawback of the singleton build style * * @param server */ public static void onServerAboutToStart( MinecraftServer server ) { File worldDirectory = DimensionManager.getCurrentSaveRootDirectory(); if( worldDirectory == null ) { worldDirectory = server.getActiveAnvilConverter().getSaveLoader( server.getFolderName(), false ).getWorldDirectory(); } final WorldData newInstance = new WorldData( worldDirectory ); instance = newInstance; newInstance.onServerStarting(); }
/** * Register dimensions. */ public static final void registerDimensions() { DimensionManager.registerDimension(CLOUD_DIM_ID, CLOUD_DIM_TYPE); }
@Override public ISpatialDimension getSpatialDimension() { final int id = AppEng.instance().getStorageDimensionID(); World w = DimensionManager.getWorld( id ); if( w == null ) { DimensionManager.initDimension( id ); w = DimensionManager.getWorld( id ); } if( w != null && w.hasCapability( Capabilities.SPATIAL_DIMENSION, null ) ) { return w.getCapability( Capabilities.SPATIAL_DIMENSION, null ); } return null; }
config.setStorageDimensionID( DimensionManager.getNextFreeDimId() ); config.save(); DimensionManager.registerDimension( this.storageDimensionID, this.storageDimensionType );
public static @Nonnull String getDimenionName(int dim) { if (!DimensionManager.isDimensionRegistered(dim)) { return Integer.toString(dim); } DimensionType type = DimensionManager.getProviderType(dim); if (type == null) { return Integer.toString(dim); } String name = type.getName(); int[] dims = DimensionManager.getDimensions(type); if (dims != null && dims.length > 1) { name += " " + dim; } return name; }
public static void connectToPipe(ItemStack stack, PipeItemsRemoteOrdererLogistics pipe) { stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setInteger("connectedPipe-x", pipe.getX()); stack.getTagCompound().setInteger("connectedPipe-y", pipe.getY()); stack.getTagCompound().setInteger("connectedPipe-z", pipe.getZ()); int dimension = 0; for (Integer dim : DimensionManager.getIDs()) { if (pipe.getWorld().equals(DimensionManager.getWorld(dim.intValue()))) { dimension = dim.intValue(); break; } } stack.getTagCompound().setInteger("connectedPipe-world-dim", dimension); }
@Nullable private static Integer findFreeDimensionID() { for (int i=2; i<Integer.MAX_VALUE; i++) { if (!DimensionManager.isDimensionRegistered(i)) { // DEBUG System.out.println("Found free dimension ID = "+i); return i; } } // DEBUG System.out.println("ERROR: Could not find free dimension ID"); return null; }
public static void preInit() { DimensionType seasons = DimensionType.register("seasons", "seasons", OVERWORLD_ID, HFWorldProvider.class, true); DimensionManager.unregisterDimension(0); DimensionManager.registerDimension(0, seasons); HFApi.calendar.registerSeasonProvider(1, HIDDEN); HFApi.calendar.registerSeasonProvider(-1, HIDDEN); }
public StructureWatcherGeneric(String datFileName, int dimension, MarkerType marker, String label) { this(datFileName, DimensionManager.getProviderType(dimension), marker, label); }
@Nullable public World getWorld(MinecraftServer server) { World world = this.world.get(); if (world == null && DimensionManager.isDimensionRegistered(dimension)) { this.world = new WeakReference<>(world = server.getWorld(dimension)); } return world; }
@Nonnull @Override public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (!config.getConfig(Constants.Compat.WAILA_CONFIG_TELEPOSER)) return currenttip; if (accessor.getNBTData().hasKey("focus")) { NBTTagCompound focusData = accessor.getNBTData().getCompoundTag("focus"); BlockPos boundPos = NBTUtil.getPosFromTag(focusData.getCompoundTag("pos")); int boundDim = focusData.getInteger("dim"); String dimName = WordUtils.capitalizeFully(DimensionManager.getProviderType(boundDim).getName().replace("_", " ")); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.bound", dimName, boundPos.getX(), boundPos.getY(), boundPos.getZ())); } return currenttip; }
@Override public World getServerWorld(int id) { return DimensionManager.getWorld(id); }
public static File getLPFolder() { return new File(DimensionManager.getCurrentSaveRootDirectory(), "LogisticsPipes"); }
private static void registerDimensions() { DimensionManager.registerDimension(Config.dimensionId, testDimensionType); }
@Nullable public ForgeChunkManager.Ticket requestTicket(MinecraftServer server, TicketKey key) { ForgeChunkManager.Ticket ticket = ticketMap.get(key); if (ticket == null && DimensionManager.isDimensionRegistered(key.dimension)) { WorldServer worldServer = server.getWorld(key.dimension); ticket = ForgeChunkManager.requestTicket(FTBUtilities.INST, worldServer, ForgeChunkManager.Type.NORMAL); if (ticket != null) { ticketMap.put(key, ticket); ticket.getModData().setString("Team", key.teamId); } } return ticket; }
@Override public World getServerWorld(int id) { return DimensionManager.getWorld(id); }
protected @Nonnull File getSaveFile() { return new File(DimensionManager.getCurrentSaveRootDirectory(), ident + ".json"); }
public static void init() { worldType = new LostWorldType(); if (LostCities.biomesoplenty) { worldTypeBOP = new LostWorldTypeBOP(); } for (String worldtype : LostCityConfiguration.ADAPTING_WORLDTYPES) { worldTypeAdapterList.add(new LostWorldTypeAdapter(worldtype)); } if (LostCityConfiguration.DIMENSION_ID != -1) { lostDimensionType = DimensionType.register(LostCities.MODID, "_lost", LostCityConfiguration.DIMENSION_ID, LostWorldProvider.class, false); DimensionManager.registerDimension(LostCityConfiguration.DIMENSION_ID, lostDimensionType); dimensionProfileMap.put(LostCityConfiguration.DIMENSION_ID, LostCityConfiguration.DIMENSION_PROFILE); } for (String dimInfo : LostCityConfiguration.ADDITIONAL_DIMENSIONS) { String[] split = StringUtils.split(dimInfo, ':'); int id = Integer.parseInt(split[0]); String profile = split[1]; if (lostDimensionType == null) { lostDimensionType = DimensionType.register(LostCities.MODID, "_lost", id, LostWorldProvider.class, false); } DimensionManager.registerDimension(id, lostDimensionType); dimensionProfileMap.put(id, profile); } MapGenStructureIO.registerStructure(LostWoodlandMansion.Start.class, "LostMansion"); }
@Override public void fromNBT(NBTTagCompound tag) { NBTTagList list = tag.getTagList("list", MinecraftHelpers.NBTTag_Types.NBTTagCompound.ordinal()); for(int i = 0; i < list.tagCount(); i++) { NBTTagCompound elementTag = list.getCompoundTagAt(i); int dimensionId = elementTag.getInteger("dimension"); BlockPos pos = BlockPos.fromLong(elementTag.getLong("pos")); EnumFacing side = null; if (elementTag.hasKey("side", Constants.NBT.TAG_INT)) { side = EnumFacing.VALUES[elementTag.getInteger("side")]; } if(!net.minecraftforge.common.DimensionManager.isDimensionRegistered(dimensionId)) { IntegratedDynamics.clog(Level.WARN, String.format("Skipped loading part from a network at the " + "invalid dimension id %s.", dimensionId)); } else { World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dimensionId); IPathElement pathElement = TileHelpers.getCapability(world, pos, side, PathElementConfig.CAPABILITY); if(pathElement == null) { IntegratedDynamics.clog(Level.WARN, String.format("Skipped loading part from a network at " + "position %s in world %s because it has no valid path element.", pos, dimensionId)); } else { elements.add(SidedPathElement.of(pathElement, side)); } } } } }