Skip to content

Commit

Permalink
Fix #20, workaround for error
Browse files Browse the repository at this point in the history
  • Loading branch information
Andromander committed Jan 28, 2020
1 parent f29c5fc commit c3d23b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/main/java/com/androsa/nifty/ColourHandler.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package com.androsa.nifty;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.item.BlockItem;
import net.minecraft.world.GrassColors;
import net.minecraft.world.biome.BiomeColors;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.OnlyIn;

@Mod.EventBusSubscriber(modid = NiftyMod.MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
@OnlyIn(Dist.CLIENT)
public class ColourHandler {

@SubscribeEvent
public static void registerBlockColors(ColorHandlerEvent.Block e) {
BlockColors blocks = e.getBlockColors();
public static void registerBlockColors() {
BlockColors blocks = Minecraft.getInstance().getBlockColors();

blocks.register((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null ? BiomeColors.getGrassColor(worldIn, pos) : GrassColors.get(0.5D, 1.0D),
ModBlocks.grass_fence.get(),
Expand All @@ -26,10 +24,9 @@ public static void registerBlockColors(ColorHandlerEvent.Block e) {
ModBlocks.grass_door.get());
}

@SubscribeEvent
public static void registerItemColors(ColorHandlerEvent.Item e) {
BlockColors blocks = e.getBlockColors();
ItemColors items = e.getItemColors();
public static void registerItemColors() {
BlockColors blocks = Minecraft.getInstance().getBlockColors();
ItemColors items = Minecraft.getInstance().getItemColors();

items.register((stack, tintIndex) -> blocks.getColor(((BlockItem)stack.getItem()).getBlock().getDefaultState(), null, null, tintIndex),
ModBlocks.grass_fence.get(),
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/androsa/nifty/NiftyMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private void setup(final FMLCommonSetupEvent event) {

private void clientSetup(final FMLClientSetupEvent event) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> NiftyMod::registerRenders);
DistExecutor.runWhenOn(Dist.CLIENT, () -> ColourHandler::registerBlockColors);
DistExecutor.runWhenOn(Dist.CLIENT, () -> ColourHandler::registerItemColors);
}

@OnlyIn(Dist.CLIENT)
Expand Down

0 comments on commit c3d23b6

Please sign in to comment.