mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-11 15:57:31 +00:00
Merge remote-tracking branch 'origin/nei' into dev
This commit is contained in:
commit
623fa9fddb
8 files changed
+254
-10
No files matched your search
@@ -2034,6 +2034,8 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable stonebricksmooth = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(1.5F).setResistance(10.0F)
|
||||
.setStepSound(Block.soundTypeStone);
|
||||
if (Configurations.allowSmoothStone)
|
||||
Carving.chisel.addVariation("stonebricksmooth", Blocks.stone, 0, -1);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i == 1) {
|
||||
if (Configurations.allowMossy)
|
||||
@@ -2527,19 +2529,19 @@ public enum Features {
|
||||
|
||||
private String requiredMod;
|
||||
|
||||
Features() {
|
||||
private Features() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
Features(Features parent) {
|
||||
private Features(Features parent) {
|
||||
this(null, parent);
|
||||
}
|
||||
|
||||
Features(String requiredMod) {
|
||||
private Features(String requiredMod) {
|
||||
this(requiredMod, null);
|
||||
}
|
||||
|
||||
Features(String requriedMod, Features parent) {
|
||||
private Features(String requriedMod, Features parent) {
|
||||
this.requiredMod = requriedMod;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.cricketcraft.chisel.carving;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -99,9 +99,6 @@ public class Carving {
|
||||
}
|
||||
|
||||
public CarvingGroup getGroup(Block block, int metadata) {
|
||||
if (block.equals(Blocks.stone))
|
||||
block = Blocks.stonebrick;
|
||||
|
||||
// Check name first
|
||||
CarvingGroup res;
|
||||
int i = OreDictionary.getOreID(block.getUnlocalizedName());
|
||||
@@ -123,7 +120,7 @@ public class Carving {
|
||||
return null;
|
||||
}
|
||||
|
||||
CarvingGroup getGroup(String name) {
|
||||
public CarvingGroup getGroup(String name) {
|
||||
CarvingGroup group = carvingGroupsByName.get(name);
|
||||
if (group == null) {
|
||||
group = new CarvingGroup(name);
|
||||
@@ -179,4 +176,13 @@ public class Carving {
|
||||
|
||||
return blockGroup.sound;
|
||||
}
|
||||
|
||||
public List<String> getSortedGroupNames() {
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (String s : carvingGroupsByName.keySet()) {
|
||||
names.add(s);
|
||||
}
|
||||
Collections.sort(names);
|
||||
return names;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.cricketcraft.chisel.carving;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class CarvingGroup {
|
||||
|
||||
public CarvingGroup(String n) {
|
||||
@@ -15,4 +17,17 @@ public class CarvingGroup {
|
||||
String oreName;
|
||||
|
||||
List<CarvingVariation> variations = new ArrayList<CarvingVariation>();
|
||||
}
|
||||
|
||||
public List<CarvingVariation> getVariations() {
|
||||
return ImmutableList.copyOf(variations);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getOreName() {
|
||||
return oreName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cricketcraft.chisel.carving;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CarvingVariation implements Comparable<CarvingVariation> {
|
||||
|
||||
@@ -20,4 +21,9 @@ public class CarvingVariation implements Comparable<CarvingVariation> {
|
||||
public Block block;
|
||||
public int meta;
|
||||
public int damage;
|
||||
|
||||
public ItemStack getStack() {
|
||||
return new ItemStack(block, 1, damage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.cricketcraft.chisel.compat.nei;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
public class NEIChiselConfig implements IConfigureNEI {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Chisel.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return Chisel.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
RecipeHandlerChisel handler = new RecipeHandlerChisel();
|
||||
API.registerRecipeHandler(handler);
|
||||
API.registerUsageHandler(handler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package com.cricketcraft.chisel.compat.nei;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.carving.CarvingGroup;
|
||||
import com.cricketcraft.chisel.carving.CarvingVariation;
|
||||
|
||||
public class RecipeHandlerChisel extends TemplateRecipeHandler {
|
||||
|
||||
private static final int SLOTS_PER_PAGE = 45;
|
||||
|
||||
public class CachedChiselRecipe extends CachedRecipe {
|
||||
|
||||
private List<PositionedStack> input = new ArrayList<PositionedStack>();
|
||||
private List<PositionedStack> outputs = new ArrayList<PositionedStack>();
|
||||
public Point focus;
|
||||
|
||||
public CachedChiselRecipe(List<ItemStack> variations, ItemStack base, ItemStack focus) {
|
||||
PositionedStack pStack = new PositionedStack(base != null ? base : variations, 74, 4);
|
||||
pStack.setMaxSize(1);
|
||||
this.input.add(pStack);
|
||||
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
for (ItemStack v : variations) {
|
||||
this.outputs.add(new PositionedStack(v, 3 + 18 * col, 37 + 18 * row));
|
||||
|
||||
if (focus != null && NEIServerUtils.areStacksSameTypeCrafting(focus, v)) {
|
||||
this.focus = new Point(2 + 18 * col, 36 + 18 * row);
|
||||
}
|
||||
|
||||
col++;
|
||||
if (col > 8) {
|
||||
col = 0;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CachedChiselRecipe(List<ItemStack> variations) {
|
||||
this(variations, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return this.getCycledIngredients(cycleticks / 20, this.input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks() {
|
||||
return this.outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "Chisel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "Chisel:textures/chiselNEI.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 130);
|
||||
|
||||
Point focus = ((CachedChiselRecipe) this.arecipes.get(recipeIndex)).focus;
|
||||
if (focus != null) {
|
||||
GuiDraw.drawTexturedModalRect(focus.x, focus.y, 166, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75, 22, 15, 13), "chisel2.chisel", new Object[0]));
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("chisel2.chisel")) {
|
||||
for (String name : Carving.chisel.getSortedGroupNames()) {
|
||||
CarvingGroup g = Carving.chisel.getGroup(name);
|
||||
if (!g.getVariations().isEmpty()) {
|
||||
addCached(getVariationStacks(g));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (String name : Carving.chisel.getSortedGroupNames()) {
|
||||
CarvingGroup g = Carving.chisel.getGroup(name);
|
||||
List<ItemStack> variations = getVariationStacks(g);
|
||||
for (ItemStack stack : variations) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack, result)) {
|
||||
addCached(variations, null, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (String name : Carving.chisel.getSortedGroupNames()) {
|
||||
CarvingGroup g = Carving.chisel.getGroup(name);
|
||||
List<ItemStack> variations = getVariationStacks(g);
|
||||
for (ItemStack stack : variations) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) {
|
||||
addCached(variations, ingredient, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addCached(List<ItemStack> variations, ItemStack base, ItemStack focus) {
|
||||
if (variations.size() > SLOTS_PER_PAGE) {
|
||||
List<List<ItemStack>> parts = new ArrayList<List<ItemStack>>();
|
||||
int size = variations.size();
|
||||
for (int i = 0; i < size; i += SLOTS_PER_PAGE) {
|
||||
parts.add(new ArrayList<ItemStack>(variations.subList(i, Math.min(size, i + SLOTS_PER_PAGE))));
|
||||
}
|
||||
for (List<ItemStack> part : parts) {
|
||||
this.arecipes.add(new CachedChiselRecipe(part, base, focus));
|
||||
}
|
||||
} else {
|
||||
this.arecipes.add(new CachedChiselRecipe(variations, base, focus));
|
||||
}
|
||||
}
|
||||
|
||||
private void addCached(List<ItemStack> variations) {
|
||||
addCached(variations, null, null);
|
||||
}
|
||||
|
||||
private static List<ItemStack> getVariationStacks(CarvingGroup g) {
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for (CarvingVariation v : g.getVariations()) {
|
||||
stacks.add(v.getStack());
|
||||
}
|
||||
String oreName = g.getOreName();
|
||||
if (oreName != null) {
|
||||
check: for (ItemStack ore : OreDictionary.getOres(oreName)) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack, ore)) {
|
||||
continue check;
|
||||
}
|
||||
}
|
||||
stacks.add(ore.copy());
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class Configurations {
|
||||
public static boolean ghostCloud;
|
||||
public static int factoryBlockAmount;
|
||||
public static boolean allowMossy;
|
||||
public static boolean allowSmoothStone;
|
||||
public static boolean chiselRecipe;
|
||||
public static boolean enableFMP;
|
||||
public static boolean chiselStoneToCobbleBricks;
|
||||
@@ -54,6 +55,7 @@ public class Configurations {
|
||||
ghostCloud = config.get(category, "doesCloudRenderLikeGhost", true).getBoolean(true);
|
||||
factoryBlockAmount = config.get(category, "amountYouGetFromFactoryBlockCrafting", 32).getInt(32);
|
||||
allowMossy = config.get(category, "allowCobbleToMossyInChisel", true).getBoolean(true);
|
||||
allowSmoothStone = config.get(category, "allowSmoothStoneToStoneBricksAndBack", true).getBoolean(true);
|
||||
chiselRecipe = config.get(category, "chiselAlternateRecipe", false, "Use alternative crafting recipe for the chisel").getBoolean(false);
|
||||
enableFMP = config.get(category, "enableFMP", true, "Do you want to enable FMP").getBoolean(true);
|
||||
chiselStoneToCobbleBricks = config.get(category, "chiselStoneToCobbleBricks", true, "Chisel stone to cobblestone and bricks by left clicking.").getBoolean(false);
|
||||
|
||||
Reference in new issue
Block a user