Gems are flattened

This commit is contained in:
drcrazy 2018-08-23 17:16:17 +03:00
parent 2939ee02a3
commit aadc7150f3
16 changed files with 188 additions and 116 deletions

View file

@ -50,8 +50,8 @@ import reborncore.common.util.OreDrop;
import reborncore.common.util.StringUtils;
import techreborn.events.TRRecipeHandler;
import techreborn.init.ModBlocks;
import techreborn.init.ModGems;
import techreborn.items.ItemDusts;
import techreborn.items.ItemGems;
import techreborn.lib.ModInfo;
import techreborn.utils.TechRebornCreativeTab;
import techreborn.world.config.IOreNameProvider;
@ -143,10 +143,10 @@ public class BlockOre extends Block implements IOreNameProvider {
// Secondary drop, like peridot from sapphire ore added via event handler.
if (variant.equalsIgnoreCase("Ruby")) {
OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby", rubyMinQuatity), rubyMaxQuantity);
OreDrop ruby = new OreDrop(ModGems.RUBY.getStack(rubyMinQuatity), rubyMaxQuantity);
drops.add(ruby.getDrops(fortune, random));
} else if (variant.equalsIgnoreCase("Sapphire")) {
OreDrop sapphire = new OreDrop(ItemGems.getGemByName("sapphire", sapphireMinQuantity), sapphireMaxQuantity);
OreDrop sapphire = new OreDrop(ModGems.SAPPHIRE.getStack(sapphireMinQuantity), sapphireMaxQuantity);
drops.add(sapphire.getDrops(fortune, random));
} else if (variant.equalsIgnoreCase("Pyrite")) {
OreDrop pyriteDust = new OreDrop(ItemDusts.getDustByName("pyrite", pyriteMinQuatity), pyriteMaxQuantity);

View file

@ -37,6 +37,7 @@ import techreborn.blocks.cable.BlockCable;
import techreborn.blocks.cable.EnumCableType;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.init.ModGems;
import techreborn.init.ModItems;
import techreborn.init.ModNuggets;
import techreborn.init.ModPlates;
@ -129,11 +130,7 @@ public class RegisterItemJsons {
registerBlockstate(ModItems.INGOTS, i, name[i], "items/materials/");
}
name = ItemGems.types.clone();
for (int i = 0; i < ItemGems.types.length; ++i) {
registerBlockstate(ModItems.GEMS, i, name[i], "items/materials/");
}
ModGems.registerModel();
ModPlates.registerModel();
ModNuggets.registerModel();

View file

@ -36,9 +36,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.OreDrop;
import techreborn.init.ModGems;
import techreborn.init.ModItems;
import techreborn.items.ItemDusts;
import techreborn.items.ItemGems;
import techreborn.lib.ModInfo;
import techreborn.utils.OreDictUtils;
@ -68,11 +68,11 @@ public class BlockBreakHandler {
List<ItemStack> drops = event.getDrops();
Random random = new Random();
if (OreDictUtils.isOre(state, "oreRuby")) {
OreDrop redGarnet = new OreDrop(ItemGems.getGemByName("red_garnet"), redGarnetDropChance, 1);
OreDrop redGarnet = new OreDrop(ModGems.RED_GARNET.getStack(), redGarnetDropChance, 1);
drops.add(redGarnet.getDrops(event.getFortuneLevel(), random));
}
else if (OreDictUtils.isOre(state, "oreSapphire")) {
OreDrop peridot = new OreDrop(ItemGems.getGemByName("peridot"), peridotDropChance, 1);
OreDrop peridot = new OreDrop(ModGems.PERIDOT.getStack(), peridotDropChance, 1);
drops.add(peridot.getDrops(event.getFortuneLevel(), random));
}
else if (OreDictUtils.isOre(state, "oreSodalite")) {
@ -84,7 +84,7 @@ public class BlockBreakHandler {
drops.add(redstone.getDrops(event.getFortuneLevel(), random));
}
else if (OreDictUtils.isOre(state, "oreSphalerite")) {
OreDrop yellowGarnet = new OreDrop(ItemGems.getGemByName("yellowGarnet"), yellowGarnetDropChance, 1);
OreDrop yellowGarnet = new OreDrop(ModGems.YELLOW_GARNET.getStack(), yellowGarnetDropChance, 1);
drops.add(yellowGarnet.getDrops(event.getFortuneLevel(), random));
}
}

View file

@ -0,0 +1,83 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.init;
import java.util.Arrays;
import com.google.common.base.CaseFormat;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornRegistry;
import techreborn.items.ItemGems;
import techreborn.lib.ModInfo;
/**
* @author drcrazy
*
*/
public enum ModGems implements IStringSerializable {
PERIDOT, RED_GARNET, RUBY, SAPPHIRE, YELLOW_GARNET;
public final String name;
public final Item item;
private ModGems() {
name = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "GEM_" + this.toString());
item = new ItemGems();
item.setRegistryName(new ResourceLocation(ModInfo.MOD_ID, name));
item.setTranslationKey(ModInfo.MOD_ID + "." + name);
}
public ItemStack getStack() {
return new ItemStack(item);
}
public ItemStack getStack(int amount) {
return new ItemStack(item, amount);
}
public static void register() {
Arrays.stream(ModGems.values()).forEach(gem -> RebornRegistry.registerItem(gem.item));
}
@SideOnly(Side.CLIENT)
public static void registerModel() {
ResourceLocation blockstateJson = new ResourceLocation(ModInfo.MOD_ID, "items/materials/gems");
Arrays.stream(ModGems.values()).forEach(gem -> ModelLoader.setCustomModelResourceLocation(gem.item, 0,
new ModelResourceLocation(blockstateJson, "type=" + gem.name)));
}
@Override
public String getName() {
return name;
}
}

View file

@ -45,7 +45,6 @@ import javax.annotation.Nullable;
public class ModItems {
public static Item GEMS;
public static Item INGOTS;
public static Item DUSTS;
@ -156,8 +155,6 @@ public class ModItems {
public static DynamicCell CELL;
public static void init() {
GEMS = new ItemGems();
registerItem(GEMS, "gem");
INGOTS = new ItemIngots();
registerItem(INGOTS, "ingot");
DUSTS = new ItemDusts();
@ -165,6 +162,7 @@ public class ModItems {
SMALL_DUSTS = new ItemDustsSmall();
registerItem(SMALL_DUSTS, "smallDust");
ModGems.register();
ModPlates.register();
ModNuggets.register();

View file

@ -1,5 +1,25 @@
/**
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.init;
@ -41,6 +61,10 @@ public enum ModNuggets implements IStringSerializable {
return new ItemStack(item);
}
public ItemStack getStack(int amount) {
return new ItemStack(item, amount);
}
public static void register() {
Arrays.stream(ModNuggets.values()).forEach(nugget -> RebornRegistry.registerItem(nugget.item));
}

View file

@ -64,6 +64,10 @@ public enum ModPlates implements IStringSerializable {
return new ItemStack(item);
}
public ItemStack getStack(int amount) {
return new ItemStack(item, amount);
}
public static void register() {
Arrays.stream(ModPlates.values()).forEach(plate -> RebornRegistry.registerItem(plate.item));
}

View file

@ -84,15 +84,16 @@ public class OreDict {
OreUtil.registerOre("pulpWood", ItemDusts.getDustByName("saw_dust"));
OreUtil.registerOre("dustAsh", ItemDusts.getDustByName("ashes"));
for (String type : ItemGems.types) {
OreUtil.registerOre(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "gem_" + type), ItemGems.getGemByName(type));
boolean ignoreIt = false;
for (String ignore : plateGenIgnores)
if (type.startsWith(ignore))
ignoreIt = true;
// TODO: fix recipe
// for (String type : ItemGems.types) {
// OreUtil.registerOre(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "gem_" + type), ItemGems.getGemByName(type));
// boolean ignoreIt = false;
// for (String ignore : plateGenIgnores)
// if (type.startsWith(ignore))
// ignoreIt = true;
// if (!ignoreIt)
// ItemPlates.registerType(type);
}
// }
for (String type : ItemIngots.types) {
OreUtil.registerOre(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "ingot_" + type), ItemIngots.getIngotByName(type));

View file

@ -66,12 +66,16 @@ public class SubItemRetriever implements ISubItemRetriever {
@Override
public ItemStack getGemByName(String name) {
return ItemGems.getGemByName(name);
// TODO: Fix recipe
//return ItemGems.getGemByName(name);
return null;
}
@Override
public ItemStack getGemByName(String name, int count) {
return ItemGems.getGemByName(name, count);
// TODO: Fix recipe
//return ItemGems.getGemByName(name, count);
return null;
}
@Override

View file

@ -38,15 +38,15 @@ import java.security.InvalidParameterException;
*/
public class ImplosionCompressorRecipes extends RecipeMethods {
public static void init() {
// TODO: fix recipe
// register(getOre("ingotIridiumAlloy"), getMaterial("iridium_alloy", Type.PLATE), 4);
register(getOre("dustDiamond", 4), getStack(Items.DIAMOND, 3), 16);
register(getOre("dustEmerald", 4), getStack(Items.EMERALD, 3), 12);
register(getOre("dustRuby", 4), getMaterial("ruby", 3, Type.GEM), 12);
register(getOre("dustSapphire", 4), getMaterial("sapphire", 3, Type.GEM), 12);
register(getOre("dustPeridot", 4), getMaterial("peridot", 3, Type.GEM), 12);
register(getOre("dustRedGarnet", 4), getMaterial("red_garnet", 3, Type.GEM), 8);
register(getOre("dustYellowGarnet", 4), getMaterial("yellow_garnet", 3, Type.GEM), 8);
// TODO: fix recipe
// register(getOre("ingotIridiumAlloy"), getMaterial("iridium_alloy", Type.PLATE), 4);
// register(getOre("dustRuby", 4), getMaterial("ruby", 3, Type.GEM), 12);
// register(getOre("dustSapphire", 4), getMaterial("sapphire", 3, Type.GEM), 12);
// register(getOre("dustPeridot", 4), getMaterial("peridot", 3, Type.GEM), 12);
// register(getOre("dustRedGarnet", 4), getMaterial("red_garnet", 3, Type.GEM), 8);
// register(getOre("dustYellowGarnet", 4), getMaterial("yellow_garnet", 3, Type.GEM), 8);
if (oresExist("dustApatite", "gemApatite")) {
register(getOre("dustApatite", 4), getOre("gemApatite", 3), 12);
}

View file

@ -100,9 +100,7 @@ public class IndustrialGrinderRecipes extends RecipeMethods {
register(getOre("orePitchblende"), WATER, 100, 64, getOre("uran238", 8), getOre("smallUran235", 2));
}
register(getOre("oreRuby"), WATER, 100, 64, getMaterial("ruby", Type.GEM), getMaterial("ruby", 6, Type.SMALL_DUST), getMaterial("red_garnet", 2, Type.SMALL_DUST));
register(getOre("oreSapphire"), WATER, 100, 64, getMaterial("sapphire", Type.GEM), getMaterial("sapphire", 6, Type.SMALL_DUST), getMaterial("peridot", 2, Type.SMALL_DUST));
register(getOre("oreQuartz"), WATER, 100, 64, getStack(Items.QUARTZ, 2), getMaterial("sulfur", 2, Type.SMALL_DUST));
@ -118,8 +116,9 @@ public class IndustrialGrinderRecipes extends RecipeMethods {
// TODO: Fix recipe
// register(getOre("oreSheldonite"), WATER, 100, 64, getMaterial("platinum", 2, Type.DUST), getMaterial("nickel", Type.DUST), getMaterial("iridium", 2, Type.NUGGET));
// register(getOre("oreSheldonite"), MERCURY, 100, 64, getMaterial("platinum", 3, Type.DUST), getMaterial("nickel", Type.DUST), getMaterial("iridium", 2, Type.NUGGET));
register(getOre("orePeridot"), WATER, 100, 64, getMaterial("peridot", Type.GEM), getMaterial("peridot", 6, Type.SMALL_DUST), getMaterial("emerald", 2, Type.SMALL_DUST));
// register(getOre("orePeridot"), WATER, 100, 64, getMaterial("peridot", Type.GEM), getMaterial("peridot", 6, Type.SMALL_DUST), getMaterial("emerald", 2, Type.SMALL_DUST));
// register(getOre("oreRuby"), WATER, 100, 64, getMaterial("ruby", Type.GEM), getMaterial("ruby", 6, Type.SMALL_DUST), getMaterial("red_garnet", 2, Type.SMALL_DUST));
// register(getOre("oreSapphire"), WATER, 100, 64, getMaterial("sapphire", Type.GEM), getMaterial("sapphire", 6, Type.SMALL_DUST), getMaterial("peridot", 2, Type.SMALL_DUST));
register(getOre("oreSodalite"), WATER, 100, 64, getMaterial("sodalite", 12, Type.DUST), getMaterial("aluminum", 3, Type.DUST));

View file

@ -48,8 +48,8 @@ public abstract class RecipeMethods {
return ItemDustsSmall.getSmallDustByName(name, count);
} else if (type == Type.INGOT) {
return ItemIngots.getIngotByName(name, count);
} else if (type == Type.GEM) {
return ItemGems.getGemByName(name, count);
// } else if (type == Type.GEM) {
// return ItemGems.getGemByName(name, count);
// TODO: fix recipe
// } else if (type == Type.PLATE) {
// return ItemPlates.getPlateByName(name, count);

View file

@ -35,7 +35,6 @@ import techreborn.api.recipe.machines.ScrapboxRecipe;
import techreborn.init.ModBlocks;
import techreborn.items.DynamicCell;
import techreborn.items.ItemDusts;
import techreborn.items.ItemGems;
import techreborn.utils.StackWIPHandler;
/**
@ -196,10 +195,10 @@ public class ScrapboxRecipes extends RecipeMethods {
// for (String i : ItemNuggets.types) {
// register(ItemNuggets.getNuggetByName(i));
// }
for (String i : ItemGems.types) {
register(ItemGems.getGemByName(i));
}
//
// for (String i : ItemGems.types) {
// register(ItemGems.getGemByName(i));
// }
registerDyable(Items.DYE);
registerDyable(Blocks.WOOL);

View file

@ -24,61 +24,26 @@
package techreborn.items;
import com.google.common.base.CaseFormat;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import techreborn.events.TRRecipeHandler;
import techreborn.init.ModItems;
import techreborn.utils.TechRebornCreativeTab;
import java.security.InvalidParameterException;
public class ItemGems extends ItemTR {
public static final String[] types = new String[] { "ruby", "sapphire", "peridot", "red_garnet", "yellow_garnet" };
public ItemGems() {
setCreativeTab(TechRebornCreativeTab.instance);
setTranslationKey("techreborn.gem");
setHasSubtypes(true);
TRRecipeHandler.hideEntry(this);
}
public static ItemStack getGemByName(String name, int count) {
name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
for (int i = 0; i < types.length; i++) {
if (types[i].equalsIgnoreCase(name)) {
return new ItemStack(ModItems.GEMS, count, i);
}
}
throw new InvalidParameterException("The gem " + name + " could not be found.");
}
public static ItemStack getGemByName(String name) {
return getGemByName(name, 1);
}
@Override
// gets Unlocalized Name depending on meta data
public String getTranslationKey(ItemStack itemStack) {
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= types.length) {
meta = 0;
}
return super.getTranslationKey() + "." + types[meta];
}
// Adds Dusts SubItems To Creative Tab
@Override
public void getSubItems(CreativeTabs creativeTabs, NonNullList<ItemStack> list) {
if (!isInCreativeTab(creativeTabs)) {
return;
}
for (int meta = 0; meta < types.length; ++meta) {
list.add(new ItemStack(this, 1, meta));
}
}
// public static ItemStack getGemByName(String name, int count) {
// name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
// for (int i = 0; i < types.length; i++) {
// if (types[i].equalsIgnoreCase(name)) {
// return new ItemStack(ModItems.GEMS, count, i);
// }
// }
// throw new InvalidParameterException("The gem " + name + " could not be found.");
// }
//
// public static ItemStack getGemByName(String name) {
// return getGemByName(name, 1);
// }
}

View file

@ -6,27 +6,27 @@
},
"variants": {
"type": {
"ruby": {
"textures": {
"layer0": "techreborn:items/gem/ruby"
}
},
"sapphire": {
"textures": {
"layer0": "techreborn:items/gem/sapphire"
}
},
"peridot": {
"gemperidot": {
"textures": {
"layer0": "techreborn:items/gem/peridot"
}
},
"red_garnet": {
"gemredgarnet": {
"textures": {
"layer0": "techreborn:items/gem/red_garnet"
}
},
"yellow_garnet": {
"gemruby": {
"textures": {
"layer0": "techreborn:items/gem/ruby"
}
},
"gemsapphire": {
"textures": {
"layer0": "techreborn:items/gem/sapphire"
}
},
"gemyellowgarnet": {
"textures": {
"layer0": "techreborn:items/gem/yellow_garnet"
}

View file

@ -364,11 +364,11 @@ item.techreborn.dustsmall.diorite.name=Small Pile of Diorite Dust
item.techreborn.dustsmall.granite.name=Small Pile of Granite Dust
#Gems
item.techreborn.gem.ruby.name=Ruby
item.techreborn.gem.sapphire.name=Sapphire
item.techreborn.gem.peridot.name=Peridot
item.techreborn.gem.red_garnet.name=Red Garnet
item.techreborn.gem.yellow_garnet.name=Yellow Garnet
item.techreborn.gemPeridot.name=Peridot
item.techreborn.gemRedGarnet.name=Red Garnet
item.techreborn.gemRuby.name=Ruby
item.techreborn.gemSapphire.name=Sapphire
item.techreborn.gemYellowGarnet.name=Yellow Garnet
#Ingots
item.techreborn.ingot.aluminum.name=Aluminium Ingot
@ -418,8 +418,6 @@ item.techreborn.nuggetTungsten.name=Tungsten Nugget
item.techreborn.nuggetTungstensteel.name=Tungstensteel Nugget
item.techreborn.nuggetZinc.name=Zinc Nugget
#Plates
item.techreborn.plateAdvancedAlloy.name=Advanced Alloy Plate
item.techreborn.plateAluminum.name=Aluminium Plate