-
Posts
94 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Zacomat
-
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
-
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"); } }
-
Found InputEvent.MouseButton.Pre that should work better than read input directly. Thx
-
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?
-
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?
-
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()
-
Thank you very much Is it possible to make a multi line component (if exists)? to be rendered as platename?
-
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
-
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!
-
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.
-
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
-
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
-
Thx! It works now
-
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
-
How do you do this for 1.19?
-
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!
-
Thanks warjort! You have been very helpful as always!
-
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
Zacomat replied to Zacomat's topic in Modder Support
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
Zacomat replied to Zacomat's topic in Modder Support
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); -
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
Zacomat replied to Zacomat's topic in Modder Support
Yes but it returns boolean. I want a long tick... There are other ways i'm investigating... -
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!
-
Ok i've added a dummy FishingHook too. When instanced the field private boolean openWater is true. The dummyHook goes in the loot context as THIS_ENTITY. It seems to work! I made many tests. This is the code private List<ItemStack> fish() { FishingHook dummyHook = new FishingHook(EntityType.FISHING_BOBBER, level); ItemStack dummyStack = new ItemStack(Items.FISHING_ROD); dummyStack.setTag(orig); System.err.println("fish: dummyStack=" + dummyStack + " " + dummyStack.getTag()); LootContext.Builder lootcontext$builder = new LootContext.Builder((ServerLevel) level) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(worldPosition)) .withParameter(LootContextParams.TOOL, dummyStack) .withRandom(level.random) .withLuck(fishingLuck) .withParameter(LootContextParams.THIS_ENTITY, dummyHook); System.err.println("fish: fishingLuck=" + fishingLuck); System.err.println("fish: dummyHook.isOpenWaterFishing()=" + dummyHook.isOpenWaterFishing()); FishingHookPredicate pr = FishingHookPredicate.inOpenWater(true); System.err.println("fish: pr matches? " + pr.matches(dummyHook, (ServerLevel) level, Vec3.atCenterOf(worldPosition))); LootContext context = lootcontext$builder.create(LootContextParamSets.FISHING); System.err.println("fish: context.getLootingModifier()=" + context.getLootingModifier()); System.err.println("fish: context.getLuck()=" + context.getLuck()); LootTable loottable = level.getServer().getLootTables().get(BuiltInLootTables.FISHING); System.err.println("fish: loottable.getLootTableId()=" + loottable.getLootTableId()); List<ItemStack> list = loottable.getRandomItems(context); return list; } And ttis is the output: fish: dummyStack=1 fishing_rod {Damage:0,Enchantments:[{id:"minecraft:luck_of_the_sea",lvl:3s}]} fish: fishingLuck=3 fish: dummyHook.isOpenWaterFishing()=true fish: pr matches? true fish: context.getLootingModifier()=0 fish: context.getLuck()=3.0 fish: loottable.getLootTableId()=minecraft:gameplay/fishing update: list=[1 cod] The predicate is unused only for test... Thx very much!!!
-
Hi all! So I have my wonderful, enchantiable fishing net up and running!!! But when I generate the loot, almost always the drop table "minecraft:gameplay/fishing/fish" is choosen and almost never the drop table "minecraft:gameplay/fishing/treasure" is choosen even if I use luck of the sea 3. This is the method in my NetBlockEntity where i get items to spawn: private List<ItemStack> fish() { ItemStack dummyStack = new ItemStack(Items.FISHING_ROD); dummyStack.setTag(orig); System.err.println("fish: dummyStack=" + dummyStack + " " + dummyStack.getTag()); LootContext.Builder lootcontext$builder = new LootContext.Builder((ServerLevel) level) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(worldPosition)) .withParameter(LootContextParams.TOOL, dummyStack) .withRandom(level.random) .withLuck(fishingLuck); System.err.println("fish: fishingLuck=" + fishingLuck); System.err.println("fish: lootcontext$builder=" + lootcontext$builder); LootContext context = lootcontext$builder.create(LootContextParamSets.FISHING); System.err.println("fish: context.getLootingModifier()=" + context.getLootingModifier()); System.err.println("fish: context.getLuck()=" + context.getLuck()); LootTable loottable = level.getServer().getLootTables().get(BuiltInLootTables.FISHING); System.err.println("fish: loottable.getLootTableId()=" + loottable.getLootTableId()); List<ItemStack> list = loottable.getRandomItems(context); return list; } and this is the output: fish: dummyStack=1 fishing_rod {Damage:0,Enchantments:[{id:"minecraft:luck_of_the_sea",lvl:3s}]} fish: fishingLuck=3 fish: lootcontext$builder=net.minecraft.world.level.storage.loot.LootContext$Builder@642e2643 fish: context.getLootingModifier()=0 fish: context.getLuck()=3.0 fish: loottable.getLootTableId()=minecraft:gameplay/fishing update: list=[1 pufferfish] What is the value to pass to lootcontext$builder..withLuck()? It seems that the level of the enchantment (int fishingLuck in my case) is not working... The loot is very different from that obtained with fishing with an enchanted fishing rod. Thx.