Jump to content

chxr

Members
  • Posts

    54
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by chxr

  1. The thought process for this would be checking the EnderMan class, as its not behaviour intrinsecally connected to the item but rather the enderman: The EnderMan.isLookingAtMeMethod should return false when a player is wearing your armour piece. In that method you can see a call to ForgeHooks.shouldSuppressEnderManAnger() which uses an ItemStack of the object on the players head. This uses IForgeItem's isEnderMask method that brings you to: default boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEntity) { return stack.getItem() == Blocks.CARVED_PUMPKIN.asItem(); } which means you can override it on your armour item (since all item classes extend from IForgeItem, including ArmorItem from which you will most likely want to extend from) As for the second thing you'll most likely need to get creative: Using levitation can work if you want to make it floaty, but you most likely want to make it work as if the player is walking on air. I'd suggest something along the lines of checking the block immediately in the direction the player is facing, and if its air, place a transparent, solid block the player will walk on. As the player walks in some arbitrarry direction, keep checking to generate blocks in their path as well as deleting the ones left behind/in any direction the player isn't looking at. You will have to get *even more creative* to think how can you implement it as for only the armour user can stand on air (placing a solid block will make anyone be able to stand on it regardless of if wearing the armour or not) So yeah. First thing pretty straightforward, second one youll have to make your own idea around it.
  2. I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
  3. You need to create a class implementing the ITeleporter Interface, and override its placeEntity() method in which you'll have the logic to safely place the teleported entity in the inbound dimension. Whenever you need to use said class just create a new instance of it and call the changeDimension method of the entity you want to teleport with the ServerLevel instance of the target dimension and the teleporter class: MinecraftServer mcServer = level.getServer(); ServerLevel targetDimension = mcServer.getLevel(TARGETDIMENSIONLEVELKEY); if (targetDimension != null) { CustomITeleporter teleporter = new CustomITeleporter(. . .); entity.changeDimension(targetDimension, teleporter); } EDIT: As far as i can tell this works on 1.19+. You didn't specify your version so I defaulted to the most recent one(s)
  4. If you need translucency (semitransparent/semiopaque) you will also need to mark the renderypes of whichever blocks you need as translucent in the client via a FMLClientSetupEvent (It is like this in 1.20+ and im pretty sure it works as well on 1.19)
  5. Como ya he dicho, si. Puedes seguir las instrucciones que te han dejado arriba si lo quieres hacer en tu ordenador, pero seguramente tendrás que hacer cosas como abrir puertos, usar programas como Hamachi o algun tipo de servidor virtual. Además de que tendrás que encargarte TU de encender tu PC y cargar el servidor cada vez que alguien quiera entrar
  6. Pues para empezar, el querer tenerlo encendido todo el día en tu PC no es recomendable, tanto por los puertos que tendrías que abrir como por el consumo. Necesitarías un buen pC para tener un servidor, jugar y hacer otras cosas a la vez y tus amigos NO podrían encenderlo ellos a no ser que les des acceso remoto a tu ordenador (cosa no recomendable) por lo que en principio te recomendaría un servicio de hosting para el servidor, aunque lo más probable es que tendrías que pagar.
  7. We might be able to help you if you tell us where exactly you have problems
  8. Te puedo ayudar, pero necesito mas info. ¿Hosteado en tu PC? ¿En una web de hosting? ¿Que version? ¿Qué problemas tienes? ¿Qué capacidades quieres que tenga el servidor? (Encendido todo el dia/Solo cuando estes tu, cuantos mods quieres, para cuanta gente. . .)
  9. Ok it was literally WAAAY easier using blockstates. Thanks for reminding me they exist lmao
  10. I've ended up doing it the "dirty" way and had 8 different subblocks spawning from placing the "full block". All of them share the same class and share a small logic block to handle what happens when they're mined. Will check the blockstate thing though.
  11. You can theoretically do this by implementing your own ChunkGenerator, but im not sure how. I'm also tinkering with dimensions so if i come to a more specific answer i'll tell you
  12. What would be the best logic to manage a multiple block block? I already know how some use halves like doors, but mine is supposed to be a 2x2x2 block. Is just decor, doesn't do anything special, so what is the recommended way to go about it since bounding boxes have a limit of 1 block?
  13. So im full into world generation right now, carving shit for a dimension I'm doing. I understand what the CarvingMask is, if i understand correctly, an array of bits that, for each chunk, marks wether the block the bit represent is (1) or isn't (0) carved. But I'm not seeing what uses it can have. Under what circumstances is good to make and keep track of a carvingmask?
  14. Yes, it is possible. You should develop the API as a separate project. Wether you want your mod to have the API integrated or have a dependency on it is up to you. I'd say that for testing the API integration, you should have it separated and add it as a dependency to your mod (at least, thats how I've done it in the past). I recall there is also option to compile different parts of your project on different jars. Either way, thats more of a forgegradle question, if i understand it correctly
  15. Yeah I had a similar idea, at some point I also just got the numBlocksCorrupted++ out of the if block so it would just do a loop numBlocksCorrupted amount of times but it still caused some troubles. I've ended up using an extra feature to generate the blob around the ore and its working wonders so I won't be scratching my head much longer with it
  16. I think i've found a more "generation friendly way" of generating random blobs of mineral around the ore. This both does the trick and make the generation work flawlessly (albeit i need to make some adjustments). I just ended up thinking "MAYBE there is another Feature I can use to place the minerals instead of doing it manually" And, low and behold, SCATTERED_ORE is actually a thing. I don't really know how "orthodox" this solution is, but it works and rids me of all the problems I had witht my original "manual" implementation. If anybody has any insight on why my original class could've been causing lag to the point of freezes and chunk generation just refusing to keep loading new chunks, I'm also all ears: Here is the full if (placed) block for anyone with a smiliar issue: if (placed) { // Define the block to replace surrounding blocks with BlockState surroundingBlockState = BlockInit.ABERRANT_MINERALOID.get().defaultBlockState(); RuleTest stoneReplacement = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES); //Tag which indicates ores that can replace stone RuleTest deepslateReplacement = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES); //Tag which indicates ores that can replace deepslate // Create a list of TargetBlockState for the Aberrant Mineraloids List<OreConfiguration.TargetBlockState> targets = new ArrayList<>(); targets.add(OreConfiguration.target(stoneReplacement, surroundingBlockState)); targets.add(OreConfiguration.target(deepslateReplacement, surroundingBlockState)); // Create a new OreConfiguration for the Aberrant Mineraloids OreConfiguration mineraloidConfig = new OreConfiguration(targets, 9); // vein size // Create a new context for the Aberrant Mineraloids FeaturePlaceContext<OreConfiguration> mineraloidCtx = new FeaturePlaceContext<>( Optional.empty(), world, ctx.chunkGenerator(), ctx.random(), offsetOrigin, mineraloidConfig ); // Generate the Aberrant Mineraloids using the SCATTERED_ORE configuration boolean mineraloidsPlaced = Feature.SCATTERED_ORE.place(mineraloidCtx); }
  17. Ok so this specific code freezes the game on world creation. This is what gets me so confused, i get that it might not be the best thing, but is it really so generation heavy?
  18. I've tested the same code on three different envionrments (Desktop win10, desktop Linux and Laptop Linux) and it kinda blows up all the same. Gonna try this code and see if i can tune it
  19. So i have a custom ore and, arround the ore, a bunch of randomly placed custom stone blocks should be placed. After applying it, i've found that it causes moderate to extreme world generation lag (new chunks refusing to load after moving for a while, height slices of the same chunk appearing and disappearing as I get into them instead of the usual long continous chunk, new chunks generating extremely close to me instead of to the set render distance...) I've been debugging for a while and I know for a fact this is causing the lag (and sometimes freeze of the world loading screen on a new world and/or the saving world screen when quitting), since comenting it just makes the worldgen work as usual and I want to see if its really that computationally expensive, if there are other ways of doing it or if the process can be simplfied or optimized. I've tried a lot of combinations for the same code but I am just stuck. Is it some kind of generation cascading im missing? Here is the code for the class. The code inside the if (placed) is the one causing this mess. I can see that the code might not be the most optimized thing, but it does what's supposed to... but at the cost of causing all this. Any tips? package es.nullbyte.relativedimensions.worldgen.oregen.oreplacements; import es.nullbyte.relativedimensions.blocks.BlockInit; import es.nullbyte.relativedimensions.blocks.ModBlockTags; import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.OreFeature; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; import java.util.Optional; public class AberrantOreFeature extends OreFeature { public AberrantOreFeature() { super(OreConfiguration.CODEC); } @Override public boolean place(FeaturePlaceContext<OreConfiguration> ctx) { // Get the world and the position from the context WorldGenLevel world = ctx.level(); BlockPos origin = ctx.origin(); // Offset the origin by 8 in the x and z directions to avoid cascading chunk generation BlockPos offsetOrigin = origin.offset(8, 0, 8); // Create a new context with the offset origin FeaturePlaceContext<OreConfiguration> offsetCtx = new FeaturePlaceContext<>( Optional.empty(), world, ctx.chunkGenerator(), ctx.random(), offsetOrigin, ctx.config() ); // Generate the entire vein of ore at the offset origin boolean placed = super.place(offsetCtx); // If the vein was generated successfully if (placed) { // Define the block to replace surrounding blocks with BlockState surroundingBlockState = BlockInit.ABERRANT_MINERALOID.get().defaultBlockState(); // Generate a random size for the area of corruption int areaSizeX = ctx.random().nextInt(3) + 1; // between 1 and 4 int areaSizeY = ctx.random().nextInt(3) + 1; // between 1 and 4 int areaSizeZ = ctx.random().nextInt(3) + 1; // between 1 and 4 // Calculate the number of blocks to be corrupted based on the area size double numBlocksToCorrupt = (areaSizeX + areaSizeY + areaSizeZ / 2.0) ; // Counter for the number of blocks corrupted int numBlocksCorrupted = 0; // Loop for each block to be corrupted while (numBlocksCorrupted < numBlocksToCorrupt) { // Generate a random position within the area, using the offset origin BlockPos randomPos = offsetOrigin.offset( ctx.random().nextInt(2 * areaSizeX + 1) - areaSizeX, // between -areaSize and areaSize ctx.random().nextInt(2 * areaSizeY + 1) - areaSizeY, ctx.random().nextInt(2 * areaSizeZ + 1) - areaSizeZ ); // If the block at the random position is in the IS_ORE_ABERRANTABLE tag, replace it if (world.getBlockState(randomPos).is(ModBlockTags.STONE_ABERRANTABLE)) { world.setBlock(randomPos, surroundingBlockState, 2); numBlocksCorrupted++; } } } return placed; } }
  20. Here is a tutorial from this same forum that I tried and kinda made work. Take into account that you will have to manage the offset (like rotation, and the offset relative to things like the main hand, offhand etc) by yourself and that can get very troublesome at times.
  21. Ok so: Two things to note: It got stuck due to my dimension type. It was previously the same as the overworld dimension tpye but after changing it , it didn't freeze during spawn generation. ALSO, APPARENTLY, the way I'm doing things, the game can't have two extremely-rich dimensions or it will make the new chunk generation be veeery VEEERY slow. I'm doing the dimension file genreation all in the data generation step now, so it's all good. Mostly. If anybody has any tips regarding how can i more efficently generate a biome-rich dimension, im all ears.
  22. Now it gets stuck at "Preparing start region for dimension overworld" once i was able to generate a full customzied json. Any insights?
  23. I need help understanding if this is possible. As i understand it, modifying the actual overworld is harder and requires 3rd party plugins or using mixins to inject the new biomes, but im not looking for that. I need to make a new dimension that is a copy of the overworld - but with some other custom biomes. I've tried making a copy of the 30k biome list of the regular overworld with my own biomes patched after. It does make my biome spawn, but it does it high up in the air, far away from the actual terrain so no actual physical terrain is ever affected by it. I ignore if this is due to the parameters i give to the biomes and / or if there is an easier way to do it or if im doing it correctly or if its possible overall. I've tried using the overworld template and injecting the rest of biomes via terrablender, but didn't get anything neither. Any tips? EDIT: I was thinking to make a customc lass extending whatever the game uses to generate biomes, but I still understand shit about the world generation code (Hell, i think i understand x10 times better the underlaying mathematical implementation at this point) I understand MultiNoiseBiomeSource and OverworldBiomeBuilder play a part in this (NoiseBasedChunkGenerator and NoiseGenerationSettings too) but on my mother I im failing to understand what can i change to make it, if its even possible.
  24. Last month i was tinkering with terrablender but decided to drop the dependency altogether, since I mainly wanted it to inject new biomes on the overworld and I dont need that anymore. I made a custom dimension, but I forgot the fact that Terrablender was also managing the injection of the custom surface rules I had set. Is there a way (programatically via a data generator or otherwise manually in the resources) to have new surface rules to change the surface appearance of my biomes? I lost track of whatever the hell happened on 1.18 and all I found was "Yeah support for the new surface rules is a TODO for forge team". Was that ever developed? Do i just not complicate it and just go back to have TB as a dependency? Any other not-that-hard way?
  25. Changing the event to RenderGuiEvent.post kinda did the trick. If there is any more suitable events please tell me, and thanks for the help!
×
×
  • Create New...

Important Information

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