mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 20:22:12 +00:00
Merge branch 'master' of https://github.com/CrazyPants/EnderIO.git
This commit is contained in:
commit
5ad1fa44e2
28 files changed
+633
-308
No files matched your search
@@ -129,6 +129,7 @@ public final class Config {
|
||||
public static String[] travelStaffBlinkBlackList = new String[] {
|
||||
"minecraft:bedrock"
|
||||
};
|
||||
public static float travelAnchorZoomScale = 0.2f;
|
||||
|
||||
public static int enderIoRange = 8;
|
||||
public static boolean enderIoMeAccessEnabled = true;
|
||||
@@ -588,6 +589,9 @@ public final class Config {
|
||||
.getBoolean(travelStaffBlinkThroughClearBlocksEnabled);
|
||||
travelStaffBlinkBlackList = config.getStringList("travelStaffBlinkBlackList", sectionStaff.name, travelStaffBlinkBlackList,
|
||||
"Lists the blocks that cannot be teleported through in the form 'modID:blockName'");
|
||||
travelAnchorZoomScale = config.getFloat("travelAnchorZoomScale", sectionStaff.name, travelAnchorZoomScale, 0, 1,
|
||||
"Set the max zoomed size of a travel anchor as an aprox. percentage of screen height");
|
||||
|
||||
|
||||
enderIoRange = config.get(sectionEfficiency.name, "enderIoRange", enderIoRange,
|
||||
"Range accessable (in blocks) when using the Ender IO.").getInt(enderIoRange);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package crazypants.enderio.machine.farm;
|
||||
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
@@ -23,60 +25,11 @@ public class FarmingStationSpecialRenderer extends TileEntitySpecialRenderer{
|
||||
return;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslated(x + 0.5, y + 1.5, z + 0.5); // center of block and 1 block up
|
||||
glRotatef(180, 1, 0, 0); // text is upside-down by default (idk)
|
||||
float scale = 0.025f;
|
||||
glScalef(scale, scale, scale); // text is huge!
|
||||
glDisable(GL_LIGHTING);
|
||||
rotateToPlayer();
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-fnt.getStringWidth(toRender) / 2, 0, 0);
|
||||
|
||||
renderBackground(tessellator, fnt, toRender);
|
||||
|
||||
fnt.drawString(toRender, 0, 0, 0xFFFFFF);
|
||||
glTranslatef(0.5f, 0.5f, 0.1f);
|
||||
fnt.drawString(toRender, 0, 0, 0x555555); // manual shadow
|
||||
|
||||
RenderUtil.drawBillboardedText(new Vector3f(x + 0.5, y + 1.5, z + 0.5), toRender, 0.25f);
|
||||
glEnable(GL_LIGHTING);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
private void rotateToPlayer()
|
||||
{
|
||||
glRotatef(RenderManager.instance.playerViewY + 180, 0.0F, 1.0F, 0.0F);
|
||||
glRotatef(-RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
private void renderBackground(Tessellator tessellator, FontRenderer fnt, String toRender) {
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDepthMask(false);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
OpenGlHelper.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); // stop random disappearing
|
||||
|
||||
float width = (float) fnt.getStringWidth(toRender);
|
||||
float height = (float) fnt.FONT_HEIGHT;
|
||||
float padding = 2f;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA(70, 20, 100, 200);
|
||||
tessellator.addVertex(-padding, -padding, 0);
|
||||
tessellator.addVertex(-padding, height + padding, 0);
|
||||
tessellator.addVertex(width + padding, height + padding, 0);
|
||||
tessellator.addVertex(width + padding, -padding, 0);
|
||||
tessellator.draw();
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTickTime) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package crazypants.enderio.machine.spawner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockMobSpawner;
|
||||
@@ -15,7 +16,10 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
@@ -66,10 +70,13 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
|
||||
BlockPoweredSpawner res = new BlockPoweredSpawner();
|
||||
MinecraftForge.EVENT_BUS.register(res);
|
||||
FMLCommonHandler.instance().bus().register(res);
|
||||
res.init();
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<DropInfo> dropQueue = new ArrayList<BlockPoweredSpawner.DropInfo>();
|
||||
|
||||
protected BlockPoweredSpawner() {
|
||||
super(ModObject.blockPoweredSpawner, TilePoweredSpawner.class);
|
||||
}
|
||||
@@ -77,7 +84,7 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
@SubscribeEvent
|
||||
public void onBreakEvent(BlockEvent.BreakEvent evt) {
|
||||
if(evt.block instanceof BlockMobSpawner) {
|
||||
if(evt.getPlayer() != null && !evt.getPlayer().capabilities.isCreativeMode && !evt.getPlayer().worldObj.isRemote) {
|
||||
if(evt.getPlayer() != null && !evt.getPlayer().capabilities.isCreativeMode && !evt.getPlayer().worldObj.isRemote && !evt.isCanceled()) {
|
||||
TileEntity tile = evt.getPlayer().worldObj.getTileEntity(evt.x, evt.y, evt.z);
|
||||
if(tile instanceof TileEntityMobSpawner) {
|
||||
|
||||
@@ -90,8 +97,8 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
if(logic != null) {
|
||||
String name = logic.getEntityNameToSpawn();
|
||||
if(name != null && !isBlackListed(name)) {
|
||||
ItemStack drop = ItemBrokenSpawner.createStackForMobType(name);
|
||||
Util.dropItems(evt.getPlayer().worldObj, drop, evt.x, evt.y, evt.z, true);
|
||||
ItemStack drop = ItemBrokenSpawner.createStackForMobType(name);
|
||||
dropQueue.add(new DropInfo(evt, drop));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,6 +106,17 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.ServerTickEvent event) {
|
||||
if(event.phase != TickEvent.Phase.END) {
|
||||
return;
|
||||
}
|
||||
for (DropInfo action : dropQueue) {
|
||||
action.doDrop();
|
||||
}
|
||||
dropQueue.clear();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handleAnvilEvent(AnvilUpdateEvent evt) {
|
||||
if(evt.left == null || evt.left.stackSize != 1 || evt.left.getItem() != Item.getItemFromBlock(EnderIO.blockPoweredSpawner) ||
|
||||
@@ -195,4 +213,26 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
|
||||
public int getDefaultDisplayMask(World world, int x, int y, int z) {
|
||||
return IWailaInfoProvider.BIT_DETAILED;
|
||||
}
|
||||
|
||||
private static class DropInfo {
|
||||
|
||||
BlockEvent.BreakEvent evt;
|
||||
ItemStack drop;
|
||||
|
||||
DropInfo(BreakEvent evt, ItemStack stack) {
|
||||
super();
|
||||
this.evt = evt;
|
||||
this.drop = stack;
|
||||
}
|
||||
|
||||
void doDrop() {
|
||||
if(evt.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
Util.dropItems(evt.getPlayer().worldObj, drop, evt.x, evt.y, evt.z, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -53,9 +53,11 @@ public class TileTransceiver extends AbstractPoweredTaskEntity implements IFluid
|
||||
private Map<ForgeDirection, IFluidHandler> neighbourFluidHandlers = null;
|
||||
|
||||
private PowerDistributor powerDistributor;
|
||||
|
||||
|
||||
private final EnderRailController railController;
|
||||
|
||||
private boolean inFluidFill = false;
|
||||
|
||||
public TileTransceiver() {
|
||||
super(new SlotDefinition(8, 8, 0));
|
||||
for (ChannelType type : ChannelType.values()) {
|
||||
@@ -64,8 +66,8 @@ public class TileTransceiver extends AbstractPoweredTaskEntity implements IFluid
|
||||
}
|
||||
currentTask = new ContinuousTask(Config.transceiverUpkeepCostRF);
|
||||
railController = new EnderRailController(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EnderRailController getRailController() {
|
||||
return railController;
|
||||
}
|
||||
@@ -233,10 +235,10 @@ public class TileTransceiver extends AbstractPoweredTaskEntity implements IFluid
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
railController.writeToNBT(nbtRoot);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readCommon(NBTTagCompound nbtRoot) {
|
||||
super.readCommon(nbtRoot);
|
||||
super.readCommon(nbtRoot);
|
||||
readChannels(nbtRoot, sendChannels, "sendChannels");
|
||||
readChannels(nbtRoot, recieveChannels, "recieveChannels");
|
||||
}
|
||||
@@ -264,7 +266,7 @@ public class TileTransceiver extends AbstractPoweredTaskEntity implements IFluid
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
|
||||
|
||||
NBTTagList channelTags = createTagList(sendChannels);
|
||||
nbtRoot.setTag("sendChannels", channelTags);
|
||||
|
||||
@@ -380,13 +382,21 @@ public class TileTransceiver extends AbstractPoweredTaskEntity implements IFluid
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
if(getSendChannels(ChannelType.FLUID).isEmpty() || !redstoneCheckPassed || !getIoMode(from).canRecieveInput()) {
|
||||
return 0;
|
||||
try {
|
||||
inFluidFill = true;
|
||||
if(getSendChannels(ChannelType.FLUID).isEmpty() || !redstoneCheckPassed || !getIoMode(from).canRecieveInput()) {
|
||||
return 0;
|
||||
}
|
||||
return ServerChannelRegister.instance.fill(this, getSendChannels(ChannelType.FLUID), resource, doFill);
|
||||
} finally {
|
||||
inFluidFill = false;
|
||||
}
|
||||
return ServerChannelRegister.instance.fill(this, getSendChannels(ChannelType.FLUID), resource, doFill);
|
||||
}
|
||||
|
||||
public int recieveFluid(List<Channel> channels, FluidStack resource, boolean doFill) {
|
||||
if(inFluidFill) {
|
||||
return 0;
|
||||
}
|
||||
if(!hasRecieveChannel(channels, ChannelType.FLUID) || !redstoneCheckPassed) {
|
||||
return 0;
|
||||
}
|
||||
@@ -482,7 +492,7 @@ public class TileTransceiver extends AbstractPoweredTaskEntity implements IFluid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.canInsertItem(slot, itemstack, j);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@ import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import crazypants.enderio.machine.alloy.AlloyRecipeManager;
|
||||
import crazypants.enderio.machine.alloy.GuiAlloySmelter;
|
||||
import crazypants.enderio.machine.alloy.VanillaSmeltingRecipe;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.machine.recipe.IManyToOneRecipe;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class AlloySmelterRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "enderio:textures/gui/alloySmelter.png";
|
||||
return "enderio:textures/gui/nei/alloySmelter.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,18 +87,26 @@ public class AlloySmelterRecipeHandler extends TemplateRecipeHandler {
|
||||
if(recipe.isValidInput(0, ingredient)) {
|
||||
ItemStack output = recipe.getOutputs()[0].getOutput();
|
||||
AlloySmelterRecipe res = new AlloySmelterRecipe(recipe.getEnergyRequired(), recipe.getInputs(), output);
|
||||
res.setIngredientPermutation(res.input, ingredient);
|
||||
arecipes.add(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
drawProgressBar(98, 25, 176, 0, 22, 13, 48, 3);
|
||||
drawProgressBar(50, 25, 176, 0, 22, 13, 48, 3);
|
||||
drawProgressBar(51, 31, 166, 0, 22, 13, 48, 3);
|
||||
drawProgressBar(99, 31, 166, 0, 22, 13, 48, 3);
|
||||
AlloySmelterRecipe recipe = (AlloySmelterRecipe) arecipes.get(recipeIndex);
|
||||
String energyString = PowerDisplayUtil.formatPower(recipe.getEnergy()) + " " + PowerDisplayUtil.abrevation();
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(energyString, 100, 50, 0xFFFFFFFF);
|
||||
GuiDraw.drawString(energyString, 100, 52, 0x808080, false);
|
||||
}
|
||||
|
||||
public List<ItemStack> getInputs(RecipeInput input) {
|
||||
@@ -119,7 +127,6 @@ public class AlloySmelterRecipeHandler extends TemplateRecipeHandler {
|
||||
private PositionedStack output;
|
||||
private int energy;
|
||||
|
||||
// Possible energy cost in the future?
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
@@ -137,20 +144,21 @@ public class AlloySmelterRecipeHandler extends TemplateRecipeHandler {
|
||||
public AlloySmelterRecipe(int energy, RecipeInput[] ingredients, ItemStack result) {
|
||||
int recipeSize = ingredients.length;
|
||||
this.input = new ArrayList<PositionedStack>();
|
||||
int yOff = 8;
|
||||
if(recipeSize > 0) {
|
||||
this.input.add(new PositionedStack(getInputs(ingredients[0]), 49, 14 - yOff));
|
||||
this.input.add(new PositionedStack(getInputs(ingredients[0]), 50, 13));
|
||||
}
|
||||
if(recipeSize > 1) {
|
||||
this.input.add(new PositionedStack(getInputs(ingredients[1]), 73, 4 - yOff));
|
||||
this.input.add(new PositionedStack(getInputs(ingredients[1]), 75, 3));
|
||||
}
|
||||
if(recipeSize > 2) {
|
||||
this.input.add(new PositionedStack(getInputs(ingredients[2]), 98, 14 - yOff));
|
||||
this.input.add(new PositionedStack(getInputs(ingredients[2]), 99, 13));
|
||||
}
|
||||
if(result != null) {
|
||||
this.output = new PositionedStack(result, 74, 54 - yOff);
|
||||
this.output = new PositionedStack(result, 75, 42);
|
||||
}
|
||||
this.energy = energy;
|
||||
this.energy = energy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
@@ -15,6 +13,8 @@ import net.minecraft.enchantment.EnchantmentData;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import crazypants.enderio.machine.enchanter.EnchanterRecipe;
|
||||
@@ -57,12 +57,12 @@ public class EnchanterRecipeHandler extends TemplateRecipeHandler {
|
||||
}
|
||||
Map<Number, Number> enchants = EnchantmentHelper.getEnchantments(result);
|
||||
List<EnchanterRecipe> recipes = EnchanterRecipeManager.getInstance().getRecipes();
|
||||
|
||||
for(Number id : enchants.keySet()) {
|
||||
|
||||
for (Number id : enchants.keySet()) {
|
||||
if(id != null && id.intValue() >= 0 && id.intValue() < Enchantment.enchantmentsList.length) {
|
||||
Enchantment ench = Enchantment.enchantmentsList[id.intValue()];
|
||||
if(ench != null && ench.getName() != null) {
|
||||
|
||||
|
||||
for (EnchanterRecipe recipe : recipes) {
|
||||
if(recipe.isValid() && recipe.getEnchantment().getName().equals(ench.getName())) {
|
||||
EnchantmentData enchantment = new EnchantmentData(recipe.getEnchantment(), 1);
|
||||
@@ -71,18 +71,17 @@ public class EnchanterRecipeHandler extends TemplateRecipeHandler {
|
||||
EnchanterRecipeNEI rec = new EnchanterRecipeNEI(recipe, output, enchantment);
|
||||
arecipes.add(rec);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if(outputId.equals("EIOEnchanter") && getClass() == EnchanterRecipeHandler.class) {
|
||||
if(outputId.equals("EIOEnchanter") && getClass() == EnchanterRecipeHandler.class) {
|
||||
List<EnchanterRecipe> recipes = EnchanterRecipeManager.getInstance().getRecipes();
|
||||
for (EnchanterRecipe recipe : recipes) {
|
||||
if(recipe.isValid()) {
|
||||
@@ -102,25 +101,29 @@ public class EnchanterRecipeHandler extends TemplateRecipeHandler {
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
List<EnchanterRecipe> recipes = EnchanterRecipeManager.getInstance().getRecipes();
|
||||
for (EnchanterRecipe recipe : recipes) {
|
||||
if(recipe.isValid() && recipe.isInput(ingredient)) {
|
||||
if(recipe.isValid()) {
|
||||
EnchantmentData enchantment = new EnchantmentData(recipe.getEnchantment(), 1);
|
||||
ItemStack output = new ItemStack(Items.enchanted_book);
|
||||
Items.enchanted_book.addEnchantment(output, enchantment);
|
||||
EnchanterRecipeNEI rec = new EnchanterRecipeNEI(recipe, output, enchantment);
|
||||
arecipes.add(rec);
|
||||
if(rec.contains(rec.input, ingredient)) {
|
||||
rec.setIngredientPermutation(rec.input, ingredient);
|
||||
arecipes.add(rec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
public void drawExtras(int recipeIndex) {
|
||||
EnchanterRecipeNEI recipe = (EnchanterRecipeNEI) arecipes.get(recipeIndex);
|
||||
|
||||
GuiDraw.drawStringC(recipe.getEnchantName(), 83, 10, 0x808080, false);
|
||||
|
||||
int cost = TileEnchanter.getEnchantmentCost(recipe.recipe, 1);
|
||||
if(cost > 0) {
|
||||
String s = I18n.format("container.repair.cost", new Object[] {Integer.valueOf(cost)});
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int sw = fr.getStringWidth(s);
|
||||
fr.drawStringWithShadow(s, 90 - (sw/2), 48, 8453920);
|
||||
String s = I18n.format("container.repair.cost", new Object[] { Integer.valueOf(cost) });
|
||||
GuiDraw.drawStringC(s, 83, 46, 0x80FF20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +144,10 @@ public class EnchanterRecipeHandler extends TemplateRecipeHandler {
|
||||
private EnchantmentData enchData;
|
||||
private EnchanterRecipe recipe;
|
||||
|
||||
public String getEnchantName() {
|
||||
return StatCollector.translateToLocal(enchData.enchantmentobj.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 20, input);
|
||||
|
||||
@@ -3,7 +3,6 @@ package crazypants.enderio.nei;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.gas.GasUtil;
|
||||
import crazypants.enderio.config.Config;
|
||||
@@ -12,9 +11,9 @@ public class NEIEnderIOConfig implements IConfigureNEI {
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
API.registerRecipeHandler(new AlloySmelterRecipeHandler());
|
||||
API.registerRecipeHandler(new AlloySmelterRecipeHandler());
|
||||
API.registerUsageHandler(new AlloySmelterRecipeHandler());
|
||||
|
||||
|
||||
API.registerRecipeHandler(new SagMillRecipeHandler());
|
||||
API.registerUsageHandler(new SagMillRecipeHandler());
|
||||
|
||||
@@ -23,10 +22,10 @@ public class NEIEnderIOConfig implements IConfigureNEI {
|
||||
|
||||
API.registerRecipeHandler(new EnchanterRecipeHandler());
|
||||
API.registerUsageHandler(new EnchanterRecipeHandler());
|
||||
|
||||
|
||||
API.registerRecipeHandler(new SliceAndSpliceRecipeHandler());
|
||||
API.registerUsageHandler(new SliceAndSpliceRecipeHandler());
|
||||
|
||||
|
||||
API.registerRecipeHandler(new SoulBinderRecipeHandler());
|
||||
API.registerUsageHandler(new SoulBinderRecipeHandler());
|
||||
|
||||
@@ -68,8 +67,7 @@ public class NEIEnderIOConfig implements IConfigureNEI {
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "0.0.1";
|
||||
return EnderIO.VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package crazypants.enderio.nei;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
@@ -25,7 +23,6 @@ import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.machine.recipe.Recipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.recipe.RecipeOutput;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@@ -38,7 +35,7 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "enderio:textures/gui/crusher.png";
|
||||
return "enderio:textures/gui/nei/crusher.png";
|
||||
}
|
||||
|
||||
public PositionedStack getResult() {
|
||||
@@ -57,7 +54,6 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
//Set this up later to show all alloy recipes
|
||||
transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(149, 32, 16, 16), "EnderIOSagMill", new Object[0]));
|
||||
}
|
||||
|
||||
@@ -93,24 +89,31 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
|
||||
List<Recipe> recipes = CrusherRecipeManager.getInstance().getRecipes();
|
||||
for (Recipe recipe : recipes) {
|
||||
if(recipe.isValidInput(0, ingredient)) {
|
||||
MillRecipe res = new MillRecipe(recipe.getEnergyRequired(), recipe.getInputs()[0], recipe.getOutputs());
|
||||
MillRecipe res = new MillRecipe(recipe.getEnergyRequired(), recipe.getInputs()[0], recipe.getOutputs());
|
||||
if(res.contains(res.input, ingredient)) {
|
||||
res.setIngredientPermutation(res.input, ingredient);
|
||||
arecipes.add(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
drawProgressBar(98, 33, 176, 0, 22, 13, 48, 3);
|
||||
drawProgressBar(50, 33, 176, 0, 22, 13, 48, 3);
|
||||
drawProgressBar(73, 20, 166, 0, 17, 24, 40, 1);
|
||||
drawProgressBar(136, 12, 166, 24, 4, 16, 160, 11);
|
||||
|
||||
MillRecipe recipe = (MillRecipe) arecipes.get(recipeIndex);
|
||||
String energyString = PowerDisplayUtil.formatPower(recipe.getEnergy()) + " " + PowerDisplayUtil.abrevation();
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(energyString, 90, 22, 0xFFFFFFFF);
|
||||
GuiDraw.drawString(energyString, 96, 33, 0x808080, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,39 +123,14 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
if(chance > 0 && chance < 1) {
|
||||
int chanceInt = (int) (chance * 100);
|
||||
if(chanceInt == 0) {
|
||||
currenttip.add("Less than 1%");
|
||||
currenttip.add(EnumChatFormatting.GRAY + "Chance: <1%");
|
||||
} else {
|
||||
currenttip.add(chanceInt + "% Chance");
|
||||
currenttip.add(EnumChatFormatting.GRAY + "Chance: " + chanceInt + "%");
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public void renderIcon(IIcon icon, double x, double y, double width, double height, double zLevel) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
RenderUtil.bindItemTexture();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
float minU = icon.getMinU();
|
||||
float minV = icon.getMinV();
|
||||
float maxU = icon.getMaxU();
|
||||
float maxV = icon.getMaxV();
|
||||
tessellator.addVertexWithUV(x, y + height, zLevel, minU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + height, zLevel, maxU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + 0, zLevel, maxU, minV);
|
||||
tessellator.addVertexWithUV(x, y + 0, zLevel, minU, minV);
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawProgressBar(int x, int y, int tx, int ty, int w, int h, float completion, int direction) {
|
||||
super.drawProgressBar(87 - 13, 37 - 16, 200, 0, 17, 24, completion, 1);
|
||||
}
|
||||
|
||||
public List<ItemStack> getInputs(RecipeInput input) {
|
||||
List<ItemStack> result = new ArrayList<ItemStack>();
|
||||
result.add(input.getInput());
|
||||
@@ -165,8 +143,6 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Point offset = new Point(5, 11);
|
||||
|
||||
public class MillRecipe extends TemplateRecipeHandler.CachedRecipe {
|
||||
|
||||
protected int numTargetOuput;
|
||||
@@ -176,7 +152,7 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
private ArrayList<PositionedStack> otherOutputs;
|
||||
private float[] outputChance;
|
||||
private int energy;
|
||||
|
||||
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
@@ -220,20 +196,20 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
|
||||
this.energy = energy;
|
||||
|
||||
input = new ArrayList<PositionedStack>(2);
|
||||
input.add(new PositionedStack(getInputs(ingredient), 80 - offset.x, 12 - offset.y));
|
||||
input.add(new PositionedStack(getInputs(ingredient), 74, 2));
|
||||
|
||||
input.add(new PositionedStack(getBalls(), 122 - offset.x, 23 - offset.y));
|
||||
input.add(new PositionedStack(getBalls(), 116, 12));
|
||||
|
||||
output = new PositionedStack(outputs[0].getOutput(), 49 - offset.x, 59 - offset.y);
|
||||
output = new PositionedStack(outputs[0].getOutput(), 43, 46);
|
||||
otherOutputs = new ArrayList<PositionedStack>();
|
||||
if(outputs.length > 1) {
|
||||
otherOutputs.add(new PositionedStack(outputs[1].getOutput(), 70 - offset.x, 59 - offset.y));
|
||||
otherOutputs.add(new PositionedStack(outputs[1].getOutput(), 64, 46));
|
||||
}
|
||||
if(outputs.length > 2) {
|
||||
otherOutputs.add(new PositionedStack(outputs[2].getOutput(), 91 - offset.x, 59 - offset.y));
|
||||
otherOutputs.add(new PositionedStack(outputs[2].getOutput(), 85, 46));
|
||||
}
|
||||
if(outputs.length > 3) {
|
||||
otherOutputs.add(new PositionedStack(outputs[3].getOutput(), 112 - offset.x, 59 - offset.y));
|
||||
otherOutputs.add(new PositionedStack(outputs[3].getOutput(), 106, 46));
|
||||
}
|
||||
|
||||
outputChance = new float[outputs.length];
|
||||
|
||||
@@ -5,10 +5,13 @@ import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
@@ -82,16 +85,26 @@ public class SliceAndSpliceRecipeHandler extends TemplateRecipeHandler {
|
||||
for (IRecipe recipe : recipes) {
|
||||
if(recipe.isValidInput(0, ingredient)) {
|
||||
SliceAndSpliceRecipe res = new SliceAndSpliceRecipe(recipe);
|
||||
res.setIngredientPermutation(res.input, ingredient);
|
||||
arecipes.add(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(16, 0, 29, 11, 142, 65);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
drawProgressBar(90, 35, 177, 14, 23, 17, 120, 0);
|
||||
|
||||
SliceAndSpliceRecipe recipe = (SliceAndSpliceRecipe) arecipes.get(recipeIndex);
|
||||
String energyString = PowerDisplayUtil.formatPower(recipe.getEnergy()) + " " + PowerDisplayUtil.abrevation();
|
||||
Minecraft.getMinecraft().fontRenderer.drawString(energyString, 100, 58, 0xFFFFFFFF);
|
||||
GuiDraw.drawString(energyString, 100, 57, 0x808080, false);
|
||||
}
|
||||
|
||||
public List<ItemStack> getInputs(RecipeInput input) {
|
||||
@@ -130,7 +143,7 @@ public class SliceAndSpliceRecipeHandler extends TemplateRecipeHandler {
|
||||
int recipeSize = recipe.getInputs().length;
|
||||
input = new ArrayList<PositionedStack>();
|
||||
int yOff = 11;
|
||||
int xOff = 5;
|
||||
int xOff = 13;
|
||||
|
||||
Point pos;
|
||||
for (RecipeInput recipeInput : recipe.getInputs()) {
|
||||
|
||||
@@ -2,35 +2,26 @@ package crazypants.enderio.nei;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentData;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.IMachineRecipe;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.enchanter.EnchanterRecipe;
|
||||
import crazypants.enderio.machine.enchanter.EnchanterRecipeManager;
|
||||
import crazypants.enderio.machine.enchanter.GuiEnchanter;
|
||||
import crazypants.enderio.machine.enchanter.TileEnchanter;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.machine.soul.GuiSoulBinder;
|
||||
import crazypants.enderio.machine.soul.ISoulBinderRecipe;
|
||||
import crazypants.enderio.nei.EnchanterRecipeHandler.EnchanterRecipeNEI;
|
||||
|
||||
public class SoulBinderRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@@ -110,9 +101,9 @@ public class SoulBinderRecipeHandler extends TemplateRecipeHandler {
|
||||
}
|
||||
for (IMachineRecipe recipe : recipes.values()) {
|
||||
if(recipe instanceof ISoulBinderRecipe) {
|
||||
ISoulBinderRecipe sbr = (ISoulBinderRecipe) recipe;
|
||||
if(sbr.getInputStack().isItemEqual(ingredient)) {
|
||||
arecipes.add(new SoulBinderRecipeNEI((ISoulBinderRecipe) recipe));
|
||||
SoulBinderRecipeNEI sbr = new SoulBinderRecipeNEI((ISoulBinderRecipe) recipe);
|
||||
if(sbr.contains(sbr.input, ingredient)) {
|
||||
arecipes.add(sbr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,36 +111,48 @@ public class SoulBinderRecipeHandler extends TemplateRecipeHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
public void drawBackground(int recipeIndex) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(18, 0, 29, 11, 142, 65);
|
||||
}
|
||||
|
||||
// public List<ItemStack> getInputs(RecipeInput input) {
|
||||
// List<ItemStack> result = new ArrayList<ItemStack>();
|
||||
// result.add(input.getInput());
|
||||
// ItemStack[] equivs = input.getEquivelentInputs();
|
||||
// if(equivs != null && equivs.length > 0) {
|
||||
// result.addAll(Arrays.asList(equivs));
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
drawProgressBar(70, 23, 177, 14, 23, 17, 160, 0);
|
||||
|
||||
SoulBinderRecipeNEI recipe = (SoulBinderRecipeNEI) arecipes.get(recipeIndex);
|
||||
|
||||
String energyString = PowerDisplayUtil.formatPower(recipe.getEnergy()) + " " + PowerDisplayUtil.abrevation();
|
||||
GuiDraw.drawStringC(energyString, 83, 45, 0x808080, false);
|
||||
|
||||
int cost = recipe.getExperience();
|
||||
if(cost > 0) {
|
||||
String s = I18n.format("container.repair.cost", new Object[] { Integer.valueOf(cost) });
|
||||
GuiDraw.drawStringC(s, 83, 55, 0x80FF20);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ArrayList<PositionedStack> EMPTY_VIAL_OUTPUT = new ArrayList<PositionedStack>();
|
||||
static {
|
||||
EMPTY_VIAL_OUTPUT.add(new PositionedStack(new ItemStack(EnderIO.itemSoulVessel), 107, 23));
|
||||
EMPTY_VIAL_OUTPUT.add(new PositionedStack(new ItemStack(EnderIO.itemSoulVessel), 101, 23));
|
||||
}
|
||||
|
||||
public class SoulBinderRecipeNEI extends TemplateRecipeHandler.CachedRecipe {
|
||||
|
||||
private final ArrayList<PositionedStack> input = new ArrayList<PositionedStack>();
|
||||
|
||||
private final PositionedStack output;
|
||||
|
||||
private int energy;
|
||||
private int experience;
|
||||
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
public int getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 20, input);
|
||||
@@ -166,18 +169,20 @@ public class SoulBinderRecipeHandler extends TemplateRecipeHandler {
|
||||
}
|
||||
|
||||
public SoulBinderRecipeNEI(ISoulBinderRecipe recipe) {
|
||||
this(recipe.getInputStack(), recipe.getOutputStack(), recipe.getEnergyRequired(), recipe.getSupportedSouls());
|
||||
this(recipe.getInputStack(), recipe.getOutputStack(), recipe.getEnergyRequired(), recipe.getExperienceRequired(), recipe.getSupportedSouls());
|
||||
}
|
||||
|
||||
public SoulBinderRecipeNEI(ItemStack inputStack, ItemStack result, int energy, List<String> list) {
|
||||
public SoulBinderRecipeNEI(ItemStack inputStack, ItemStack result, int energy, int experience, List<String> list) {
|
||||
|
||||
int yOff = 11;
|
||||
int xOff = 6;
|
||||
int xOff = 11;
|
||||
|
||||
input.add(new PositionedStack(getSoulVialInputs(list), 38 - xOff, 34 - yOff));
|
||||
input.add(new PositionedStack(inputStack, 60 - xOff, 34 - yOff));
|
||||
input.add(new PositionedStack(inputStack, 59 - xOff, 34 - yOff));
|
||||
output = new PositionedStack(result, 134 - xOff, 34 - yOff);
|
||||
|
||||
this.energy = energy;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
private List<ItemStack> getSoulVialInputs(List<String> mobs) {
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
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;
|
||||
@@ -28,7 +23,6 @@ import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.still.GuiVat;
|
||||
import crazypants.enderio.machine.still.VatRecipeManager;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class VatRecipeHandler extends TemplateRecipeHandler {
|
||||
@@ -124,12 +118,20 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
|
||||
if(addRecipe) {
|
||||
FluidStack output = recipe.getOutputs()[0].getFluidOutput();
|
||||
InnerVatRecipe res = new InnerVatRecipe(recipe.getEnergyRequired(), recipe.getInputs(), output);
|
||||
res.setIngredientPermutation(res.inputs, ingredient);
|
||||
arecipes.add(res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(22, 0, 27, 11, 123, 52);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipeIndex) {
|
||||
InnerVatRecipe rec = (InnerVatRecipe) arecipes.get(recipeIndex);
|
||||
@@ -142,24 +144,15 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
|
||||
.renderGuiTank(rec.result, rec.result.amount, rec.result.amount, outTankBounds.x, outTankBounds.y, 0, outTankBounds.width, outTankBounds.height);
|
||||
}
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
String energyString = PowerDisplayUtil.formatPower(rec.energy) + " " + PowerDisplayUtil.abrevation();
|
||||
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);
|
||||
fr.drawString(energyString, 86 - width / 2, 55, col, true);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GuiDraw.drawStringC(energyString, 86, 54, 0x808080, false);
|
||||
|
||||
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);
|
||||
|
||||
GuiDraw.drawStringC(str, ps.relx + 8, ps.rely + 19, 0x808080, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,41 +188,16 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
|
||||
InnerVatRecipe rec = (InnerVatRecipe) arecipes.get(index);
|
||||
if(in) {
|
||||
if(rec.inFluid != null && rec.inFluid.getFluid() != null) {
|
||||
list.add(rec.inFluid.getFluid().getLocalizedName());
|
||||
list.add(rec.inFluid.getFluid().getLocalizedName(rec.inFluid));
|
||||
}
|
||||
} else {
|
||||
if(rec.result != null && rec.result.getFluid() != null) {
|
||||
list.add(rec.result.getFluid().getLocalizedName());
|
||||
list.add(rec.result.getFluid().getLocalizedName(rec.result));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void renderIcon(IIcon icon, double x, double y, double width, double height, double zLevel) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
RenderUtil.bindItemTexture();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
float minU = icon.getMinU();
|
||||
float minV = icon.getMinV();
|
||||
float maxU = icon.getMaxU();
|
||||
float maxV = icon.getMaxV();
|
||||
tessellator.addVertexWithUV(x, y + height, zLevel, minU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + height, zLevel, maxU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + 0, zLevel, maxU, minV);
|
||||
tessellator.addVertexWithUV(x, y + 0, zLevel, minU, minV);
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawProgressBar(int x, int y, int tx, int ty, int w, int h, float completion, int direction) {
|
||||
super.drawProgressBar(87 - 13, 37 - 16, 200, 0, 17, 24, completion, 1);
|
||||
}
|
||||
|
||||
public List<ItemStack> getInputs(RecipeInput input) {
|
||||
List<ItemStack> result = new ArrayList<ItemStack>();
|
||||
result.add(input.getInput());
|
||||
|
||||
@@ -122,7 +122,6 @@ public class BlockEnderRail extends BlockRail implements IResourceTooltipProvide
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
if(!world.isRemote) {
|
||||
TileEntity te = world.getTileEntity(x, y - 1, z);
|
||||
System.out.println("BlockEnderRail.removedByPlayer: " + te);
|
||||
if(te instanceof TileTransceiver) {
|
||||
((TileTransceiver) te).getRailController().dropNonSpawnedCarts();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.teleport.packet.PacketAccessMode;
|
||||
import crazypants.enderio.teleport.packet.PacketConfigSync;
|
||||
import crazypants.enderio.teleport.packet.PacketDrainStaff;
|
||||
import crazypants.enderio.teleport.packet.PacketLabel;
|
||||
import crazypants.enderio.teleport.packet.PacketOpenAuthGui;
|
||||
import crazypants.enderio.teleport.packet.PacketTravelEvent;
|
||||
import crazypants.util.Lang;
|
||||
@@ -44,6 +45,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt
|
||||
public static BlockTravelAnchor create() {
|
||||
|
||||
PacketHandler.INSTANCE.registerMessage(PacketAccessMode.class, PacketAccessMode.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketLabel.class, PacketLabel.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketTravelEvent.class, PacketTravelEvent.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketDrainStaff.class, PacketDrainStaff.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketOpenAuthGui.class, PacketOpenAuthGui.class, PacketHandler.nextID(), Side.SERVER);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ContainerTravelAccessable extends Container {
|
||||
}
|
||||
|
||||
arrInv = new PasswordInventory(new ItemStack[] {ta.getItemLabel()}, false);
|
||||
x = 80;
|
||||
x = 125;
|
||||
y = 10;
|
||||
addSlotToContainer(new TemplateSlot(arrInv, 0, x, y));
|
||||
|
||||
|
||||
@@ -5,15 +5,18 @@ import java.awt.Color;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.gui.CheckBoxEIO;
|
||||
import crazypants.enderio.gui.IGuiOverlay;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.teleport.TileTravelAnchor.AccessMode;
|
||||
import crazypants.enderio.teleport.packet.PacketAccessMode;
|
||||
import crazypants.enderio.teleport.packet.PacketLabel;
|
||||
import crazypants.gui.GuiContainerBase;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
@@ -30,6 +33,8 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
private CheckBoxEIO privateCB;
|
||||
private CheckBoxEIO protectedCB;
|
||||
|
||||
private GuiTextField tf;
|
||||
|
||||
private String publicStr;
|
||||
private String privateStr;
|
||||
private String protectedStr;
|
||||
@@ -52,6 +57,8 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
tf = new GuiTextField(fr, 7, 12, 90, 16);
|
||||
|
||||
col1x = 88;
|
||||
col0x = (col1x - fr.getStringWidth(protectedStr) / 2) / 2;
|
||||
col2x = (col1x + fr.getStringWidth(protectedStr) / 2);
|
||||
@@ -98,6 +105,43 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
publicCB.onGuiInit();
|
||||
privateCB.onGuiInit();
|
||||
protectedCB.onGuiInit();
|
||||
|
||||
tf.xPosition = getGuiLeft() + 30;
|
||||
tf.yPosition = getGuiTop() + 10;
|
||||
tf.setCanLoseFocus(false);
|
||||
tf.setMaxStringLength(32);
|
||||
tf.setFocused(true);
|
||||
String txt = te.getLabel();
|
||||
if(txt != null && txt.length() > 0) {
|
||||
tf.setText(txt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char par1, int par2) {
|
||||
if(par2 == 1) {
|
||||
for (IGuiOverlay overlay : overlays) {
|
||||
if(overlay.isVisible()) {
|
||||
overlay.setVisible(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
tf.textboxKeyTyped(par1, par2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
tf.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int x, int y, int par3) {
|
||||
super.mouseClicked(x, y, par3);
|
||||
tf.mouseClicked(x, y, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,6 +167,40 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
x = sx + col2x - fontRenderer.getStringWidth(publicStr) / 2;
|
||||
fontRenderer.drawStringWithShadow(publicStr, x, y, col);
|
||||
|
||||
tf.drawTextBox();
|
||||
checkLabelForChange();
|
||||
|
||||
}
|
||||
|
||||
private void checkLabelForChange() {
|
||||
String newTxt = tf.getText();
|
||||
if(newTxt != null && newTxt.length() == 0) {
|
||||
newTxt = null;
|
||||
}
|
||||
|
||||
String curText = te.getLabel();
|
||||
if(curText != null && curText.length() == 0) {
|
||||
curText = null;
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
if(newTxt == null) {
|
||||
if(curText == null) {
|
||||
changed = false;
|
||||
} else {
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
changed = !newTxt.equals(curText);
|
||||
}
|
||||
if(!changed) {
|
||||
return;
|
||||
}
|
||||
te.setLabel(newTxt);
|
||||
BlockCoord bc = te.getLocation();
|
||||
PacketLabel p = new PacketLabel(bc.x, bc.y, bc.z, te.getLabel());
|
||||
PacketHandler.INSTANCE.sendToServer(p);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,10 @@ public interface ITravelAccessable {
|
||||
ItemStack getItemLabel();
|
||||
|
||||
void setItemLabel(ItemStack lableIcon);
|
||||
|
||||
String getLabel();
|
||||
|
||||
void setLabel(String label);
|
||||
|
||||
String getPlacedBy();
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
private ItemStack[] password = new ItemStack[5];
|
||||
|
||||
private ItemStack itemLabel;
|
||||
|
||||
private String label;
|
||||
|
||||
private String placedBy;
|
||||
|
||||
@@ -142,6 +144,16 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
this.itemLabel = lableIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlacedBy() {
|
||||
return placedBy;
|
||||
@@ -233,6 +245,10 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
sourceBlock = Block.getBlockFromName(sourceBlockStr);
|
||||
sourceBlockMetadata = root.getInteger(KEY_SOURCE_BLOCK_META);
|
||||
|
||||
label = root.getString("label");
|
||||
if(label == null || label.trim().length() == 0) {
|
||||
label = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -269,6 +285,11 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
root.setString(KEY_SOURCE_BLOCK_ID, Block.blockRegistry.getNameForObject(sourceBlock));
|
||||
}
|
||||
root.setInteger(KEY_SOURCE_BLOCK_META, sourceBlockMetadata);
|
||||
|
||||
if(label != null && label.trim().length() > 0) {
|
||||
root.setString("label", label);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -248,14 +248,14 @@ public class TravelController {
|
||||
lookAt.add(eye);
|
||||
Matrix4d mv = VecmathUtil.createMatrixAsLookAt(eye, lookAt, new Vector3d(0, 1, 0));
|
||||
|
||||
float fov = 70 + Minecraft.getMinecraft().gameSettings.fovSetting * 40.0F;
|
||||
float fov = Minecraft.getMinecraft().gameSettings.fovSetting;
|
||||
Matrix4d pr = VecmathUtil.createProjectionMatrixAsPerspective(fov, 0.05f, mc.gameSettings.renderDistanceChunks * 16, mc.displayWidth,
|
||||
mc.displayHeight);
|
||||
mc.displayHeight);
|
||||
currentView.setProjectionMatrix(pr);
|
||||
currentView.setViewMatrix(mv);
|
||||
currentView.setViewport(0, 0, mc.displayWidth, mc.displayHeight);
|
||||
|
||||
fovRad = Math.toRadians(fov) / 2;
|
||||
fovRad = Math.toRadians(fov);
|
||||
tanFovRad = Math.tanh(fovRad);
|
||||
}
|
||||
|
||||
@@ -507,24 +507,11 @@ public class TravelController {
|
||||
return;
|
||||
}
|
||||
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
Vector3d point = new Vector3d();
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
for (BlockCoord bc : candidates.keySet()) {
|
||||
if(!bc.equals(onBlockCoord)) {
|
||||
point.set(bc.x + 0.5, bc.y + 0.5, bc.z + 0.5);
|
||||
|
||||
Vector2d sp = currentView.getScreenPoint(new Vector3d(point.x, point.y, point.z));
|
||||
Vector2d mid = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
|
||||
mid.scale(0.5);
|
||||
|
||||
double d = sp.distance(mid);
|
||||
if(d != d) {
|
||||
d = 0f;
|
||||
}
|
||||
float ratio = (float) d / Minecraft.getMinecraft().displayWidth;
|
||||
|
||||
|
||||
candidates.put(bc, ratio);
|
||||
double d = addRatio(bc);
|
||||
if(d < closestDistance) {
|
||||
selectedCoord = bc;
|
||||
closestDistance = d;
|
||||
@@ -539,22 +526,16 @@ public class TravelController {
|
||||
|
||||
Vector2d screenMidPixel = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
|
||||
screenMidPixel.scale(0.5);
|
||||
double ratio = blockCenterPixel.distance(screenMidPixel) / Minecraft.getMinecraft().displayWidth;
|
||||
|
||||
|
||||
Vector3d blockLeft = new Vector3d();
|
||||
Vector3d up = new Vector3d(0,1,0);
|
||||
up.add(currentView.getEyePoint());
|
||||
blockLeft.cross(currentView.getEyePoint(), up);
|
||||
blockLeft.normalize();
|
||||
blockLeft.scale(0.5);
|
||||
blockLeft.add(blockCenter);
|
||||
|
||||
Vector2d blockLeftPixel = currentView.getScreenPoint(blockLeft);
|
||||
double blockSizeRatio = blockCenterPixel.distance(blockLeftPixel)/ Minecraft.getMinecraft().displayWidth;
|
||||
double maxRatio = Math.max(0.2, blockSizeRatio);
|
||||
if(ratio > maxRatio) {
|
||||
double pixDist = blockCenterPixel.distance(screenMidPixel);
|
||||
double rat = pixDist / Minecraft.getMinecraft().displayHeight;
|
||||
if(rat != rat) {
|
||||
rat = 0;
|
||||
}
|
||||
if(rat > 0.07) {
|
||||
selectedCoord = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -569,12 +550,8 @@ public class TravelController {
|
||||
}
|
||||
if(ratio < 0) {
|
||||
//no cached value
|
||||
Vector2d sp = currentView.getScreenPoint(new Vector3d(bc.x, bc.y, bc.z));
|
||||
Vector2d mid = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
|
||||
mid.scale(0.5);
|
||||
double d = sp.distance(mid);
|
||||
ratio = (float) d / Minecraft.getMinecraft().displayWidth;
|
||||
candidates.put(bc, ratio);
|
||||
addRatio(bc);
|
||||
ratio = candidates.get(bc);
|
||||
}
|
||||
|
||||
//smoothly zoom to a larger size, starting when the point is the middle 20% of the screen
|
||||
@@ -583,21 +560,37 @@ public class TravelController {
|
||||
double mix = MathHelper.clamp_float((start - ratio) / (start - end), 0, 1);
|
||||
double scale = 1;
|
||||
if(mix > 0) {
|
||||
double d = tanFovRad * currentView.getEyePoint().distance(loc);
|
||||
scale = d / tanFovRad;
|
||||
|
||||
scale = scale * 0.1;// why I need this is completely beyond me.
|
||||
|
||||
Vector3d eyePoint = Util.getEyePositionEio(EnderIO.proxy.getClientPlayer());
|
||||
scale = tanFovRad * eyePoint.distance(loc);
|
||||
|
||||
//Using this scale will give us the block full screen, we will make it 20% of the screen
|
||||
scale *= Config.travelAnchorZoomScale;
|
||||
|
||||
//only apply 70% of the scaling so more distance targets are still smaller than closer targets
|
||||
float nf = 1 - MathHelper.clamp_float((float) currentView.getEyePoint().distanceSquared(loc) / TravelSource.STAFF.maxDistanceTravelledSq, 0, 1);
|
||||
float nf = 1 - MathHelper.clamp_float((float) eyePoint.distanceSquared(loc) / TravelSource.STAFF.maxDistanceTravelledSq, 0, 1);
|
||||
scale = scale * (0.3 + 0.7 * nf);
|
||||
|
||||
scale = (scale * mix) + (1 - mix);
|
||||
scale = Math.max(1, scale);
|
||||
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
private double addRatio(BlockCoord bc) {
|
||||
Vector2d sp = currentView.getScreenPoint(new Vector3d(bc.x + 0.5, bc.y + 0.5, bc.z + 0.5));
|
||||
Vector2d mid = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
|
||||
mid.scale(0.5);
|
||||
double d = sp.distance(mid);
|
||||
if(d != d) {
|
||||
d = 0f;
|
||||
}
|
||||
float ratio = (float) d / Minecraft.getMinecraft().displayWidth;
|
||||
candidates.put(bc, ratio);
|
||||
return d;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int getMaxTravelDistanceSqForPlayer(EntityClientPlayerMP player) {
|
||||
if(isTravelItemActive(player)) {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package crazypants.enderio.teleport;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -17,8 +22,8 @@ import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Util;
|
||||
import crazypants.vecmath.Matrix4d;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
@@ -61,7 +66,7 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
TravelController.instance.addCandidate(bc);
|
||||
|
||||
Minecraft.getMinecraft().entityRenderer.disableLightmap(0);
|
||||
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||
@@ -76,16 +81,17 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
|
||||
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
renderBlock(sf);
|
||||
Tessellator.instance.draw();
|
||||
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
Tessellator.instance.setBrightness(15 << 20 | 15 << 4);
|
||||
if(TravelController.instance.isBlockSelected(bc)) {
|
||||
Tessellator.instance.setColorRGBA_F(selectedColor.x, selectedColor.y, selectedColor.z, selectedColor.w);
|
||||
CubeRenderer.render(BoundingBox.UNIT_CUBE.scale(sf + 0.05, sf + 0.05, sf + 0.05), getSelectedIcon());
|
||||
@@ -101,36 +107,82 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopAttrib();
|
||||
|
||||
|
||||
Minecraft.getMinecraft().entityRenderer.enableLightmap(0);
|
||||
|
||||
}
|
||||
|
||||
private void renderLabel(TileEntity tileentity, double x, double y, double z, ITravelAccessable ta, double sf) {
|
||||
float globalScale = (float) sf;
|
||||
ItemStack itemLabel = ta.getItemLabel();
|
||||
if(itemLabel != null) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR);
|
||||
GL14.glBlendColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
IIcon tex = itemLabel.getIconIndex();
|
||||
if(tex == null) {
|
||||
return;
|
||||
if(itemLabel != null && itemLabel.getItem() != null) {
|
||||
|
||||
boolean isBlock = false;
|
||||
Block block = Block.getBlockFromItem(itemLabel.getItem());
|
||||
if(block != null && block != Blocks.air) {
|
||||
isBlock = true;
|
||||
}
|
||||
if(itemLabel.getItemSpriteNumber() == 0) {
|
||||
RenderUtil.bindBlockTexture();
|
||||
} else {
|
||||
RenderUtil.bindItemTexture();
|
||||
}
|
||||
|
||||
Matrix4d lookMat = RenderUtil.createBillboardMatrix(tileentity, Minecraft.getMinecraft().thePlayer);
|
||||
RenderUtil.renderBillboard(lookMat, tex.getMinU(), tex.getMaxU(), tex.getMaxV(), tex.getMinV(), sf * 0.75, 0);
|
||||
float alpha = 0.5f;
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR);
|
||||
float col = 0.5f;
|
||||
GL14.glBlendColor(col, col, col, col);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
|
||||
if(!isBlock) {
|
||||
GL11.glRotatef(-player.rotationYaw, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(player.rotationPitch, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(globalScale, globalScale, globalScale);
|
||||
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
if(isBlock) {
|
||||
GL11.glTranslatef(0f, -0.25f, 0);
|
||||
} else {
|
||||
GL11.glTranslatef(0f, -0.5f, 0);
|
||||
}
|
||||
GL11.glScalef(2, 2, 2);
|
||||
EntityItem ei = new EntityItem(tileentity.getWorldObj(), x, y, z, itemLabel);
|
||||
ei.age = 0;
|
||||
ei.hoverStart = 0;
|
||||
RenderManager.instance.getEntityRenderObject(ei).doRender(ei, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
String toRender = ta.getLabel();
|
||||
if(toRender != null && toRender.trim().length() > 0) {
|
||||
Vector4f bgCol = RenderUtil.DEFAULT_TEXT_BG_COL;
|
||||
if(TravelController.instance.isBlockSelected(new BlockCoord(tileentity))) {
|
||||
bgCol = new Vector4f(selectedColor.x, selectedColor.y, selectedColor.z, selectedColor.w);
|
||||
}
|
||||
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(globalScale, globalScale, globalScale);
|
||||
Vector3f pos = new Vector3f(0, 1.2f, 0);
|
||||
float size = 0.5f;
|
||||
RenderUtil.drawBillboardedText(pos, toRender, size, bgCol);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.enderio.teleport.ITravelAccessable;
|
||||
import crazypants.enderio.teleport.TileTravelAnchor;
|
||||
|
||||
/**
|
||||
@@ -47,8 +48,8 @@ public class PacketAccessMode implements IMessage, IMessageHandler<PacketAccessM
|
||||
public IMessage onMessage(PacketAccessMode message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
||||
if(te instanceof TileTravelAnchor) {
|
||||
((TileTravelAnchor) te).setAccessMode(message.mode);
|
||||
if(te instanceof ITravelAccessable) {
|
||||
((ITravelAccessable) te).setAccessMode(message.mode);
|
||||
player.worldObj.markBlockForUpdate(message.x, message.y, message.z);
|
||||
player.worldObj.markTileEntityChunkModified(message.x, message.y, message.z, te);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package crazypants.enderio.teleport.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.enderio.teleport.ITravelAccessable;
|
||||
import crazypants.enderio.teleport.TileTravelAnchor;
|
||||
|
||||
public class PacketLabel implements IMessage, IMessageHandler<PacketLabel, IMessage> {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
boolean labelNull;
|
||||
String label;
|
||||
|
||||
|
||||
public PacketLabel() {
|
||||
}
|
||||
|
||||
public PacketLabel(int x, int y, int z, String label) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.label = label;
|
||||
labelNull = label == null || label.length() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeBoolean(labelNull);
|
||||
if(!labelNull) {
|
||||
ByteBufUtils.writeUTF8String(buf, label);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
labelNull = buf.readBoolean();
|
||||
if(labelNull) {
|
||||
label = null;
|
||||
} else {
|
||||
label = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public IMessage onMessage(PacketLabel message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
||||
if(te instanceof ITravelAccessable) {
|
||||
((ITravelAccessable) te).setLabel(message.label);
|
||||
player.worldObj.markBlockForUpdate(message.x, message.y, message.z);
|
||||
player.worldObj.markTileEntityChunkModified(message.x, message.y, message.z, te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,10 @@ public final class ColorUtil {
|
||||
return getRGB((int) (r * 255), (int) (g * 255), (int) (b * 255));
|
||||
}
|
||||
|
||||
public static int getRGBA(Vector4f col) {
|
||||
return getRGBA(col.x, col.y,col.z,col.w);
|
||||
}
|
||||
|
||||
public static int getRGBA(float r, float g, float b, float a) {
|
||||
return getRGBA((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,29 @@
|
||||
package crazypants.render;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.*;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.WEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_ALL_ATTRIB_BITS;
|
||||
import static org.lwjgl.opengl.GL11.GL_ALPHA_TEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
||||
import static org.lwjgl.opengl.GL11.GL_CULL_FACE;
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE;
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_SMOOTH;
|
||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||
import static org.lwjgl.opengl.GL11.GL_ZERO;
|
||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||
import static org.lwjgl.opengl.GL11.glDisable;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.glPopAttrib;
|
||||
import static org.lwjgl.opengl.GL11.glPushAttrib;
|
||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||
import static org.lwjgl.opengl.GL11.glShadeModel;
|
||||
import static org.lwjgl.opengl.GL11.glTranslatef;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
@@ -11,7 +34,10 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -39,6 +65,12 @@ import crazypants.vecmath.Vertex;
|
||||
|
||||
public class RenderUtil {
|
||||
|
||||
public static final Vector4f DEFAULT_TEXT_SHADOW_COL = new Vector4f(0.33f,0.33f,0.33f,0.33f);
|
||||
|
||||
public static final Vector4f DEFAULT_TXT_COL = new Vector4f(1,1,1,1);
|
||||
|
||||
public static final Vector4f DEFAULT_TEXT_BG_COL = new Vector4f(0.275f,0.08f,0.4f, 0.75f);
|
||||
|
||||
public static final Vector3d UP_V = new Vector3d(0, 1, 0);
|
||||
|
||||
public static final Vector3d ZERO_V = new Vector3d(0, 0, 0);
|
||||
@@ -530,6 +562,65 @@ public class RenderUtil {
|
||||
tessellator.addVertexWithUV(x, y, z, icon.getMinU(), icon.getMinV());
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawBillboardedText(Vector3f pos, String text, float size) {
|
||||
drawBillboardedText(pos, text, size, DEFAULT_TXT_COL, true, DEFAULT_TEXT_SHADOW_COL, true, DEFAULT_TEXT_BG_COL);
|
||||
}
|
||||
|
||||
public static void drawBillboardedText(Vector3f pos, String text, float size, Vector4f bgCol) {
|
||||
drawBillboardedText(pos, text, size, DEFAULT_TXT_COL, true, DEFAULT_TEXT_SHADOW_COL, true, bgCol);
|
||||
}
|
||||
|
||||
public static void drawBillboardedText(Vector3f pos, String text, float size, Vector4f txtCol, boolean drawShadow, Vector4f shadowCol, boolean drawBackground, Vector4f bgCol) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(pos.x, pos.y,pos.z);
|
||||
glRotatef(180, 1, 0, 0);
|
||||
|
||||
FontRenderer fnt = Minecraft.getMinecraft().fontRenderer;
|
||||
float scale = size / fnt.FONT_HEIGHT;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
glRotatef(RenderManager.instance.playerViewY + 180, 0.0F, 1.0F, 0.0F);
|
||||
glRotatef(-RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
|
||||
glTranslatef(-fnt.getStringWidth(text) / 2, 0, 0);
|
||||
if(drawBackground) {
|
||||
renderBackground(fnt, text, bgCol);
|
||||
}
|
||||
fnt.drawString(text, 0, 0, ColorUtil.getRGBA(txtCol));
|
||||
if(drawShadow) {
|
||||
glTranslatef(0.5f, 0.5f, 0.1f);
|
||||
fnt.drawString(text, 0, 0, ColorUtil.getRGBA(shadowCol));
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
}
|
||||
|
||||
public static void renderBackground(FontRenderer fnt, String toRender, Vector4f color) {
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDepthMask(false);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
OpenGlHelper.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); // stop random disappearing
|
||||
|
||||
float width = (float) fnt.getStringWidth(toRender);
|
||||
float height = (float) fnt.FONT_HEIGHT;
|
||||
float padding = 2f;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(color.x, color.y, color.z, color.w);
|
||||
tessellator.addVertex(-padding, -padding, 0);
|
||||
tessellator.addVertex(-padding, height + padding, 0);
|
||||
tessellator.addVertex(width + padding, height + padding, 0);
|
||||
tessellator.addVertex(width + padding, -padding, 0);
|
||||
tessellator.draw();
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
private static class EdgeNeighbour {
|
||||
final ForgeDirection dir;
|
||||
|
||||
Reference in new issue
Block a user