Jump to content

Rurido

Members
  • Posts

    23
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    rurido.de
  • Location
    Germany
  • Personal Text
    null != 0 null !<0 null !> 0 BUT null <= 0 null >= 0 Number(null) == 0 (JavaScript)

Rurido's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Is there a way to check if a dimension is already unloaded? (if the dimension should be deleted before it was loaded e.g. when no player joined the world yet) EDIT: nvm, I found a way: for(Integer i : DimensionManager.getIDs()){ if(id == i){ //Dimension is loaded. return false; //queued } } //Dimension is not loaded //continue
  2. I see... if(w == null || !ForgeChunkManager.getPersistentChunksFor(w).isEmpty() || !w.playerEntities.isEmpty() || dimension.type.shouldLoadSpawn()){ FMLLog.log.debug("Aborting unload for dimension {} as status changed", id); continue; } Well, i can teleport all players out of this dimension so that this list would be empty. I also found ForgeChunkManager.unloadWorld(World world) which removes its persistent chunks (forcedChunks.remove(world);) so that public static ImmutableSetMultimap<ChunkPos, Ticket> getPersistentChunksFor(World world){ return forcedChunks.containsKey(world) ? forcedChunks.get(world) : ImmutableSetMultimap.<ChunkPos,Ticket>of(); } would return an empty set. The spawn is not marked as "keep loaded" by my DimensionType. At last i would steal some code from DimensionManager.unloadWorlds(...); to get WorldServer w = worlds.get(id); MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w)); w.flush(); setWorld(id, null, w.getMinecraftServer()); which should unload it immediately if i got things right. But isn't there a more elegant way or do I have to to all steps by myself?
  3. Do I have to use the event (I found WorldEvent.Unload) or can i force te dimension to unload immediately?
  4. I never wanted to remove a DimensionType. I want to remove a Dimension (by its id)!
  5. If the comment above the function is right, then you are wrong, idk... I give a DimensionType (which can also be identified by its id), and get a list of dimension ids... package net.minecraftforge.common; public class DimensionManager{ /*...*/ /** * 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, Dimension> ent : dimensions.entrySet()){ if (ent.getValue().type == type){ ret[x++] = ent.getKey(); } } return Arrays.copyOf(ret, x); } /*...*/ }
  6. I don't know if my way creating dimensions is right, but I do use one DimensionType for multiple dimensions and all of them work fine: Screenshot: https://rurido.de/temp/mc_dim_list.png (Post was too long) [19:39:12] [Server thread/INFO] [RR55's Server+]: WorldInfo set on dimension 2 [19:39:12] [Server thread/INFO] [FML]: Loading dimension 2 (Test1) (net.minecraft.server.dedicated.DedicatedServer@2f011051) [19:39:15] [Server thread/INFO] [RR55's Server+]: WorldInfo set on dimension 3 [19:39:15] [Server thread/INFO] [FML]: Loading dimension 3 (Test2) (net.minecraft.server.dedicated.DedicatedServer@2f011051) [19:39:18] [Server thread/INFO] [RR55's Server+]: WorldInfo set on dimension 4 [19:39:18] [Server thread/INFO] [FML]: Loading dimension 4 (Test3) (net.minecraft.server.dedicated.DedicatedServer@2f011051) [19:39:20] [Server thread/INFO] [RR55's Server+]: WorldInfo set on dimension 5 [19:39:20] [Server thread/INFO] [FML]: Loading dimension 5 (Test4) (net.minecraft.server.dedicated.DedicatedServer@2f011051) So I would say that a DimensionType can be used for ore than one Dimension, because as I understand it, DimensionTypes don't say "what dimension are you?" but "what kind of dimension are you?". But I can also be wrong
  7. Please clarify what you mean by "this". I am talking about EnumHelper. And you? You said: Well, i never use the EnumHelper directly. It is used by DimensionType.register(...) but I don't want to remove (or add) DimensionTypes - I only do this once for all my custom dimensions which use all the same type: My code: public static DimensionType dimensionType; //<--- I could make it final, because it is only initialized once at FMLServerStartingEvent /*...*/ dimensionType = DimensionType.register("custom", "_custom", 5, CustomWorldProvider.class, false); Minecraft's source: net.minecraft.world.DimensionType: public static DimensionType register(String name, String suffix, int id, Class<? extends WorldProvider> provider, boolean keepLoaded){ String enum_name = name.replace(" ", "_").toLowerCase(); DimensionType ret = net.minecraftforge.common.util.EnumHelper.addEnum(DimensionType.class, enum_name, ENUM_ARGS, id, name, suffix, provider); return ret.setLoadSpawn(keepLoaded); } So as I said, i don't want to remove the entire type, I just want to remove some dimensions (all of my custom type tho). I really think we talk past each other
  8. If you call this a terrible hack, okay... And there is not "another terrible hack" to remove them?
  9. Adding them works just fine, no errors, nothing. My approach: So i thought removing them would be also that easy. Well if it CAN NOT be done, the server crash is "not a bug" but "a feature"...
  10. I try to remove dimensions (custom, not -1/0/1). After it was successfully removed, the server crashes. I think I forgot one thing but I can't figure out what. This is the remove-code: /*some imports*/ import net.minecraftforge.common.DimensionManager; import /*my package*/.util.LogHelper; public class Dimensions { /*some stuff*/ public static boolean removeDimension(int id) { if(!DimensionManager.isDimensionRegistered(id)) return false; try { LogHelper.info("Unloading dimension " + id); DimensionManager.unloadWorld(id); }catch (Exception ex){ LogHelper.warn(ex.getMessage()); } try { LogHelper.info("Unregistering dimension " + id); DimensionManager.unregisterDimension(id); }catch (Exception ex){ LogHelper.error(ex.getMessage()); return false; } LogHelper.info("Removing dimension " + id + " from data storage"); if( !DimensionDataStorage.removeDimension(id) ){ //<---DimensionDataStorage extends WorldSavedData LogHelper.warn("Could not delete data from DimensionDataStorage. This occurs if no data was found."); return false; } LogHelper.info("Dimension " + id + " successfully removed"); return true; } Crash Log after calling removeDimension(id[=3]): It looks like the dimension still exists after removing it; but when I restart the server it is gone exept that if I create a new dimension it's id is the id of the removed dimension +1, that's why the id is 3 and not 2 . Also the DIM[ID] folder is not beeing deleted. Any Idea what I forgot to add [or rather remove ^^]?
  11. You could use EntityJoinWorldEvent but this will also fire if for example the player re-enters a chunk where ItemFrames already were created. Nevertheless you can check what item is in there and then decide what to do.
  12. Can you please post your code to find the error? Some argument or variable seems to be null or a function returns null.
  13. Hi. I made a command to create new dimensions and I get some weitd bugs. Most of them are not relevant - the only thing that is "visible" for players is the following: If it starts to rain (no matter what dimension) and while it rains the player changes the dimension there is "rains" in the target dimension too. Also, if it doesn't rain but it rains in the target dimension, it also doesn't update the weather. I wonder if there is a SPacketSomething I can manually send to the player via ((EntityPlayerMp)player).connection.sendPacket(...); I found one for time (SPacketTimeUpdate) but none for weather. Is there another packet which sends the weather or can I do that somehow else? Everything has to happen @ Side.SERVER If a mistake is already in the teleportation - here is the code: public class CommandWorld extends CommandBase{ /*Command Stuff*/ @Override public void execute(...) throws CommandException { /*Argument stuff,...*/ WorldServer targetWorld = server.getWorld(target); server.getPlayerList().transferPlayerToDimension(player, target, new CustomTeleporter(targetWorld)); BlockPos targetSpawn = targetWorld.getTopSolidOrLiquidBlock(targetWorld.getSpawnPoint()); player.connection.setPlayerLocation(targetSpawn.getX(), targetSpawn.getY(), targetSpawn.getZ(), player.rotationYaw, player.rotationPitch); } } And as always - thanks in advance! EDIT: I found a kind of workaround.
  14. Good to know. I did so now.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.