Remove old partsystem, time for a new one

This commit is contained in:
modmuss50 2016-03-02 15:43:39 +00:00
parent 06d23b10b7
commit 721ba370bb
36 changed files with 0 additions and 3707 deletions

View file

@ -1,158 +0,0 @@
package techreborn.compat.nei;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import reborncore.common.util.ItemUtils;
import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.client.gui.GuiFusionReactor;
import java.awt.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class FustionReacorRecipeHandler extends TemplateRecipeHandler {
public class CachedReactorRecipe extends CachedRecipe {
private List<PositionedStack> input = new ArrayList<PositionedStack>();
private List<PositionedStack> outputs = new ArrayList<PositionedStack>();
public Point focus;
public FusionReactorRecipe recipe;
public CachedReactorRecipe(FusionReactorRecipe recipe) {
this.recipe = recipe;
addPositionedStacks(input, outputs, recipe);
}
@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 void drawBackground(int recipeIndex) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78);
GuiDraw.drawTooltipBox(10, 80, 145, 50);
GuiDraw.drawString("Info:", 14, 84, -1);
CachedRecipe recipe = arecipes.get(recipeIndex);
if (recipe instanceof CachedReactorRecipe) {
CachedReactorRecipe genericRecipe = (CachedReactorRecipe) recipe;
float scale = 0.9F;
GL11.glScalef(scale, scale, scale);
DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
symbols.setGroupingSeparator('.');
formatter.setDecimalFormatSymbols(symbols);
GuiDraw.drawString("Start: " + formatter.format(genericRecipe.recipe.getStartEU()) + "EU", 16, 105, -1);
GuiDraw.drawString("EU/t: " + genericRecipe.recipe.getEuTick() , 16, 115, -1);
GuiDraw.drawString("Ticks to process: " + genericRecipe.recipe.getTickTime(), 14, 125, -1);
GuiDraw.drawString("Time to process: " + genericRecipe.recipe.getTickTime() / 20 + " seconds", 14, 135, -1);
}
}
@Override
public int recipiesPerPage() {
return 1;
}
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getRecipeName())) {
for (FusionReactorRecipe recipeType : FusionReactorRecipeHelper.reactorRecipes) {
addCached(recipeType);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (FusionReactorRecipe recipeType : FusionReactorRecipeHelper.reactorRecipes) {
if (ItemUtils.isItemEqual(recipeType.getOutput(), result, true, false, true)) {
addCached(recipeType);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (FusionReactorRecipe recipeType : FusionReactorRecipeHelper.reactorRecipes) {
if (ItemUtils.isItemEqual(ingredient, recipeType.getTopInput(), true, false, true)) {
addCached(recipeType);
}
if (ItemUtils.isItemEqual(ingredient, recipeType.getBottomInput(), true, false, true)) {
addCached(recipeType);
}
}
}
private void addCached(FusionReactorRecipe recipie) {
this.arecipes.add(new CachedReactorRecipe(recipie));
}
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, FusionReactorRecipe recipeType) {
int offset = 4;
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getTopInput()), 88 - offset, 17 - offset, false);
input.add(pStack);
if(recipeType.getBottomInput() != null){
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getBottomInput()), 88 - offset, 53 - offset, false);
input.add(pStack2);
}
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(), 148 - offset, 35 - offset, false);
outputs.add(pStack3);
}
@Override
public String getRecipeName() {
return "Fustion Reactor";
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/fusion_reactor.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiFusionReactor.class;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(82, 23, 52, 18), getRecipeName(), new Object[0]));
}
}

View file

@ -1,82 +0,0 @@
package techreborn.compat.nei;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import techreborn.api.recipe.machines.VacuumFreezerRecipe;
import techreborn.compat.nei.recipes.*;
import techreborn.lib.ModInfo;
public class NEIConfig implements IConfigureNEI {
@Override
public String getName() {
return ModInfo.MOD_ID;
}
@Override
public String getVersion() {
return ModInfo.MOD_VERSION;
}
@Override
public void loadConfig() {
ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler();
ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler();
ImplosionCompressorRecipeHandler implosion = new ImplosionCompressorRecipeHandler();
API.registerUsageHandler(implosion);
API.registerRecipeHandler(implosion);
AlloySmelterRecipeHandler alloy = new AlloySmelterRecipeHandler();
API.registerUsageHandler(alloy);
API.registerRecipeHandler(alloy);
IronAlloySmelterRecipeHandler ironAlloy = new IronAlloySmelterRecipeHandler();
API.registerUsageHandler(ironAlloy);
API.registerRecipeHandler(ironAlloy);
IndustrialSawmillRecipeHandler sawmill = new IndustrialSawmillRecipeHandler();
API.registerUsageHandler(sawmill);
API.registerRecipeHandler(sawmill);
ChemicalReactorRecipeHandler chem = new ChemicalReactorRecipeHandler();
API.registerUsageHandler(chem);
API.registerRecipeHandler(chem);
CentrifugeRecipeHandler cent = new CentrifugeRecipeHandler();
API.registerUsageHandler(cent);
API.registerRecipeHandler(cent);
GrinderRecipeHandler grind = new GrinderRecipeHandler();
API.registerUsageHandler(grind);
API.registerRecipeHandler(grind);
IndustrialElectrolyzerRecipeHandler elec = new IndustrialElectrolyzerRecipeHandler();
API.registerUsageHandler(elec);
API.registerRecipeHandler(elec);
BlastFurnaceRecipeHandler blast = new BlastFurnaceRecipeHandler();
API.registerUsageHandler(blast);
API.registerRecipeHandler(blast);
API.registerUsageHandler(shapedRollingMachineHandler);
API.registerRecipeHandler(shapedRollingMachineHandler);
API.registerUsageHandler(shapelessRollingMachineHandler);
API.registerRecipeHandler(shapelessRollingMachineHandler);
AssemblingMachineRecipeHandler assemblingMachineRecipe = new AssemblingMachineRecipeHandler();
API.registerUsageHandler(assemblingMachineRecipe);
API.registerRecipeHandler(assemblingMachineRecipe);
FustionReacorRecipeHandler fustionReacorRecipeHandler = new FustionReacorRecipeHandler();
API.registerUsageHandler(fustionReacorRecipeHandler);
API.registerRecipeHandler(fustionReacorRecipeHandler);
VacuumFreezerRecipeHandler vacuumFreezerRecipe = new VacuumFreezerRecipeHandler();
API.registerUsageHandler(vacuumFreezerRecipe);
API.registerRecipeHandler(vacuumFreezerRecipe);
}
}

View file

@ -1,111 +0,0 @@
//Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapedRecipeHandler.java
package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapedRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe;
import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine;
import java.awt.*;
import java.util.List;
public class ShapedRollingMachineHandler extends ShapedRecipeHandler {
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiRollingMachine.class;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24,
18), "rollingcrafting", new Object[0]));
}
@Override
public String getRecipeName() {
return "Shaped Rolling Machine";
}
@Override
public String getOverlayIdentifier() {
return "rollingcrafting";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("rollingcrafting")
&& getClass() == ShapedRollingMachineHandler.class) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
.getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null)
continue;
recipe.computeVisuals();
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
.getRecipeList()) {
if (NEIServerUtils.areStacksSameTypeCrafting(
irecipe.getRecipeOutput(), result)) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null)
continue;
recipe.computeVisuals();
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
.getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null
|| !recipe.contains(recipe.ingredients,
ingredient.getItem()))
continue;
recipe.computeVisuals();
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/rolling_machine.png";
}
}

View file

@ -1,116 +0,0 @@
//Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapelessRecipeHandler.java
package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapelessRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine;
import java.awt.*;
import java.util.List;
public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiRollingMachine.class;
}
public String getRecipeName() {
return "Shapeless Rolling Machine";
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18),
"rollingcraftingnoshape"));
}
@Override
public String getOverlayIdentifier() {
return "rollingcraftingnoshape";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("rollingcraftingnoshape")
&& getClass() == ShapelessRollingMachineHandler.class) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes) {
if (NEIServerUtils.areStacksSameTypeCrafting(
irecipe.getRecipeOutput(), result)) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) {
if (recipe.recipeItems == null)
return null;
return new CachedShapelessRecipe(recipe.recipeItems,
recipe.getRecipeOutput());
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/rolling_machine.png";
}
}

View file

@ -1,54 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiAlloySmelter;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class AlloySmelterRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 47 - offset, 17 - offset, false);
input.add(pStack);
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset, false);
input.add(pStack2);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset, false);
outputs.add(pStack3);
}
@Override
public String getRecipeName() {
return Reference.alloySmelteRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/electric_alloy_furnace.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiAlloySmelter.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(75, 20, 25, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}

View file

@ -1,59 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiAssemblingMachine;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class AssemblingMachineRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 47 - offset, 17 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset, false);
outputs.add(pStack3);
}
}
@Override
public String getRecipeName() {
return Reference.assemblingMachineRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/assembling_machine.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiAssemblingMachine.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(80, 20, 20, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}

View file

@ -1,79 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class BlastFurnaceRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 40 - offset, 25 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 40 - offset, 43 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 100 - offset, 35 - offset, false);
outputs.add(pStack3);
}
if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 118 - offset, 35 - offset, false);
outputs.add(pStack4);
}
}
@Override
public String getRecipeName() {
return Reference.blastFurnaceRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/industrial_blast_furnace.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiBlastFurnace.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(55, 20, 25, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
@Override
public void drawBackground(int recipeIndex) {
super.drawBackground(recipeIndex);
CachedRecipe recipe = arecipes.get(recipeIndex);
if (recipe instanceof CachedGenericRecipe) {
if (((CachedGenericRecipe) recipe).recipie instanceof BlastFurnaceRecipe) {
BlastFurnaceRecipe blastFurnaceRecipeHandler = (BlastFurnaceRecipe) ((CachedGenericRecipe) recipe).recipie;
GuiDraw.drawString("Requires " + blastFurnaceRecipeHandler.neededHeat + " heat", 14, 135, -1);
}
}
}
}

View file

@ -1,75 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class CentrifugeRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 80 - offset, 35 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 50 - offset, 5 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 80 - offset, 5 - offset, false);
outputs.add(pStack3);
}
if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 110 - offset, 35 - offset, false);
outputs.add(pStack4);
}
if (recipeType.getOutputsSize() > 2) {
PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 80 - offset, 65 - offset, false);
outputs.add(pStack5);
}
if (recipeType.getOutputsSize() > 3) {
PositionedStack pStack6 = new PositionedStack(recipeType.getOutput(3), 50 - offset, 35 - offset, false);
outputs.add(pStack6);
}
}
@Override
public String getRecipeName() {
return Reference.centrifugeRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/industrial_centrifuge.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiCentrifuge.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64, 25, 10, 10), getNeiBaseRecipe().getRecipeName(), new Object[0]));
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(94, 25, 10, 10), getNeiBaseRecipe().getRecipeName(), new Object[0]));
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(78, 15, 10, 10), getNeiBaseRecipe().getRecipeName(), new Object[0]));
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(78, 40, 10, 10), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}

View file

@ -1,59 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiChemicalReactor;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class ChemicalReactorRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 70 - offset, 21 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 90 - offset, 21 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 80 - offset, 51 - offset, false);
outputs.add(pStack3);
}
}
@Override
public String getRecipeName() {
return Reference.chemicalReactorRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/chemical_reactor.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiChemicalReactor.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(70, 20, 25, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}

View file

@ -1,141 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.RecipeHandler;
import java.awt.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public abstract class GenericRecipeHander extends TemplateRecipeHandler {
public INeiBaseRecipe getNeiBaseRecipe() {
return null;
}
public class CachedGenericRecipe extends CachedRecipe {
private List<PositionedStack> input = new ArrayList<PositionedStack>();
private List<PositionedStack> outputs = new ArrayList<PositionedStack>();
public Point focus;
public IBaseRecipeType recipie;
public INeiBaseRecipe neiBaseRecipe;
public CachedGenericRecipe(IBaseRecipeType recipe, INeiBaseRecipe neiBaseRecipe) {
this.recipie = recipe;
this.neiBaseRecipe = neiBaseRecipe;
neiBaseRecipe.addPositionedStacks(input, outputs, recipe);
}
@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 RecipeHandler.getUserFreindlyName(getNeiBaseRecipe().getRecipeName());
}
@Override
public String getGuiTexture() {
return getNeiBaseRecipe().getGuiTexture();
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return getNeiBaseRecipe().getGuiClass();
}
@Override
public void drawBackground(int recipeIndex) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78);
GuiDraw.drawTooltipBox(10, 80, 145, 50);
GuiDraw.drawString("Info:", 14, 84, -1);
CachedRecipe recipe = arecipes.get(recipeIndex);
if (recipe instanceof CachedGenericRecipe) {
CachedGenericRecipe genericRecipe = (CachedGenericRecipe) recipe;
float scale = 0.9F;
GL11.glScalef(scale, scale, scale);
DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
symbols.setGroupingSeparator('.');
formatter.setDecimalFormatSymbols(symbols);
GuiDraw.drawString("EU needed: " + formatter.format(new Integer(genericRecipe.recipie.euPerTick() * genericRecipe.recipie.tickTime()).longValue()), 16, 105, -1);
GuiDraw.drawString("Ticks to process: " + genericRecipe.recipie.tickTime(), 14, 115, -1);
GuiDraw.drawString("Time to process: " + genericRecipe.recipie.tickTime() / 20 + " seconds", 14, 125, -1);
}
}
@Override
public int recipiesPerPage() {
return 1;
}
// public void loadTransferRects() {
// this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
// new Rectangle(0, 0, 20, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
// }
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getNeiBaseRecipe().getRecipeName())) {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) {
addCached(recipeType);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) {
for (int i = 0; i < recipeType.getOutputsSize(); i++) {
if (ItemUtils.isItemEqual(recipeType.getOutput(i), result, true, false, true)) {
addCached(recipeType);
}
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) {
for (ItemStack input : recipeType.getInputs()) {
if (ItemUtils.isItemEqual(ingredient, input, true, false, true)) {
addCached(recipeType);
}
}
}
}
private void addCached(IBaseRecipeType recipie) {
this.arecipes.add(new CachedGenericRecipe(recipie, getNeiBaseRecipe()));
}
}

View file

@ -1,104 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import reborncore.client.gui.GuiUtil;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.machines.GrinderRecipe;
import techreborn.client.gui.GuiGrinder;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class GrinderRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 32 - offset, 26 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 32 - offset, 44 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 77 - offset, 35 - offset, false);
outputs.add(pStack3);
}
if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 95 - offset, 35 - offset, false);
outputs.add(pStack4);
}
if (recipeType.getOutputsSize() > 2) {
PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 113 - offset, 35 - offset, false);
outputs.add(pStack5);
}
if (recipeType.getOutputsSize() > 3) {
PositionedStack pStack6 = new PositionedStack(recipeType.getOutput(3), 131 - offset, 35 - offset, false);
outputs.add(pStack6);
}
}
@Override
public String getRecipeName() {
return Reference.grinderRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/industrial_grinder.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiGrinder.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(44, 20, 25, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
@Override
public void drawBackground(int recipeIndex) {
super.drawBackground(recipeIndex);
CachedRecipe recipe = arecipes.get(recipeIndex);
if (recipe instanceof CachedGenericRecipe) {
if (((CachedGenericRecipe) recipe).recipie instanceof GrinderRecipe) {
GrinderRecipe grinderRecipe = (GrinderRecipe) ((CachedGenericRecipe) recipe).recipie;
if (grinderRecipe.fluidStack != null) {
IIcon fluidIcon = grinderRecipe.fluidStack.getFluid().getIcon();
if (fluidIcon != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
int liquidHeight = grinderRecipe.fluidStack.amount * 100 / 16000;
GuiUtil.drawRepeated(fluidIcon, 7, 22 + 47 - liquidHeight, 14.0D, liquidHeight, GuiDraw.gui.getZLevel());
}
GuiDraw.drawString(grinderRecipe.fluidStack.amount + "mb of " + grinderRecipe.fluidStack.getLocalizedName(), 14, 135, -1);
}
}
}
}
}

View file

@ -1,36 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import net.minecraft.client.gui.inventory.GuiContainer;
import techreborn.api.recipe.IBaseRecipeType;
import java.util.List;
/**
* Use this to make your neiHandler
*/
public interface INeiBaseRecipe {
/**
* Add the inputs and the outputs
*
* @param input add the input stacks to this
* @param outputs add this output stacks to this
*/
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType);
/**
* @return the recipe name that is used for the recipe
*/
public String getRecipeName();
/**
* @return the guiTexture location
*/
public String getGuiTexture();
/**
* @return the gui class for the recipe
*/
public Class<? extends GuiContainer> getGuiClass();
}

View file

@ -1,64 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiImplosionCompressor;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class ImplosionCompressorRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 37 - offset, 26 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 37 - offset, 44 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 93 - offset, 35 - offset, false);
outputs.add(pStack3);
}
if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 111 - offset, 35 - offset, false);
outputs.add(pStack4);
}
}
@Override
public String getRecipeName() {
return Reference.implosionCompressorRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/implosion_compressor.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiImplosionCompressor.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(50, 20, 25, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}

View file

@ -1,73 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class IndustrialElectrolyzerRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 80 - offset, 51 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 50 - offset, 51 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 50 - offset, 19 - offset, false);
outputs.add(pStack3);
}
if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 70 - offset, 19 - offset, false);
outputs.add(pStack4);
}
if (recipeType.getOutputsSize() > 2) {
PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 90 - offset, 19 - offset, false);
outputs.add(pStack5);
}
if (recipeType.getOutputsSize() > 3) {
PositionedStack pStack6 = new PositionedStack(recipeType.getOutput(3), 110 - offset, 19 - offset, false);
outputs.add(pStack6);
}
}
@Override
public String getRecipeName() {
return Reference.industrialElectrolyzerRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/industrial_electrolyzer.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiIndustrialElectrolyzer.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(80, 20, 15, 15), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}

View file

@ -1,97 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import reborncore.client.gui.GuiUtil;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
import techreborn.client.gui.GuiIndustrialSawmill;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class IndustrialSawmillRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
if (recipeType.getInputs().size() > 0) {
PositionedStack pStack = new PositionedStack(recipeType.getInputs().get(0), 32 - offset, 26 - offset, false);
input.add(pStack);
}
if (recipeType.getInputs().size() > 1) {
PositionedStack pStack2 = new PositionedStack(recipeType.getInputs().get(1), 32 - offset, 44 - offset, false);
input.add(pStack2);
}
if (recipeType.getOutputsSize() > 0) {
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 84 - offset, 35 - offset, false);
outputs.add(pStack3);
}
if (recipeType.getOutputsSize() > 1) {
PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 102 - offset, 35 - offset, false);
outputs.add(pStack4);
}
if (recipeType.getOutputsSize() > 2) {
PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 120 - offset, 35 - offset, false);
outputs.add(pStack5);
}
}
@Override
public String getRecipeName() {
return Reference.industrialSawmillRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/industrial_sawmill.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiIndustrialSawmill.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(50, 20, 25, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
@Override
public void drawBackground(int recipeIndex) {
super.drawBackground(recipeIndex);
CachedRecipe recipe = arecipes.get(recipeIndex);
if (recipe instanceof CachedGenericRecipe) {
if (((CachedGenericRecipe) recipe).recipie instanceof IndustrialSawmillRecipe) {
IndustrialSawmillRecipe grinderRecipe = (IndustrialSawmillRecipe) ((CachedGenericRecipe) recipe).recipie;
if (grinderRecipe.fluidStack != null) {
IIcon fluidIcon = grinderRecipe.fluidStack.getFluid().getIcon();
if (fluidIcon != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
int liquidHeight = grinderRecipe.fluidStack.amount * 100 / 16000;
GuiUtil.drawRepeated(fluidIcon, 7, 22 + 47 - liquidHeight, 14.0D, liquidHeight, GuiDraw.gui.getZLevel());
}
GuiDraw.drawString(grinderRecipe.fluidStack.amount + "mb of " + grinderRecipe.fluidStack.getLocalizedName(), 14, 135, -1);
}
}
}
}
}

View file

@ -1,86 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.ItemList;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
import org.lwjgl.opengl.GL11;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiAlloyFurnace;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Created by MrBretzel on 01/11/2015.
*/
public class IronAlloySmelterRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 46 - offset, 9 - offset, false);
input.add(pStack);
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 64 - offset, 9 - offset, false);
input.add(pStack2);
Iterator i = ItemList.items.iterator();
List<ItemStack> fuels = new ArrayList<ItemStack>();
while(i.hasNext()) {
ItemStack item = (ItemStack) i.next();
if(!fuels.contains(new ItemStack(item.getItem()))) {
int burnTime = TileEntityFurnace.getItemBurnTime(item);
if(burnTime > 0) {
fuels.add(new ItemStack(item.getItem()));
}
}
}
PositionedStack pStack3 = new PositionedStack(fuels, 51, 42, false);
input.add(pStack3);
PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(0), 115 - offset, 28 - offset, false);
outputs.add(pStack4);
}
@Override
public String getRecipeName() {
return Reference.alloySmelteRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/alloy_furnace.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiAlloyFurnace.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(75, 20, 25, 20), Reference.alloySmelteRecipe, new Object[0]));
}
@Override
public void drawBackground(int recipeIndex) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 65);
}
}

View file

@ -1,51 +0,0 @@
package techreborn.compat.nei.recipes;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.IBaseRecipeType;
import techreborn.client.gui.GuiVacuumFreezer;
import techreborn.lib.Reference;
import java.awt.*;
import java.util.List;
public class VacuumFreezerRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
@Override
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
int offset = 4;
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 34 - offset, false);
input.add(pStack);
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset, false);
outputs.add(pStack3);
}
@Override
public String getRecipeName() {
return Reference.vacuumFreezerRecipe;
}
@Override
public String getGuiTexture() {
return "techreborn:textures/gui/vacuum_freezer.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiVacuumFreezer.class;
}
@Override
public INeiBaseRecipe getNeiBaseRecipe() {
return this;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(75, 20, 25, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
}
}

View file

@ -1,14 +0,0 @@
package techreborn.partSystem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import java.util.ArrayList;
public interface ICustomHighlight {
ArrayList<AxisAlignedBB> getBoxes(World world, int x, int y, int z,
EntityPlayer player);
}

View file

@ -1,120 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import java.util.List;
/**
* This is based of
* https://github.com/Qmunity/QmunityLib/blob/master/src/main/java
* /uk/co/qmunity/lib/part/IPart.java
* <p/>
* You should not be implementing this.
*/
public interface IModPart {
/**
* Adds all of this part's collision boxes to the list. These boxes can
* depend on the entity that's colliding with them.
*/
public void addCollisionBoxesToList(List<Vecs3dCube> boxes, Entity entity);
/**
* Gets this part's selection boxes.
*/
public List<Vecs3dCube> getSelectionBoxes();
/**
* Gets this part's occlusion boxes.
*/
public List<Vecs3dCube> getOcclusionBoxes();
/**
* Renders this part dynamically (every render tick).
*/
@SideOnly(Side.CLIENT)
public void renderDynamic(Vecs3d translation, double delta);
/**
* Renders this part statically. A tessellator has alredy started drawing. <br>
* Only called when there's a block/lighting/render update in the chunk this
* part is in.
*/
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vecs3d translation, int pass);
/**
* Writes the part's data to an NBT tag, which is saved with the game data.
*/
public void writeToNBT(NBTTagCompound tag);
/**
* Reads the part's data from an NBT tag, which was stored in the game data.
*/
public void readFromNBT(NBTTagCompound tag);
/**
* Gets the itemstack that places this part.
*/
public ItemStack getItem();
/**
* Gets the name of this part.
*/
public String getName();
/**
* Gets the world of this part.
*/
public World getWorld();
/**
* This is the item texture eg: "network:cable"
*/
public String getItemTextureName();
/**
* Gets the X cord of this part.
*/
public int getX();
/**
* Gets the Y cord of this part.
*/
public int getY();
/**
* Gets the Z cord of this part.
*/
public int getZ();
/**
* Called every tick
*/
public void tick();
/**
* Called when a block or part has been changed. Can be used for cables to
* check nearby blocks
*/
public void nearByChange();
public void onAdded();
public void onRemoved();
public IModPart copy();
public boolean needsItem();
}

View file

@ -1,10 +0,0 @@
package techreborn.partSystem;
import net.minecraft.nbt.NBTTagCompound;
public interface IPartDesc {
public void readDesc(NBTTagCompound tagCompound);
public void writeDesc(NBTTagCompound tagCompound);
}

View file

@ -1,34 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3dCube;
public interface IPartProvider {
public String modID();
public void registerPart();
public boolean checkOcclusion(World world, Location location,
Vecs3dCube cube);
public boolean hasPart(World world, Location location, String name);
public boolean placePart(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int side, float hitX, float hitY, float hitZ,
ModPart modPart);
public boolean isTileFromProvider(TileEntity tileEntity);
public IModPart getPartFromWorld(World world, Location location, String name);
public void init();
}

View file

@ -1,103 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import reborncore.common.misc.Location;
/**
* Extend this class to make your multipart
*/
public abstract class ModPart extends TileEntity implements IModPart {
/**
* The world of the part
*/
public World world;
/**
* The location of the part
*/
public Location location;
/**
* This is the world
*/
@Override
public World getWorld() {
return world;
}
/**
* This sets the world Don't use this unless you know what you are doing.
*/
public void setWorld(World world) {
this.world = world;
setWorldObj(world);
}
/**
* Gets the x position in the world
*/
@Override
public int getX() {
return location.getX();
}
/**
* Gets the y position in the world
*/
@Override
public int getY() {
return location.getY();
}
/**
* Gets the z position in the world
*/
@Override
public int getZ() {
return location.getZ();
}
/**
* Gets the location of the part
*/
public Location getLocation() {
return location;
}
/**
* Sets the x position in the world
*/
public void setLocation(Location location) {
this.location = location;
this.getPos().getX() = location.getX();
this.getPos().getY() = location.getY();
this.getPos().getZ() = location.getZ();
}
@Override
public World getWorldObj() {
return getWorld();
}
@Override
public void setWorldObj(World p_145834_1_) {
super.setWorldObj(p_145834_1_);
}
@Override
public String getItemTextureName() {
return "";
}
@Override
public boolean needsItem() {
return true;
}
}

View file

@ -1,61 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.util.EnumFacing;
import uk.co.qmunity.lib.ref.Names;
public class ModPartItem extends Item {
ModPart modPart;
public ModPartItem(ModPart part) {
modPart = part;
setUnlocalizedName(Names.Unlocalized.Items.MULTIPART);
}
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int face, float x_, float y_, float z_) {
EnumFacing dir = EnumFacing.getOrientation(face);
if (ModPartUtils.hasPart(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, modPart.getName())) {
x = x + dir.offsetX;
y = y + dir.offsetY;
z = z + dir.offsetZ;
}
if (ModPartUtils.hasPart(world, x, y, z, modPart.getName())) {
return false;
}
if (ModPartRegistry.masterProvider != null) {
if (ModPartRegistry.masterProvider.placePart(item, player,
world, x, y, z, face, x_, y_, z_, (ModPart) modPart.copy())) {
player.swingItem();
return true;
}
}
{
for (IPartProvider partProvider : ModPartRegistry.providers) {
if (partProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, (ModPart) modPart.copy())) {
player.swingItem();
return true;
}
}
return true;
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return modPart.getName();
}
public ModPart getModPart() {
return modPart;
}
}

View file

@ -1,107 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import ic2.api.item.IC2Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import techreborn.Core;
import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModParts;
import techreborn.partSystem.parts.CablePart;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class ModPartRegistry {
public static ArrayList<ModPart> parts = new ArrayList<ModPart>();
public static ArrayList<IPartProvider> providers = new ArrayList<IPartProvider>();
public static IPartProvider masterProvider = null;
public static Map<String, Item> itemParts = new HashMap<String, Item>();
public static void registerPart(ModPart iModPart) {
parts.add(iModPart);
}
public static void addAllPartsToSystems() {
for (IPartProvider iPartProvider : providers) {
iPartProvider.init();
}
Core.logHelper.info("Started to load all parts");
for (ModPart modPart : ModPartRegistry.parts) {
if (modPart.needsItem()) {
Item part = new ModPartItem(modPart)
.setUnlocalizedName(modPart.getName())
.setCreativeTab(TechRebornCreativeTab.instance)
.setTextureName(modPart.getItemTextureName());
GameRegistry.registerItem(part, modPart.getName());
itemParts.put(modPart.getName(), part);
if (modPart instanceof CablePart) {
GameRegistry.addShapelessRecipe(new ItemStack(part), IC2Items.getItem(CablePart.getTextureNameFromType(((CablePart) modPart).type)));
((CablePart) modPart).stack = new ItemStack(part);
ModParts.stackCable.put(((CablePart) modPart).type, new ItemStack(part));
}
}
}
for (IPartProvider iPartProvider : providers) {
iPartProvider.registerPart();
}
}
public static Item getItem(String string) {
for (Map.Entry<String, Item> entry : itemParts.entrySet()) {
if (entry.getValue().equals(string)) {
return entry.getValue();
}
}
return null;
}
public static void addProvider(String className, String modid) {
if (Loader.isModLoaded(modid) || modid.equals("Minecraft")) {
try {
IPartProvider iPartProvider = null;
iPartProvider = (IPartProvider) Class.forName(className)
.newInstance();
providers.add(iPartProvider);
//I am doing this because the qlibProvider is the most stable
if (modid.equals("qmunitylib")) {
masterProvider = iPartProvider;
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
Core.logHelper.error("Failed to load " + className
+ " to the part system!");
} catch (InstantiationException e) {
e.printStackTrace();
Core.logHelper.error("Failed to load " + className
+ " to the part system!");
} catch (IllegalAccessException e) {
e.printStackTrace();
Core.logHelper.error("Failed to load " + className
+ " to the part system!");
}
}
}
// Only use this one if it is a standalone Provider
public static void addProvider(IPartProvider iPartProvider) {
if (Loader.isModLoaded(iPartProvider.modID())
|| iPartProvider.modID().equals("Minecraft")) {
providers.add(iPartProvider);
}
}
}

View file

@ -1,94 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3dCube;
import java.util.Map;
public class ModPartUtils {
public static boolean checkOcclusion(World world, Location location,
Vecs3dCube cube) {
if (world == null) {
return false;
}
IPartProvider partProvider = getPartProvider(world, location);
if (partProvider != null) {
return partProvider.checkOcclusion(world, location, cube);
}
return false;
}
public static boolean checkOcclusion(World world, int x, int y, int z, Vecs3dCube cube) {
return !checkOcclusion(world, new Location(x, y, z), cube);
}
public static boolean checkOcclusionInvert(World world, Location location,
Vecs3dCube cube) {
if (world == null) {
return false;
}
for (IPartProvider iPartProvider : ModPartRegistry.providers) {
if (!iPartProvider.checkOcclusion(world, location, cube)) {
return false;
}
}
return false;
}
public static boolean checkOcclusionInvert(World world, int x, int y,
int z, Vecs3dCube cube) {
return checkOcclusionInvert(world, new Location(x, y, z), cube);
}
public static boolean hasPart(World world, Location location, String name) {
for (IPartProvider iPartProvider : ModPartRegistry.providers) {
if (iPartProvider.hasPart(world, location, name)) {
return true;
}
}
return false;
}
public static boolean hasPart(World world, int x, int y, int z, String name) {
return hasPart(world, new Location(x, y, z), name);
}
public static Item getItemForPart(String string) {
for (Map.Entry<String, Item> item : ModPartRegistry.itemParts
.entrySet()) {
if (item.getValue().equals(string)) {
return item.getValue();
}
}
return null;
}
public static IPartProvider getPartProvider(World world, Location location) {
for (IPartProvider partProvider : ModPartRegistry.providers) {
if (partProvider.isTileFromProvider(world.getTileEntity(
location.getX(), location.getY(), location.getZ()))) {
return partProvider;
}
}
return null;
}
public static IModPart getPartFromWorld(World world, Location location, String name) {
for (IPartProvider partProvider : ModPartRegistry.providers) {
IModPart tempPart = null;
tempPart = partProvider.getPartFromWorld(world, location, name);
if (tempPart != null) {
return tempPart;
}
}
return null;
}
}

View file

@ -1,54 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.QLib;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import uk.co.qmunity.lib.vec.Vec3d;
import uk.co.qmunity.lib.vec.Vec3dCube;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mark on 09/12/14.
*/
public class ModLib2QLib {
public static Vec3d convert(Vecs3d input) {
return new Vec3d(input.getX(), input.getY(), input.getZ());
}
public static Vec3dCube convert(Vecs3dCube input) {
return new Vec3dCube(input.toAABB());
}
public static Vecs3d convert(Vec3d input) {
return new Vecs3d(input.getX(), input.getY(), input.getZ());
}
public static Vecs3dCube convert(Vec3dCube input) {
return new Vecs3dCube(input.toAABB());
}
public static List<Vecs3dCube> convert(List<Vec3dCube> input) {
List<Vecs3dCube> list = new ArrayList<Vecs3dCube>();
for (Vec3dCube cube : input) {
list.add(new Vecs3dCube(cube.toAABB()));
}
return list;
}
// Its got to be called becuase of some weird thing see:
// https://stackoverflow.com/questions/1998544/method-has-the-same-erasure-as-another-method-in-type
public static List<Vec3dCube> convert2(List<Vecs3dCube> input) {
List<Vec3dCube> list = new ArrayList<Vec3dCube>();
for (Vecs3dCube cube : input) {
list.add(new Vec3dCube(cube.toAABB()));
}
return list;
}
}

View file

@ -1,149 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.QLib;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.partSystem.ModPart;
import uk.co.qmunity.lib.client.render.RenderHelper;
import uk.co.qmunity.lib.part.*;
import uk.co.qmunity.lib.raytrace.QMovingObjectPosition;
import uk.co.qmunity.lib.raytrace.RayTracer;
import uk.co.qmunity.lib.vec.Vec3d;
import uk.co.qmunity.lib.vec.Vec3dCube;
import uk.co.qmunity.lib.vec.Vec3i;
import java.util.ArrayList;
import java.util.List;
public class QModPart extends PartBase implements IPartCollidable,
IPartSelectable, IPartRenderPlacement, IPartTicking,
IPartUpdateListener {
ModPart iModPart;
public QModPart(ModPart iModPart) {
this.iModPart = iModPart;
}
@Override
public void setParent(ITilePartHolder parent) {
super.setParent(parent);
}
@Override
public String getType() {
return iModPart.getName();
}
@Override
public ItemStack getItem() {
return iModPart.getItem();
}
@Override
public void addCollisionBoxesToList(List<Vec3dCube> boxes, Entity entity) {
List<Vecs3dCube> cubes = new ArrayList<Vecs3dCube>();
iModPart.addCollisionBoxesToList(cubes, entity);
for (Vecs3dCube cube : cubes) {
if (cube != null)
boxes.add(ModLib2QLib.convert(cube));
}
}
@Override
public void renderDynamic(Vec3d translation, double delta, int pass) {
iModPart.renderDynamic(ModLib2QLib.convert(translation), delta);
}
@Override
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
return iModPart.renderStatic(new Vecs3d(translation.getX(), translation.getY(), translation.getZ()), pass);
}
@Override
public QMovingObjectPosition rayTrace(Vec3d start, Vec3d end) {
return RayTracer.instance().rayTraceCubes(this, start, end);
}
@Override
public List<Vec3dCube> getSelectionBoxes() {
return ModLib2QLib.convert2(iModPart.getSelectionBoxes());
}
@Override
public World getWorld() {
return getParent().getWorld();
}
@Override
public void update() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.tick();
}
@Override
public void onPartChanged(IPart part) {
iModPart.nearByChange();
}
@Override
public void onNeighborBlockChange() {
iModPart.nearByChange();
}
@Override
public void onNeighborTileChange() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.nearByChange();
}
@Override
public void onAdded() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.nearByChange();
iModPart.onAdded();
}
@Override
public void onRemoved() {
iModPart.onRemoved();
}
@Override
public void onLoaded() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(getWorld());
iModPart.setLocation(new Location(getX(), getY(), getZ()));
}
iModPart.nearByChange();
}
@Override
public void onUnloaded() {
}
@Override
public void onConverted() {
}
}

View file

@ -1,117 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.QLib;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.util.EnumFacing;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.IPartProvider;
import techreborn.partSystem.ModPart;
import techreborn.partSystem.ModPartRegistry;
import uk.co.qmunity.lib.QLModInfo;
import uk.co.qmunity.lib.part.IPart;
import uk.co.qmunity.lib.part.IPartFactory;
import uk.co.qmunity.lib.part.PartRegistry;
import uk.co.qmunity.lib.part.compat.MultipartCompatibility;
import uk.co.qmunity.lib.tile.TileMultipart;
import uk.co.qmunity.lib.vec.Vec3dCube;
import uk.co.qmunity.lib.vec.Vec3i;
public class QModPartFactory implements IPartFactory, IPartProvider {
@Override
public IPart createPart(String type, boolean client) {
for (ModPart modPart : ModPartRegistry.parts) {
if (modPart.getName().equals(type)) {
return new QModPart((ModPart) modPart.copy());
}
}
return null;
}
@Override
public boolean placePart(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int face, float x_, float y_, float z_,
ModPart modPart) {
IPart part = createPart(
item,
player,
world,
new MovingObjectPosition(x, y, z, face, Vec3
.createVectorHelper(x + x_, y + y_, z + z_)), modPart);
if (part == null)
return false;
EnumFacing dir = EnumFacing.getOrientation(face);
return MultipartCompatibility.placePartInWorld(part, world, new Vec3i(
x, y, z), dir, player, item);
}
@Override
public boolean isTileFromProvider(TileEntity tileEntity) {
return tileEntity instanceof TileMultipart;
}
@Override
public IModPart getPartFromWorld(World world, Location location, String name) {
IPart part = MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name);
if (part != null) {
if (part instanceof QModPart) {
return ((QModPart) part).iModPart;
}
}
return null;
}
@Override
public void init() {
}
public String getCreatedPartType(ItemStack item, EntityPlayer player,
World world, MovingObjectPosition mop, ModPart modPart) {
return modPart.getName();
}
public IPart createPart(ItemStack item, EntityPlayer player, World world,
MovingObjectPosition mop, ModPart modPart) {
return PartRegistry.createPart(
getCreatedPartType(item, player, world, mop, modPart),
world.isRemote);
}
@Override
public String modID() {
return QLModInfo.MODID;
}
@Override
public void registerPart() {
PartRegistry.registerFactory(new QModPartFactory());
}
@Override
public boolean checkOcclusion(World world, Location location,
Vecs3dCube cube) {
return MultipartCompatibility.checkOcclusion(world, location.x,
location.y, location.z, new Vec3dCube(cube.toAABB()));
}
@Override
public boolean hasPart(World world, Location location, String name) {
if (MultipartCompatibility.getPartHolder(world, location.getX(), location.getY(), location.getZ()) == null) {
return false;
}
return MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name) == null;
}
}

View file

@ -1,141 +0,0 @@
package techreborn.partSystem.client;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraft.util.EnumFacing;
import org.lwjgl.opengl.GL11;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3d;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.ModPartItem;
/**
* This is based of
* https://github.com/Qmunity/QmunityLib/blob/master/src%2Fmain%
* 2Fjava%2Fuk%2Fco%2Fqmunity%2Flib%2Fclient%2Frender%2FRenderPartPlacement.java
* <p/>
* You should go check them out!
*/
@SideOnly(Side.CLIENT)
public class PartPlacementRenderer {
private Framebuffer fb = null;
private int width = 0, height = 0;
@SubscribeEvent
public void onRenderTick(RenderWorldLastEvent event) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
ItemStack item = player.getCurrentEquippedItem();
if (item == null)
return;
if (!(item.getItem() instanceof ModPartItem))
return;
if (Minecraft.getMinecraft().gameSettings.hideGUI
&& Minecraft.getMinecraft().currentScreen == null)
return;
MovingObjectPosition mop = player.rayTrace(
player.capabilities.isCreativeMode ? 5 : 4, 0);
if (mop == null
|| mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK)
return;
IModPart part = ((ModPartItem) item.getItem()).getModPart();
if (part == null)
return;
EnumFacing faceHit = EnumFacing.getOrientation(mop.sideHit);
Location location = new Location(mop.blockX, mop.blockY, mop.blockZ);
if (fb == null || width != Minecraft.getMinecraft().displayWidth
|| height != Minecraft.getMinecraft().displayHeight) {
width = Minecraft.getMinecraft().displayWidth;
height = Minecraft.getMinecraft().displayHeight;
fb = new Framebuffer(width, height, true);
}
GL11.glPushMatrix();
{
Minecraft.getMinecraft().getFramebuffer().unbindFramebuffer();
GL11.glPushMatrix();
{
GL11.glLoadIdentity();
fb.bindFramebuffer(true);
GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT
| GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glClearColor(0, 0, 0, 0);
net.minecraft.client.renderer.RenderHelper
.enableStandardItemLighting();
GL11.glPushMatrix();
{
Vec3 playerPos = player.getPosition(event.partialTicks);
double x = location.getX() - playerPos.getPos().getX()
+ faceHit.offsetX;
double y = location.getY() - playerPos.getPos().getY()
+ faceHit.offsetY;
double z = location.getZ() - playerPos.getPos().getZ()
+ faceHit.offsetZ;
GL11.glRotated(player.rotationPitch, 1, 0, 0);
GL11.glRotated(player.rotationYaw - 180, 0, 1, 0);
GL11.glTranslated(x, y, z);
part.renderDynamic(new Vecs3d(0, 0, 0), event.partialTicks);
}
GL11.glPopMatrix();
net.minecraft.client.renderer.RenderHelper
.disableStandardItemLighting();
fb.unbindFramebuffer();
}
GL11.glPopMatrix();
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
GL11.glPushMatrix();
{
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution scaledresolution = new ScaledResolution(mc,
mc.displayWidth, mc.displayHeight);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, scaledresolution.getScaledWidth_double(),
scaledresolution.getScaledHeight_double(), 0, 0.1,
10000D);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
fb.bindFramebufferTexture();
{
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,
GL11.GL_ONE_MINUS_SRC_ALPHA);
Tessellator tessellator = Tessellator.instance;
int w = scaledresolution.getScaledWidth();
int h = scaledresolution.getScaledHeight();
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(1, 1, 1, 0.5F);
tessellator.addVertexWithUV(w, h, 0.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV(w, 0, 0.0D, 1.0D, 1.0D);
tessellator.addVertexWithUV(0, 0, 0.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV(0, h, 0.0D, 0.0D, 0.0D);
tessellator.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
}
fb.unbindFramebufferTexture();
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glPopMatrix();
fb.framebufferClear();
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
}
GL11.glPopMatrix();
}
}

View file

@ -1,135 +0,0 @@
package techreborn.partSystem.fmp;
import codechicken.lib.packet.PacketCustom;
import codechicken.lib.raytracer.RayTracer;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import ic2.api.item.IC2Items;
import ic2.core.block.wiring.BlockCable;
import ic2.core.block.wiring.TileEntityCable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import reborncore.common.packets.AddDiscriminatorEvent;
import reborncore.common.packets.PacketHandler;
import techreborn.partSystem.parts.CablePart;
import java.util.Arrays;
public class CableConverter implements MultiPartRegistry.IPartConverter {
@Override
public Iterable<Block> blockTypes() {
return Arrays.asList(Block.getBlockFromItem(IC2Items.getItem("copperCableBlock").getItem()));
}
@Override
public TMultiPart convert(World world, BlockCoord blockCoord) {
Block block = world.getBlock(blockCoord.x, blockCoord.y, blockCoord.z);
if (block instanceof BlockCable) {
TileEntity tileEntity = world.getTileEntity(blockCoord.x, blockCoord.y, blockCoord.z);
if (tileEntity instanceof TileEntityCable) {
TileEntityCable cable = (TileEntityCable) tileEntity;
int type = cable.cableType;
CablePart newPart = new CablePart();
newPart.setType(type);
return new FMPModPart(newPart);
}
}
return null;
}
private final ThreadLocal<Object> placing = new ThreadLocal<Object>();
@SubscribeEvent(priority = EventPriority.LOW)
public void playerInteract(PlayerInteractEvent event) {
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote) {
if (placing.get() != null) return;//for mods that do dumb stuff and call this event like MFR
placing.set(event);
if (place(event.entityPlayer, event.entityPlayer.worldObj)) event.setCanceled(true);
placing.set(null);
}
}
public static boolean place(EntityPlayer player, World world) {
MovingObjectPosition hit = RayTracer.reTrace(world, player);
if (hit == null) return false;
BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ);
ItemStack held = player.getHeldItem();
FMPModPart part = null;
if (held == null) return false;
Item heldItem = held.getItem();
if (heldItem == IC2Items.getItem("copperCableItem").getItem()) {
CablePart cablePart = new CablePart();
cablePart.setType(held.getItemDamage());
part = new FMPModPart(cablePart);
}
if (part == null) return false;
if (world.isRemote && !player.isSneaking())//attempt to use block activated like normal and tell the server the right stuff
{
Vector3 f = new Vector3(hit.hitVec).add(-hit.blockX, -hit.blockY, -hit.blockZ);
Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
if (!ignoreActivate(block) && block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float) f.x, (float) f.y, (float) f.z)) {
player.swingItem();
PacketCustom.sendToServer(new C08PacketPlayerBlockPlacement(hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float) f.x, (float) f.y, (float) f.z));
return true;
}
}
TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
if (tile == null || !tile.canAddPart(part)) {
pos = pos.offset(hit.sideHit);
tile = TileMultipart.getOrConvertTile(world, pos);
if (tile == null || !tile.canAddPart(part)) return false;
}
if (!world.isRemote) {
TileMultipart.addPart(world, pos, part);
world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, Blocks.wool.stepSound.func_150496_b(), (Blocks.wool.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.wool.stepSound.getPitch() * 0.8F);
if (!player.capabilities.isCreativeMode) {
held.stackSize--;
if (held.stackSize == 0) {
player.inventory.mainInventory[player.inventory.currentItem] = null;
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held));
}
}
} else {
player.swingItem();
PacketHandler.sendPacketToServer(new PacketFMPPlacePart());
}
return true;
}
/**
* Because vanilla is weird.
*/
private static boolean ignoreActivate(Block block) {
if (block instanceof BlockFence) return true;
return false;
}
@SubscribeEvent
public void addDiscriminator(AddDiscriminatorEvent event) {
event.getPacketHandler().addDiscriminator(event.getPacketHandler().nextDiscriminator, PacketFMPPlacePart.class);
}
}

View file

@ -1,141 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.fmp;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Cuboid6;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.NormallyOccludedPart;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import net.minecraftforge.fml.common.Loader;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.IPartProvider;
import techreborn.partSystem.ModPart;
import techreborn.partSystem.ModPartRegistry;
import java.util.List;
public class FMPFactory implements MultiPartRegistry.IPartFactory2,
IPartProvider {
public TMultiPart createPart(String type, boolean client) {
for (ModPart modPart : ModPartRegistry.parts) {
if (modPart.getName().equals(type)) {
return new FMPModPart((ModPart) modPart.copy());
}
}
return null;
}
public boolean placePart(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int side, float hitX, float hitY, float hitZ,
ModPart modPart) {
return new FakeFMPPlacerItem(modPart).onItemUse(item, player, world, x,
y, z, side, hitX, hitY, hitZ);
}
@Override
public boolean isTileFromProvider(TileEntity tileEntity) {
return tileEntity instanceof TileMultipart;
}
@Override
public IModPart getPartFromWorld(World world, Location location, String name) {
TileEntity tileEntity = world.getTileEntity(location.getX(),
location.getY(), location.getZ());
if (tileEntity instanceof TileMultipart) {
TileMultipart mp = (TileMultipart) tileEntity;
boolean ret = false;
List<TMultiPart> t = mp.jPartList();
for (TMultiPart p : t) {
if (ret == false) {
if (p.getType().equals(name)) {
if (p instanceof FMPModPart) {
return ((FMPModPart) p).iModPart;
}
ret = true;
}
}
}
return null;
}
return null;
}
@Override
public void init() {
if (Loader.isModLoaded("IC2")) {
MultiPartRegistry.registerConverter(new CableConverter());
MinecraftForge.EVENT_BUS.register(new CableConverter());
}
}
@Override
public String modID() {
return "ForgeMultipart";
}
@Override
public void registerPart() {
for (ModPart modPart : ModPartRegistry.parts) {
MultiPartRegistry.registerParts(new FMPFactory(), new String[]
{modPart.getName()});
}
}
@Override
public boolean checkOcclusion(World world, Location location,
Vecs3dCube cube) {
codechicken.multipart.TileMultipart tmp = codechicken.multipart.TileMultipart
.getOrConvertTile(world, new BlockCoord(location.getX(),
location.getY(), location.getZ()));
if (tmp == null)
return false;
return !tmp.occlusionTest(tmp.partList(), new NormallyOccludedPart(
new Cuboid6(cube.toAABB())));
}
@Override
public boolean hasPart(World world, Location location, String name) {
TileEntity tileEntity = world.getTileEntity(location.getX(),
location.getY(), location.getZ());
if (tileEntity instanceof TileMultipart) {
TileMultipart mp = (TileMultipart) tileEntity;
boolean ret = false;
List<TMultiPart> t = mp.jPartList();
for (TMultiPart p : t) {
if (ret == false) {
if (p.getType().equals(name)) {
ret = true;
}
}
}
return ret;
}
return false;
}
@Override
public TMultiPart createPart(String s, NBTTagCompound nbtTagCompound) {
return createPart(s, false);
}
@Override
public TMultiPart createPart(String s, MCDataInput mcDataInput) {
return createPart(s, false);
}
}

View file

@ -1,224 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.fmp;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.raytracer.IndexedCuboid6;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.ISidedHollowConnect;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.NormalOcclusionTest;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TSlottedPart;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.partSystem.IPartDesc;
import techreborn.partSystem.ModPart;
import java.util.ArrayList;
import java.util.List;
public class FMPModPart extends TMultiPart implements TSlottedPart,
JNormalOcclusion, ISidedHollowConnect {
ModPart iModPart;
public FMPModPart(ModPart iModPart) {
this.iModPart = iModPart;
}
@Override
public int getHollowSize(int i) {
return 0;
}
@Override
public Iterable<Cuboid6> getOcclusionBoxes() {
List<Cuboid6> cubes = new ArrayList<Cuboid6>();
for (Vecs3dCube c : iModPart.getOcclusionBoxes())
if (c != null)
cubes.add(new Cuboid6(c.toAABB()));
return cubes;
}
@Override
public boolean occlusionTest(TMultiPart npart) {
return NormalOcclusionTest.apply(this, npart);
}
@Override
public Iterable<Cuboid6> getCollisionBoxes() {
List<Cuboid6> cubes = new ArrayList<Cuboid6>();
List<Vecs3dCube> boxes = new ArrayList<Vecs3dCube>();
iModPart.addCollisionBoxesToList(boxes, null);
for (Vecs3dCube c : boxes) {
if (c != null)
cubes.add(new Cuboid6(c.toAABB()));
}
return cubes;
}
@Override
public Iterable<IndexedCuboid6> getSubParts() {
List<IndexedCuboid6> cubes = new ArrayList<IndexedCuboid6>();
if (iModPart.getSelectionBoxes() != null) {
for (Vecs3dCube c : iModPart.getSelectionBoxes())
if (c != null)
cubes.add(new IndexedCuboid6(0, new Cuboid6(c.toAABB())));
if (cubes.size() == 0)
cubes.add(new IndexedCuboid6(0, new Cuboid6(0, 0, 0, 1, 1, 1)));
}
return cubes;
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(Vector3 pos, float frame, int pass) {
iModPart.renderDynamic(new Vecs3d(pos.x, pos.y, pos.z), frame);
}
@Override
public String getType() {
return iModPart.getName();
}
@Override
public int getSlotMask() {
return 0;
}
public World getWorld() {
return world();
}
public int getX() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(world());
iModPart.setLocation(new Location(x(), y(), z()));
}
return x();
}
public int getY() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(world());
iModPart.setLocation(new Location(x(), y(), z()));
}
return y();
}
public int getZ() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(world());
iModPart.setLocation(new Location(x(), y(), z()));
}
return z();
}
@Override
public void onAdded() {
iModPart.setWorld(world());
iModPart.setLocation(new Location(x(), y(), z()));
iModPart.nearByChange();
iModPart.onAdded();
}
@Override
public void update() {
if (iModPart.location != null) {
iModPart.tick();
}
}
@Override
public void onNeighborChanged() {
super.onNeighborChanged();
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(world());
iModPart.setLocation(new Location(x(), y(), z()));
}
iModPart.nearByChange();
}
public void onRemoved() {
iModPart.onRemoved();
super.onRemoved();
}
@Override
public boolean renderStatic(Vector3 pos, int pass) {
boolean render;
render = iModPart.renderStatic(new Vecs3d((int) pos.x, (int) pos.y, (int) pos.z), pass);
return render;
}
@Override
public Iterable<ItemStack> getDrops() {
List<ItemStack> stackArrayList = new ArrayList<ItemStack>();
if (iModPart.getItem() != null) {
stackArrayList.add(iModPart.getItem().copy());
}
return stackArrayList;
}
@Override
public void onPartChanged(TMultiPart part) {
super.onPartChanged(part);
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(world());
iModPart.setLocation(new Location(x(), y(), z()));
}
iModPart.nearByChange();
}
@Override
public void readDesc(MCDataInput packet) {
super.readDesc(packet);
if (iModPart instanceof IPartDesc) {
((IPartDesc) iModPart).readDesc(packet.readNBTTagCompound());
}
}
@Override
public void writeDesc(MCDataOutput packet) {
super.writeDesc(packet);
if (iModPart instanceof IPartDesc) {
NBTTagCompound tagCompound = new NBTTagCompound();
((IPartDesc) iModPart).writeDesc(tagCompound);
packet.writeNBTTagCompound(tagCompound);
}
}
@Override
public void onWorldJoin() {
if (iModPart.world == null || iModPart.location == null) {
iModPart.setWorld(world());
iModPart.setLocation(new Location(x(), y(), z()));
}
iModPart.onAdded();
}
@Override
public void onWorldSeparate() {
iModPart.onChunkUnload();
}
}

View file

@ -1,34 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.fmp;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TMultiPart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import techreborn.partSystem.ModPart;
/**
* This item is never added into the game, it is only used to add the part to
* the world.
*/
public class FakeFMPPlacerItem extends JItemMultiPart {
ModPart modPart;
public FakeFMPPlacerItem(ModPart part) {
modPart = part;
}
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world,
BlockCoord pos, int side, Vector3 vhit) {
TMultiPart w = MultiPartRegistry.createPart(modPart.getName(), false);
return w;
}
}

View file

@ -1,29 +0,0 @@
package techreborn.partSystem.fmp;
import io.netty.buffer.ByteBuf;
import reborncore.common.packets.SimplePacket;
import java.io.IOException;
public class PacketFMPPlacePart extends SimplePacket {
public PacketFMPPlacePart() {
}
@Override
public void writeData(ByteBuf out) throws IOException {
}
@Override
public void readData(ByteBuf in) throws IOException {
}
@Override
public void execute() {
CableConverter.place(player, player.worldObj);
}
}

View file

@ -1,597 +0,0 @@
package techreborn.partSystem.parts;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyConductor;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.info.IC2Classic;
import ic2.api.item.IC2Items;
import ic2.api.network.INetworkTileEntityEventListener;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.util.EnumFacing;
import reborncore.common.misc.Functions;
import reborncore.common.misc.Location;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.client.render.RenderCablePart;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.IPartDesc;
import techreborn.partSystem.ModPart;
import techreborn.partSystem.ModPartUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CablePart extends ModPart implements IEnergyConductor, INetworkTileEntityEventListener, IPartDesc {
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
public float center = 0.6F;
public float offset = 0.10F;
public Map<EnumFacing, TileEntity> connectedSides;
public int ticks = 0;
public boolean addedToEnergyNet = false;
public ItemStack stack;
public int type = 0;
protected EnumFacing[] dirs = EnumFacing.values();
private boolean[] connections = new boolean[6];
private boolean hasCheckedSinceStartup;
public CablePart() {
connectedSides = new HashMap<EnumFacing, TileEntity>();
}
public static int getMaxCapacity(int type) {
switch (type) {
case 0:
return 128;
case 1:
return 128;
case 2:
return 512;
case 3:
return 512;
case 4:
return 512;
case 5:
return 2048;
case 6:
return 2048;
case 7:
return 2048;
case 8:
return 2048;
case 9:
return 8192;
case 10:
return 32;
case 11:
return 8192;
case 12:
return 8192;
case 13:
return 32;
case 14:
return 32;
default:
return 0;
}
}
public static float getCableThickness(int cableType) {
float p = 1.0F;
switch (cableType) {
case 0:
p = 6.0F;
break;
case 1:
p = 4.0F;
break;
case 2:
p = 3.0F;
break;
case 3:
p = 6.0F;
break;
case 4:
p = 6.0F;
break;
case 5:
p = 6.0F;
break;
case 6:
p = 10.0F;
break;
case 7:
p = 10.0F;
break;
case 8:
p = 12.0F;
break;
case 9:
p = 4.0F;
break;
case 10:
p = 4.0F;
break;
case 11:
p = 8.0F;
break;
case 12:
p = 8.0F;
break;
case 13:
p = 16.0F;
break;
case 14:
p = 6.0F;
}
return p / 16.0F;
}
public static String getNameFromType(int cableType) {
String p = null;
switch (cableType) {
case 0:
p = "insulatedCopperCable";
break;
case 1:
p = "copperCable";
break;
case 2:
p = "goldCable";
break;
case 3:
p = "insulatedGoldCable";
break;
case 4:
p = "doubleInsulatedGoldCable";
break;
case 5:
p = "ironCable";
break;
case 6:
p = "insulatedIronCable";
break;
case 7:
p = "doubleInsulatedIronCable";
break;
case 8:
p = "trippleInsulatedIronCable";
break;
case 9:
p = "glassFiberCable";
break;
case 10:
p = "tinCable";
break;
case 11:
p = "detectorCableBlock";//Detector
break;
case 12:
p = "splitterCableBlock";// Splitter
break;
case 13:
p = "insulatedtinCable";
break;
case 14:
p = "unused"; // unused?
}
return p;
}
public static String getTextureNameFromType(int cableType) {
String p = null;
switch (cableType) {
case 0:
p = "insulatedCopperCableItem";
break;
case 1:
p = "copperCableItem";
break;
case 2:
p = "goldCableItem";
break;
case 3:
p = "insulatedGoldCableItem";
break;
case 4:
p = "doubleInsulatedGoldCableItem";
break;
case 5:
p = "ironCableItem";
break;
case 6:
p = "insulatedIronCableItem";
break;
case 7:
p = "doubleInsulatedIronCableItem";
break;
case 8:
p = "trippleInsulatedIronCableItem";
break;
case 9:
p = "glassFiberCableItem";
break;
case 10:
p = "tinCableItem";
break;
case 11:
p = "detectorCableItem";//Detector
break;
case 12:
p = "splitterCableItem";// Splitter
break;
case 13:
p = "insulatedTinCableItem";
break;
case 14:
p = "unused"; // unused?
}
return p;
}
public void setType(int newType) {
this.type = newType;
refreshBounding();
}
public void refreshBounding() {
float centerFirst = center - offset;
double w = getCableThickness(type) / 2;
boundingBoxes[6] = new Vecs3dCube(centerFirst - w - 0.03, centerFirst
- w - 0.08, centerFirst - w - 0.03, centerFirst + w + 0.08,
centerFirst + w + 0.04, centerFirst + w + 0.08);
boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w,
centerFirst - w, centerFirst + w, centerFirst + w, centerFirst
+ w);
int i = 0;
for (EnumFacing dir : EnumFacing.VALID_DIRECTIONS) {
double xMin1 = (dir.offsetX < 0 ? 0.0
: (dir.offsetX == 0 ? centerFirst - w : centerFirst + w));
double xMax1 = (dir.offsetX > 0 ? 1.0
: (dir.offsetX == 0 ? centerFirst + w : centerFirst - w));
double yMin1 = (dir.offsetY < 0 ? 0.0
: (dir.offsetY == 0 ? centerFirst - w : centerFirst + w));
double yMax1 = (dir.offsetY > 0 ? 1.0
: (dir.offsetY == 0 ? centerFirst + w : centerFirst - w));
double zMin1 = (dir.offsetZ < 0 ? 0.0
: (dir.offsetZ == 0 ? centerFirst - w : centerFirst + w));
double zMax1 = (dir.offsetZ > 0 ? 1.0
: (dir.offsetZ == 0 ? centerFirst + w : centerFirst - w));
boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1,
yMax1, zMax1);
i++;
}
}
@Override
public void addCollisionBoxesToList(List<Vecs3dCube> boxes, Entity entity) {
for (EnumFacing dir : EnumFacing.VALID_DIRECTIONS) {
if (connectedSides.containsKey(dir))
boxes.add(boundingBoxes[Functions.getIntDirFromDirection(dir)]);
}
boxes.add(boundingBoxes[6]);
}
@Override
public List<Vecs3dCube> getSelectionBoxes() {
List<Vecs3dCube> vec3dCubeList = new ArrayList<Vecs3dCube>();
for (EnumFacing dir : EnumFacing.VALID_DIRECTIONS) {
if (connectedSides.containsKey(dir))
vec3dCubeList.add(boundingBoxes[Functions
.getIntDirFromDirection(dir)]);
}
vec3dCubeList.add(boundingBoxes[6]);
return vec3dCubeList;
}
@Override
public List<Vecs3dCube> getOcclusionBoxes() {
List<Vecs3dCube> vecs3dCubesList = new ArrayList<Vecs3dCube>();
vecs3dCubesList.add(boundingBoxes[6]);
return vecs3dCubesList;
}
@Override
public void renderDynamic(Vecs3d translation, double delta) {
}
@Override
public boolean renderStatic(Vecs3d translation, int pass) {
return RenderCablePart.renderStatic(translation, pass, this);
}
@Override
public void writeToNBT(NBTTagCompound tag) {
tag.setInteger("type", type);
writeConnectedSidesToNBT(tag);
}
@Override
public void readFromNBT(NBTTagCompound tag) {
type = tag.getInteger("type");
}
@Override
public String getName() {
return "Cable." + getNameFromType(type);
}
@SideOnly(Side.CLIENT)
@Override
public String getItemTextureName() {
if (IC2Classic.getLoadedIC2Type() == IC2Classic.IC2Type.SpeigersClassic) {
return IC2Items.getItem("copperCableBlock").getItem().getIcon(new ItemStack(IC2Items.getItem("copperCableBlock").getItem(), type), 1).getIconName();
}
return IC2Items.getItem(getTextureNameFromType(type)).getIconIndex().getIconName();
}
@Override
public void tick() {
if (!FMLCommonHandler.instance().getEffectiveSide().isClient() && !this.addedToEnergyNet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this.addedToEnergyNet = true;
nearByChange();
}
if (worldObj != null) {
if (worldObj.getTotalWorldTime() % 80 == 0 || !hasCheckedSinceStartup) {
checkConnectedSides();
hasCheckedSinceStartup = true;
}
}
}
@Override
public void nearByChange() {
checkConnectedSides();
for (EnumFacing direction : EnumFacing.VALID_DIRECTIONS) {
worldObj.markBlockForUpdate(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
IModPart part = ModPartUtils.getPartFromWorld(world, new Location(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ), this.getName());
if (part != null) {
CablePart cablePart = (CablePart) part;
cablePart.checkConnectedSides();
}
}
}
@Override
public void onAdded() {
checkConnections(world, getX(), getY(), getZ());
if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this.addedToEnergyNet = true;
nearByChange();
}
nearByChange();
}
@Override
public void onRemoved() {
if (!FMLCommonHandler.instance().getEffectiveSide().isClient() && this.addedToEnergyNet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
this.addedToEnergyNet = false;
}
}
@Override
public IModPart copy() {
CablePart part = new CablePart();
part.setType(type);
return part;
}
@Override
public ItemStack getItem() {
return new ItemStack(IC2Items.getItem("copperCableItem").getItem(), 1, type);
}
public boolean shouldConnectTo(TileEntity entity, EnumFacing dir) {
if (entity == null) {
return false;
} else if (entity instanceof IEnergyTile) {
return true;
} else {
<<<<<<< HEAD:ToAddBack/partSystem/parts/CablePart.java
if (ModPartUtils.hasPart(entity.getWorldObj(), entity.getPos().getX(), entity.getPos().getY(), entity.getPos().getZ(), this.getName())) {
CablePart otherCable = (CablePart) ModPartUtils.getPartFromWorld(entity.getWorldObj(), new Location(entity.getPos().getX(), entity.getPos().getY(), entity.getPos().getZ()), this.getName());
=======
if (ModPartUtils.hasPart(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord, this.getName())) {
CablePart otherCable = (CablePart) ModPartUtils.getPartFromWorld(entity.getWorldObj(), new Location(entity.xCoord, entity.yCoord, entity.zCoord), this.getName());
if(otherCable == null || dir == null){
return false;
}
>>>>>>> master:src/main/java/techreborn/partSystem/parts/CablePart.java
int thisDir = Functions.getIntDirFromDirection(dir);
int thereDir = Functions.getIntDirFromDirection(dir.getOpposite());
boolean hasconnection = otherCable.connections[thereDir];
otherCable.connections[thereDir] = false;
if (ModPartUtils.checkOcclusion(entity.getWorldObj(), entity.getPos().getX(), entity.getPos().getY(), entity.getPos().getZ(), boundingBoxes[thereDir])) {
otherCable.connections[thereDir] = true;
return true;
}
otherCable.connections[thereDir] = hasconnection;
}
return false;
}
}
public void checkConnectedSides() {
refreshBounding();
connectedSides = new HashMap<EnumFacing, TileEntity>();
for (EnumFacing dir : EnumFacing.VALID_DIRECTIONS) {
int d = Functions.getIntDirFromDirection(dir);
if (world == null) {
return;
}
TileEntity te = world.getTileEntity(getX() + dir.offsetX, getY()
+ dir.offsetY, getZ() + dir.offsetZ);
if (shouldConnectTo(te, dir)) {
if (ModPartUtils.checkOcclusion(getWorld(), getX(),
getY(), getZ(), boundingBoxes[d])) {
connectedSides.put(dir, te);
}
}
if (te != null) {
te.getWorldObj().markBlockForUpdate(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
}
}
checkConnections(world, getX(), getY(), getZ());
getWorld().markBlockForUpdate(getX(), getY(), getZ());
}
public void checkConnections(World world, int x, int y, int z) {
for (int i = 0; i < 6; i++) {
EnumFacing dir = dirs[i];
int dx = x + dir.offsetX;
int dy = y + dir.offsetY;
int dz = z + dir.offsetZ;
connections[i] = shouldConnectTo(world.getTileEntity(dx, dy, dz),
dir);
world.func_147479_m(dx, dy, dz);
}
world.func_147479_m(x, y, z);
}
public double getConductionLoss() {
switch (this.type) {
case 0:
return 0.2D;
case 1:
return 0.3D;
case 2:
return 0.5D;
case 3:
return 0.45D;
case 4:
return 0.4D;
case 5:
return 1.0D;
case 6:
return 0.95D;
case 7:
return 0.9D;
case 8:
return 0.8D;
case 9:
return 0.025D;
case 10:
return 0.025D;
case 11:
return 0.5D;
case 12:
return 0.5D;
case 13:
default:
return 0.025D;
case 14:
return 0.2D;
}
}
public double getInsulationEnergyAbsorption() {
return (double) getMaxCapacity(this.type);
}
public double getInsulationBreakdownEnergy() {
return 9001.0D;
}
public double getConductorBreakdownEnergy() {
return (double) (getMaxCapacity(this.type) + 1);
}
@Override
public void removeInsulation() {
}
@Override
public void removeConductor() {
}
@Override
public boolean acceptsEnergyFrom(TileEntity tileEntity,
EnumFacing forgeDirection) {
return connectedSides.containsKey(forgeDirection);
}
@Override
public boolean emitsEnergyTo(TileEntity tileEntity,
EnumFacing forgeDirection) {
return connectedSides.containsKey(forgeDirection);
}
@Override
public void onNetworkEvent(int i) {
switch (i) {
case 0:
this.worldObj.playSoundEffect((double) ((float) this.getPos().getX() + 0.5F), (double) ((float) this.getPos().getY() + 0.5F), (double) ((float) this.getPos().getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.8F);
for (int l = 0; l < 8; ++l) {
this.worldObj.spawnParticle("largesmoke", (double) this.getPos().getX() + Math.random(), (double) this.getPos().getY() + 1.2D, (double) this.getPos().getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
}
return;
default:
}
}
private void readConnectedSidesFromNBT(NBTTagCompound tagCompound) {
NBTTagCompound ourCompound = tagCompound.getCompoundTag("connectedSides");
for (EnumFacing dir : EnumFacing.VALID_DIRECTIONS) {
connections[dir.ordinal()] = ourCompound.getBoolean(dir.ordinal() + "");
}
checkConnectedSides();
}
private void writeConnectedSidesToNBT(NBTTagCompound tagCompound) {
NBTTagCompound ourCompound = new NBTTagCompound();
int i = 0;
for (boolean b : connections) {
ourCompound.setBoolean(i + "", b);
i++;
}
tagCompound.setTag("connectedSides", ourCompound);
}
@Override
public void readDesc(NBTTagCompound tagCompound) {
readConnectedSidesFromNBT(tagCompound);
}
@Override
public void writeDesc(NBTTagCompound tagCompound) {
writeConnectedSidesToNBT(tagCompound);
}
@Override
public boolean needsItem() {
return false;
}
}

View file

@ -1,98 +0,0 @@
/*
* This file was made by modmuss50. View the licence file to see what licence this is is on. You can always ask me if you would like to use part or all of this file in your project.
*/
package techreborn.partSystem.parts;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import reborncore.common.misc.vecmath.Vecs3d;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.ModPart;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mark on 11/12/14.
*/
public class NullPart extends ModPart {
@Override
public void addCollisionBoxesToList(List<Vecs3dCube> boxes, Entity entity) {
boxes.add(new Vecs3dCube(0, 0, 0, 1, 1, 1));
}
@Override
public List<Vecs3dCube> getSelectionBoxes() {
List<Vecs3dCube> cubes = new ArrayList<Vecs3dCube>();
cubes.add(new Vecs3dCube(0, 0, 0, 1, 1, 1));
return cubes;
}
@Override
public List<Vecs3dCube> getOcclusionBoxes() {
return null;
}
@Override
public void renderDynamic(Vecs3d translation, double delta) {
}
@Override
public boolean renderStatic(Vecs3d translation, int pass) {
return false;
}
@Override
public void writeToNBT(NBTTagCompound tag) {
}
@Override
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public ItemStack getItem() {
return null;
}
@Override
public String getName() {
return "NullPart";
}
@Override
public String getItemTextureName() {
return "";
}
@Override
public void tick() {
}
@Override
public void nearByChange() {
}
@Override
public void onAdded() {
}
@Override
public void onRemoved() {
}
@Override
public IModPart copy() {
return new NullPart();
}
}