
profjb58
Members-
Posts
12 -
Joined
-
Last visited
Everything posted by profjb58
-
[Solved] [1.15.2] Rendering fixed lines between tile entities
profjb58 replied to profjb58's topic in Modder Support
Fully working now. Thanks for the tip on drawing the lines twice. Works like a treat. https://imgur.com/gHuEhDx -
Mcjtys tutorials do seem to be the best for tutorials but the Jabelar stuff I posted i think of more like extended unofficial (if a bit outdated) documentation. It explains some of the concepts of forge and MC in general in greater detail than the official forge documentation, but not everything. It's also really well split up. If you wanted to find the closest thing to an api manual or documentation with examples this is probably the closest you can get outside official forge documentation. There are sections which are very outdated on there though so take that with a grain of salt. To be honest though there are so many mods out there, most being free to view on Github or simular platforms and with things like MinecraftByExample it's easier to just look at there structure and interpret what you need from it. Since MinecraftByExample is commented as well that helps a lot.
-
Apologies. I think I got registry events confused with the FML lifecycle events. Not entirely sure how. I've had multiple attempts at modding since 1.7.10 so in comparison the registry events and deffered registry are a massive improvement. I think deffered registry is a fairly recent thing as well. There is a thing on Jabelars site about FML lifecycle events & events in general as well although he uses a proxy which I don't think is needed really and it's a bit outdated. Some info on changes in 1.10.2 for the modeventbussubscriber so it's not too bad though. http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html lol tbf I don't know enough yet to really comment on this stuff. Basically just a combo of everything available seems to work in learning MC modding. Very different to programming for Android for example but a lot more fun :P.
-
Bit late to the thread here but I’m about a month into making a mod, thought I’d share how I’m learning stuff. Basically it seems to be a combination of... Reading the docs for reference, watching tutorials on the more complicated topics, I’d honestly say registry events and the order in which they are fired confused me the most. Older tutorials can still be useful especially when understanding how minecraft works, e.g. the sided approach. Although make sure that tutorial isn’t ancient. this is quite outdated now but is still very useful: http://jabelarminecraft.blogspot.com. Also provides links to other sites. I kinda of think of the tutorial stuff as unofficial documentation sometimes. Also mcjtys stuff is in note form as well if you look for it. The rest is looking at others mods, asking for help on discord or on the forums, trying stuff out and failing very often. oh also, if your looking at how to do something by viewing another mods code i seem to find it’s better to go with simpler mods so your not searching for what you need for long and the larger mods/older mods tend to have there own way of doing things which works great for them but is annoying for someone trying to understand the basics.
-
[Solved] [1.15.2] Rendering fixed lines between tile entities
profjb58 replied to profjb58's topic in Modder Support
Added a post. Realized it wasn't relevant, can't delete it now :P. -
[Solved] [1.15.2] Rendering fixed lines between tile entities
profjb58 replied to profjb58's topic in Modder Support
I had a quick go last night thinking that might be the best approach. I'm almost certain it's the only approach that would be scaleable now. The idea of drawing 2 lines from either marker so either one is unlikely to stop rendering upon unloading a chunk is a brilliant idea, thank you. Since I have previous and next positions that is entirely possible for every marker as well. The only problems i'm having now is the ability to update the rendering based upon the information of the connected tile entities (markers) updating. E.g. one being removed or added. I have the correct methods overrided and sending data, e.g. onDataPacket, getUpdatePacket. I think I might be missing something here. I'll send the code for it. There is also a weird effect whereby once the player stops looking at the tile the connecting tiles lines dissapear. Thinking about it though drawing 2 lines between the markers would fix this I think. gist link: https://gist.github.com/profjb58/3b7960e437386228c3f472bd05e49764 (A lot of code, didn't want to spam this thread) I think i'm limiting the amount of data I sync to the client from what I can tell to only include 'connectedFacing > direction the marker is pointing' 'isTail' > is this marker the tail of the list. prevMarker & nextMarker' * * The only variables required for the TER. everything else used for drawing a line from the tail (end marker) to the player. p.s. the gist code is a bit of a mess. It works but i'm sure there is a better way of laying it out. -
[Solved] [1.15.2] Rendering fixed lines between tile entities
profjb58 replied to profjb58's topic in Modder Support
I also have all the positions I need for the next and previous tiles (markers) within the NBT storage of each marker so i'm wondering if using the TER approach would be better since I don't need the position of the player. -
[Solved] [1.15.2] Rendering fixed lines between tile entities
profjb58 replied to profjb58's topic in Modder Support
So i've managed to get it working (partially). I've attached an image of it. Essentially it kinda works. It renders properly but say if another render event happens during when I place the markers down, this line gets broken. It also produces a random pattern when logging back in and out. This is acctually kinda cool and i'm guessing is because the render world last event is essentially pretty much random. static void drawTileToTile(TileEntity tileStart, TileEntity tileEnd, ClientPlayerEntity player, MatrixStack matrixStack){ IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); IVertexBuilder lineBuilder = buffer.getBuffer(CustomRenderTypes.THICK_LINES); BlockPos tileStartPos = tileStart.getPos(); BlockPos tileEndPos = tileEnd.getPos(); float[] lineColour = getLineColour(tileStart.getBlockState().getBlock()); drawLine(lineBuilder, generateProjectedMatrix(matrixStack),tileStartPos.getX() + 0.5f,tileStartPos.getY() + 0.6f,tileStartPos.getZ() + 0.5f, tileEndPos.getX() + 0.5f, tileEndPos.getY() + 0.5f, tileEndPos.getZ() + 0.5f, lineColour); matrixStack.pop(); buffer.finish(CustomRenderTypes.THICK_LINES); } Modified code for drawing between tiles. I included -
I'm wondering how I can render fixed lines between tile entities in a simular way to buildcraft markers or immersive engineering wires. The actual rendering and render types i've figured out and I have it rendering from a single tile to a player mostly using mcjtys tutorial https://wiki.mcjty.eu/modding/index.php?title=Tut15_Ep15 for tile entity rendering. the issue is that I essentially have a kind of linked list of a bunch of points that are all linked together using real world positions but to draw this on the clientside relative to the player seems incredibly difficult since the only event I can think of is the client tick events and then I don't know how I would grab the matrix stack equivalent positions relative to the player from the actual positions within the world. I'm not sure if thats even possible. The vast majority of the code is essentially very simular to mcjtys tutorial code with a few very minor edits so for a better reference: https://wiki.mcjty.eu/modding/index.php?title=Tut15_Ep15 for tile entity rendering. Tile > player method (currently works) static void drawTileToPlayer(TileEntity tile, ClientPlayerEntity player, MatrixStack matrixStack){ IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); IVertexBuilder lineBuilder = buffer.getBuffer(CustomRenderTypes.THICK_LINES); BlockPos playerPos = player.getPosition(); BlockPos tilePos = tile.getPos(); int px = playerPos.getX(); int py = playerPos.getY(); int pz = playerPos.getZ(); float[] lineColour = getLineColour(tile.getBlockState().getBlock()); drawLine(lineBuilder, generateProjectedMatrix(matrixStack),tilePos.getX() + 0.5f,tilePos.getY() + 0.6f,tilePos.getZ() + 0.5f, px + 0.5f, py + 0.5f, pz + 0.5f, lineColour); matrixStack.pop(); buffer.finish(CustomRenderTypes.THICK_LINES); } This draws a line from the tile to the player position using a matrix stack from the renderworldlastevent event. Generate projected matrix private static Matrix4f generateProjectedMatrix(MatrixStack matrixStack){ // Begin pushing to the matrix stack. matrixStack.push(); // Get actual position of player and translate back to the actual location. E.g. blockpos is discrete integers. projected view isn't. Vec3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView(); matrixStack.translate(-projectedView.x, -projectedView.y, -projectedView.z); return matrixStack.getLast().getMatrix(); } Drawline method private static void drawLine(IVertexBuilder builder, Matrix4f posMatrix, float x1, float y1, float z1, float x2, float y2, float z2, float[] colour){ builder.pos(posMatrix, x1, y1, z1) .color(colour[0], colour[1], colour[2], colour[3]) .endVertex(); builder.pos(posMatrix, x2, y2, z2) .color(colour[0], colour[1], colour[2], colour[3]) .endVertex(); } I did think of using blocks simular to string that would generate between the marker points as they are placed but unlike buildcraft i'm fixing where you can place the markers in the X & Z planes but not in the Y plane so that wont work.
-
[1.15.2] Checking when specific vanilla commands are fired
profjb58 replied to profjb58's topic in Modder Support
EDIT: I realized essentially I could just do player.hasPermissionLevel(4) on my tile entity block break to check an operator can still remove the tile which is tied to a specific players UUID meaning I didn't have to write any of this essentially. *Sighs*. Either way i'll leave the code I would have used below just incase anyone else would benefit from it. Thank you all the same though. I can use the following apporach (below) if i ever have to check for a different type of command. Thank you. Thats a much better way of checking for the command. For reference the code i've used is... ParseResults<CommandSource> parseResults = event.getParseResults(); CommandNode pcn = parseResults.getContext().getNodes().get(0).getNode(); if(pcn instanceof LiteralCommandNode){ LiteralCommandNode lcn = (LiteralCommandNode) pcn; if(lcn.getLiteral().equals("op")){ Metropolis.LOGGER.debug("Op command fired."); } } Instead of using names as well I can grab the UUID of the player it seems by searching the player list for anyone with a permission level of 4. Wondering if this might be a better approach. List<ServerPlayerEntity> spe = ds.getPlayerList().getPlayers(); for(ServerPlayerEntity player: spe){ if(player.hasPermissionLevel(4)){ UUID uuid = player.getUniqueID(); } } Obviously this is just test code. I would add the UUID to a list instead to check. I also load in the playerlist of operators at server startup but essentially i'm just making sure that if a player has permission level 4, IE is an operator that they have access to delete certain tile entities I am creating within my mod. -
[1.15.2] Checking when specific vanilla commands are fired
profjb58 posted a topic in Modder Support
I need to check for the command /op or 'op' from the console so that I can identify when the list of operators contained within the PlayerList for the dedicated server changes. I do have a system that works right now, it involves checking the 'MinecraftServer' from a command event and from this event getting an opped player list. It works however on simply checking the string equivalent of the command. Although it works I figured there must be a better way of implementing this, e.g. with an instanceof check. @Mod.EventBusSubscriber(modid = Metropolis.MOD_ID, value = Dist.DEDICATED_SERVER, bus = Mod.EventBusSubscriber.Bus.FORGE) public class CommandEvent { public static String[] OP_LIST = null; @SubscribeEvent(priority = EventPriority.LOW) public static void dedicatedServerCommand(final net.minecraftforge.event.CommandEvent event){ if(FMLEnvironment.dist == Dist.DEDICATED_SERVER){ ParseResults<CommandSource> parseResults = event.getParseResults(); String cRaw = parseResults.getReader().getRead(); String c = cRaw.replace("/", ""); if(c.startsWith("op") || c.startsWith("deop") || c.startsWith("reload")){ Metropolis.LOGGER.debug("Metropolis permissions updated"); MinecraftServer ds = parseResults.getContext().getSource().getServer(); OP_LIST = ds.getPlayerList().getOppedPlayerNames(); } } } } -
So your modding tutorial might be the only one that makes sense without over complicating things, explains everything well and uses the new registry system for 1.12. In short, thanks. It's been a big help in understanding the basics. p.s. a bunch of the changes suggested by @diesieben07 also really helped.