Everything posted by Zacomat
-
1.19.4 What is the 3rd parameter of Level.setBlock(BlockPos , BlockState , int)
Found it, thanks!
-
1.19.4 What is the 3rd parameter of Level.setBlock(BlockPos , BlockState , int)
I have noticed that the third parameter in Level.setBlock(BlockPos, BlockState, int) is a bitmask. I have seen that the value 3 is often passed, sometimes 11, and I manage to make it work. However, I would like to know if there are any defined constants somewhere that explain these bits. Can anyone help me?
-
1.19.4 Entity Events cllient side
Ok I was trying to make a client side mod that shows how much time is needed for an animal to breed again... But it seems not possible then. Thx
-
1.19.4 Entity Events cllient side
Is there a way to listen to entity events pakets that are sent from server to client? I'm interested to know when an Animal "makes hearts" from server: level.broadcastEntityEvent(this, (byte)18) in Animal.setInLove and Animal.spawnChildFromBreeding to client: public void handleEntityEvent(byte b) in Animal class where heart particles are added I want to listen to this entity event packet... Maybe i have to register a listener to handle packets like this client side? Something like: public class MyGameListener implements ClientGamePacketListener { ... @Override public void handleEntityEvent(ClientboundEntityEventPacket p_131393_) { System.err.println("handleEntityEvent ClientboundEntityEventPacket"); } }
-
1.19.4 read mouse or keyboard input
Found InputEvent.MouseButton.Pre that should work better than read input directly. Thx
-
1.19.4 read mouse or keyboard input
Hi all! Where is the code that reads the input from keyboard or mouse? Is it possible to read them directly instead of using events like RightClickItem or LeftClickEmpty?
-
1.19.4 calculate entity speed
Hi all! I'm trying to calculate the speed of an entity client-side. For example, I calculate the vertical speed like this: vy = entity.getY() - entity.yo. This should give me the speed in blocks per tick. If I want it in blocks per second, should I multiply it by ticks per second, right? But where can I read the ticks per second?
-
1.19.4 Name tag like rendering
Thanks again! Now I have another question: How do I get player reputation with a villager in client side to show in nameplate? I found villager.getPlayerReputation(mc.player) but in client side it gives 0 and I didn't find any attribute for it to use with entity.getAttribute()
-
1.19.4 Name tag like rendering
Thank you very much Is it possible to make a multi line component (if exists)? to be rendered as platename?
-
1.19.4 Name tag like rendering
Hello everyone I would like to make a mod that displays more information when targeting a living entity, such as when targeting one that has been renamed with the name tag. For example health, max health, reputation of villagers, etc... Is there an event like the one for itemstack tooltips where you add lines of text and it's done? Or something else? Can anyone point me in the right direction? Thank you
-
Player id
Hi all! I want to use players as keys for a hashmap. Actually I use the name as String: player.getName().getString() But there must be a better field for a unique identifier of the player that I'm missing... Can someone help me plz? Thx!
-
[1.19.2] Automatic local player actions
The main purpose is to satisfy my curiosity and learn new things! However I made the most useful mod: the fishing bot! (ironic tone lol). To make the fishing rod used automatically I used the Minecraft.getInstance().startUseItem() method during the ClientTickEvent using access transformers.
-
1.19.2 Make player perform an animation
Hi all! I want to make the player perform the bow animation when he is holding a compass in main hand. I dont want to subclass compass so i'd like to make it with events: HashSet<Player> players = new HashSet<>(); @SubscribeEvent public void onRightClickItem(RightClickItem event) { Player player = event.getEntity(); Level level = player.getLevel(); if (!player.isUsingItem() && player.getItemInHand(InteractionHand.MAIN_HAND).getItem() == Items.COMPASS) { players.add(player); player.startUsingItem(InteractionHand.MAIN_HAND); event.setCanceled(true); event.setCancellationResult(InteractionResult.sidedSuccess(level.isClientSide)); } } @SubscribeEvent public void onLivingEntityUseItemEvent(LivingEntityUseItemEvent.Start event) { if (players.contains(event.getEntity())) { System.err.println("### Start"); event.setDuration(100); //start perform bow animation with a compass in hand } } @SubscribeEvent public void onLivingEntityUseItemEvent(LivingEntityUseItemEvent.Tick event) { if (players.contains(event.getEntity())) { System.err.println("### Tick duretion=" + event.getDuration()); //update pulling animation } } @SubscribeEvent public void onLivingEntityUseItemEvent(LivingEntityUseItemEvent.Stop event) { if (players.contains(event.getEntity())) { System.err.println("### Stop"); //stop pulling animation players.remove(event.getEntity()); } } @SubscribeEvent public void onLivingEntityUseItemEvent(LivingEntityUseItemEvent.Finish event) { if (players.contains(event.getEntity())) { System.err.println("### Finish"); //stop pulling animation and do something players.remove(event.getEntity()); } } This seems to work but i dont know how to make the player perform that animation. Any suggestion? Thx
-
[1.19.2] Automatic local player actions
Hi all! How can I make the LocalPlayer perform an action without user intervention? For example use the itemstack in the main hand? Or jump? Thx
-
[1.19.2][Solved] Access Transformers
Thx! It works now
-
[1.19.2][Solved] Access Transformers
Hi all! I want to access the field of the class net.minecraft.world.entity.projectile.FishingHook private static final EntityDataAccessor<Boolean> DATA_BITING = SynchedEntityData.defineId(FishingHook.class, EntityDataSerializers.BOOLEAN); According to documentation i created the file src/main/resources/META-INF/accesstransformer.cfg which contains only one line: public net.minecraft.world.entity.projectile.FishingHook DATA_BITING And added in forge-1.19.2-43.1.7-mdk/build.gradle ... minecraft { accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') ... Now in my mod i try to access that variable private FishingHook fishingHook; @SubscribeEvent public void onTick(ClientTickEvent event) { if (fishingHook != null) { if (fishingHook.isRemoved()) { fishingHook = null; return; } SynchedEntityData data = fishingHook.getEntityData(); EntityDataAccessor<Boolean> accessor = FishingHook.DATA_BITING; Boolean biting = data.get(accessor); System.err.println("biting=" + biting); } } But the compiler says the variable is not visible. what else do i need to do to make the access transformers work? Run genEclipseRun or eclipse? Thx
-
Using "config" button in Mods menu
How do you do this for 1.19?
-
1.19 Rendering blocks with custom textures
Hello everyone! I have a Block with its bBockEntity. I would like to draw it with textures that depend on the BlockEntity parameters instead of those of the BlockState. The code I use to draw the block is: blockState = NetMod.NET_BLOCK.get().defaultBlockState(); vertexconsumer = VertexMultiConsumer.create(buffer.getBuffer(RenderType.glint()), buffer.getBuffer(RenderType.cutout())); pose.pushPose(); pose.translate(0.005f, 0.005f, 0.005f); pose.scale(0.99f, 0.99f, 0.99f); dispatcher.getModelRenderer().tesselateBlock(level, model, blockState, be.getBlockPos(), pose, vertexconsumer, false, level.getRandom(), light, overlay); pose.popPose(); The RenderType.cutout () does not allow me to specify different textures and the one defined in the blockState is taken i think. I could solve it by declaring many models for each parameter, but it seems to me an impossible path if the parameters are many ... Is there another way? Thank you all!
-
[SOLVED] [1.19] glint rendering
Thanks warjort! You have been very helpful as always!
-
[SOLVED] [1.19] glint rendering
Hello everyone! I know how to draw a model using a custom texture. In this example I draw a book like in the enchantment table in my method render in my BlockEntityRenderer: pose.pushPose(); pose.translate(0.5D, 1.0625D, 0.5D); pose.mulPose(Vector3f.YP.rotationDegrees(0)); pose.mulPose(Vector3f.ZP.rotationDegrees(67.5F)); pose.translate(0.0D, -0.125D, 0.0D); bookModel.setupAnim(0.0F, 0.1F, 0.9f, 1.2F); VertexConsumer vertexconsumer = buffer.getBuffer(RenderType.entitySolid(bookTexture)); bookModel.render(pose, vertexconsumer, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); pose.popPose(); Now I'm looking for a way to draw the book with its texture and with the added glint effect like that of enchanted items. Can anyone tell me what is the right RenderType if there is any? Or is there another way? Thank you all
-
Porting from TileEntityRenderer 1.16 to BlockEntityRenderer 1.19
No problem for performance. I'll do it later. I just want an example running... What i still dont understand is how and where to set a custom texture before rendering a model.
-
Porting from TileEntityRenderer 1.16 to BlockEntityRenderer 1.19
Thx! Very interesting! So let's say i want to render an enchanting table book in my render function i added this: public void render(NetBlockEntity be, float partial, PoseStack pose, MultiBufferSource buffer, int light, int overlay) { BookModel model = new BookModel(context.bakeLayer(ModelLayers.BOOK)); pose.pushPose(); pose.translate(0.5D, 1.0625D, 0.5D); pose.mulPose(Vector3f.YP.rotationDegrees(0)); pose.mulPose(Vector3f.ZP.rotationDegrees(67.5F)); pose.translate(0.0D, -0.125D, 0.0D); model.setupAnim(0.0F, 0.1F, 0.9f, 1.2F); RenderSystem.setShaderTexture(0, new ResourceLocation("textures/entity/enchanting_table_book")); RenderSystem.setShaderColor(1f, 1f, 0f, 0.5f); VertexConsumer vertexconsumer = sprite().wrap(buffer.getBuffer(RenderType.entityCutout(BLOCK_ATLAS))); model.render(pose, vertexconsumer, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); pose.popPose(); } but the texture is from my block. The texture specified in RenderSystem.setShaderTexture(0, new ResourceLocation("textures/entity/enchanting_table_book")) is not used... Nor colors worked: RenderSystem.setShaderColor(1f, 1f, 0f, 0.5f);
-
Porting from TileEntityRenderer 1.16 to BlockEntityRenderer 1.19
Hello everyone! I want to port my old TileEntityRenderer from version 1.16 to 1.19. It seems like a lot of things have changed in the rendering system and I can't find any documentation about it. The block is drawn automatically since FishingnetBlock#getRenderType returns BlockRenderType.MODEL. This drawing includes only the faces of the cube. In my tile entity renderer I want to draw two additional rectangles as specified in the FishingnetModel class below. These rectangles are oriented at an angle specified in my tile entity. The textures of the rectangles depend on a parameter of my tile entity. Can anyone help me do this update? Where can I find documentation on the 1.19 rendering system? Thank you all. This is the code of the FishingnetTileEntityRenderer class: package com.polipo.fishing_net.client.renderer.tileentity; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.polipo.fishing_net.FishingnetMod; import com.polipo.fishing_net.client.renderer.model.FishingnetModel; import com.polipo.fishing_net.tileentity.FishingnetTileEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.ResourceLocation; public class FishingnetTileEntityRenderer extends TileEntityRenderer<FishingnetTileEntity> { FishingnetModel model = new FishingnetModel(); ResourceLocation[] textures = { new ResourceLocation(FishingnetMod.MODID + ":textures/block/net0.png"), new ResourceLocation(FishingnetMod.MODID + ":textures/block/net1.png"), new ResourceLocation(FishingnetMod.MODID + ":textures/block/net2.png"), new ResourceLocation(FishingnetMod.MODID + ":textures/block/net3.png"), new ResourceLocation(FishingnetMod.MODID + ":textures/block/net4.png"), new ResourceLocation(FishingnetMod.MODID + ":textures/block/net5.png"), }; public FishingnetTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) { super(rendererDispatcherIn); } @Override public void render(FishingnetTileEntity tileEntityNet, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { int textureIndex = tileEntityNet.getItemsCount(); if (textureIndex > textures.length - 1) { textureIndex = textures.length - 1; } if (textureIndex < 0) { textureIndex = 0; } renderDispatcher.textureManager.bindTexture(textures[textureIndex]); model.rotateY(tileEntityNet.facing); IVertexBuilder ivertexbuilder = bufferIn.getBuffer(model.getRenderType(textures[textureIndex])); model.render(matrixStackIn, ivertexbuilder, combinedLightIn, combinedOverlayIn, 1, 1, 1, 1); } } and this is the code of the FishingnetModel class: package com.polipo.fishing_net.client.renderer.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; public class FishingnetModel extends Model { ModelRenderer shape1; ModelRenderer shape2; public FishingnetModel() { super(RenderType::getEntityCutoutNoCull); textureWidth = 64; textureHeight = 64; shape1 = new ModelRenderer(this); shape1.setTextureSize(64, 64); shape1.setTextureOffset(0, 32); shape1.setRotationPoint(8, 0, 8); shape1.mirror = false; shape1.rotateAngleX = 0; shape1.rotateAngleY = 0.785f; shape1.rotateAngleZ = 0; shape1.addBox(-11, 0, 0, 22, 16, 0); shape2 = new ModelRenderer(this); shape2.setTextureSize(64, 64); shape2.setTextureOffset(0, 48); shape2.setRotationPoint(8, 0, 8); shape2.mirror = false; shape2.rotateAngleX = 0; shape2.rotateAngleY = 2.356f; shape2.rotateAngleZ = 0; shape2.addBox(-11, 0, 0, 22, 16, 0); } public void rotateY(int facing) { shape1.rotateAngleY = 0.0245f * facing; shape2.rotateAngleY = 1.570f + 0.0245f * facing; } @Override public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { shape1.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); shape2.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); } }
-
1.19 how to get scheduled tick for a given BlockPos
Yes but it returns boolean. I want a long tick... There are other ways i'm investigating...
-
1.19 how to get scheduled tick for a given BlockPos
Hi all! I want to schedule a tick for my block but only if it is before a scheduled tick if already exists. Is there a way to get the next scheduled tick for a given Block in a given BlockPos? Thx all!
IPS spam blocked by CleanTalk.