Advertisement
Vaerys_Dawn

Colour information Code

May 30th, 2021 (edited)
1,456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. // HoneyFluidAttributes.java
  2.     @Override
  3.     public int getColor(BlockAndTintGetter world, BlockPos pos) {
  4.         return getColor();
  5.     }
  6.  
  7.     @Override
  8.     public int getColor(FluidStack stack){
  9.         return getColor();
  10.     }
  11.  
  12.     @Override
  13.     public int getColor(){
  14.         return honeyData.getColor().getValue() | 0xff000000;
  15.     }
  16.  
  17. // Color.java
  18.     public Color(int value) {
  19.         this.a = (value >> 24) & 0xFF;
  20.         this.r = (value >> 16) & 0xFF;
  21.         this.g = (value >> 8) & 0xFF;
  22.         this.b = value & 0xFF;
  23.         this.value = value;
  24.  
  25.         updateFloats();
  26.     }
  27.  
  28.     public static Color parse(String color) {
  29.         if (colorsWithNames.containsKey(color.toLowerCase()))
  30.             return colorsWithNames.get(color.toLowerCase());
  31.         return new Color(parseColor(color));
  32.     }
  33.  
  34.     public static int parseColor(String color){
  35.         Objects.requireNonNull(color);
  36.         if (color.startsWith("0x") || color.startsWith("#"))
  37.             return Long.decode(color).intValue();
  38.         else if (colorsWithNames.containsKey(color.toLowerCase()))
  39.             return colorsWithNames.get(color.toLowerCase()).getValue();
  40.         return 0;
  41.     }
  42.  
  43.     public int getValue() { return value; }
  44.  
  45. // Sweet.json
  46. {
  47.   "hunger": 3,
  48.   "saturation": 0.25,
  49.   "color": "#D4FFC9",
  50.   "honeyEffects": [
  51.     {
  52.       "effect": "minecraft:glowing",
  53.       "duration": 2400,
  54.       "strength": 0,
  55.       "chance": 1
  56.     }
  57.   ]
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement