Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/17/17 in all areas

  1. Okay, so after digging around for a bit, it is a bit tricky to intercept block gen after everything has been populated. The most efficient place is where the ChunkPrimer is directly accessible, but the replaceBiomeBlocks event is too early for many types of surface biome-based blocks -- the event seems to be intended for entirely replacing the generation. I think I'll file an issue and maybe a pull request to allow the ChunkPrimer be availabile in most gen events and also ensure there is an event that is fired just before the ChunkPrimer is copied into the Chunk thereby allowing editing after everything else is complete. In any case, it seems that the most consistent place where you have access to all the blocks after they are freshly created is the ChunkEvent.Load event which is called both after generation as well as actual loading. So the following example worked for me -- for fun I replaced all grass with slime blocks: public static Block fromBlock = Blocks.GRASS; // change this to suit your need public static Block toBlock = Blocks.SLIME_BLOCK; // change this to suit your need @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public static void onEvent(ChunkEvent.Load event) { Chunk theChunk = event.getChunk(); // replace all blocks of a type with another block type for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { for (int y = theChunk.getHeightValue(x, z)-20; y < theChunk.getHeightValue(x, z)+1; ++y) { if (theChunk.getBlockState(x, y, z).getBlock() == fromBlock) { theChunk.setBlockState(new BlockPos(x, y, z), toBlock.getDefaultState()); } } } } theChunk.markDirty(); } How deep you go from the top block is up to you. For replacing grass I just needed to find the surface blocks, but I found some cases where grass would be under a floating island or other overhang and so technically wasn't the top block. If you were replacing ores for example you'd want to go deeper and such. I didn't notice any lag, but I've got a decent computer. For very specific cases, there are other events that are better. But in the generic case it seems that currently the load event is best.
    1 point
  2. If you still have problems with the CurseForge web site, then you'll probably find more info there than you can here. This is a development help forum, not tech support for remote sites.
    1 point
  3. Override 'getItemEnchantability' and return respective tool material enchantability.
    1 point
  4. Sorry, you couldn't have done that fully or it would be obvious where the problem happens. As Choonster mentions, onBlockActivated() probably isn't even being called -- which would be obvious in the console statements (since they wouldn't print when you expect them to). Also, your if statements are still not that simple as there are conditions besides the sneaking that need to be satisfied. The thing with debugging is you have to double-check all your assumptions. Of course you expect everything is working because you wrote the code intending for it to work. So you literally have to confirm that every step of code executes exactly as you expect. You need to confirm that the method is called when you expect, that the parameter values are what you expect, that the if statement executes as you expect, and so forth.
    1 point
  5. Sneak-right clicking on a Block with an Item will only call Item#onItemUse by default, ignoring Block#onBlockActivated. To change this behaviour, either override Item#doesSneakBypassUse to return true (for your own Items) or subscribe to PlayerInteractEvent.RightClickBlock and call PlayerInteractEvent.RightClickBlock#setUseBlock with Result.ALLOW (for Items from Vanilla or other mods). This is handled in PlayerInteractionManager#processRightClickBlock on the server and PlayerControllerMP#processRightClickBlock on the client. Don't compare to ItemStack.EMPTY directly, it's just one of many possible empty ItemStacks. Use ItemStack#isEmpty instead.
    1 point
  6. the last time i downloaded forge, i catched a cold. i dont know if that was accidental. but that can happen... last time i downloaded minecraft i got diarrhea... viruses everywhere...
    1 point
×
×
  • Create New...

Important Information

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