@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { StabilityHandler.addChunkData(world.provider.getDimension(), new ChunkPos(chunkX, chunkZ), StabilityHandler.generateChunkStability(random)); if (world.provider.getDimensionType() == DimensionType.OVERWORLD) { WorldGenMinable lodestone = new WorldGenMinable(RegistryManager.lodestone_ore.getDefaultState(), Config.LODESTONE_VEIN_SIZE); for (int i = 0; i < Config.LODESTONE_FREQUENCY; i++) { int x = chunkX * 16 + random.nextInt(16); int y = random.nextInt(Config.LODESTONE_MAX_Y - Config.LODESTONE_MIN_Y) + Config.LODESTONE_MIN_Y; int z = chunkZ * 16 + random.nextInt(16); lodestone.generate(world, random, new BlockPos(x, y, z)); } BlockPos pos = new BlockPos(chunkX * 16, 0, chunkZ * 16); WorldGenRift rift = new WorldGenRift(); rift.generate(world, random, pos); } }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onWitherBoneHarvestEvent(BlockEvent.HarvestDropsEvent event) { if (event.getHarvester() == null) { return; } EntityPlayer player = event.getHarvester(); ItemStack stack = player.getHeldItemMainhand(); boolean flag = false; if (stack.getItem() instanceof IHaftTool) { if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) { flag = true; } } if (flag) { if (player.dimension != DimensionType.NETHER.getId()) { stack.damageItem(7, player); } } }
@SubscribeEvent public void onWitherBoneAttackEvent(AttackEntityEvent event) { EntityPlayer player = event.getEntityPlayer(); ItemStack stack = player.getHeldItemMainhand(); boolean flag = false; if (stack.getItem() instanceof IHaftTool) { if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) { flag = true; } } if (flag) { if (player.dimension != DimensionType.NETHER.getId()) { stack.damageItem(7, player); } } }
public static Vec3d getWorldFogColor(Vec3d p_getWorldFogColor_0_, World p_getWorldFogColor_1_, Entity p_getWorldFogColor_2_, float p_getWorldFogColor_3_) { DimensionType dimensiontype = p_getWorldFogColor_1_.provider.getDimensionType(); switch (dimensiontype) { case NETHER: p_getWorldFogColor_0_ = getFogColorNether(p_getWorldFogColor_0_); break; case OVERWORLD: Minecraft minecraft = Minecraft.getMinecraft(); p_getWorldFogColor_0_ = getFogColor(p_getWorldFogColor_0_, minecraft.world, p_getWorldFogColor_2_.posX, p_getWorldFogColor_2_.posY + 1.0D, p_getWorldFogColor_2_.posZ); break; case THE_END: p_getWorldFogColor_0_ = getFogColorEnd(p_getWorldFogColor_0_); } return p_getWorldFogColor_0_; }
public static Vec3d getWorldSkyColor(Vec3d p_getWorldSkyColor_0_, World p_getWorldSkyColor_1_, Entity p_getWorldSkyColor_2_, float p_getWorldSkyColor_3_) { DimensionType dimensiontype = p_getWorldSkyColor_1_.provider.getDimensionType(); switch (dimensiontype) { case OVERWORLD: Minecraft minecraft = Minecraft.getMinecraft(); p_getWorldSkyColor_0_ = getSkyColor(p_getWorldSkyColor_0_, minecraft.world, p_getWorldSkyColor_2_.posX, p_getWorldSkyColor_2_.posY + 1.0D, p_getWorldSkyColor_2_.posZ); break; case THE_END: p_getWorldSkyColor_0_ = getSkyColorEnd(p_getWorldSkyColor_0_); } return p_getWorldSkyColor_0_; }
public static final String getDimensionName(UUID requestID, int dimension){ if(FMLCommonHandler.instance().getSide() == Side.SERVER){ try{ DimensionType type = DimensionManager.getProviderType(dimension); return type.getName(); } catch(Exception e){} } else { if(!DIMENSION_NAMES.containsKey(dimension)){ CrystalModNetwork.sendToServer(new PacketDimensionNameRequest(requestID, dimension)); } else { return DIMENSION_NAMES.get(dimension); } } return ""+dimension; }
public static void worldLoad(FMLServerStartedEvent serverStartedEvent) throws IOException { File worldFile = new File(FMLCommonHandler.instance().getSavesDirectory(), FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName()); File dataFile = new File(worldFile, fileName); if (!dataFile.exists()) { return; } String json = FileUtils.readFileToString(dataFile); Gson gson = new Gson(); Type typeOfHashMap = new TypeToken<List<DimData>>() { }.getType(); List<DimData> tempDataList = gson.fromJson(json, typeOfHashMap); for (DimData data : tempDataList) { DimensionType type = DimensionType.register("technicaldimensions", data.name, data.id, CustomWorldProvider.class, false); DimensionManager.registerDimension(data.id, type); data.type = type; dimDataHashMap.put(data.id, data); dimDataList.add(data); } }
@Mod.EventHandler public void load(FMLInitializationEvent event) { if (Config.voidNether == true) { wtvn = new WorldTypeVoidNether(); DimensionManager.unregisterDimension(-1); DimensionManager.registerDimension(-1, DimensionType.register("VoidNether", "_nether", -1, WorldProviderVoidNether.class, false)); } if (Config.voidOverworld == true) { wtvo = new WorldTypeVoidOverworld(); DimensionManager.unregisterDimension(0); DimensionManager.registerDimension(0, DimensionType.register("VoidOverworld", "overworld", 0, WorldProviderVoidOverworld.class, false)); } if (Config.voidEnd == true) { wtve = new WorldTypeVoidEnd(); DimensionManager.unregisterDimension(1); DimensionManager.registerDimension(1, DimensionType.register("VoidEnd", "end", 1, WorldProviderVoidEnd.class, false)); } }
@Override public void process(EntityPlayer player, Side side) { if(ResearchDimensions.get(player.world).researchDimIDs.get(this.username) == null) { DimensionType researchDim = DimensionType.register("research" + this.username, "", this.dimID, WorldProviderResearch.class, false); DimensionManager.registerDimension(this.dimID, researchDim); ResearchDimensions.get(player.world).researchDimIDs.put(this.username, this.dimID); ResearchDimensions.get(player.world).researchDimTypes.put(this.dimID, researchDim); }else{ ResearchDimensions.get(player.world).researchDimIDs.put(this.username, this.dimID); ResearchDimensions.get(player.world).researchDimTypes.put(this.dimID, DimensionType.getById(this.dimID)); } }
/** * Determines if a water block was replaced with cobblestone because this structure was built in the nether or the end. * @param configuration The structure configuration. * @param block The build block object. * @param world The workd object. * @param originalPos The original block position this structure was built on. * @param assumedNorth The assumed north direction (typically north). * @param foundBlock The actual block found at the current location. * @param blockState The block state to set for the current block. * @param player The player requesting this build. * @return Returns true if the water block was replaced by cobblestone, otherwise false. */ protected Boolean WaterReplacedWithCobbleStone(StructureConfiguration configuration, BuildBlock block, World world, BlockPos originalPos, EnumFacing assumedNorth, Block foundBlock, IBlockState blockState, EntityPlayer player) { // Replace water blocks with cobblestone. if (foundBlock instanceof BlockLiquid && blockState.getMaterial() == Material.WATER && (world.provider.getDimensionType() == DimensionType.NETHER)) { block.setBlockDomain(Blocks.COBBLESTONE.getRegistryName().getResourceDomain()); block.setBlockName(Blocks.COBBLESTONE.getRegistryName().getResourcePath()); block.setBlockState(Blocks.COBBLESTONE.getDefaultState()); // Add this as a priority 3 block since it should be done at the end. this.priorityThreeBlocks.add(block); return true; } return false; }
private static void registerDimension(int id, DimensionConfigEntry entry) { if (entry.getUnregister() || entry.hasDimensionTypeEntry() == false) { return; } if (DimensionManager.isDimensionRegistered(id)) { DimensionType type = DimensionManager.getProviderType(id); if (type.createDimension().getClass() != entry.getDimensionTypeEntry().getProviderClass()) { JustEnoughDimensions.logInfo("DimensionSyncPacket.registerDimension: Dimension {} already registered, unregistering the old one", id); DimensionManager.unregisterDimension(id); } } if (DimensionManager.isDimensionRegistered(id) == false) { JustEnoughDimensions.logInfo("DimensionSyncPacket.registerDimension: Registering dimension {}", id); DimensionManager.registerDimension(id, entry.getDimensionTypeEntry().registerDimensionType()); } }
public static void init() { //Not really working // if(ConfigHandler.StationOfAwakeningID.equals("auto")) diveToTheHeartID = DimensionManager.getNextFreeDimId(); diveToTheHeart = DimensionType.register("Dive to the Heart", "", diveToTheHeartID, WorldProviderDiveToTheHeart.class, false); DimensionManager.registerDimension(diveToTheHeartID, diveToTheHeart); traverseTownID = DimensionManager.getNextFreeDimId(); traverseTown = DimensionType.register("Traverse Town", "", traverseTownID, WorldProviderTraverseTown.class, false); DimensionManager.registerDimension(traverseTownID, traverseTown); destinyIslandsID = DimensionManager.getNextFreeDimId(); destinyIslands = DimensionType.register("Destiny Islands", "", destinyIslandsID, WorldProviderDestinyIslands.class, false); DimensionManager.registerDimension(destinyIslandsID, destinyIslands); //else //diveToTheHeartID = Integer.parseInt(ConfigHandler.StationOfAwakeningID); }
@Override public void serialize(JsonWriter writer) throws IOException { writer.beginArray(); for(DimensionType dimension : dimensions) { writer.value(dimension.getName()); } writer.endArray(); }
@Override public void deserialize(JsonReader reader) throws IOException { reader.beginArray(); while(reader.hasNext() && reader.peek().equals(JsonToken.STRING)) { String dim = reader.nextString(); for(DimensionType type : DimensionType.values()) if(Objects.equals(type.getName(), dim)) { add(type); break; } } }
@Override public String helpText() { final StringBuilder builder = new StringBuilder("{"); Iterator<DimensionType> it = dimensions.iterator(); while(it.hasNext()) { String name = it.next().getName(); builder.append(name); if(it.hasNext()) builder.append(", "); } builder.append("}"); return builder.toString(); }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (!world.isRemote) { RandoresConfig config = Randores.getConfigObj(); RandoresModules modules = config.getModules(); boolean flag = modules.isDimensionLess(); boolean flag2 = modules.isYoutubeMode(); int ores = config.getMaxOres(); if (RandoresWorldData.hasData(world)) { RandoresWorldData data = RandoresWorldData.getSimply(world); for (OreType oreType : OreTypeRegistry.instance().values()) { if (flag || oreType.getIsDimension().apply(world)) { List<MaterialDefinition> target = data.shuffleAndGetDimensionCache(oreType, random); if (!target.isEmpty()) { int count = Math.min(ores, target.size()) * (flag2 ? 2 : 1); for (int i = 0; i < count; i++) { MaterialDefinition element = target.get(i); OreComponent component = element.getOre(); this.generateOre(component.getBlock().getDefaultState().withProperty(RandoresOre.HARVEST_LEVEL, component.getHarvestLevel()), element.getData(), world, random, chunkX * 16, chunkZ * 16, component.getVeinSize(), component.getMaxY(), component.getMinY(), component.getMaxOccurrences(), component.getMinOccurrences(), component.getOreType().getGenerateIn()); } } } } } if (flag || DimensionType.OVERWORLD.getId() == world.provider.getDimension()) { this.generateOre(CraftingBlocks.craftiniumOre.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 6, world.getHeight(), 0, 100, 50, new Block[] {Blocks.STONE}); } } }
@Override public DimensionType getDimensionType() { if(m_realProvider != null) { return m_realProvider.getDimensionType(); } else { return null; } }
@Override public DimensionType getDimensionType() { if (m_proxyProvider != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyProvider.getDimensionType(); } else if (m_realProvider != null) { return m_realProvider.getDimensionType(); } else { return null; } }
@Override protected void channelRead0(ChannelHandlerContext ctx, DimensionRegisterMessage msg) throws Exception { if (!DimensionManager.isDimensionRegistered(msg.dimensionId)) { DimensionManager.registerDimension(msg.dimensionId, DimensionType.valueOf(msg.providerId)); } }
/** * Returns a list of dimensions associated with this DimensionType. */ public static int[] getDimensions(DimensionType type) { int[] ret = new int[dimensions.size()]; int x = 0; for (Map.Entry<Integer, DimensionType> ent : dimensions.entrySet()) { if (ent.getValue() == type) { ret[x++] = ent.getKey(); } } return Arrays.copyOf(ret, x); }
public static void init() { if (hasInit) { return; } hasInit = true; registerDimension( 0, DimensionType.OVERWORLD); registerDimension(-1, DimensionType.NETHER); registerDimension( 1, DimensionType.THE_END); }
public static void registerDimension(int id, DimensionType type) { DimensionType.getById(type.getId()); //Check if type is invalid {will throw an error} No clue how it would be invalid tho... if (dimensions.containsKey(id)) { throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, One is already registered", id)); } dimensions.put(id, type); if (id >= 0) { dimensionMap.set(id); } }
public static DimensionType getProviderType(int dim) { if (!dimensions.containsKey(dim)) { throw new IllegalArgumentException(String.format("Could not get provider type for dimension %d, does not exist", dim)); } return dimensions.get(dim); }
@EventHandler public void init(FMLInitializationEvent event) { DimensionManager.registerDimension(DIM, DimensionType.OVERWORLD); //We need to select a random dim id. //We also should look into not doing this but instead adding a config GUI to the TE itself. //And being able to select what dim we wanna move over. //Would be cool to be like 'I want a chunk of the nether in the overworld! // This is where crafting recipes would go IF I HAD ANNY!!! }
@Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv){ super.addInformation(stack, player, list, adv); if(isValid(stack)){ BlockPos pos = getBlockPos(stack); list.add("Panel location {"+pos.getX()+", "+pos.getY()+", "+pos.getZ()+"}"); int dim = ItemNBTHelper.getInteger(stack, "PanelDim", 0); String name = ""+dim; if (!DimensionManager.isDimensionRegistered(dim)) { name = Integer.toString(dim); }else { DimensionType type = DimensionManager.getProviderType(dim); if (type == null) { name = Integer.toString(dim); }else { name = type.getName(); int[] dims = DimensionManager.getDimensions(type); if (dims != null && dims.length > 1) { name += " " + dim; } } } list.add("Panel Dimension: "+name); } }
public static int createDim(DimData dimData) { int dimId = DimensionManager.getNextFreeDimId(); DimensionType type = DimensionType.register("technicaldimensions", dimData.name, dimId, CustomWorldProvider.class, false); dimData.type = type; dimData.id = dimId; Random random = new Random(); dimData.seed = random.nextLong(); DimensionManager.registerDimension(dimId, type); dimDataHashMap.put(dimId, dimData); dimDataList.add(dimData); return dimId; }
@Override public void init() { if (Config.voidBiomeEnd) { this.biomeProvider = new BiomeProviderSingle(Biomes.SKY); } else { this.biomeProvider = new VoidBiomeProvider(world); } if (Config.endDragonEnabled) { NBTTagCompound nbttagcompound = this.world.getWorldInfo().getDimensionData(DimensionType.THE_END.getId()); this.dragonFightManager = this.world instanceof WorldServer ? new DragonFightVoid((WorldServer)this.world, nbttagcompound.getCompoundTag("DragonFight")) : null; } }
@Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { //dimId = DimensionManager.getNextFreeDimId(); dimId = Integer.MIN_VALUE + (int)(3.14159 * 1337); DimensionManager.registerDimension(dimId, DimensionType.register("pp_fake", "", dimId, WorldProviderSurface.class, false)); fakeServer = new FakeServer(Minecraft.getMinecraft(), "saves", "pp_fake", new WorldSettings(new WorldInfo(new NBTTagCompound())), null, null, null, null); }
@Mod.EventHandler public void serverStarted(FMLServerStartedEvent e) { World world = DimensionManager.getWorld(DimensionType.OVERWORLD.getId()); SavedData data = SavedData.get(world); ChunkLoaders chunkLoadersModel = data.getChunkLoaders(); for (ChunkLoaderPos chunkLoaderPos : chunkLoadersModel.getLoaders()) { world = DimensionManager.getWorld(chunkLoaderPos.dimension); if (world != null && !world.isRemote) { ChunkLoaderTileEntity chunkLoader = (ChunkLoaderTileEntity) world.getTileEntity(chunkLoaderPos.pos); if (chunkLoader != null && chunkLoader.getEnabled()) { chunkLoader.setWorld(world); chunkLoader.validate(); //FMLLog.log(Level.INFO, "The chunk at " + chunkLoaderPos + " has been loaded."); } else { chunkLoadersModel.removeLoader(chunkLoaderPos); } } } }
@Nullable public static DimensionType findDimensionType(Class<?> provider) { for (DimensionType type : DimensionType.values()) if (Tool.isSubclass(type.clazz, provider)) return type; return null; }
@Nullable public static DimensionType findDimensionType(String name) { for (DimensionType type : DimensionType.values()) if (type.getName().equals(name)) return type; return null; }
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack itemStackIn = playerIn.getHeldItem(hand); if (!worldIn.isRemote) { if (!ConfigurationHandler.dimension_Lock) { if (!isLocked) { Util.openGUI(playerIn,worldIn,EnumIDs.GUI_ENDER_BAG,isLocked); return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); } else { return new ActionResult<>(EnumActionResult.FAIL, itemStackIn); } } else { if(playerIn.dimension == DimensionType.OVERWORLD.getId()) { if (!isLocked) { Util.openGUI(playerIn,worldIn,EnumIDs.GUI_ENDER_BAG,isLocked); return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); } else { return new ActionResult<>(EnumActionResult.FAIL, itemStackIn); } } else { return new ActionResult<>(EnumActionResult.FAIL, itemStackIn); } } } return new ActionResult<>(EnumActionResult.PASS, itemStackIn); }
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack itemStackIn = playerIn.getHeldItem(hand); if(!worldIn.isRemote) { if(!ConfigurationHandler.dimension_Lock) { if (!isLocked) { Util.openGUI(playerIn,worldIn, EnumIDs.GUI_ENDER_BACKPACK,isLocked); return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); } }else { if(playerIn.dimension == DimensionType.OVERWORLD.getId()) { if (!isLocked) { Util.openGUI(playerIn,worldIn,EnumIDs.GUI_ENDER_BACKPACK,isLocked); return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); } } else { } } } return new ActionResult<>(EnumActionResult.PASS, itemStackIn); }
@Override public DimensionType getDimensionType() { DimensionType type = null; try { type = DimensionManager.getProviderType(this.getDimension()); } catch (IllegalArgumentException e) { } return type != null ? type : DimensionType.OVERWORLD; }
@Nonnull public static BlockPos findSuitableSpawnpoint(World world) { WorldProvider provider = world.provider; BlockPos pos; // Likely end type dimensions if (provider.getDimensionType() == DimensionType.THE_END || provider instanceof WorldProviderEnd) { pos = provider.getSpawnCoordinate(); if (pos == null) { pos = getSuitableSpawnBlockInColumn(world, BlockPos.ORIGIN); } } // Likely nether type dimensions else if (provider.getDimensionType() == DimensionType.NETHER || provider instanceof WorldProviderHell || provider instanceof WorldProviderHellJED) { pos = findNetherSpawnpoint(world); } else if (world.getWorldInfo().getTerrainType() == WorldType.DEBUG_ALL_BLOCK_STATES) { pos = BlockPos.ORIGIN.up(64); } // Mostly overworld type dimensions else { pos = findOverworldSpawnpoint(world); } return pos; }
@Override public DimensionType getDimensionType() { DimensionType type = null; try { type = DimensionManager.getProviderType(this.getDimension()); } catch (IllegalArgumentException e) { } return type != null ? type : super.getDimensionType(); }
private DimensionType getVanillaDimensionType(int dim) { switch (dim) { case 1: return DimensionType.THE_END; case -1: return DimensionType.NETHER; default: return DimensionType.OVERWORLD; } }
public DimensionType registerDimensionType() { if (this.dimensionTypeName != null) { DimensionType type = null; try { type = DimensionType.valueOf(this.dimensionTypeName); JustEnoughDimensions.logInfo("Using a vanilla DimensionType (or some other existing one) '{}' for dim {}", type, this.id); } catch (Exception e) { } if (type == null) { type = DimensionType.OVERWORLD; JustEnoughDimensions.logger.warn("Failed to get a DimensionType by the name '{}' for dim {}, falling back to DimensionType.OVERWORLD", this.dimensionTypeName, this.id); } return type; } else { JustEnoughDimensions.logInfo("Registering a DimensionType with values: {}", this.getDescription()); return DimensionType.register(this.name, this.suffix, this.id, this.providerClass, this.keepLoaded); } }
@Override public void update() { if (menuMusic()); else if (dimensionMusic(DimensionType.OVERWORLD.getId(), MusicType.OVERWORLD, mc.player)); else if (dimensionMusic(DimensionType.NETHER.getId(), MusicType.NETHER, mc.player)); else if (dimensionMusic(DimensionType.THE_END.getId(), MusicType.END, mc.player)); else if (dimensionMusic(ModDimensions.diveToTheHeartID, MusicType.SOA, mc.player)); else if (dimensionMusic(ModDimensions.destinyIslandsID, MusicType.DESTINYISLANDS, mc.player)); else if (dimensionMusic(ModDimensions.traverseTownID, MusicType.TRAVERSETOWN, mc.player)); else stopMusic(); }
@SideOnly(Side.CLIENT) @Override public void addInformation (ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) { if(Minecraft.getMinecraft().player != null) tooltip.add("You are in: "+DimensionType.getById(Minecraft.getMinecraft().player.dimension)); super.addInformation(stack, world, tooltip, flag); }