-
Posts
3624 -
Joined
-
Last visited
-
Days Won
58
Everything posted by Cadiboo
-
@SubscribeEvent public static void drawBlockHighlightEvent(final DrawBlockHighlightEvent event) { try { final EntityPlayer player = event.getPlayer(); if (player == null) { return; } final RayTraceResult rayTraceResult = event.getTarget(); if ((rayTraceResult == null) || (rayTraceResult.typeOfHit != RayTraceResult.Type.BLOCK)) { return; } final World world = player.world; if (world == null) { return; } final float partialTicks = event.getPartialTicks(); final BlockPos pos = rayTraceResult.getBlockPos(); final IBlockState blockState = world.getBlockState(pos); if ((blockState.getMaterial() == Material.AIR) || !world.getWorldBorder().contains(pos)) { return; } final Block block = blockState.getBlock(); if (!(block instanceof YOURBLOCK)) { return; } event.setCanceled(true); final List<AxisAlignedBB> boxes = new ArrayList<>(); blockState.addCollisionBoxToList(world, pos, new AxisAlignedBB(pos), boxes, player, false); final double renderX = player.lastTickPosX + ((player.posX - player.lastTickPosX) * partialTicks); final double renderY = player.lastTickPosY + ((player.posY - player.lastTickPosY) * partialTicks); final double renderZ = player.lastTickPosZ + ((player.posZ - player.lastTickPosZ) * partialTicks); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.glLineWidth(2.0F); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); for (AxisAlignedBB box : boxes) { if (box==Block.NULL_AABB) { continue; } final AxisAlignedBB renderBox = box.grow(0.0020000000949949026D).offset(-renderX, -renderY, -renderZ); event.getContext().drawSelectionBoundingBox(renderBox, 0.0F, 0.0F, 0.0F, 0.4F); } GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } catch (final Exception e) { event.setCanceled(false); } } So much for pseudo code, just put this in a CLIENT @Mod.EventSubscriber class, replace YOURBLOCK and you should be good to go. You should read the documentation on sides and the documentation on events before implementing this, as I said before it’s pretty technical. This code is taken directly from here What this code does: 1) checks if it can & should render a box 2) gets all the boxes from addCollisionBoxToList 3) sets up all the GLStateManager flags needed to render the box 4) renders the box using the RenderGlobal from event.getContext 5) resets all the GLStateManager flags 6) catches any exceptions reverts to normal selection box rendering (you might want to disable this catch part until you get everything working) If any moderators could move the code into a spoiler it would be much appreciated (and then delete this part of the comment).
-
I’m not sure, I’m on holiday right now & don’t have a computer with me, the best I can recommend is to copy my code from here, delete stuff you don’t need, and replace the instance of check with a check on your block. I’ll try and modify my code and then post it, I can’t use spoilers/code tags on mobile so prepare for a wall of pseudo code
-
Is it possible to use has/getCapability with capabilities that may or may not exist (provided by mods that may or may not be inatalled). For example if your building an energy/electricity based mod & want to support but not require RedstoneFlux & Tesla.
-
Yeah, it doesn’t work horribly though, it’s what fences & iron bars & glass use
-
Your right, I think that if your trying to render more than one (selected) bounding box you have two options: 1) Manually render it yourself with the DrawBlockHighlightEvent (example) 2) return a bounding box that is a union of bottom, middle and top (example)
-
@Animefan8888 is much more experienced than I am, I’ve only been modding for a little while, and I didn’t even know Java before I started.
-
If your asking how to add collision boxes to the list, you need to override addCollisionBoxToList() (this one has the parameters: IBlockState, World, BlockPos, AxisAlignedBB, List<AxisAlignedBB>, Entity, boolean) and in this method call this.addCollisionBoxToList() (this one has the parameters: BlockPos, AxisAlignedBB, List<AxisAlignedBB>, AxisAlignedBB) for each box. An example of this can be found here: https://github.com/Cadiboo/WIPTechAlpha/blob/c179d852e43f08d6e9f34db62bd2a59c36475e6b/src/main/java/cadiboo/wiptech/block/BlockWire.java#L130-L157 If your asking about how to make your selected bounding box fit your model, in short, you can’t do this. This is because you can only return one bounding box from getBoundingBox, getCollisionBoundingBox and getSelectedBoundingBox. However, as you’ve seen, you can add more than one box in addCollisionBoxesToList. If you really want to do this you can though: If you want to render more than one selected bounding box you can subscribe to the DrawBlockHighlightEvent and draw your own selected bounding box, but I wouldn’t recommend this because - it’s decently technical and requires knowing how to render boxes (or other shapes if that’s what your going for) - it completely breaks the selected bounding box for anyone who wants to use a different model for your block in a resource pack - it doesn’t fit in with the way vanilla does it (this may be what your going for though) I suggest that you look at what vanilla did with the selected bounding box for the anvil - they made the anvil have a different (smaller) bounding box than a full cube, but didn’t go overboard. If you still want to render your own selected bounding box, an example can be found here: https://github.com/Cadiboo/WIPTechAlpha/blob/c179d852e43f08d6e9f34db62bd2a59c36475e6b/src/main/java/cadiboo/wiptech/client/ClientEventSubscriber.java#L638-L727
-
Forge 1.12.2 Game is open for seconds then crashes
Cadiboo replied to Wolfieskies25's topic in Support & Bug Reports
Remember to report it to the author so that they can improve their mod! -
To get around this you can draw your own selected bounding box, but I wouldn’t recommend this because - it’s decently technical and requires knowing how to render boxes (or other shapes if that’s what your going for) - if someone wants to make a texture pack that overrides your model, they may not want the bounding box that you made it have Look at vanilla’s example with the anvil, they made it have a smaller bounding box, but didn’t go overboard
-
Forge 1.12.2 - 14.23.4.2768 Startup Crash
Cadiboo replied to Fandomaniac's topic in Support & Bug Reports
If I had to guess, Forge added a feature (or one of the mods added/removed a feature) and this breaks the other mods. Tell them to make sure that their mods work with the latest Forge versions -
Forge 1.12.2 Game is open for seconds then crashes
Cadiboo replied to Wolfieskies25's topic in Support & Bug Reports
It seems to me as though Additional Structures OR Biomes O’ Plenty thinks that a block at a position is a certain type when it actually isn’t. I suggest seeing if removing one (or both) of the mods fixes your issue -
It looks like a core mod caused world gen related crash to me, so try removing ever core mod that has to do with world gen. I’m guessing that Aroma1997Core, Quark, RandomPatches and AstralCore would be a good place to start. However, you have so many mods that I’ve never seen before that those are just weak guesses. Edit: Apparently the cause of the crash was NotEnoughIDs.
-
You can only return a single bounding box in every method except addCollisionBoundigBoxesToList
-
Where was it meant to be created? Place a breakpoint there and see if it hits.
-
In Java it’s usually better performance wise to do create & let the GC destroy than do Object pooling just because Java was designed this way (Taken from this answer on stackoverflow). So I think that it’s ok to use Minecraft & Forge’s system. ALSO - IMO trying to optimise anything in Minecraft is a waste of time.
-
[1.12.2] Custom model doesn't render correctly
Cadiboo replied to Spaceboy Ross's topic in Modder Support
Interesting, I think that that plugin may not have been properly tested with rotated boxes and might not be outputting your boxes with rotations correctly. I think that you should rename all your variables to make the code readable, and try moving the calls to setRotationPoint and setRotateAngle around (maybe swap which one gets called first? maybe move them above the call to addBox?) I think that when the model is rendered it’s getting scaled before rotated when it should be getting rotated before scaled (or visa versa). -
[Solved] How Do I Send Information to the GUI if I use ItemHandlers
Cadiboo replied to DeathSpawn's topic in Modder Support
Yeah, just add “[SOLVED] “ to the start of the title (if you want to & if there’s space) -
If the issue truely is solved, edit the original post and add “[SOLVED] “ to the start of the title.
-
[Solved] How Do I Send Information to the GUI if I use ItemHandlers
Cadiboo replied to DeathSpawn's topic in Modder Support
Are you syncing (and saving) your data? By default data is not synced to the client. -
I need help the game is crashing!!!!!!!!!
Cadiboo replied to Derves34's topic in Support & Bug Reports
Try removing All of these Edit: the offending core-mod appears to have been NotEnoughIDs -
Did you update Forge versions since yesterday? Does it crash if you use the normal launcher & not the Twitch launcher? If you remove Just Enough Dimensions and the crash persists, please post that log too.
-
Why doesn’t Forge use the JRE shipped with Minecraft?
Cadiboo replied to Cadiboo's topic in Modder Support
I believe that Minecraft (or most of it at least) should work with pretty much any Java >= Java_8u151. However it was designed to work with Java_8u151 (the JRE that it ships with). It does not require any specific Java (except that the Java you use must be compatible with Java_8u151). Forge on the other hand currently requires Java 8 because You would have to ask someone else for a concrete reason as to why a lot of work went into making Forge able to use Java 9 (for the 1.13 version of Forge), but here’s my speculation: - They were already rewriting the entirety of the mod loading system (The Internals that use Java’s (Sun’s) Internals) - It will allow modders to use new Java features not available in Java 8 - Security patches/upgrades etc. - Performance patches/upgrades etc. - Newer versions of software is almost universally better. -
I’m going off this comment which you agreed with, This isn’t an easy thing to do & there’s many ways in which you could implement it. If your still thinking of attempting it I think that this is the most straightforward solution. - Have a custom slot - Have a capability (shouldActiveHandBeEmpty? isActiveHandEmpty?) - Enable/Disable your capability with a keybind - In the player tick event check if the hand should be empty. If it should be empty try and move the active stack to the custom slot. If you can’t do this, try and move the active stack somewhere else in the inventory. If you can’t move it drop it. If it should not be empty see if there is anything in your custom slot. If there is try and move the custom slot stack to the active stack. If the active stack isn’t empty try and move one of the stacks somewhere else in the inventory or drop it. Heres some code. For readability I’ve turned if(!isEmpty){do stuff} into if(isEmpty){} else {do stuff} (Written on mobile so I can’t put it into spoiler or code tags, I hope I got the formatting right) if (ActiveStackShouldBeEmptyCapability.shouldBeEmpty()) { if (activeHandHeldStack.isEmpty()) { // nothing to do here, you can return - everything’s going smoothly } else { if (customSlot.isEmpty()) { //transfer active stack to custom slot } else { //drop active stack OR drop custom slot stack and move active stack into custom slot } } } else { // hand should not be empty if (customSlot.isEmpty()) { // nothing to do here, you can return - everything’s going smoothly } else { if (activeStack.isEmpty()) { //transfer custom slot stack to active stack } else { //drop active stack and move custom slot stack into active stack slot OR drop custom slot stack } } }