Jump to content

Zacomat

Members
  • Posts

    58
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://www.patreon.com/user?u=4995675
  • Personal Text
    I am new!

Recent Profile Visitors

7247 profile views

Zacomat's Achievements

Stone Miner

Stone Miner (3/8)

1

Reputation

  1. 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
  2. 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
  3. 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!
  4. Thanks warjort! You have been very helpful as always!
  5. 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
  6. 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.
  7. 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);
  8. 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); } }
  9. Yes but it returns boolean. I want a long tick... There are other ways i'm investigating...
  10. 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!
  11. 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!!!
  12. 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.
  13. Thank you very much! It was easier than I expected. I added @Override public boolean isEnchantable(ItemStack itemstack) { return true; } too. And implemented @Override public boolean canApplyAtEnchantingTable(ItemStack itemstack, Enchantment e) { return e == Enchantments.FISHING_LUCK || e == Enchantments.FISHING_SPEED || e == Enchantments.UNBREAKING; } @Override public int getEnchantmentValue(ItemStack itemstack) { return 2; } this way.
×
×
  • Create New...

Important Information

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