Jump to content

Maciej916

Members
  • Posts

    57
  • Joined

  • Last visited

Posts posted by Maciej916

  1. How I can use multiple texture locations while drawing gui elements. I know how to use only one texture. Please be tolerant Im trying to learn something new.

     

        @Override
        protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) {
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            getMinecraft().getTextureManager().bindTexture(BACKGROUND_TEXTURE);
    
            int startX = this.guiLeft;
            int startY = this.guiTop;
            this.blit(startX, startY, 0, 0, this.xSize, this.ySize);
    
            this.blit(x, y, u, v, width, height);
    
    		// How can i draw another element here using other texture than "BACKGROUND_TEXTURE"
          
        }

     

  2. I tried to use DistExecutor but error remain the same:

     

        public void handle(Supplier<NetworkEvent.Context> ctx) {
            ctx.get().enqueueWork(() -> {
    
                DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
                    
                    PlayerEntity player = Minecraft.getInstance().player;
                    IEnchants enchantsCap = PlayerUtil.getEnchantsCapability(player);
                    enchantsCap.setMultiJump(multiJump);
    
                });
            });
            ctx.get().setPacketHandled(true);
        }

     

  3. Hello I want to sent packet from server to client and everything is working in single player but mod don't want to start on dedicated server because in packet I use Minecraft class. How can I fix this, can I use @OnlyIn()

     

     

    public class PacketMultiJumpSync {
    
        private final int multiJump;
    
        public PacketMultiJumpSync(int multiJump) {
            this.multiJump = multiJump;
        }
    
        public PacketMultiJumpSync(PacketBuffer buf) {
            multiJump = buf.readInt();
        }
    
        public void toBytes(PacketBuffer buf) {
            buf.writeInt(multiJump);
        }
    
        public void handle(Supplier<NetworkEvent.Context> ctx) {
            ctx.get().enqueueWork(() -> {
                PlayerEntity player = Minecraft.getInstance().player;
                IEnchants enchantsCap = PlayerUtil.getEnchantsCapability(player);
                enchantsCap.setMultiJump(multiJump);
            });
            ctx.get().setPacketHandled(true);
        }
    }

     

    INSTANCE.registerMessage(nextID(), PacketMultiJumpSync.class, PacketMultiJumpSync::toBytes, PacketMultiJumpSync::new, PacketMultiJumpSync::handle);

     

  4. I want to change amount of item drops and i want to do that by using BlockEvent.HarvestDropsEvent but it seems like it's never called and idk why. It's weird because i have other BlockEvents  in this class and they work just fine. My forge version is 28.1.90

     

        @SubscribeEvent(priority = EventPriority.HIGHEST)
        public static void onHarvest(BlockEvent.HarvestDropsEvent event) {
            // not working
        }
    
        @SubscribeEvent(priority = EventPriority.HIGHEST)
        public static void onPlace(BlockEvent.EntityPlaceEvent event) {
            // working
    
        }
    
    
        @SubscribeEvent
        public static void onBreak(BlockEvent.BreakEvent event) {
            // working
        }

     

  5. Hello I want to add new enchant from my mod to my mod creative tab but i don't know how to do that.

     

    for (final Enchantment enchantment : ForgeRegistries.ENCHANTMENTS.getValues()) {
      final ResourceLocation enchantmentRegistryName = enchantment.getRegistryName();
      if (!enchantmentRegistryName.getNamespace().equals(MyMod.MODID)) {
      	continue;
      }
      final Item.Properties properties = new Item.Properties().group(MOD_ITEM_GROUP);
    
      // how to set ItemGroup
    }

     

  6. Hello, Im having trouble to teleport player from the end to overworld. For example if player teleport from end to nether it or from nether to overworld it works just fine but if player wants to teleport from end to overworld it always teleport him to spawn location not coordinates i want to.

    Here is code what i use:

        public static void teleportPlayer(ServerPlayerEntity player, Location loc, boolean exact) {
            if (player.dimension.getId() != loc.dim) {
                player.changeDimension(DimensionType.getById(loc.dim));
            }
            ServerWorld world = player.getServerWorld();
            if (exact) {
                player.teleport(world, loc.posX, loc.posY, loc.posZ, loc.rotationYaw, loc.rotationPitch);
            } else {
                player.teleport(world, loc.x + 0.5, loc.y + 0.5, loc.z, player.rotationYaw, player.rotationPitch);
            }
        }

     

×
×
  • Create New...

Important Information

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