-
Posts
424 -
Joined
-
Last visited
Everything posted by Daeruin
-
I am making a GUI in which the player can click various buttons to disable/hide them (similar to the knapping interface in Terrafirmacraft). The problem is that whenever the Minecraft window is resized, the GUI refreshes and redraws all the buttons as enabled. The buttons are all drawn in #initGui which I realize is called every time the screen is resized. But I don't know how else to do it. Is there a way to get the GUI to remember which buttons are disabled when resizing or redrawing the screen? Or should I be drawing them in a different method?
-
Like jeffreyfisher mentioned, it would probably be more efficient for you to use World#getTopSolidOrLiquidBlock, and if the results of that happen to be a leaf or log, iterate downward until you find a non-leaf/log. Vanilla crops use a similar algorithm.
-
I think it's supposed to be "fact".
-
I've been working on my mod for a long time, and it's still not in a releasable state. But I think I'm getting there soon. So what do you do to promote your mod? Do you just make a post on Minecraftforum.net or Curse and let it go from there? Are there good reddits to hang out in? Also, is it a good idea to release an alpha version that may not have the full feature set you have in mind, just to get involve the community and get feedback? It seems I've seen people do it different ways, and I'm wondering what kind of experiences people have had. Finally, what do you do to test your mod? Do you play it with close friends first? How do you make sure it's really solid and ready for prime time?
-
[SOLVED] [1.10.2] How to tell if a block can be "occupied" by an entity
Daeruin replied to Daeruin's topic in Modder Support
I finally figured this out. I have edited the title of the post to reflect the question I actually should have been asking. All I needed to do was check if the block had a collision bounding box (using world.getBlockState.getCollisionBoundingBox). Blocks with a bounding box aren't legitimate targets for an entity to move to, so if it has a bounding box, I check the blocks above it until I find a block with no bounding box. Then I check the light level, and if it's dark enough, I tell the entity to move there. I also implemented a boolean toggle in the AI task that defaults to false. I turn it to true as soon as I find a legitimate block to move to. In the AI task's shouldExecute method, I first check if the toggle is true—if so, the entity is already moving somewhere, so we don't need to try to flee again. As soon as the entity has no path (i.e., they reached their destination), I set the toggle back to false. New AI task code: -
Difference between EntityJoinWorldEvent and LivingSpawnEvent?
Daeruin replied to salmjak's topic in Modder Support
Hmm. I may have to play around with it more. Thanks for the reply. -
Edit: I updated the title to get closer to what I'm actually asking, which is how to tell if a block can be "occupied" by a living entity. See the second paragraph for more detail. I'm creating a new entity AI that causes mobs to flee from any light source when it's night. I used EntityAIFleeSun as the base, and it's working decently. What I can't figure out is how to prevent it from picking destinations that are underground. EntityAIFleeSun simply picks 10 random blocks within 10 blocks n/w/s/e and 3 blocks up/down, then checks the light level of that block and makes sure it can't see the sky. But there doesn't seem to be anything to prevent it from picking blocks underground, and since solid blocks always have a light level of 0 it seems this would be a problem. I'm not sure why it works. My AI that's based on EntityAIFleeSun sends my mobs running around insanely trying to reach blocks that are underground, because they always have a light level of 0. I must be missing something obvious. I was thinking I could solve it by checking if the block is "transparent" or otherwise able to be occupied by a living entity, but I'm not sure how to determine that. There are a million methods in the block class that all seem identical (isNormalCube, isFullCube, isOpaqueCube, isFullyOpaque, etc.). I also considered the method World#getTopSolidOrLiquidBlock, but that gets the top block from the height map, which wouldn't work when mobs are in caves or under trees. What am I missing? Any ideas? My AI class:
-
I wasn't aware pets could follow anyone except the owner, but since I started modding I haven't actually played Minecraft much for a long time. Haha. If you want to change how they behave, you will have to tinker around with the entity's AI. There's one called EntityAIFollowOwner. You can create your own AI based on it, then during the EntityJoinWorldEvent you can remove the old one and register yours. Here's a decent tutorial that covers the basics: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2281106-tutorial-how-to-change-an-existing-mobs-ai
-
Difference between EntityJoinWorldEvent and LivingSpawnEvent?
Daeruin replied to salmjak's topic in Modder Support
What do you mean by "entities that spawn passively"? When I tried using LivingSpawnEvent I found it couldn't detect any mob spawning that I was interested in (passive mobs that spawn when chunks load, hostile mobs that spawn at night). -
In Eclipse Ctrl+Shift+o should detect any needed imports and import them. I do it all the time as I type up code.
-
[1.10.2] Detect when it's raining on a vanilla block
Daeruin replied to Daeruin's topic in Modder Support
Well, I played around with substitution aliases with no luck. Any other ideas, or links to successful implementations, would be appreciated. -
[1.10.2] Detect when it's raining on a vanilla block
Daeruin replied to Daeruin's topic in Modder Support
I'm using 1.10.2. I updated the post title accordingly. I have never heard of either of your suggestions. A quick Google search brings up only complaints about substitution aliases not working, and nothing relevant for overriding block registry entries. Can you point me to an explanation somewhere? -
[1.11.2] The models for an item with a metadata are not registered
Daeruin replied to Minebot1708's topic in Modder Support
Registry names are supposed to be all lowercase from 1.11 on, I believe. Not sure if this is causing your problem, but it may be. -
I want to do something when a particular vanilla block (dirt) is getting rained on. Any clue how to detect when a vanilla block is getting rained on? I looked over all the events and didn't see anything that seemed useful.
-
The method gets called on the client and the server. For each of those, it's likely that it also gets called once for each player hand (main hand and off hand) since the player could have the needed item in either hand. So, four times total.
-
This post also gives another example using the newer registration events and a couple simple items and blocks.
-
You may benefit from a straightforward beginner's tutorial like those from ShadowFacts. https://shadowfacts.net/tutorials/forge-modding-1112/ You'll want to work through all the tutorials up through Basic Blocks to make sure you get all the pieces right.
-
[SOLVED] How to store multiple values with a single capability?
Daeruin replied to Daeruin's topic in Modder Support
I did an override of the default methods that return an NBTBase. That seemed to handle the NBTTagCompounds just fine. Example: @Override public NBTBase writeNBT(Capability<ICapability> capability, ICapability instance, EnumFacing side) { NBTTagCompound tag = new NBTTagCompound(); <use tag.setBoolean, or tag.setDouble, etc., to write whatever data you need to the NBTTagCompound> return tag; } -
[1.10.2] getHitVec returning different results in same event firing
Daeruin replied to Daeruin's topic in Modder Support
The player can place the block from either their main or off hand. I want the event to run for whichever hand is placing the block, but not the other hand. If the player is holding items in both their main and off hands, I don't really want to hijack the logic that decides which one gets used, but I'm having trouble getting everything to work right. When I check for the player's active hand, it is ALWAYS their main hand, even if their main hand is empty and the block is being placed from their off hand. -
[1.10.2] getHitVec returning different results in same event firing
Daeruin replied to Daeruin's topic in Modder Support
I figured it out. PlayerInteractEvent gets called once for each hand. So, once for each hand on client, once for each hand on server, for a total of four times. I fixed it by checking which hand the event is being run for and seeing if it's the player's active hand. if (event.getHand() == event.getEntityPlayer().getActiveHand()) The client doesn't seem to know about active hands, so it always returns null from getActiveHand, and this prevents the code from running for the client at all. I thought that would be a problem since I'm sometimes canceling the block placement, and I had trouble only doing that from the server before. That part seems to actually be working OK--not sure why. There's some other residual weirdness, but I'll post about that later if I can't figure it out. -
[1.10.2] getHitVec returning different results in same event firing
Daeruin replied to Daeruin's topic in Modder Support
I now think that the second hit vectors being returned are from the block I'm placing later on in the code (not shown in code snippet above). Like it's detecting my click on the original block, placing my block, then running the event again and returning the hit vector for the placed block. I don't understand why it would do this. -
I am trying to determine where the player clicked on a block by getting the hit vector from the PlayerInteractEvent. The first issue is that the event seems to be firing twice per side. I'm intentionally running the code on both client and server, so I expected the event to fire twice total, not twice per side. I'm printing out hit vectors to the console, and they appear twice on the client thread and twice on the server thread. The second issue is that the hit vectors are sometimes different between the two firings on the same thread. For example, this code: @SubscribeEvent public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { if (event.getResult() != Result.DENY) { EntityPlayer player = event.getEntityPlayer(); ItemStack heldItemStack = player.getHeldItemMainhand(); if (heldItemStack != null) { Item heldItem = heldItemStack.getItem(); if (heldItem instanceof ItemDoor) { System.out.println("z hitVec: " + event.getHitVec().zCoord); System.out.println("x hitVec: " + event.getHitVec().xCoord); System.out.println("y hitVec: " + event.getHitVec().yCoord); } } } } Gives me this result: [00:22:57] [Client thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:186]: z hitVec: 256.0 [00:22:57] [Client thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:187]: x hitVec: -122.70772898075859 [00:22:57] [Client thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:188]: y hitVec: 79.44237080478545 [00:22:57] [Client thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:186]: z hitVec: 255.87712782211653 [00:22:57] [Client thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:187]: x hitVec: -123.0 [00:22:57] [Client thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:188]: y hitVec: 79.47316804515869 [00:22:57] [Server thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:186]: z hitVec: 256.0 [00:22:57] [Server thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:187]: x hitVec: -122.70772898075859 [00:22:57] [Server thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:188]: y hitVec: 79.44237080478545 [00:22:57] [Server thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:186]: z hitVec: 255.87712782211653 [00:22:57] [Server thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:187]: x hitVec: -123.0 [00:22:57] [Server thread/INFO] [STDOUT]: [com.daeruin.primalcraft.events.PrimalPlayerInteractEvent:onPlayerInteract:188]: y hitVec: 79.47316804515869 What gives?
-
[1.10.2] Placing door from player interact event
Daeruin replied to Daeruin's topic in Modder Support
Ah, yes. That makes sense. I've used reflection before and could probably do it again. I'd much prefer a generic solution to hard coding the placement for each type of door. Thanks! -
I am trying to place a door from a PlayerInteractEvent, because I want to add some extra conditions on placing a door (I want to require two solid wood blocks where the hinge is going to be). I tried this: Item heldItem = event.getEntityPlayer().getHeldItemMainhand().getItem(); if (heldItem instanceof ItemDoor) { ...check various conditions... IBlockState iblockstate = Block.getBlockFromItem(heldItem).getDefaultState().withProperty(BlockDoor.FACING, doorFacing).withProperty(BlockDoor.HINGE, isRightHinge ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT); world.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2); world.setBlockState(posUp, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2); } but it gives a null reference exception from Block.getBlockFromItem(heldItem) since the held item is not an instance of ItemBlock (it's an ItemDoor). I also tried BlockDoor.getDefaultstate()... but getDefaultState is not a static method, and I don't have an instance of BlockDoor to call it from. I can't make a new instance, because the constructor for BlockDoor is protected. ItemDoor has a block variable, but it's private. I also tried using ItemDoor's built-in placeDoor() method, but its parameters also require a BlockDoor, which I don't have. What do I need to do here? Thanks in advance.
-
[1.8.9] Slabs dropping their item when doubled
Daeruin replied to blahblahbal's topic in Modder Support
I only glanced at your classes, but in my slab class I have overridden this method that you don't seem to be using: @Override public int quantityDropped(Random random) { return this.isDouble() ? 2 : 1; } When you say "manually forcing" them to drop two, how did you try doing that?