Jump to content

Zyl

Members
  • Posts

    6
  • Joined

  • Last visited

Zyl's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Awesome! I hope the devs have interest in increasing modding options for servers that want to support vanilla clients. For clarity, it might help to figure out what the client actually does use the DimensionType id for. The most important fact, however, is that the client never calls createChunkProvider().
  2. Before I abandon Forge, I'd really like to understand why exactly my approach is causing problems and what the common solution is (e.g. allowing client-side modding), because I cannot imagine to be the first person attempting to make custom dimensions with Forge. Transferring the player between dimensions does, after all, work. It is only that reconnecting to the custom-created one causes problems. I understand that I need to read code, but I would greatly appreciate if someone who has worked with this before can give me a helping hand. Thanks for the answers so far, by the way.
  3. I have seen servers running custom dimensions without the need of client-side mods before. Are there any pointers towards how to get that to work?
  4. I have a simple mod intended as a server-side only mod that creates an additional dimension with id 2 using the existing DimensionType DimensionType.OVERWORLD. If a player disconnects after being transferred to this world any attempts to reconnect will result in what appears to be a client-side soft lock (The connection attempt can be cancelled by pressing the cancel button, but will never time-out by itself). If the player is disconnected only after being returned to the default world, they can connect again without any problems. If the server is shut down, the world folder deleted, and the server then started again, the player can also connect again. Used server and MDK version: 1.12 - 14.21.1.2413 What I have tried to fix the issue: - Use a Forge client to connect instead of a vanilla client. - Try calling the function to move the player between worlds from a different event callback. (This failed because ServerChatEvent - which I tried to use - does not appear to catch any chat messages) Other unwanted observed behaviour: - After being transferred from one world to the other, an afterimage of the obsidian block and the redstone torch (see onInteract() in my code for context) are visible in the new world (desync). My code: QuestWorldsEventHandler.java package usr.zyl.questworlds; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.DimensionType; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(acceptableRemoteVersions = "*", modid = QuestWorldsEventHandler.MODID, version = QuestWorldsEventHandler.VERSION) public class QuestWorldsEventHandler { public static final String MODID = "questworlds"; public static final String VERSION = "1.0"; private static QuestWorldsEventHandler questWorldsEventHandler; // DimensionType and dimension id reference (called "canyon" because I wanted to make a canyon lol) public static DimensionType canyonDimensionType; // Just aggressively try to get this id for now (because this is the only mod being run) public static final int canyonDimensionId = 2; public QuestWorldsEventHandler() { } @EventHandler public static void init(FMLInitializationEvent event) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { questWorldsEventHandler = new QuestWorldsEventHandler(); System.out.println("Got ID for our custom world: " + canyonDimensionId); DimensionManager.registerDimension(canyonDimensionId, DimensionType.getById(0)); MinecraftForge.EVENT_BUS.register(questWorldsEventHandler); } } // Warp the player when he places a redstone torch on top of an obsidian block. @SubscribeEvent public void onInteract(PlayerInteractEvent event) { if (FMLCommonHandler.instance().getEffectiveSide() != Side.SERVER) return; if (event == null) return; if (EnumFacing.UP.equals(event.getFace())) { if (EnumHand.MAIN_HAND.equals(event.getHand())) { if (Item.getItemFromBlock(Blocks.REDSTONE_TORCH).equals(event.getItemStack().getItem())) { if (Blocks.OBSIDIAN.equals(event.getWorld().getBlockState(event.getPos()).getBlock())) { EntityPlayer ep = event.getEntityPlayer(); if (ep instanceof EntityPlayerMP) { System.out.println("Warping!"); ep.sendMessage(new TextComponentString("Warping!")); if (ep.dimension == 0) // If in overworld, warp to our dimension warpPlayerToDimension(ep, canyonDimensionId); else // If not in the overworld, warp to the overworld warpPlayerToDimension(ep, 0); } } } } } } // Alternative trigger. Unfortunately this never gets called for unknown reasons. @SubscribeEvent public void onChat(ServerChatEvent event) { if (event == null) return; EntityPlayerMP epmp = event.getPlayer(); String text = event.getComponent().getUnformattedComponentText(); System.out.print("Player \"" + event.getUsername() + "\" sent text: \"" + text + "\""); if (text.startsWith("/warp ")) { String number = text.substring(5, text.length()); try { int dimensionId = Integer.valueOf(number); if (DimensionManager.isDimensionRegistered(dimensionId)) warpPlayerToDimension(epmp, dimensionId); } catch (NumberFormatException ex) {} } } public static boolean warpPlayerToDimension(EntityPlayer ep, int dimension) { return warpPlayerToDimension(ep, dimension, ep.getPosition()); } public static boolean warpPlayerToDimension(EntityPlayer ep, int dimension, BlockPos pos) { if (ep instanceof EntityPlayerMP) { EntityPlayerMP epmp = (EntityPlayerMP) ep; WorldServer ws = epmp.mcServer.getWorld(dimension); BlockPos top = ws.getTopSolidOrLiquidBlock(pos); epmp.mcServer.getPlayerList().transferPlayerToDimension(epmp, dimension, new SimpleTeleporter(ws)); ep.motionX = 0; ep.motionY = 0; ep.motionZ = 0; ep.setPositionAndUpdate(top.getX() + 0.5, top.getY() + 2.5, top.getZ() + 0.5); return true; } return false; } } SimpleTeleporter.java package usr.zyl.questworlds; import net.minecraft.entity.Entity; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; public class SimpleTeleporter extends Teleporter { public SimpleTeleporter(WorldServer worldServer) { super(worldServer); } @Override public void placeInPortal(Entity entityIn, float rotationYaw) { } @Override public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) { return true; } @Override public boolean makePortal(Entity entityIn) { return true; } } Any clues on what might be going wrong here?
  5. I have a simple mod intended as a server-side only mod that creates an additional dimension with id 2 using the existing DimensionType DimensionType.OVERWORLD. If a player disconnects after being transferred to this world any attempts to reconnect will result in what appears to be a client-side soft lock (The connection attempt can be cancelled by pressing the cancel button, but will never time-out by itself). If the player is disconnected only after being returned to the default world, they can connect again without any problems. If the server is shut down, the world folder deleted, and the server then started again, the player can also connect again. Used server and MDK version: 1.12 - 14.21.1.2413 What I have tried to fix the issue: - Use a Forge client to connect instead of a vanilla client. - Try calling the function to move the player between worlds from a different event callback. (This failed because ServerChatEvent - which I tried to use - does not appear to catch any chat messages) Other unwanted observed behaviour: - After being transferred from one world to the other, an afterimage of the obsidian block and the redstone torch (see onInteract() in my code for context) are visible in the new world (desync). My code: QuestWorldsEventHandler.java package usr.zyl.questworlds; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.DimensionType; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(acceptableRemoteVersions = "*", modid = QuestWorldsEventHandler.MODID, version = QuestWorldsEventHandler.VERSION) public class QuestWorldsEventHandler { public static final String MODID = "questworlds"; public static final String VERSION = "1.0"; private static QuestWorldsEventHandler questWorldsEventHandler; // DimensionType and dimension id reference (called "canyon" because I wanted to make a canyon lol) public static DimensionType canyonDimensionType; // Just aggressively try to get this id for now (because this is the only mod being run) public static final int canyonDimensionId = 2; public QuestWorldsEventHandler() { } @EventHandler public static void init(FMLInitializationEvent event) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { questWorldsEventHandler = new QuestWorldsEventHandler(); System.out.println("Got ID for our custom world: " + canyonDimensionId); DimensionManager.registerDimension(canyonDimensionId, DimensionType.getById(0)); MinecraftForge.EVENT_BUS.register(questWorldsEventHandler); } } // Warp the player when he places a redstone torch on top of an obsidian block. @SubscribeEvent public void onInteract(PlayerInteractEvent event) { if (FMLCommonHandler.instance().getEffectiveSide() != Side.SERVER) return; if (event == null) return; if (EnumFacing.UP.equals(event.getFace())) { if (EnumHand.MAIN_HAND.equals(event.getHand())) { if (Item.getItemFromBlock(Blocks.REDSTONE_TORCH).equals(event.getItemStack().getItem())) { if (Blocks.OBSIDIAN.equals(event.getWorld().getBlockState(event.getPos()).getBlock())) { EntityPlayer ep = event.getEntityPlayer(); if (ep instanceof EntityPlayerMP) { System.out.println("Warping!"); ep.sendMessage(new TextComponentString("Warping!")); if (ep.dimension == 0) // If in overworld, warp to our dimension warpPlayerToDimension(ep, canyonDimensionId); else // If not in the overworld, warp to the overworld warpPlayerToDimension(ep, 0); } } } } } } // Alternative trigger. Unfortunately this never gets called for unknown reasons. @SubscribeEvent public void onChat(ServerChatEvent event) { if (event == null) return; EntityPlayerMP epmp = event.getPlayer(); String text = event.getComponent().getUnformattedComponentText(); System.out.print("Player \"" + event.getUsername() + "\" sent text: \"" + text + "\""); if (text.startsWith("/warp ")) { String number = text.substring(5, text.length()); try { int dimensionId = Integer.valueOf(number); if (DimensionManager.isDimensionRegistered(dimensionId)) warpPlayerToDimension(epmp, dimensionId); } catch (NumberFormatException ex) {} } } public static boolean warpPlayerToDimension(EntityPlayer ep, int dimension) { return warpPlayerToDimension(ep, dimension, ep.getPosition()); } public static boolean warpPlayerToDimension(EntityPlayer ep, int dimension, BlockPos pos) { if (ep instanceof EntityPlayerMP) { EntityPlayerMP epmp = (EntityPlayerMP) ep; WorldServer ws = epmp.mcServer.getWorld(dimension); BlockPos top = ws.getTopSolidOrLiquidBlock(pos); epmp.mcServer.getPlayerList().transferPlayerToDimension(epmp, dimension, new SimpleTeleporter(ws)); ep.motionX = 0; ep.motionY = 0; ep.motionZ = 0; ep.setPositionAndUpdate(top.getX() + 0.5, top.getY() + 2.5, top.getZ() + 0.5); return true; } return false; } } SimpleTeleporter.java package usr.zyl.questworlds; import net.minecraft.entity.Entity; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; public class SimpleTeleporter extends Teleporter { public SimpleTeleporter(WorldServer worldServer) { super(worldServer); } @Override public void placeInPortal(Entity entityIn, float rotationYaw) { } @Override public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) { return true; } @Override public boolean makePortal(Entity entityIn) { return true; } } Any clues on what might be going wrong here?
  6. Hello, I just started Minecraft modding with Forge this morning following this guide and I believe I have gotten the hang of it. One of the mods I wanted to make is change the drop behavior of items on death. This is working perfectly, except one issue. When you die, and this happens even without any mods, all armor pieces break instead of dropping. Is this a bug or is it a setting of some sort? I used the 1.12 - 14.21.1.2387 installer. EDIT: I was able to fix the problem by updating to 1.12 - 14.21.1.2413.
×
×
  • Create New...

Important Information

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