Skip to content

Commit

Permalink
last few textures
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Sep 4, 2021
1 parent d0d14c6 commit 8b57bfb
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 13 deletions.
23 changes: 23 additions & 0 deletions src/main/java/gregtech/api/render/SimpleCubeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,57 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import gregtech.api.GTValues;
import gregtech.common.ConfigHolder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.ArrayUtils;

import javax.annotation.Nullable;

public class SimpleCubeRenderer implements ICubeRenderer, IIconRegister {

private final String basePath;
private final boolean hasEmissive;

@SideOnly(Side.CLIENT)
private TextureAtlasSprite sprite;

@Nullable
@SideOnly(Side.CLIENT)
private TextureAtlasSprite spriteEmissive;

public SimpleCubeRenderer(String basePath) {
this(basePath, false);
}

public SimpleCubeRenderer(String basePath, boolean hasEmissive) {
this.basePath = basePath;
this.hasEmissive = hasEmissive;
Textures.iconRegisters.add(this);
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(TextureMap textureMap) {
this.sprite = textureMap.registerSprite(new ResourceLocation(GTValues.MODID, "blocks/" + basePath));
if (hasEmissive) {
this.spriteEmissive = textureMap.registerSprite(new ResourceLocation(GTValues.MODID, "blocks/" + basePath + "_emissive"));
}
}

@SideOnly(Side.CLIENT)
public void renderSided(EnumFacing side, Matrix4 translation, Cuboid6 bounds, CCRenderState renderState, IVertexOperation[] pipeline) {
Textures.renderFace(renderState, translation, pipeline, side, bounds, sprite);
if (spriteEmissive != null) {
if (ConfigHolder.U.clientConfig.emissiveTextures) {
IVertexOperation[] lightPipeline = ArrayUtils.add(pipeline, new LightMapOperation(240, 240));
Textures.renderFace(renderState, translation, lightPipeline, side, bounds, spriteEmissive);
} else Textures.renderFace(renderState, translation, pipeline, side, bounds, spriteEmissive);
}
}

@SideOnly(Side.CLIENT)
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/gregtech/api/render/SimpleSidedCubeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import gregtech.api.GTValues;
import gregtech.common.ConfigHolder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.ArrayUtils;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -31,23 +34,38 @@ public static RenderSide bySide(EnumFacing side) {
}

protected final String basePath;
protected final boolean hasEmissive;

@SideOnly(Side.CLIENT)
protected Map<RenderSide, TextureAtlasSprite> sprites;

@Nullable
@SideOnly(Side.CLIENT)
protected Map<RenderSide, TextureAtlasSprite> spritesEmissive;

public SimpleSidedCubeRenderer(String basePath) {
this(basePath, false);
}

public SimpleSidedCubeRenderer(String basePath, boolean hasEmissive) {
this.basePath = basePath;
this.hasEmissive = hasEmissive;
Textures.iconRegisters.add(this);
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(TextureMap textureMap) {
this.sprites = new HashMap<>();
if (hasEmissive) this.spritesEmissive = new HashMap<>();
for (RenderSide overlayFace : RenderSide.values()) {
String faceName = overlayFace.name().toLowerCase();
ResourceLocation resourceLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/%s/%s", basePath, faceName));
sprites.put(overlayFace, textureMap.registerSprite(resourceLocation));
if (hasEmissive) {
ResourceLocation emissiveLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/%s/%s_emissive", basePath, faceName));
spritesEmissive.put(overlayFace, textureMap.registerSprite(emissiveLocation));
}
}
}

Expand All @@ -69,7 +87,13 @@ public void render(CCRenderState renderState, Matrix4 translation, IVertexOperat
RenderSide overlayFace = RenderSide.bySide(renderSide);
TextureAtlasSprite renderSprite = sprites.get(overlayFace);
Textures.renderFace(renderState, translation, pipeline, renderSide, bounds, renderSprite);
if (spritesEmissive != null) {
TextureAtlasSprite spriteEmissive = spritesEmissive.get(overlayFace);
if (ConfigHolder.U.clientConfig.emissiveTextures) {
IVertexOperation[] lightPipeline = ArrayUtils.add(pipeline, new LightMapOperation(240, 240));
Textures.renderFace(renderState, translation, lightPipeline, renderSide, bounds, spriteEmissive);
} else Textures.renderFace(renderState, translation, pipeline, renderSide, bounds, spriteEmissive);
}
}
}

}
22 changes: 10 additions & 12 deletions src/main/java/gregtech/api/render/Textures.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Textures {
public static final List<IIconRegister> iconRegisters = new ArrayList<>();

// Custom Renderers
public static ClipboardRenderer CLIPBOARD_RENDERER = new ClipboardRenderer();
public static final ClipboardRenderer CLIPBOARD_RENDERER = new ClipboardRenderer();
public static final CrateRenderer WOODEN_CRATE = new CrateRenderer("storage/crates/wooden_crate");
public static final CrateRenderer METAL_CRATE = new CrateRenderer("storage/crates/metal_crate");
public static final DrumRenderer WOODEN_DRUM = new DrumRenderer("storage/drums/wooden_drum");
Expand Down Expand Up @@ -60,10 +60,8 @@ public class Textures {
public static final SimpleCubeRenderer TITANIUM_FIREBOX_ACTIVE = new SimpleCubeRenderer("casings/firebox/machine_casing_firebox_titanium_active");
public static final SimpleCubeRenderer TUNGSTENSTEEL_FIREBOX = new SimpleCubeRenderer("casings/firebox/machine_casing_firebox_tungstensteel");
public static final SimpleCubeRenderer TUNGSTENSTEEL_FIREBOX_ACTIVE = new SimpleCubeRenderer("casings/firebox/machine_casing_firebox_tungstensteel_active");

// TODO These two may need to be emissive
public static final SimpleCubeRenderer FUSION_TEXTURE = new SimpleCubeRenderer("casings/fusion/machine_casing_fusion_glass");
public static final SimpleCubeRenderer ACTIVE_FUSION_TEXTURE = new SimpleCubeRenderer("casings/fusion/machine_casing_fusion_glass_yellow");
public static final SimpleCubeRenderer ACTIVE_FUSION_TEXTURE = new SimpleCubeRenderer("casings/fusion/machine_casing_fusion_glass_yellow", true);

// Simple Sided Cube Renderers
public static final SimpleSidedCubeRenderer STEAM_CASING_BRONZE = new SimpleSidedCubeRenderer("casings/steam/bronze");
Expand All @@ -72,10 +70,8 @@ public class Textures {
public static final SimpleSidedCubeRenderer STEAM_BRICKED_CASING_STEEL = new SimpleSidedCubeRenderer("casings/steam/bricked_steel");
public static final SimpleSidedCubeRenderer[] VOLTAGE_CASINGS = new SimpleSidedCubeRenderer[GTValues.V.length];
public static final SimpleSidedCubeRenderer PRIMITIVE_PUMP = new SimpleSidedCubeRenderer("casings/pump_deck");

// todo these two may need to be emissive
public static final SimpleSidedCubeRenderer MAGIC_ENERGY_ABSORBER = new SimpleSidedCubeRenderer("casings/magic/absorber/normal");
public static final SimpleSidedCubeRenderer MAGIC_ENERGY_ABSORBER_ACTIVE = new SimpleSidedCubeRenderer("casings/magic/absorber/active");
public static final SimpleSidedCubeRenderer MAGIC_ENERGY_ABSORBER = new SimpleSidedCubeRenderer("casings/magic/absorber/normal", true);
public static final SimpleSidedCubeRenderer MAGIC_ENERGY_ABSORBER_ACTIVE = new SimpleSidedCubeRenderer("casings/magic/absorber/active", true);

// Simple Oriented Cube Renderers
public static final SimpleOrientedCubeRenderer CRAFTING_TABLE = new SimpleOrientedCubeRenderer("casings/crafting_table");
Expand Down Expand Up @@ -150,7 +146,7 @@ public class Textures {
public static final OrientedOverlayRenderer GAS_TURBINE_OVERLAY = new OrientedOverlayRenderer("generators/gas_turbine", SIDE);
public static final OrientedOverlayRenderer STEAM_TURBINE_OVERLAY = new OrientedOverlayRenderer("generators/steam_turbine", SIDE);

// Simple Overlay Renderers todo do last
// Simple Overlay Renderers
public static final SimpleOverlayRenderer SCREEN = new SimpleOverlayRenderer("overlay/machine/overlay_screen", true);
public static final SimpleOverlayRenderer DISPLAY = new SimpleOverlayRenderer("cover/overlay_display", true);
public static final SimpleOverlayRenderer SHUTTER = new SimpleOverlayRenderer("cover/overlay_shutter");
Expand All @@ -163,11 +159,13 @@ public class Textures {
public static final SimpleOverlayRenderer PIPE_OUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_pipe_out");
public static final SimpleOverlayRenderer PIPE_IN_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_pipe_in");

// todo emissive for these hatch overlays
public static final SimpleOverlayRenderer FLUID_HATCH_OUTPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_fluid_hatch_output");
public static final SimpleOverlayRenderer FLUID_HATCH_INPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_fluid_hatch_input");
// todo should we do emissive for these auto-output overlays?
public static final SimpleOverlayRenderer FLUID_OUTPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_fluid_output");
public static final SimpleOverlayRenderer ITEM_OUTPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_item_output");

// todo should we do emissive for these hatch overlays?
public static final SimpleOverlayRenderer FLUID_HATCH_OUTPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_fluid_hatch_output");
public static final SimpleOverlayRenderer FLUID_HATCH_INPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_fluid_hatch_input");
public static final SimpleOverlayRenderer ITEM_HATCH_OUTPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_item_hatch_output");
public static final SimpleOverlayRenderer ITEM_HATCH_INPUT_OVERLAY = new SimpleOverlayRenderer("overlay/machine/overlay_item_hatch_input");

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b57bfb

Please sign in to comment.