Jump to content

PianoManu

Members
  • Posts

    31
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Germany
  • Personal Text
    Obese Platypus

Recent Profile Visitors

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

PianoManu's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I'm sorry I scared you with my stupidity 😛 Many thanks for your help!
  2. Hey guys, I'm updating my mod to 1.19 and I realized, the "getRegistryName()" method for blocks and items anymore. I guess there's a new way for that I don't know about yet? To be more specific, I've created a block overriding the use(...) method, and I want to check in there, whether the held item is from my own mod (then nothing should happen). In 1.18 and prior I achieved this via public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitresult) { //The item the player is holding Item item = player.getItemInHand(hand).getItem(); if (!level.isClientSide) { //compare namespace of item whether it is from my mod -> then nothing should happen if(item.getRegistryName().getNamespace().equals(BlockCarpentryMain.MOD_ID)) { return InteractionResult.PASS; } ... } } But now the getRegistryName() can't be called anymore and the ForgeRegistryEntry class seems to be gone. So my question is: Is there a new or different method now? Or should I do something completely different to retrieve the item's origin? As always, many thanks in advance for your help! Regards, Manu
  3. You're awesome! Thank you so much for your help, this fixed it for me! Regards, Manu This topic can be closed now, as the problem is solved.
  4. public class RenderSetup { public static void setup() { ... ItemBlockRenderTypes.setRenderLayer(Registration.STAIRS_FRAMEBLOCK.get(), RenderType.translucent()); ... } } Here's what I'm currently doing in my setup class. And the setup() method is called when the FMLClientSetupEvent is fired. The "..." are similar lines I removed, because the only things that change, are the blocks in the first parameter... As I said, I already used RenderType.solid() and RenderType.cutout() and although it changed the model's appearance, it did not fix the problem. Or perhaps I misunderstood you? In that case, could you please be more specific, what I should do? Many thanks for your help! Regards, Manu
  5. Hey guys! I encountered the following problem when updating my mod from 1.16 to 1.17: If I place a block of my mod (e.g. stairs) in front of another block, the hidden side of the back block is not rendered. It worked perfectly on 1.16, the problem only appeared when I moved to 1.17. I have already tried setting the render layer of the blocks from translucent to solid and to cutout, but nothing has changed. The main feature of my mod is that the blocks of my mod (frames) can take the texture of any block. If I then take a transparent block (e.g. red stained glass) and "disguise" the frame stairs with it, you can see that on all sides that are completely covered by the stairs, the blocks behind them become invisible. (see 2nd picture) But on the side that is only covered to 3/4, the grass block behind is visible through the "red stained glass stairs" (see 3rd picture), which is correct. For the stairs used in the first picture, a classic json model is used; when the stairs are disguised (2nd and 3rd picture), I created a BakedModel. Please let me know, if you need more information or specific code parts. It looks to me like I'm missing on something very obvious, so I'm sorry if this question is stupid... please don't be mad at me Here's my github repository: https://github.com/PianoManu/BlockCarpentry/tree/Forge-1.17 The block's main class is mod.pianomanu.blockcarpentry.block.StairsFrameBlock The class where I created the baked model is mod.pianomanu.blockcarpentry.bakedmodels.StairsBakedModel I'm setting the render layers in mod.pianomanu.blockcarpentry.setup.RenderSetup All blocks and items are registered in mod.pianomanu.blockcarpentry.setup.Registration Thanks in advance!! Regards, Manu
  6. Hey, thank you very much for your tip! Your approach was very veeeeeery helpful. That gave me a good idea and it works now, although I've chosen a slightly different way. This is how I solved the problem: At first I took a look into the PlayerEvent class (which is highly documentated, special thanks to whoever did that - it is unfortunately not very common), so I had the idea to search for some sort of "WorldEvent" class and check, whether it contains some useful events, and tah-dah, it contains a static class "WorldEvent.Load", where I can get an IWorld-instance, that features a player list. (The WorldEvent class is also documented pretty well, thanks again, you've made it easy for me!) I concluded, that I have to listen for both events, since I need the world (with the player list) and the player entity (to check, whether he is already registered in said list. The exact code looks like this: @SubscribeEvent public void playerLogginIn(final PlayerEvent.PlayerLoggedInEvent event) { //listen for "logging in"-event ServerPlayerEntity player = (ServerPlayerEntity) event.getPlayer(); if (!world.players().contains(player)) { //check whether the player (who is logging in) is already listed in the list of players on this world ServerWorld deepDark = player.server.getLevel(DDDMain.DEEP_DARK_DIMENSION); //if it's not the case (i.e. the player is new to this world), we need to teleport the player to this dimension instead if (deepDark != null) { DDDTeleporter teleporter = new DDDTeleporter(DDDConfig.SPAWN_POS); teleporter.setOverworldTeleporterPos(player.blockPosition()); player.setPos(DDDConfig.SPAWN_POS.getX(), DDDConfig.SPAWN_POS.getY(), DDDConfig.SPAWN_POS.getZ()); player.changeDimension(deepDark, teleporter); } } } @SubscribeEvent public void playerLoadsWorld(final WorldEvent.Load event) { //is called before "playerLoggingIn", so we can collect the world the player is joining world = event.getWorld(); //world is a private static IWorld-variable } After that, I registered this class to the MinecraftForge.EVENT_BUS in my Main class between "enqueueIMC" and "processIMC". I hope this was correct, I'm not quite sure where to put it, but it's working, so I think it should be okay. (Pls correct me if I'm wrong) Thanks again to you @ChampionAsh5357 for your helpful tip ❤️ Kind regards, Manu
  7. Hey guys, I made a custom dimension and everything is working completely fine (like world-generation, entering and exiting the dimension via portal block, respawning in the dimension, etc.), so I had the idea that after creating a new world, the player would start directly in my dimension instead of in the overworld. How could I achieve this? Thanks in advance, and kind regards, Manu Edit: if you need my github repository, here it is!
  8. Hey guys! I have some problems with the RenderLayers when testing my mod together with OptiFine. Some backstory: I made blocks, that can take on the model of any block using a tileentity that "stores" said block, and I also created baked models for all of them. It worked fine for solid blocks but not for transparent blocks, as they lose their transparency (see below). So I decided to change the RenderLayer to "translucent" using RenderTypeLookup.setRenderLayer(Registration.FRAMEBLOCK.get(), RenderType.getTranslucent()); where FRAMEBLOCK is the corresponding RegistryObject and "Registration" is the class where I register all my blocks and items. Right now it looks like that: (below you can see the "empty" frame blocks, namely cube, slab and stairs) You can right-click them to change the texture to the texture of the block you're holding. As I said, I used baked models to achieve the "mimicking"-effect. As you can see, it works fine, but only without OptiFine. When I use OptiFine, all my blocks are invisible and you can only see the black boundary box. I guess, it has something to do with the render layers, because I changed the RenderLayer for the "cube"-block to "solid", and the model is being rendered, again (but without transparency, see below) (Same three blocks, but I changed the RenderLayer-Type to "solid" for the cube block, the other two blocks - glass slab and stairs - are invisible, probably because of them being "translucent" and I guess OptiFine changes something how baked models are rendered) Now my question is: what can I do to make it work when using OptiFine? I already tried using "cutout" and "cutout-mipped" render types, but it wont change anything, the blocks stay invisible... Any help is appreciated. Regards, Manu If you want to take a look at the baked model: https://pastebin.com/MVPR7JW0 In case you need it, this is the github repository of my mod: https://github.com/PianoManu/BlockCarpentry/tree/Forge-1.16.2
  9. Thanks to you both @Beethoven92 and @Draco18s. That fixed my problem and helped a lot!
  10. Hey guys! I ran into some obstinate NoSuchMethodError today whilst testing my mod on a server (locally). I made a block with a tile entity, that mimics another block when it's right-clicked with said block. When I break the block containing the other block, my method "dropContainedBlock" is called to spawn an ItemEntity of the mimicked block. Now that is where I get the NoSuchMethodError exception and the server crashes. Here's my method. I mainly copied it from the vanilla jukebox, but the jukebox works a bit different because it "stores" only records, not blocks: //Used to drop the contained block //We check the tile entity, get the block from the tile entity and drop it at the block pos plus some small random coords in the world protected void dropContainedBlock(World worldIn, BlockPos pos) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof FrameBlockTile) { FrameBlockTile frameTileEntity = (FrameBlockTile) tileentity; //My custom tile entity BlockState blockState = frameTileEntity.getMimic(); //the contained blockstate if (!(blockState == null)) { worldIn.playEvent(1010, pos, 0); //some coords to spawn the item entity double d0 = (double) (worldIn.rand.nextFloat() * 0.7F) + (double) 0.15F; double d1 = (double) (worldIn.rand.nextFloat() * 0.7F) + (double) 0.060000002F + 0.6D; double d2 = (double) (worldIn.rand.nextFloat() * 0.7F) + (double) 0.15F; ItemStack itemstack1 = blockState.getBlock().asItem().getDefaultInstance(); //<---- THAT IS WHERE I GET THE ERROR ItemEntity itementity = new ItemEntity(worldIn, (double) pos.getX() + d0, (double) pos.getY() + d1, (double) pos.getZ() + d2, itemstack1); itementity.setDefaultPickupDelay(); worldIn.addEntity(itementity); //this should spawn the item entity - works fine in singleplayer but not on servers frameTileEntity.clear(); //resets my tile entity } } } } It works fine in singleplayer, but when I tried it on a local server, it crashes. I get the following error: "java.lang.NoSuchMethodError: net.minecraft.item.Item.func_190903_i()Lnet/minecraft/item/ItemStack;". This "func_190903_i()" has to be the "getDefaultInstance()"-method, it is annotated as @OnlyIn(Dist.CLIENT) and I guess that's the reason why it does not work on servers. Now my question: How do I get it to work on servers? Sorry if this is dumb, I'm pretty new and inexperienced... Regards, Manu In case you need the complete crash report: https://pastebin.com/hAa3Mcfz
  11. Oh okay, I didn't know this. I'll continue experimenting with this. Glass was the more important block right now. Thank you very much for your help! Regards, Manu
  12. I'm so stupid, you're right. Thank you so much! It works for glass, but the ice fence is still not translucent... I've changed the alpha value to 0.0f and it's working fine for glass. I also changed the render layer as you said: public static void setup() { RenderTypeLookup.setRenderLayer(Registration.FENCE_FRAMEBLOCK.get(), RenderType.getTranslucent()); } This method is called when the FMLClientSetupEvent is fired. Did I forget something concerning the ice block? As I wrote in the first post, it only needs to be translucent for ice and glass blocks and it is already very nice, that it works for glass. Thank you so much! Regards, Manu
  13. Hey guys, I'm again having a question concerning baked quads/models. How do I create transparent quads? This fence block I created takes the texture of the block it is clicked with (it can mimic blocks), but for glass and ice, the block appears solid. How can I make them transparent? Here you can see an example screenshot of the problem so far. I made a class that implements IDynamicBakedModel and for the getQuads(...)-method I made a method "createCuboid()" that returns a list of baked quads The createCuboid(...)-method: public static List<BakedQuad> createCuboid(float xl, float xh, float yl, float yh, float zl, float zh, TextureAtlasSprite texture, int tintIndex) { List<BakedQuad> quads = new ArrayList<>(); //Eight corners of the block Vec3d NWU = v(xl, yh, zl); //North-West-Up Vec3d NEU = v(xl, yh, zh); //... Vec3d NWD = v(xl, yl, zl); Vec3d NED = v(xl, yl, zh); Vec3d SWU = v(xh, yh, zl); Vec3d SEU = v(xh, yh, zh); Vec3d SWD = v(xh, yl, zl); Vec3d SED = v(xh, yl, zh); //South-East-Down //following if statements check whether one of the values goes over the block bounds -> increment/decrement them if (xl < 0) { xl++; } if (xh > 1) { xh--; } if (yl < 0) { yl++; } if (yh > 1) { yh--; } if (zl < 0) { zl++; } if (zh > 1) { zh--; } //six faces of the block, createQuad(...)-method is shown below // 1st vector, 2nd, 3rd, 4th, , small u, high u, small v, high v, quads.add(createQuad(NWU, NEU, SEU, SWU, texture, xl * 16, xh * 16, zl * 16, zh * 16, tintIndex)); quads.add(createQuad(SWD, SED, NED, NWD, texture, xl * 16, xh * 16, zl * 16, zh * 16, tintIndex)); quads.add(createQuad(SWU, SWD, NWD, NWU, texture, xl * 16, xh * 16, 16 - yh * 16, 16 - yl * 16, tintIndex)); quads.add(createQuad(NEU, NED, SED, SEU, texture, xl * 16, xh * 16, 16 - yh * 16, 16 - yl * 16, tintIndex)); quads.add(createQuad(NWU, NWD, NED, NEU, texture, zl * 16, zh * 16, 16 - yh * 16, 16 - yl * 16, tintIndex)); quads.add(createQuad(SEU, SED, SWD, SWU, texture, zl * 16, zh * 16, 16 - yh * 16, 16 - yl * 16, tintIndex)); return quads; } The createQuad(...)-method: private static BakedQuad createQuad(Vec3d v1, Vec3d v2, Vec3d v3, Vec3d v4, TextureAtlasSprite sprite, float ulow, float uhigh, float vlow, float vhigh, int tintIndex) { //normal vector for vertices and orientation Vec3d normal = v3.subtract(v2).crossProduct(v1.subtract(v2)).normalize(); BakedQuadBuilder builder = new BakedQuadBuilder(sprite); builder.setQuadOrientation(Direction.getFacingFromVector(normal.x, normal.y, normal.z)); //I've tried adding diffuse lighting but it didn't change much builder.setApplyDiffuseLighting(true); //only for tintable blocks like grass if (tintIndex > -1) { builder.setQuadTint(tintIndex); } //constructing vertices for the quad putVertex(builder, normal, v1.x, v1.y, v1.z, ulow, vlow, sprite, 1.0f, 1.0f, 1.0f); putVertex(builder, normal, v2.x, v2.y, v2.z, ulow, vhigh, sprite, 1.0f, 1.0f, 1.0f); putVertex(builder, normal, v3.x, v3.y, v3.z, uhigh, vhigh, sprite, 1.0f, 1.0f, 1.0f); putVertex(builder, normal, v4.x, v4.y, v4.z, uhigh, vlow, sprite, 1.0f, 1.0f, 1.0f); return builder.build(); } And the putVertex(...)-method: private static void putVertex(BakedQuadBuilder builder, Vec3d normal, double x, double y, double z, float u, float v, TextureAtlasSprite sprite, float r, float g, float b) { //lift of all vertexFormatElements saved in the builder and created in the makeQuads(...)-method ImmutableList<VertexFormatElement> elements = builder.getVertexFormat().getElements().asList(); for (int j = 0; j < elements.size(); j++) { //iterate through all elements and get the usage, add the corresponding values VertexFormatElement e = elements.get(j); switch (e.getUsage()) { case POSITION: builder.put(j, (float) x, (float) y, (float) z, 1.0f); break; case COLOR: builder.put(j, r, g, b, 1.0f); break; case UV: switch (e.getIndex()) { case 0: float iu = sprite.getInterpolatedU(u); float iv = sprite.getInterpolatedV(v); builder.put(j, iu, iv); break; case 2: builder.put(j, (short) 0, (short) 0); break; default: builder.put(j); break; } break; case NORMAL: builder.put(j, (float) normal.x, (float) normal.y, (float) normal.z); break; default: builder.put(j); break; } } } For this method, I've got some help from a tutorial by TurtyWurty Now as I said, I'm trying to get transparent quads. How would I achieve that? Thanks in advance, Manu
×
×
  • Create New...

Important Information

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