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 am trying to create a darkened version of mycelium and I found that the vanilla MapColors are not the right color. I have no trouble making an instance of MapColor but it just appears transparent on the map. 

 

Util.java

package drmeepster.evilshrooms.util;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import net.minecraft.block.material.MapColor;

public final class Util {
	
	private Util(){}
	
	public static int getNextMapColor(){
		//Will only be -1 if array is full
		int out = -1;
		
		for(int i = 0; i < MapColor.COLORS.length; i++){
			if(MapColor.COLORS[i] == null){
				continue;
			}
			out = i;
			break;
		}
		
		return out;
	}
	
	public static MapColor newMapColor(int index, int color){
		Constructor<MapColor> constr;
		try{
			constr = MapColor.class.getDeclaredConstructor(int.class, int.class);
		}catch (NoSuchMethodException | SecurityException e) {
			e.printStackTrace();
			return null;
		}
		
		constr.setAccessible(true);
		
		try {
			return constr.newInstance(index, color);
		} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
			e.printStackTrace();
			return null;
		}
	}
}

 

ModEvilShrooms.java

package drmeepster.evilshrooms;

import drmeepster.evilshrooms.blocks.EvilShroomBlocks;
import drmeepster.evilshrooms.util.TabEvilShroom;
import drmeepster.evilshrooms.util.Util;
import net.minecraft.block.material.MapColor;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = ModEvilShrooms.MODID, useMetadata = true, dependencies = "after:drcorester")
public class ModEvilShrooms{
	
    public static final String MODID = "evilshrooms";
    public static final TabEvilShroom EVIL_SHROOM_TAB = new TabEvilShroom();
    public static MapColor colorShadowMycelium;
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event){
    	colorShadowMycelium = Util.newMapColor(Util.getNextMapColor(), 0x281538);
    	EvilShroomBlocks.preInit();
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event){

    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event){

    }
}

 

Edited by DrMeepster

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.