Skip to content

Commit

Permalink
Lens Rework (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Dec 3, 2021
1 parent c7ec727 commit 10f688c
Showing 44 changed files with 270 additions and 52 deletions.
5 changes: 4 additions & 1 deletion src/main/java/gregtech/api/items/OreDictNames.java
Original file line number Diff line number Diff line change
@@ -32,5 +32,8 @@ public enum OreDictNames {
craftingLensPurple,
craftingLensRed,
craftingLensWhite,
craftingLensYellow
craftingLensYellow,

// Represents all dyed Glass Lenses, and the undyed version
craftingLensGlass
}
Original file line number Diff line number Diff line change
@@ -120,7 +120,6 @@ public static void register() {
STD_SOLID.addAll(Arrays.asList(GENERATE_PLATE, GENERATE_ROD, GENERATE_BOLT_SCREW, GENERATE_LONG_ROD));

STD_GEM.addAll(STD_SOLID);
STD_GEM.add(GENERATE_LENS);

STD_METAL.add(GENERATE_PLATE);

Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public static void register() {
Almandine = new Material.Builder(250, "almandine")
.gem(1).ore(6, 1)
.color(0xFF0000)
.flags(STD_GEM, GENERATE_LENS)
.flags(STD_GEM)
.components(Aluminium, 2, Iron, 3, Silicon, 3, Oxygen, 12)
.build();

@@ -215,7 +215,7 @@ public static void register() {
Emerald = new Material.Builder(278, "emerald")
.gem().ore()
.color(0x50FF50).iconSet(EMERALD)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, GENERATE_PLATE)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, GENERATE_PLATE, GENERATE_LENS)
.components(Beryllium, 3, Aluminium, 2, Silicon, 6, Oxygen, 18)
.toolStats(10.0f, 2.0f, 368, 15)
.build();
@@ -236,7 +236,7 @@ public static void register() {
GreenSapphire = new Material.Builder(281, "green_sapphire")
.gem().ore()
.color(0x64C882).iconSet(GEM_HORIZONTAL)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT)
.components(Aluminium, 2, Oxygen, 3)
.toolStats(8.0f, 3.0f, 368, 15)
.build();
@@ -446,7 +446,6 @@ public static void register() {
Pyrope = new Material.Builder(308, "pyrope")
.gem().ore(4, 1)
.color(0x783264).iconSet(RUBY)
.flags(GENERATE_LENS)
.components(Aluminium, 2, Magnesium, 3, Silicon, 3, Oxygen, 12)
.build();

@@ -468,7 +467,7 @@ public static void register() {
Ruby = new Material.Builder(311, "ruby")
.gem().ore()
.color(0xFF6464).iconSet(RUBY)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS)
.components(Chrome, 1, Aluminium, 2, Oxygen, 3)
.toolStats(8.5f, 3.0f, 256, 33)
.build();
@@ -490,7 +489,7 @@ public static void register() {
Sapphire = new Material.Builder(314, "sapphire")
.gem().ore()
.color(0x6464C8).iconSet(GEM_VERTICAL)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT)
.components(Aluminium, 2, Oxygen, 3)
.toolStats(7.5f, 4.0f, 256, 15)
.build();
@@ -584,7 +583,7 @@ public static void register() {
Tanzanite = new Material.Builder(326, "tanzanite")
.gem().ore(2, 1)
.color(0x4000C8).iconSet(GEM_VERTICAL)
.flags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS)
.flags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT)
.components(Calcium, 2, Aluminium, 3, Silicon, 3, Hydrogen, 1)
.toolStats(7.0f, 2.0f, 256, 15)
.build();
@@ -606,7 +605,7 @@ public static void register() {
Topaz = new Material.Builder(329, "topaz")
.gem(3).ore(2, 1)
.color(0xFF8000).iconSet(GEM_HORIZONTAL)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT)
.components(Aluminium, 2, Silicon, 1, Fluorine, 1, Hydrogen, 2)
.toolStats(7.0f, 2.0f, 256, 15)
.build();
@@ -1189,7 +1188,7 @@ public static void register() {
EnderPearl = new Material.Builder(416, "ender_pearl")
.gem(1)
.color(0x6CDCC8)
.flags(GENERATE_LENS, NO_SMASHING, NO_SMELTING)
.flags(NO_SMASHING, NO_SMELTING)
.components(Beryllium, 1, Potassium, 4, Nitrogen, 5)
.build();

Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public static void register() {
EnderEye = new Material.Builder(2508, "ender_eye")
.gem(1)
.color(0x66FF66)
.flags(GENERATE_LENS, NO_SMASHING, NO_SMELTING, DECOMPOSITION_BY_CENTRIFUGING)
.flags(NO_SMASHING, NO_SMELTING, DECOMPOSITION_BY_CENTRIFUGING)
.build();

Diatomite = new Material.Builder(2509, "diatomite")
Original file line number Diff line number Diff line change
@@ -50,15 +50,15 @@ public static void register() {
Opal = new Material.Builder(2005, "opal")
.gem().ore()
.color(0x0000FF).iconSet(OPAL)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING, GENERATE_LENS)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING)
.components(SiliconDioxide, 1)
.toolStats(7.5f, 3.0f, 312, 15)
.build();

Amethyst = new Material.Builder(2006, "amethyst")
.gem(3).ore()
.color(0xD232D2).iconSet(RUBY)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS)
.flags(NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT)
.components(SiliconDioxide, 4, Iron, 1)
.toolStats(7.5f, 3.0f, 312, 33)
.build();
@@ -141,15 +141,15 @@ public static void register() {
GarnetRed = new Material.Builder(2016, "garnet_red")
.gem().ore(4, 1)
.color(0xC85050).iconSet(RUBY)
.flags(STD_SOLID, GENERATE_LENS, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING)
.flags(STD_SOLID, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING)
.components(Pyrope, 3, Almandine, 5, Spessartine, 8)
.toolStats(7.5f, 3.0f, 156, 33)
.build();

GarnetYellow = new Material.Builder(2017, "garnet_yellow")
.gem().ore(4, 1)
.color(0xC8C850).iconSet(RUBY)
.flags(STD_SOLID, GENERATE_LENS, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING)
.flags(STD_SOLID, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING)
.components(Andradite, 5, Grossular, 8, Uvarovite, 3)
.toolStats(7.5f, 3.0f, 156, 33)
.build();
Original file line number Diff line number Diff line change
@@ -257,7 +257,7 @@ public static void register() {
NetherStar = new Material.Builder(1602, "nether_star")
.gem(4)
.iconSet(NETHERSTAR)
.flags(STD_SOLID, GENERATE_LENS, NO_SMASHING, NO_SMELTING)
.flags(STD_SOLID, NO_SMASHING, NO_SMELTING)
.build();

Endstone = new Material.Builder(1603, "endstone")
18 changes: 14 additions & 4 deletions src/main/java/gregtech/common/items/MetaItem1.java
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
import gregtech.api.sound.GTSounds;
import gregtech.api.terminal.hardware.HardwareProvider;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.MarkerMaterial;
import gregtech.api.unification.material.MarkerMaterials;
import gregtech.api.unification.material.MarkerMaterials.Component;
import gregtech.api.unification.material.MarkerMaterials.Tier;
import gregtech.api.unification.material.Materials;
@@ -580,10 +582,18 @@ public void registerSubItems() {
PLUGIN_ONLINE_PIC = addItem(782, "plugin.online_pic").addComponents(new OnlinePicPluginBehavior());
PLUGIN_TEXT = addItem(783, "plugin.text").addComponents(new TextPluginBehavior());

COLOURED_LEDS = addItem(800, "coloured.leds");
DISPLAY = addItem(801, "display");
COLOURED_LEDS = addItem(798, "coloured.leds");
DISPLAY = addItem(799, "display");

SUS_RECORD = addItem(802, "record.sus").addComponents(new MusicDiscStats(GTSounds.RECORD_SOUND)).setRarity(EnumRarity.RARE).setMaxStackSize(1).setInvisible();
}
// Records: 800-819
SUS_RECORD = addItem(800, "record.sus").addComponents(new MusicDiscStats(GTSounds.RECORD_SOUND)).setRarity(EnumRarity.RARE).setMaxStackSize(1).setInvisible();

// Dyed Glass Lenses: 820-840
for (int i = 0; i < MarkerMaterials.Color.VALUES.length; i++) {
MarkerMaterial color = MarkerMaterials.Color.VALUES[i];
if (color != MarkerMaterials.Color.White) {
GLASS_LENSES.put(color, addItem(820 + i, String.format("glass_lens.%s", color.toString())));
}
}
}
}
15 changes: 12 additions & 3 deletions src/main/java/gregtech/common/items/MetaItems.java
Original file line number Diff line number Diff line change
@@ -7,23 +7,24 @@
import gregtech.api.items.metaitem.MetaItem.MetaValueItem;
import gregtech.api.items.metaitem.MetaOreDictItem;
import gregtech.api.items.toolitem.ToolMetaItem;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.MarkerMaterial;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.util.GTLog;
import gregtech.common.items.armor.MetaArmor;
import gregtech.common.render.FacadeItemModel;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;

public final class MetaItems {

@@ -247,6 +248,8 @@ private MetaItems() {
public static MetaItem<?>.MetaValueItem TOOL_DATA_STICK;
public static MetaItem<?>.MetaValueItem TOOL_DATA_ORB;

public static final Map<MarkerMaterial, MetaValueItem> GLASS_LENSES = new HashMap<>();

public static MetaItem<?>.MetaValueItem SILICON_BOULE;
public static MetaItem<?>.MetaValueItem GLOWSTONE_BOULE;
public static MetaItem<?>.MetaValueItem NAQUADAH_BOULE;
@@ -606,6 +609,12 @@ public static void registerOreDict() {
((MetaPrefixItem) item).registerOreDict();
}
}
for (Map.Entry<MarkerMaterial, MetaValueItem> entry : GLASS_LENSES.entrySet()) {
// Register "craftingLensWhite" for example
OreDictUnifier.registerOre(entry.getValue().getStackForm(), OrePrefix.craftingLens, entry.getKey());
// Register "craftingLensGlass", intended only for recipes to dye lenses and not in the Engraver
OreDictUnifier.registerOre(entry.getValue().getStackForm(), String.format("%s%s", OrePrefix.craftingLens.name(), "Glass"));
}
}

@SideOnly(Side.CLIENT)
Original file line number Diff line number Diff line change
@@ -214,9 +214,22 @@ public static void processLens(OrePrefix lensPrefix, Material material, GemPrope
.EUt(16)
.buildAndRegister();

EnumDyeColor dyeColor = determineDyeColor(material.getMaterialRGB());
MarkerMaterial colorMaterial = MarkerMaterials.Color.COLORS.get(dyeColor);
OreDictUnifier.registerOre(stack, OrePrefix.craftingLens, colorMaterial);
if (material == Materials.Diamond) { // override Diamond Lens to be LightBlue
OreDictUnifier.registerOre(stack, OrePrefix.craftingLens, MarkerMaterials.Color.LightBlue);
} else if (material == Materials.Ruby) { // override Ruby Lens to be Red
OreDictUnifier.registerOre(stack, OrePrefix.craftingLens, MarkerMaterials.Color.Red);
} else if (material == Materials.Emerald) { // override Emerald Lens to be Green
OreDictUnifier.registerOre(stack, OrePrefix.craftingLens, MarkerMaterials.Color.Green);
} else if (material == Materials.Glass) { // override Glass Lens to be White, and have "default" oredict
OreDictUnifier.registerOre(stack, OrePrefix.craftingLens, MarkerMaterials.Color.White);
OreDictUnifier.registerOre(stack, OrePrefix.craftingLens.name() + material.toCamelCaseString());
} else { // add more custom lenses here if needed

// Default behavior for determining lens color, left for addons and CraftTweaker
EnumDyeColor dyeColor = determineDyeColor(material.getMaterialRGB());
MarkerMaterial colorMaterial = MarkerMaterials.Color.COLORS.get(dyeColor);
OreDictUnifier.registerOre(stack, OrePrefix.craftingLens, colorMaterial);
}
}

public static void processPlate(OrePrefix platePrefix, Material material, DustProperty property) {
Loading

0 comments on commit 10f688c

Please sign in to comment.