Merge branch 'RemoveMJ' of https://github.com/CrazyPants/EnderIO.git into RemoveMJ

This commit is contained in:
tterrag1098 committed 2014-09-20 01:16:10 -04:00
commit 17d726841a
17 files changed
+222 -54

No files matched your search

@@ -3,6 +3,9 @@ package crazypants.enderio;
import static crazypants.enderio.EnderIO.MODID;
import static crazypants.enderio.EnderIO.MOD_NAME;
import static crazypants.enderio.EnderIO.VERSION;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.material.Material;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -20,10 +23,12 @@ import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -120,6 +125,7 @@ import crazypants.enderio.material.ItemMachinePart;
import crazypants.enderio.material.ItemMaterial;
import crazypants.enderio.material.ItemPowderIngot;
import crazypants.enderio.material.MaterialRecipes;
import crazypants.enderio.nei.SagMillRecipeHandler;
import crazypants.enderio.network.MessageTileNBT;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.teleport.BlockTravelAnchor;
@@ -518,6 +524,24 @@ public class EnderIO {
}
}
}
@EventHandler
public void onImc(IMCEvent evt) {
ImmutableList<IMCMessage> messages = evt.getMessages();
for(IMCMessage msg : messages) {
if(msg.isStringMessage()) {
String key = msg.key;
String value = msg.getStringValue();
if(VatRecipeManager.IMC_KEY.equals(key)) {
VatRecipeManager.getInstance().addCustumRecipes(value);
} else if(CrusherRecipeManager.IMC_KEY.equals(key)) {
CrusherRecipeManager.getInstance().addCustomRecipes(value);
} else if(AlloyRecipeManager.IMC_KEY.equals(key)) {
AlloyRecipeManager.getInstance().addCustumRecipes(value);
}
}
}
}
@EventHandler
public void serverStarted(FMLServerStartedEvent event) {
@@ -221,7 +221,6 @@ public class EnergyUpgrade extends AbstractUpgrade {
public boolean isAbsorbDamageWithPower() {
boolean res= RANDOM.nextFloat() < Config.darkSteelPowerDamgeAbsorptionRatio;
System.out.println("EnergyUpgrade.isAbsorbDamageWithPower: "+ res);
return res;
}
@@ -11,6 +11,7 @@ import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.BlockOldLeaf;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
@@ -169,6 +170,9 @@ public class ItemDarkSteelAxe extends ItemAxe implements IEnergyContainerItem, I
if(evt.entityPlayer.isSneaking() && isEquippedAndPowered(evt.entityPlayer, Config.darkSteelAxePowerUsePerDamagePointMultiHarvest) && isLog(evt.block, evt.metadata)) {
evt.newSpeed = evt.originalSpeed / Config.darkSteelAxeSpeedPenaltyMultiHarvest;
}
if(evt.block.getMaterial() == Material.leaves) {
evt.newSpeed = 6;
}
}
@Override
@@ -187,18 +191,7 @@ public class ItemDarkSteelAxe extends ItemAxe implements IEnergyContainerItem, I
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) {
int slot = player.inventory.currentItem + 1;
if(slot < 9 && player.inventory.mainInventory[slot] != null && !(player.inventory.mainInventory[slot].getItem() instanceof IDarkSteelItem)) {
BlockCoord bc = new BlockCoord(x,y,z).getLocation(ForgeDirection.getOrientation(side));
BoundingBox bb = new BoundingBox(bc);
AxisAlignedBB aabb = bb.getAxisAlignedBB();
if(aabb.intersectsWith(player.boundingBox)) {
return false;
}
return player.inventory.mainInventory[slot].getItem().onItemUse(player.inventory.mainInventory[slot], player, world, x, y, z, side, par8,
par9, par10);
}
return false;
return ItemDarkSteelPickaxe.doRightClickItemPlace(player, world, x, y, z, side, par8, par9, par10);
}
private void applyDamage(EntityLivingBase entity, ItemStack item, int damage, boolean isMultiharvest) {
@@ -11,6 +11,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
@@ -38,7 +39,7 @@ import crazypants.util.Lang;
public class ItemDarkSteelPickaxe extends ItemPickaxe implements IEnergyContainerItem, IAdvancedTooltipProvider, IDarkSteelItem, IItemOfTravel {
private static final Set SHOVEL_BLOCKS = Sets.newHashSet(new Block[] {
private static final Set SHOVEL_BLOCKS = Sets.newHashSet(new Block[] {
Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow,
Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium });
@@ -120,22 +121,39 @@ public class ItemDarkSteelPickaxe extends ItemPickaxe implements IEnergyContaine
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) {
return doRightClickItemPlace(player, world, x, y, z, side, par8, par9, par10);
}
static boolean doRightClickItemPlace(EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) {
int slot = player.inventory.currentItem + 1;
if(slot < 9 && player.inventory.mainInventory[slot] != null && !(player.inventory.mainInventory[slot].getItem() instanceof IDarkSteelItem)) {
BlockCoord bc = new BlockCoord(x,y,z).getLocation(ForgeDirection.getOrientation(side));
BoundingBox bb = new BoundingBox(bc);
AxisAlignedBB aabb = bb.getAxisAlignedBB();
if(aabb.intersectsWith(player.boundingBox)) {
if(slot < 9 && player.inventory.mainInventory[slot] != null && !(player.inventory.mainInventory[slot].getItem() instanceof IDarkSteelItem)) {
if(!canPlaceBlockOnRightClick(player, world, x, y, z, side, slot)) {
return false;
}
}
return player.inventory.mainInventory[slot].getItem().onItemUse(player.inventory.mainInventory[slot], player, world, x, y, z, side, par8,
par9, par10);
}
return false;
}
static boolean canPlaceBlockOnRightClick(EntityPlayer player, World world, int x, int y, int z, int side, int slot) {
BlockCoord placeCoord = new BlockCoord(x, y, z).getLocation(ForgeDirection.getOrientation(side));
ItemStack toUse = player.inventory.mainInventory[slot];
AxisAlignedBB aabb;
Block blk = Block.getBlockFromItem(toUse.getItem());
if(blk != null) {
aabb = blk.getCollisionBoundingBoxFromPool(world, placeCoord.x, placeCoord.y, placeCoord.z);
} else {
BoundingBox bb = new BoundingBox(placeCoord);
aabb = bb.getAxisAlignedBB();
}
if(aabb != null && aabb.intersectsWith(player.boundingBox)) {
return false;
}
return true;
}
private void applyDamage(EntityLivingBase entity, ItemStack item, int damage) {
EnergyUpgrade eu = EnergyUpgrade.loadFromItem(item);
@@ -149,7 +167,7 @@ public class ItemDarkSteelPickaxe extends ItemPickaxe implements IEnergyContaine
}
item.setItemDamage(damage);
}
if(eu != null) {
if(eu != null) {
eu.writeToItem(item);
}
@@ -66,7 +66,7 @@ public class PoweredItemRenderer implements IItemRenderer {
g = 0.4f;
b = 1f;
y = 13;
renderBar(y, maxDam, maxDam - dispDamage, new Color(200, 100, 10), Color.red);
renderBar2(y, maxDam, maxDam - dispDamage, new Color(200, 100, 10), Color.red);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -77,6 +77,16 @@ public class PoweredItemRenderer implements IItemRenderer {
return EnergyUpgrade.loadFromItem(item) == null && item.getItemDamageForDisplay() == 0;
}
private void renderBar2(int y, double maxDam, double dispDamage, Color full, Color empty) {
double ratio = dispDamage / maxDam;
Vector4f fg = ColorUtil.toFloat(full);
Vector4f ec = ColorUtil.toFloat(empty);
fg.interpolate(ec, (float) ratio);
int barLength = (int) Math.round(12.0 * (1 - ratio));
RenderUtil.renderQuad2D(2, y, 0, barLength, 1, fg);
}
private void renderBar(int y, double maxDam, double dispDamage, Color full, Color empty) {
double ratio = dispDamage / maxDam;
Vector4f fg = ColorUtil.toFloat(full);
@@ -28,6 +28,8 @@ import crazypants.util.Util;
public class AlloyRecipeManager extends ManyToOneRecipeManager {
public static final String IMC_KEY = "recipe:alloysmelter";
private static final String CORE_FILE_NAME = "AlloySmelterRecipes_Core.xml";
private static final String CUSTOM_FILE_NAME = "AlloySmelterRecipes_User.xml";
@@ -24,6 +24,8 @@ import crazypants.util.Util;
public class CrusherRecipeManager {
public static final String IMC_KEY = "recipe:sagmill";
public static final int ORE_ENERGY_COST = 400;
public static final int INGOT_ENERGY_COST = 240;
@@ -21,13 +21,26 @@ public class BrokenSpawnerRenderer implements IItemRenderer {
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderBlocks rb = (RenderBlocks)data[0];
if(type == ItemRenderType.ENTITY) {
GL11.glPushMatrix();
GL11.glScalef(0.5f, 0.5f, 0.5f);
}
RenderBlocks rb = (RenderBlocks) data[0];
rb.setOverrideBlockTexture(EnderIO.itemBrokenSpawner.getIconFromDamage(0));
rb.renderBlockAsItem(Blocks.stone, 0, 1);
rb.setOverrideBlockTexture(null);
rb.setOverrideBlockTexture(null);
if(type == ItemRenderType.ENTITY) {
GL11.glPopMatrix();
}
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPopAttrib();
}
}
@@ -1,9 +1,13 @@
package crazypants.enderio.machine.still;
import java.awt.Color;
import java.awt.Rectangle;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
@@ -15,6 +19,7 @@ import crazypants.enderio.machine.IPoweredTask;
import crazypants.enderio.machine.IoMode;
import crazypants.enderio.machine.MachineRecipeInput;
import crazypants.gui.GuiToolTip;
import crazypants.render.ColorUtil;
import crazypants.render.RenderUtil;
import crazypants.util.Lang;
@@ -67,15 +72,14 @@ public class GuiVat extends GuiMachineBase {
int x = 30;
int y = 12;
if(mode == IoMode.PULL || mode == IoMode.PUSH_PULL) {
renderSlotHighlight(PULL_COLOR,x-2,y-2,15+4,47+4);
renderSlotHighlight(PULL_COLOR, x - 2, y - 2, 15 + 4, 47 + 4);
}
if(mode == IoMode.PUSH || mode == IoMode.PUSH_PULL) {
x = 132;
renderSlotHighlight(PUSH_COLOR,x-2,y-2,15+4,47+4);
renderSlotHighlight(PUSH_COLOR, x - 2, y - 2, 15 + 4, 47 + 4);
}
}
/**
* Draw the background layer for the GuiContainer (everything behind the
* items)
@@ -116,9 +120,36 @@ public class GuiVat extends GuiMachineBase {
int x = guiLeft + 30;
int y = guiTop + 12;
RenderUtil.renderGuiTank(vat.inputTank, x, y, zLevel, 15,47);
RenderUtil.renderGuiTank(vat.inputTank, x, y, zLevel, 15, 47);
x = guiLeft + 132;
RenderUtil.renderGuiTank(vat.outputTank, x, y, zLevel, 15,47);
RenderUtil.renderGuiTank(vat.outputTank, x, y, zLevel, 15, 47);
if(vat.getCurrentTask() != null || vat.outputTank.getFluidAmount() > 0) {
Fluid outputFluid;
if(vat.outputTank.getFluidAmount() > 0) {
outputFluid = vat.outputTank.getFluid().getFluid();
} else {
ResultStack[] res = vat.getCurrentTask().getRecipe().getCompletedResult(1, vat.getCurrentTask().getInputs());
outputFluid = res[0].fluid.getFluid();
}
float mult;
ItemStack inStack = vat.getStackInSlot(0);
if(inStack != null) {
mult = VatRecipeManager.instance.getMultiplierForInput(inStack, outputFluid);
String str = "x" + mult;
x = guiLeft + 63 - fontRendererObj.getStringWidth(str)/2;
fontRendererObj.drawString(str, x, guiTop + 32, ColorUtil.getRGB(Color.gray), false);
}
inStack = vat.getStackInSlot(1);
if(inStack != null) {
mult = VatRecipeManager.instance.getMultiplierForInput(inStack, outputFluid);
String str = "x" + mult;
x = guiLeft + 113 - fontRendererObj.getStringWidth(str)/2;
fontRendererObj.drawString(str, x, guiTop + 32, ColorUtil.getRGB(Color.gray), false);
}
}
RenderUtil.bindTexture(GUI_TEXTURE);
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
@@ -144,7 +175,6 @@ public class GuiVat extends GuiMachineBase {
drawTexturedModalRect(x, y, 0, 256 - 28, 26, 28);
}
@Override
protected int getPowerX() {
return 10;
@@ -45,7 +45,7 @@ public class VatMachineRecipe extends AbstractMachineRecipe {
result.add(new MachineRecipeInput(0, inputFluidStack));
for (MachineRecipeInput ri : inputs) {
if(!ri.isFluid()) {
if(!ri.isFluid() && ri.item != null) {
ItemStack st = ri.item.copy();
st.stackSize = rec.getNumConsumed(ri.item);
result.add(new MachineRecipeInput(ri.slotNumber, st));
@@ -20,6 +20,7 @@ public class VatRecipe implements IRecipe {
protected final RecipeInput[] inputs;
protected final RecipeOutput[] output;
protected final int energyRequired;
private int requiredItems;
public VatRecipe(IRecipe recipe) {
List<FluidStack> fluids = recipe.getInputFluidStacks();
@@ -43,6 +44,13 @@ public class VatRecipe implements IRecipe {
output = new RecipeOutput[] { new RecipeOutput(outputFluidStack) };
energyRequired = recipe.getEnergyRequired();
requiredItems = 1;
for (RecipeInput ri : inputs) {
if(!ri.isFluid() && ri.getSlotNumber() == 1) {
requiredItems = 2;
}
}
}
@@ -118,8 +126,7 @@ public class VatRecipe implements IRecipe {
}
}
}
return found == 3;
return found == requiredItems + 1;
}
@@ -3,6 +3,9 @@ package crazypants.enderio.machine.still;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import crazypants.enderio.Log;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.MachineRecipeInput;
@@ -11,9 +14,13 @@ import crazypants.enderio.machine.recipe.IRecipe;
import crazypants.enderio.machine.recipe.Recipe;
import crazypants.enderio.machine.recipe.RecipeConfig;
import crazypants.enderio.machine.recipe.RecipeConfigParser;
import crazypants.enderio.machine.recipe.RecipeInput;
import crazypants.enderio.machine.recipe.RecipeOutput;
public class VatRecipeManager {
public static final String IMC_KEY = "recipe:vat";
private static final String CORE_FILE_NAME = "VatRecipes_Core.xml";
private static final String CUSTOM_FILE_NAME = "VatRecipes_User.xml";
@@ -121,5 +128,19 @@ public class VatRecipeManager {
}
return false;
}
public float getMultiplierForInput(ItemStack input, Fluid output) {
for (IRecipe recipe : recipes) {
RecipeOutput out = recipe.getOutputs()[0];
if(out.getFluidOutput().getFluid().getID() == output.getID()) {
for(RecipeInput ri : recipe.getInputs()) {
if(ri.isInput(input)) {
return ri.getMulitplier();
}
}
}
}
return 0;
}
}
@@ -1,15 +1,18 @@
package crazypants.enderio.nei;
import java.awt.Color;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -115,7 +118,7 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
if(fluid != null) {
if(recipe.isValidInput(fluid)) {
addRecipe = true;
}
}
}
}
if(addRecipe) {
@@ -124,15 +127,7 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
arecipes.add(res);
}
}
// List<IEnderIoRecipe> recipes = RecipeReigistry.instance.getRecipesForCrafter(IEnderIoRecipe.VAT_ID);
// for (IEnderIoRecipe recipe : recipes) {
// if(recipe.isInput(ingredient)) {
// InnerVatRecipe res = new InnerVatRecipe(recipe.getRequiredEnergy(), recipe.getInputs(), recipe.getOutputs().get(0).getFluid());
// res.setIngredientPermutation(res.inputs, ingredient);
// arecipes.add(res);
// }
// }
}
@Override
@@ -147,19 +142,25 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
.renderGuiTank(rec.result, rec.result.amount, rec.result.amount, outTankBounds.x, outTankBounds.y, 0, outTankBounds.width, outTankBounds.height);
}
// drawProgressBar(98, 33, 176, 0, 22, 13, 48, 3);
// drawProgressBar(50, 33, 176, 0, 22, 13, 48, 3);
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
String energyString = PowerDisplayUtil.formatPower(rec.energy) + " " + PowerDisplayUtil.abrevation();
int width = Minecraft.getMinecraft().fontRenderer.getStringWidth(energyString);
int width = fr.getStringWidth(energyString);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int col = ColorUtil.getRGBA(0.75f, 1.0f, 1.0f, 1.0f);
Minecraft.getMinecraft().fontRenderer.drawString(energyString, 86 - width / 2, 55, col, true);
fr.drawString(energyString, 86 - width / 2, 55, col, true);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1, 1, 1, 1);
Fluid outputFluid = rec.result.getFluid();
List<PositionedStack> stacks = rec.getIngredients();
for (PositionedStack ps : stacks) {
float mult = VatRecipeManager.getInstance().getMultiplierForInput(ps.item, outputFluid);
String str = "x" + mult;
fr.drawString(str, ps.relx + 8 - fr.getStringWidth(str) / 2, ps.rely + 19, ColorUtil.getRGB(Color.gray), false);
}
}
@Override
@@ -254,7 +255,7 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
@Override
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 20, inputs);
return getCycledIngredients(cycleticks / 30, inputs);
}
@Override