Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/24/19 in all areas

  1. "Void" is the return type of a method. That thing is called a "method" and when it does not have a return, its return type is "void." import net.minecraft.item.Items; https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderfarming/HarderFarming.java#L31
    1 point
  2. 1 point
  3. 1 point
  4. I think OP wants to create a visual effect of an armor stand. There is no need for interaction or synchronizing to other clients. Entities are not meant to be used as client-side rendering techniques. Instead of spawning the entity in the client world, you should subscribe to RenderWorldLastEvent and manually render the armor stand there. One approach would be to create a static list of all the visual armor stand's data, and render ArmorStandEntity in RenderWorldLastEvent according to the list. Then, instead of creating another thread to handle the updating, simply subscribe to ClientTickEvent and make a timer to determine when movements should be applied to the rendered armor stand.
    1 point
  5. You would have to color different vertices differently based on the length they are through the string to have that type of gradient. You would need extra code to store the length of the string that you’re drawing and to use that data in the render char method
    1 point
  6. Thank you very much for putting the time into this!
    1 point
  7. So after a little testing I came up with this (for 1.12.2): I created a Subclass of FontRenderer called GradientFontRenderer. In this class, I override the method renderDefaultChar (you should probably override the unicode method too.) so that It uses the above mentioned shadeModel and has the correct vertex order. The code for this is the following, and creates a gradient from red to blue: @Override protected float renderDefaultChar(int ch, boolean italic) { float charXPos = ch % 16 * 8f; float charYPos = (ch / 16) * 8f; float italicOffset = italic ? 1f : 0f; bindTexture(this.locationFontTexture); int charWidth = this.charWidth[ch]; float width = (float)charWidth - 0.01F; GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.glBegin(GL11.GL_QUADS); GlStateManager.color(1.0f, 0.0f, 0.0f); GlStateManager.glTexCoord2f(charXPos / 128.0F, charYPos / 128.0F); // 0 0 GlStateManager.glVertex3f(this.posX + italicOffset, this.posY, 0.0F); GlStateManager.color(0.0f, 0.0f, 1.0f); GlStateManager.glTexCoord2f(charXPos / 128.0F, (charYPos + 7.99F) / 128.0F); // 0 1 GlStateManager.glVertex3f(this.posX - italicOffset, this.posY + 7.99F, 0.0F); GlStateManager.color(0.0f, 0.0f, 1.0f); GlStateManager.glTexCoord2f((charXPos + width - 1.0F) / 128.0F, (charYPos + 7.99F) / 128.0F); // 1 1 GlStateManager.glVertex3f(this.posX + width - 1.0F - italicOffset, this.posY + 7.99F, 0.0F); GlStateManager.color(1.0f, 0.0f, 0.0f); GlStateManager.glTexCoord2f((charXPos + width - 1.0F) / 128.0F, charYPos / 128.0F); // 1 0 GlStateManager.glVertex3f(this.posX + width - 1.0F + italicOffset, this.posY, 0.0F); GlStateManager.glEnd(); GlStateManager.shadeModel(GL11.GL_FLAT); return (float)charWidth; } I'm sure you can expand on this code by adding parameters and auxiliary functions to control the gradient colors to your desire. For instantiating the GradientFontRenderer, I just created an Instance in the constructor of my Gui class. You also need to call onResourceManagerReload to load the texture for the fontrenderer and all. This is the GuiScreen code: public class TestGuiScreen extends GuiScreen { private GradientFontRenderer gradientFontRenderer; public TestGuiScreen() { Minecraft mc = Minecraft.getMinecraft(); gradientFontRenderer = new GradientFontRenderer(mc.gameSettings, new ResourceLocation("textures/font/ascii.png"), mc.renderEngine, false); gradientFontRenderer.onResourceManagerReload(null); } public void render() { ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft()); this.width = res.getScaledWidth(); this.height = res.getScaledHeight(); int x = (this.width) / 2; int y = (this.height) / 2; drawHelloTextWithGradient(x, y-16, 0xFFFFFFFF, 0xFFFF0000); } private void drawHelloTextWithGradient(int x, int y, int topColor, int bottomColor) { drawRect(x-20, y-8, x+20, y+8, 0x7F000000); drawCenteredGradientString(gradientFontRenderer, "hello", x, y-4, topColor, bottomColor); } public void drawCenteredGradientString(GradientFontRenderer fontRendererIn, String text, int x, int y, int color, int colorBottom) { fontRendererIn.drawString(text, x - fontRendererIn.getStringWidth(text) / 2, y, color); } } Here is a screenshot of how it looks. I hope this was helpful. If you have any further questions, just ask
    1 point
  8. The drawGradientRect method uses the following trick to render a gradient: The top two vertices of the quad are in one color, and the bottom two vertices are in another. Then, the shadeModel GL11.GL_SMOOTH is used, so that these colors are interpolated and create a gradient effect. To render a String, the drawString method calls the renderString method, which calls the renderStringAtPos method which ultimately calls the renderGlyph method, which calls the render method of the TexturedGlyph class. In that last render method, the color is set via the function parameters. If you created a custom TexturedGlyph that hat a render method with two colors as input, you could enable the above mentioned shadeModel to render a text with a gradient. It's a bit of work but seems definitely possible. Just have a look at net.minecraft.client.gui.fonts.TexturedGlyph::render and net.minecraftforge.fml.client.config.GuiUtils::drawGradientRect PS: Since I'm currently working with 1.14, the class names (any maybe the function names) differ, but apart from that, everything I said should be applicable.
    1 point
  9. It seems like World Saved Data system has changed now, with restrictions such as server-side only and no Global World Saved Data. Is there a thing that I can use to store and access data that exists only one per game? A hacky solution would be like attach capability to overworld and retrieve from there whenever needed, but I would like to know if there's more proper solution.
    1 point
  10. If you want to add trades to existing villager professions, you need: 1. Implement EntityVillager.ITradeList 2. Get the profession from ForgeRegistries.VILLAGER_PROFESSIONS 3. Get career from the profession 4. add the ITradeList to the career - #addTrade. Example below: Implementation which adds 60 emeralds -> 1 Wither skull trade: public class Trades implements EntityVillager.ITradeList { @Override public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) { recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD,60),new ItemStack(Items.SKULL,1,1))); } } Then getting a specific profession - nitwit in this case: VillagerRegistry.VillagerProfession nitwit=ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation("minecraft:nitwit")); And adding the trade to career with id "5": nitwit.getCareer(5).addTrade(1,new Trades()); Figure out desired career and profession by inspecting vanilla classes.
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.