Jump to content

Slashking

Members
  • Posts

    13
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Slashking's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. In a way I have found a workaround for this problem, but it just doesn't quite work the way I would like it to. My plan is to spawn my custom entities on the surface of my custom dimension during daytime. So far so good. After figuring out, that entities are initialized after Biomes, I instead registered them into the biome spawn lists of my custom biomes (in a custom dimension) in the FMLCommonSetupEvent. This also works, as my entities now spawn, but only underground. As this wasn't the desired result, I read into this deeper and figured out, that I can use EntitySpawnPlacementRegistry.register to tell the game when it actually is appropriate to spawn my entity. Since I just wanted to get this to work, I just returned true in a custom method for this at all times. Still didn't work, only underground spawning. My (somewhat) working workaround is to use LivingSpawnEvent.CheckSpawn and allow any and all spawns. This sort of works, but it spams entities pretty hard, as it just allows any and all spawns. Surely there is a better way to make this work properly? I also have another different MonsterEntity that I want to spawn on the surface (but this time only the surface). With this one I only registered it as a creature, not as a monster and once again just allowed any and all entities above a certain y level to spawn. Barely any entities seem to spawn though, or atleast they seem to immediately despawn again, since the console claims to have spawned them, but when I actually go to the aledged coords nothing is actually there. I even tried to change them to AnimalEntities (since these seem to be handled differently from monsters) but still no luck. I also fiddled with disallowing despawns, some (probably all) of the despawn methods in the entity class (that seem to control whether an entity is allowed to despawn) but that didn't change anything either, still next to no entities to be seen anywhere, very rarely I can spot a single group of the custom entity. But as I said, this all is just a workaround and the only way to make it work (semi) properly is to spawn the entity as monsters, which then again spams it super hard, so it's either almost no entities or way too many with no real way of controlling it. My questions are: First of all I guess how do I properly get any (custom!) entity to spawn on the surface of my custom biome (in my custom dimension), as even AnimalEntities seem to not properly want to do that, and after that, how do I get a MonsterEntity to spawn that way (eventhough I'm sure that one isn't even really necessary, as I can theoretically just change the entities into AnimalEntities or something)
  2. Alright I figured it out, for people having a similiar problem in the future: If you do stuff in the RenderGameOverlayEvent, make sure to only do it "once", aka check for the event's type and only run your render code for one event type, not all of them, otherwise transparency will not work as you render the same thing over and over again, multiple times in a single frame!
  3. Hey everyone, I'm currently trying to build a custom portal block and everything is working nicely so far, however I've run into a weird issue with the portal animation (the one that plays out when standing inside the portal): Just like the vanilla game I call a function that renders the portal animation, I call it from a RenderGameOverlayEvent (which should be the correct event) and the timeInPortal value also is computed correctly (I checked to make sure, it changes as intended and is calculated the same way the vanilla portal calculates it). As far as I understand the code this value controls the alpha value of the texture, however it is always rendered with no transparency at all, even if I substitute timeInPortal with 0 and I'm not sure why. I'm assuming either the blend mode is wrong (which is unlikely, as I copied the code from the vanilla class) or I load my texture wrong/without alpha for some reason. Any pointers? (Yes, the block is set up to have translucency and as a block in the world it renders correctly, but not as an overlay texture for some reason) Edit: Just tested with the vanilla portal texture, it also is rendered with no transparency The render code (apart from grabbing a Minecraft Instance named mc this is exactly how vanilla does it aswell): public static void renderPortalAnim(float timeInPortal, int scaledWidth, int scaledHeight) { if (timeInPortal < 1.0F) { timeInPortal = timeInPortal * timeInPortal; timeInPortal = timeInPortal * timeInPortal; timeInPortal = timeInPortal * 0.8F + 0.2F; } Minecraft mc = Minecraft.getInstance(); RenderSystem.disableAlphaTest(); RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.defaultBlendFunc(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, timeInPortal); mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); TextureAtlasSprite textureatlassprite = mc.getBlockRendererDispatcher().getBlockModelShapes().getTexture(BlockInit.custom_portal.getDefaultState()); float f = textureatlassprite.getMinU(); float f1 = textureatlassprite.getMinV(); float f2 = textureatlassprite.getMaxU(); float f3 = textureatlassprite.getMaxV(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.func_225582_a_(0.0D, (double)scaledHeight, -90.0D).func_225583_a_(f, f3).endVertex(); bufferbuilder.func_225582_a_((double)scaledWidth, (double)scaledHeight, -90.0D).func_225583_a_(f2, f3).endVertex(); bufferbuilder.func_225582_a_((double)scaledWidth, 0.0D, -90.0D).func_225583_a_(f2, f1).endVertex(); bufferbuilder.func_225582_a_(0.0D, 0.0D, -90.0D).func_225583_a_(f, f1).endVertex(); tessellator.draw(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); RenderSystem.enableAlphaTest(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); }
  4. So I ran into an odd bug, I'm currently adding custom structures into the game, and so far it mostly works as expected, smaller structures generate without any problems. But bigger structures (structures with a size of around 3 chunks or more in X/Z/both directions) seem to sometimes skip individual chunks when generating. Now I know that they do indeed work as intended aswell, as they do generate fully sometimes (most of the time). But occasionally, individual chunks will just not generate a single block of the structure at all and remain entirely untouched. Why does this happen, and more importantly, how do I fix it? I don't know if it is important, but I don't use those Jigsaw/NBT Files, I have a custom StructurePiece where I generate my structures the way I want them to be in code (using setBlockState etc.). Does anyone know what I could do to fix this/why this happens? Edit: I figured out that the "skipped chunks" seem to be chunks where another/a different biome is present that does not generate the structure. So if my structure for example only generates in desert biomes and not in plains biomes, but gets generated at the edge of a desert, a chunk that is both part desert and part plains biome will simply not generate the structure at all, resulting in a "skipped" chunk and a hole in the structure. So how would I go about fixing that, or to be more precise, how do I get my structure to generate into a biome that does not normally generate my structure? Alternatively, would there be a way to specify that I want my structure to only generate in "the middle" of a biome and not at the edges?
  5. That fixed it, thanks so much, no idea how I didn't notice that
  6. I hope there is an easy solution to this, as I don't quite get why this doesn't work, it worked exactly like this so far, but it kind of just stopped working. Now, this works: Blocks.ANDESITE_WALL.getDefaultState().with(WallBlock.NORTH, true) In vanilla code this also works (check DesertPyramidPiece, that's where this line is taken from): BlockState blockstate1 = Blocks.SANDSTONE_STAIRS.getDefaultState().with(StairsBlock.FACING, Direction.NORTH); But, as soon as I copy this line 1:1 into my code it doesn't work anymore for some reason, the same exact line now underlines the "with" in red with this error: The method with(IProperty<T>, V) in the type StateHolder<Block,BlockState> is not applicable for the arguments (DirectionProperty, ChunkPaletteFormat.Direction) Any idea why that happens? I ported another mod of mine utilizing ".with(StairsBlock:FACING, Direction.SomeDirection)", I checked that code, I'm doing it exactly like that there, and that mod compiled fine. Any ideas on what could be the issue here? It seems to be a Problem with the DirectionProperty, as it works with the WallBlock Property for example, it also works fine with the .WATTERLOGGED property of the stairs block, but not with the FACING property for some reason
  7. Alright, I figured it out on my own, but I'll leave this explanation here for anyone else that might encounter a problem with renderlayers, as there is no good guide on how they work out there I feel like! Firstly, you have to add your layer only once, not multiple times! The layer "stays" in the renderer, add it again in the next tick and it will be there twice, and then thrice and so on. This will seriously impact performance, so don't do that! I'm not sure whether this layer has to be added per player or just once and then all playerentities have access to it? Some clarification on that by someone else would be nice! Either way, if you try to do what I did, you'll probably also just copy the ElytraLayer class. Now that's where my problem was, the class checks whether the player is wearing an elytra, removing that fixed my issue. Also, for anyone else asking themselves how to tell the game what to render or what not to render, that's how you do it! There is no function you need to call, you just surround your model with an if statement containing it's render condition. That way you control when it should be rendered and when it shouldn't! That's it! I would like some clarification on the question I asked earlier in this paragraph though, if at all possible, that would be neat!
  8. Huh, that's rather strange, I felt like your jsons look weird, but I guess that's actually how they're supposed to look then. You do seem to apply one less texture though in your model class, I'm counting 3 lines in yours and 4 in the loom's model class, might that be it? Maybe it's erroring out because one of the directions it needs isn't defined Edit: Unless I am completely wrong, this might be the problem: public static final RegistryObject<Block> TRADE_TERMINAL = BLOCKS.register("trade_terminal", () -> new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).sound(SoundType.STONE))); You initialize a regular Block here, instead of your custom one
  9. I think your jsons are wrong, both of them probably. Just look at the json files of a vanilla block that does what you want and copy that would be my suggestion. As an example, here are the crafting table jsons: That the blockstate I believe: { "variants": { "": { "model": "block/crafting_table" } } } And this is the model: { "parent": "block/cube", "textures": { "particle": "block/crafting_table_front", "down": "block/oak_planks", "up": "block/crafting_table_top", "north": "block/crafting_table_front", "east": "block/crafting_table_side", "south": "block/crafting_table_side", "west": "block/crafting_table_front" } } Try that I guess! Edit: Just checked, you are using a "HorizontalBlock", so just check the jsons of any vanilla HorizontalBlock, the Crafting Table might be something else!
  10. Alright, so I've searched for quite a while now, but I haven't found anything that significantly helped me, so I thought I'd just ask here instead. I have an ArmorItem that works as intended, I can equip it onto the chest slot and it renders the checkerboard error texture (as intended). Now, I'm developing for 1.15, but I'd take any help, as 1.15 doesn't have a lot of mappings so far, so if you know how to do it in 1.14, go ahead and explain how to do what I'd like to do in 1.14, that might also help me, working without mappings is hard. I would like to render my armor with the elytra model + texture instead of the "default" armor model, and I've gathered to do what I want I'll have to swap render layers/add my own render layer. So far I have copied the ElytraLayer class 1:1 into my own class to later modify to my liking, however I don't quite get how I get it to "show up" so to speak. This is the code I have for that so far: @SubscribeEvent public void renderPlayerEvent(RenderPlayerEvent event) { PlayerEntity p = event.getPlayer(); ItemStack stack = p.getItemStackFromSlot(EquipmentSlotType.CHEST); if(stack.getItem() instanceof ItemCustomChestplate) { event.getRenderer().addLayer(new LayerCustomChestplate<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>(event.getRenderer())); } } From what I've gathered so far, the addLayer call might not actually belong there, as it would keep adding the layer, instead something else has to go there. So what I need to know (I think anyways) is: Where do I add my renderlayer, how do I deactivate the default armor render layer (if necessary) and how do I then activate my custom renderlayer for my item? I believe the code checking for my custom item in the chestplate slot should be fine as is, and I already tested whether the EventHandler gets called, that does happen, but I believe the addLayer Part is wrong. Any help?
  11. Thanks a lot, I just tested it and I think this fixed it! But wow, this is some strange stuff and very inconsistent, I assume it is a bug of some kind maybe? On the client my files load absolutely fine from the assets folder, very strange indeed. Well, thanks either way, that should finally fix my problems
  12. Alright, I tried this, however I am a bit puzzled now. I think it works, kind of atleast. First of all, I'm assuming this is the correct way to add my ServerStartedEvent void to the EventBus Listeners, right? MinecraftForge.EVENT_BUS.addListener(this::dedicatedServerSetup); Now, it does execute the code, however suddenly I get a file not found exception, even though the client can find the files no problem, using exact same filename and path structure of "modid:foldername/file.extension". Does the ResourceManager work differently in the context of the ServerStartedEvent for some reason? I am assuming so, considering my file is suddenly no longer found (it is located in assets/slashking/instahouses/blueprint/blueprintfile.bp btw, but as I said, on the client I can load all of the files no problem). What kind of path would I give to this Resource Manager to find my files?
  13. Hello everyone, I essentially built a custom file format for loading in structures for a mod of mine. It is all working fine and dandy, atleast on the client side of things. I have problems on servers though. On a client, I simply use ResourceLocation loc = new ResourceLocation("instahouses:blueprint/example.bp"); InputStream in; try { in =Minecraft.getInstance().getResourceManager().getResource(loc).getInputStream(); ... } in the "private void setup(final FMLCommonSetupEvent event)" block. This works absolutely as expected and I can then utilize the InputStream for my needs. I found out, that I will have to (probably) use ServerLifecycleHooks.getCurrentServer().getResourceManager().getResource(loc).getInputStream(); Instead of the Minecraft.getInstance() code above for loading on servers. Nothing I tried worked properly though. My current setup is this: In setup, I check whether I am on a Dist.CLIENT, and incase this is true I load the files using Minecraft.getInstance()... I now have created this for servers: public void dedicatedServerSetup(FMLDedicatedServerSetupEvent event) { ResourceLocation loc = new ResourceLocation("instahouses:blueprint/example.bp"); InputStream in; try { in =ServerLifecycleHooks.getCurrentServer().getResourceManager().getResource(loc).getInputStream(); } catch (IOException e) { e.printStackTrace(); } } However if I try to run this on a server, I get the following crash log: Does anyone know either what I could instead use to load my files, or when during/after setup/or alternatively any other time when the game is still starting up I could properly use ServerLifecycleHooks? Thanks in advance!
×
×
  • Create New...

Important Information

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