Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

i have a block that is very similar to the light block, i need the texture to change depending on the light level the block has i already have the light block thing functional but the only problem is changing the texture. this is the main json for the item.

{
  "parent": "item/generated",
  "textures": {
    "layer0": "mrmod:item/darkness"
  },
  "overrides": [
    { "predicate": { "level": 0.0000 }, "model": "mrmod:item/darkness_00" },
    { "predicate": { "level": 0.0625 }, "model": "mrmod:item/darkness_01" },
    { "predicate": { "level": 0.1250 }, "model": "mrmod:item/darkness_02" },
    { "predicate": { "level": 0.1875 }, "model": "mrmod:item/darkness_03" },
    { "predicate": { "level": 0.2500 }, "model": "mrmod:item/darkness_04" },
    { "predicate": { "level": 0.3125 }, "model": "mrmod:item/darkness_05" },
    { "predicate": { "level": 0.3750 }, "model": "mrmod:item/darkness_06" },
    { "predicate": { "level": 0.4375 }, "model": "mrmod:item/darkness_07" },
    { "predicate": { "level": 0.5000 }, "model": "mrmod:item/darkness_08" },
    { "predicate": { "level": 0.5625 }, "model": "mrmod:item/darkness_09" },
    { "predicate": { "level": 0.6250 }, "model": "mrmod:item/darkness_10" },
    { "predicate": { "level": 0.6875 }, "model": "mrmod:item/darkness_11" },
    { "predicate": { "level": 0.7500 }, "model": "mrmod:item/darkness_12" },
    { "predicate": { "level": 0.8125 }, "model": "mrmod:item/darkness_13" },
    { "predicate": { "level": 0.8750 }, "model": "mrmod:item/darkness_14" },
    { "predicate": { "level": 0.9375 }, "model": "mrmod:item/darkness_15" },
    { "predicate": { "level": -0.0625 }, "model": "mrmod:item/darkness_01" },
    { "predicate": { "level": -0.1250 }, "model": "mrmod:item/darkness_02" },
    { "predicate": { "level": -0.1875 }, "model": "mrmod:item/darkness_03" },
    { "predicate": { "level": -0.2500 }, "model": "mrmod:item/darkness_04" },
    { "predicate": { "level": -0.3125 }, "model": "mrmod:item/darkness_05" },
    { "predicate": { "level": -0.3750 }, "model": "mrmod:item/darkness_06" },
    { "predicate": { "level": -0.4375 }, "model": "mrmod:item/darkness_07" },
    { "predicate": { "level": -0.5000 }, "model": "mrmod:item/darkness_08" },
    { "predicate": { "level": -0.5625 }, "model": "mrmod:item/darkness_09" },
    { "predicate": { "level": -0.6250 }, "model": "mrmod:item/darkness_10" },
    { "predicate": { "level": -0.6875 }, "model": "mrmod:item/darkness_11" },
    { "predicate": { "level": -0.7500 }, "model": "mrmod:item/darkness_12" },
    { "predicate": { "level": -0.8125 }, "model": "mrmod:item/darkness_13" },
    { "predicate": { "level": -0.8750 }, "model": "mrmod:item/darkness_14" },
    { "predicate": { "level": -0.9375 }, "model": "mrmod:item/darkness_15" }
  ]
}

i think the problem is getting the predicate to work

  • Author

i also found a class called LightPredicate but i dont know how to do something like that

package net.minecraft.advancements.critereon;

import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.GsonHelper;

public class LightPredicate {
   public static final LightPredicate ANY = new LightPredicate(MinMaxBounds.Ints.ANY);
   private final MinMaxBounds.Ints composite;

   LightPredicate(MinMaxBounds.Ints pComposite) {
      this.composite = pComposite;
   }

   public boolean matches(ServerLevel pLevel, BlockPos pPos) {
      if (this == ANY) {
         return true;
      } else if (!pLevel.isLoaded(pPos)) {
         return false;
      } else {
         return this.composite.matches(pLevel.getMaxLocalRawBrightness(pPos));
      }
   }

   public JsonElement serializeToJson() {
      if (this == ANY) {
         return JsonNull.INSTANCE;
      } else {
         JsonObject jsonobject = new JsonObject();
         jsonobject.add("light", this.composite.serializeToJson());
         return jsonobject;
      }
   }

   public static LightPredicate fromJson(@Nullable JsonElement pJson) {
      if (pJson != null && !pJson.isJsonNull()) {
         JsonObject jsonobject = GsonHelper.convertToJsonObject(pJson, "light");
         MinMaxBounds.Ints minmaxbounds$ints = MinMaxBounds.Ints.fromJson(jsonobject.get("light"));
         return new LightPredicate(minmaxbounds$ints);
      } else {
         return ANY;
      }
   }

   public static class Builder {
      private MinMaxBounds.Ints composite = MinMaxBounds.Ints.ANY;

      public static LightPredicate.Builder light() {
         return new LightPredicate.Builder();
      }

      public LightPredicate.Builder setComposite(MinMaxBounds.Ints pComposite) {
         this.composite = pComposite;
         return this;
      }

      public LightPredicate build() {
         return new LightPredicate(this.composite);
      }
   }
}

ย 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.