Skip to content

Commit

Permalink
trying a workaround for the null pointer crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Dcetidre committed Feb 24, 2020
1 parent 8694f66 commit ee1e070
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.7.8+build.184

# Mod Properties
mod_version = 1.1.9r1
mod_version = 1.1.9r2
maven_group = com.software.ddk
archives_base_name = coloredflames

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.texture.SpriteAtlasTexture;
Expand Down Expand Up @@ -40,23 +41,36 @@ public void onInitializeClient() {
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> (tintIndex == 1) ? ((DyeableItem) stack.getItem()).getColor(stack) : 0xffffff, FLINT_AND_STEEL_DYEABLE);
ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> {
World world = MinecraftClient.getInstance().world;
assert world != null;
assert pos != null;
int color = (state.getBlock().hasBlockEntity()) ? ((DyeableFireBlockEntity) Objects.requireNonNull(world.getBlockEntity(pos))).getCOLOR() : 0xffffff;
BlockEntity blockEntity;
int color = 0xffffff;
try {
if (state.getBlock().hasBlockEntity()){
assert world != null;
assert pos != null;
blockEntity = world.getBlockEntity(pos);
color = (blockEntity instanceof DyeableFireBlockEntity) ? ((DyeableFireBlockEntity) blockEntity).getCOLOR() : 0xffffff;
}
} catch (NullPointerException ex){
//todo - try to reproduce this nullpointer crash
}
return (tintIndex == 0) ? color : Colors.colorLighter(color, 0.88f);
}, DYEABLE_FIRE_BLOCK);

//dyeable torches
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> (tintIndex == 1) ? ((GenericTorchItem) stack.getItem()).getColor(stack) : 0xffffff, GENERIC_TORCH_ITEM);
ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> {
World world = MinecraftClient.getInstance().world;
assert world != null;
assert pos != null;
BlockEntity blockEntity;
int color = 0xffffff;
try {
color = (state.getBlock().hasBlockEntity()) ? ((GenericTorchBlockEntity) Objects.requireNonNull(world.getBlockEntity(pos))).getCOLOR() : 0xffffff;
} catch (NullPointerException e){
//todo - temporary fix for a crash with conveyance 0.3.2
if (state.getBlock().hasBlockEntity()){
assert world != null;
assert pos != null;
blockEntity = world.getBlockEntity(pos);
color = (blockEntity instanceof GenericTorchBlockEntity) ? ((GenericTorchBlockEntity) blockEntity).getCOLOR() : 0xffffff;
}
} catch (NullPointerException ex){
//todo - try to reproduce this nullpointer crash (Torch)
}
return (tintIndex == 0) ? color : (tintIndex == 2) ? Colors.colorLighter(color, 0.9f) : 0xffffff;
}, GENERIC_TORCH_BLOCK, GENERIC_WALL_TORCH_BLOCK);
Expand Down

0 comments on commit ee1e070

Please sign in to comment.