
yolp900
Forge Modder-
Posts
52 -
Joined
-
Last visited
Everything posted by yolp900
-
[1.10.2][SOLVED] My own mod API crashes outside of workspace
yolp900 replied to yolp900's topic in Modder Support
IAffinityHolderItem - The interface in the api that's not found. package com.yolp900.itsjustacharm.api.affinities; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import javax.annotation.Nonnull; import java.util.List; public interface IAffinityHolderItem { int getMaxAmountOfStoredAffinities(@Nonnull ItemStack stack, EntityPlayer player, World world); int getCurrentAffinityIndex(@Nonnull ItemStack stack, EntityPlayer player, World world); void setCurrentAffinityIndex(@Nonnull ItemStack stack, int index, EntityPlayer player, World world); List<IAffinity> getStoredAffinities(@Nonnull ItemStack stack, EntityPlayer player, World world); IAffinity getStoredAffinity(@Nonnull ItemStack stack, int index, EntityPlayer player, World world); boolean storeAffinity(@Nonnull ItemStack stack, @Nonnull IAffinity affinity, EntityPlayer player, World world); boolean removeAffinity(@Nonnull ItemStack stack, int index, EntityPlayer player, World world); } ItemAffinityHolder - the item which implements the interface. package com.yolp900.itsjustacharm.common.items; import com.yolp900.itsjustacharm.api.IJCConstants; import com.yolp900.itsjustacharm.api.ItsJustaCharmAPI; import com.yolp900.itsjustacharm.api.affinities.IAffinity; import com.yolp900.itsjustacharm.api.affinities.IAffinityHolderItem; import com.yolp900.itsjustacharm.common.affinities.ModAffinities; import com.yolp900.itsjustacharm.common.items.base.ModItem; import com.yolp900.itsjustacharm.util.NBTHelper; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; public class ItemAffinityHolder extends ModItem implements IAffinityHolderItem { public ItemAffinityHolder() { super(IJCConstants.Items.AffinityHolder); setMaxStackSize(1); } @Override public int getMaxAmountOfStoredAffinities(@Nonnull ItemStack stack, EntityPlayer player, World world) { return ItsJustaCharmAPI.Affinities.affinities.size(); } @Override public int getCurrentAffinityIndex(@Nonnull ItemStack stack, EntityPlayer player, World world) { return NBTHelper.getInt(stack, IJCConstants.NBT.CURRENT_AFFINITY_INDEX); } @Override public void setCurrentAffinityIndex(@Nonnull ItemStack stack, int index, EntityPlayer player, World world) { NBTHelper.setInt(stack, IJCConstants.NBT.CURRENT_AFFINITY_INDEX, index); } @Override public List<IAffinity> getStoredAffinities(@Nonnull ItemStack stack, EntityPlayer player, World world) { List<IAffinity> storedAffinities = new ArrayList<IAffinity>(getMaxAmountOfStoredAffinities(stack, player, world)); for (int i = 0; i < getMaxAmountOfStoredAffinities(stack, player, world); i++) { IAffinity currAffinity = getStoredAffinity(stack, i, player, world); if (currAffinity != null) { storedAffinities.add(currAffinity); } } return storedAffinities; } @Override public IAffinity getStoredAffinity(@Nonnull ItemStack stack, int index, EntityPlayer player, World world) { int maxAmount = getMaxAmountOfStoredAffinities(stack, player, world); if (index < 0 || index >= maxAmount) { return null; } String affinityName = NBTHelper.getString(stack, IJCConstants.NBT.STORED_AFFINITY(index)); if (affinityName == null || affinityName.equals("")) { return null; } return ItsJustaCharmAPI.Affinities.getAffinityFromName(affinityName); } @Override public boolean storeAffinity(@Nonnull ItemStack stack, @Nonnull IAffinity affinity, EntityPlayer player, World world) { List<IAffinity> storedAffinities = getStoredAffinities(stack, player, world); if (storedAffinities == null || storedAffinities.size() == 0) { NBTHelper.setString(stack, IJCConstants.NBT.STORED_AFFINITY(0), affinity.getName()); } if (storedAffinities != null) { for (IAffinity storedAffinity : storedAffinities) { if (storedAffinity != null && storedAffinity == affinity) { return false; } } for (int i = 0; i < storedAffinities.size(); i++) { if (storedAffinities.get(i) == null) { storeAffinity(stack, affinity, i); return true; } } } return false; } @Override public boolean removeAffinity(@Nonnull ItemStack stack, int index, EntityPlayer player, World world) { removeAffinity(stack, index); return true; } private void storeAffinity(@Nonnull ItemStack stack, @Nonnull IAffinity affinity, int index) { NBTHelper.setString(stack, IJCConstants.NBT.STORED_AFFINITY(index), affinity.getName()); } private void removeAffinity(@Nonnull ItemStack stack, int index) { NBTHelper.setString(stack, IJCConstants.NBT.STORED_AFFINITY(index), ""); } @Override @Nonnull public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (stack == null || !(stack.getItem() instanceof ItemAffinityHolder)) return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ); IAffinityHolderItem affinityHolder = (IAffinityHolderItem)stack.getItem(); affinityHolder.setCurrentAffinityIndex(stack, 0, player, world); Block block = world.getBlockState(pos).getBlock(); if (block == Blocks.GRASS) { affinityHolder.storeAffinity(stack, ModAffinities.Earth, player, world); } else if (block == Blocks.STONE) { affinityHolder.storeAffinity(stack, ModAffinities.Block, player, world); } else if (block == Blocks.NETHERRACK) { affinityHolder.storeAffinity(stack, ModAffinities.Fire, player, world); } else if (block == Blocks.ICE) { affinityHolder.storeAffinity(stack, ModAffinities.Water, player, world); } else if (block == Blocks.REEDS) { affinityHolder.storeAffinity(stack, ModAffinities.Air, player, world); } return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ); } } I really don't think it's the methods themselves which are the problems. I think the api is not packaged with the rest of the mod. I might be wrong. I don't know... -
[1.10.2][SOLVED] My own mod API crashes outside of workspace
yolp900 replied to yolp900's topic in Modder Support
I wish it were that easy. I tried building with "gradlew build" and got the same crash. Would it help if I post the classes which are not found? -
I am trying to test my mod outside of IntelliJ Idea. I built my mod using the Gradle task built into IntelliJ and placed the jar file I got (not the source jar) in the "mods" folder. When I load up Minecraft, I end up with this crash: ItemAffinityHolder implements the interface IAffinityHolderItem which is in my mod's api. From what I understand, the api class I use isn't found. I thought it is packaged with the mod, as it is a part of it and it is in "src.main.java.com.yolp900.itsjustacharm.api" folder inside of the source folders, but I must be wrong. How can I fix this crash and run my mod outside of the workspace? Thanks in advance!
-
First of all: I know I18n is client side only. I'm using I18n to localize the config entries' names in my mod, and it crashes when I open a server since it cannot find I18n. Is there any way to localize a text so it'll be available in the server side? How would one use localized names in the config file without using I18n? Hope someone has an answer
-
[1.9.4] GuiHandler not getting correct TileEntity
yolp900 replied to yolp900's topic in Modder Support
Wow, that actually worked on the first time! Thanks a lot! I still have a few things I need to learn about client-server handling - what happens automatically and what doesn't (for example: this ) Thanks! -
When I open my gui (using player.openGui() which calls the GuiHandler, that part works) I am trying to get the Tile Entity of the block that I'm aiming at. The GuiHandler recognizes that the Tile entity is an instance of my custom tile entity, however when I try to get data that's stored on the tile, I always get the default values of the tile, even if they're changed. My code: The GuiHandler @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if (player != null) { if (ID == Reference.Guis.ElevatorLarge.getID() && tile instanceof TileEntityElevator) { TileEntityElevator elevator = (TileEntityElevator) tile; logger.log(tile.getYUp()) //This line always gives 0, even if there is a value stored in the TileEntityElevator. return new GuiElevator(world, new BlockPos(x, y, z)); } } return null; } I hope this is enough information to find the problem... Thanks in advance!
-
[1.9.4] [Solved] I18n "Format error:" even on client side
yolp900 replied to yolp900's topic in Modder Support
I'm localizing the coords because I'm putting it in a gui with text and I want the gui to be fully modifiable to other languages, so even if the coords stay the same, there are other places using coordinates and they do have text that is interchangable between languages, so I just want to make it fully modifiable. Thanks for the Integer tip, I actually didn't know that... -
[1.9.4] [Solved] I18n "Format error:" even on client side
yolp900 replied to yolp900's topic in Modder Support
I just replaced the placeholder % with wrapping the word with * and it works... I might look into doing one of the offers to fix the general problem if it appears again, but for now it works. Thanks a lot! -
I'm trying to add localized texts to a gui. I'm using I18n.format(String string, Object... params) in order to localize the texts. When I do any alternations to the texts (like replacing regular expressions with actual strings or splitting lines using string.split(regEx)), the texts have a prefix "Format error: " on them. My gui drawScreen code: @Override public void drawScreen(int par1, int par2, float par3) { GlStateManager.color(1F, 1F, 1F, 1F); mc.renderEngine.bindTexture(texture); drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight); if (world.isRemote) { String xPos = I18n.format("guiText.ijc:xPos").replace("%xPos", "" + pos.getX()); String yPos = I18n.format("guiText.ijc:yPos").replace("%yPos", "" + pos.getY()); String zPos = I18n.format("guiText.ijc:zPos").replace("%zPos", "" + pos.getZ()); fontRendererObj.drawString(xPos, left + 16, top + 32, 4210752); fontRendererObj.drawString(yPos, left + 16, top + 48, 4210752); fontRendererObj.drawString(zPos, left + 16, top + 64, 4210752); } } My en_US.lang file: guiText.ijc:xPos=x: %xPos guiText.ijc:yPos=y: %yPos guiText.ijc:zPos=z: %zPos A visual example of the problem: http://pasteboard.co/27h0Krag.png - The "Format error: " at the beginning of each line that I translate... I hope I'm not doing something silly...
-
PlayerInteractEvent.RightClickItem says in the forge file: /** * This event is fired on both sides before the player triggers {@link net.minecraft.item.Item#onItemRightClick}. * Note that this is NOT fired if the player is targeting a block. For that case, see {@link RightClickBlock}. **/ However, when I use that event to open a gui and PlayerInteractEvent.RightClickBlock, it gets called and the gui opens even if i am looking at a block. Anybody now why this is or how to fix it?
-
[1.9.4] [Solved] Custom Crafting Table Rendering Crash
yolp900 replied to yolp900's topic in Modder Support
You were correct, thank you! I was registering my blocks and crafting recipes both in preInit. Once I moved the recipes to init, that problem was fixed... I still have a few other minor fixes to do to this constructionTable, but this problem was solved. Thanks again! -
Hey all, I'm trying to make my custom crafting table with specific recipes, and I've come into this crash that I cannot understand.. The crash report: net.minecraft.util.ReportedException: Rendering screen at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1175) ~[EntityRenderer.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1140) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:404) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:?] Caused by: java.lang.NullPointerException: Rendering screen at net.minecraft.client.renderer.RenderItem.renderItemOverlayIntoGUI(RenderItem.java:429) at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:299) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:114) at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:355) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1148) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1140) at net.minecraft.client.Minecraft.run(Minecraft.java:404) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) I can see that the exception is reported in Minecraft's code, and that it is a NullPointerException, but I can't understand how to fix it... My code (I hope it'll have a use in finding the solution) TileEntityConstructionTable (The "checkRecipes" method is called whenever an Item is placed or removed in the gui) private ItemStack[] slots = new ItemStack[18]; public void checkRecipes() { ItemStack[] gridInputs = getGridInputs(); ItemStack[] secInputs = getSecInputs(); CraftingHandlerConstructionTable.RecipeType recipeType = CraftingHandlerConstructionTable.getCurrentRecipeType(gridInputs, secInputs, worldObj); ItemStack output = null; if (recipeType != CraftingHandlerConstructionTable.RecipeType.None) { if (recipeType == CraftingHandlerConstructionTable.RecipeType.Vanilla && CraftingHandlerConstructionTable.getVanillaRecipeOutput(gridInputs, worldObj) != null) { output = CraftingHandlerConstructionTable.getVanillaRecipeOutput(gridInputs, worldObj); } else if (recipeType == CraftingHandlerConstructionTable.RecipeType.CTShaped && CraftingHandlerConstructionTable.getConstructionTableShapedRecipeOutput(gridInputs, secInputs) != null) { output = CraftingHandlerConstructionTable.getConstructionTableShapedRecipeOutput(gridInputs, secInputs); } } this.slots[0] = output; } CraftingHandlerConstructionTable public static ItemStack getVanillaRecipeOutput(ItemStack[] gridInputs, World world) { InventoryCrafting ic = new InventoryCrafting(new ContainerDummy(), 3, 3); for (int i = 0; i < 9; i++) { ic.setInventorySlotContents(i, gridInputs[i]); } return CraftingManager.getInstance().findMatchingRecipe(ic, world); } public static ItemStack getConstructionTableShapedRecipeOutput(ItemStack[] gridInputs, ItemStack[] secInputs) { ItemStack output = null; int numOfItemStacks = 0; for (ItemStack secInput : secInputs) { if (secInput != null) { numOfItemStacks++; } } ItemStack[] secNoNulls = new ItemStack[numOfItemStacks]; int index = 0; for (ItemStack secInput : secInputs) { if (secInput != null) { secNoNulls[index] = secInput; index++; } } for (RecipeBaseConstructionTable recipe : IJCAPI.constructionTableRecipes) { if (recipe instanceof RecipeShapedConstructionTable) { if (recipe.matches(gridInputs, secNoNulls)) { output = recipe.getOutput(); } } } return output; } public static RecipeType getCurrentRecipeType(ItemStack[] gridInputs, ItemStack[] secInputs, World world) { RecipeType currentType = RecipeType.None; if (getVanillaRecipeOutput(gridInputs, world) != null) currentType = RecipeType.Vanilla; if (getConstructionTableShapedRecipeOutput(gridInputs, secInputs) != null) currentType = RecipeType.CTShaped; return currentType; } public enum RecipeType { None, Vanilla, CTShaped, CTShapeless, CTPrecise } I hope this is enough. I can also post the actual methods of matching the recipes (those work, and I don't think they are the problem..)
-
When You right click the vanilla Workbench output slot it crafts until it runs out of items and then stops. Is there a function that you can use to detect when the player is right clicking the output slot (or any slot, in general) or is it a custom GUI event? I couldn't find anything in the Minecraft source code... Thanks in advance!
-
[1.7.10]Spawning particles in packets or proxies?
yolp900 replied to yolp900's topic in Modder Support
Thank you!! That fixed it! I don't even know what went through my mind when I had put return there... My bad! I think I'll lock the issue, since it is a simple java mistake and not an important method or a big problem that a lot are going to encounter. Thanks again! -
While I was coding a particle packet (From the server to the client) I tried to use the packet and my proxies to spawn particles. The packet called a function in the Mod.proxy (Which will lead it to the client proxy since it's on the client side, I figured) which used "Minecraft.getMinecraft().effectRenderer.addEffect(entityEffect)" to spawn a particle. that didn't work. I'm going to sound like a lost man, but I just can't understand: why can't you spawn particles inside packets or in the client proxy? It might not be the problem at all, but I can't see why it wouldn't work otherwise... My code: http://pastebin.com/DY2fr1ME Note: the particle did show up when I used it in the "randomDisplayTick" so I don't think it's a problem in the particle's class.
-
[SOLVED] Particle Rendering - not facing the player
yolp900 replied to yolp900's topic in Modder Support
So my friend and I figured this out, we changed the UV code itself since we couldn't find any documentation of a simpler way. float f6 = 0; float f7 = 1; float f8 = 0; float f9 = 1; float f10 = 0.1F * this.particleScale; if (this.particleIcon != null) { f6 = this.particleIcon.getMinU(); f7 = this.particleIcon.getMaxU(); f8 = this.particleIcon.getMinV(); f9 = this.particleIcon.getMaxV(); } float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)particleTicks - interpPosX); float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)particleTicks - interpPosY); float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)particleTicks - interpPosZ); tess.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); tess.addVertexWithUV((double) (f11 - par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 - par5 * f10 - par7 * f10), (double) f7, (double) f9); tess.addVertexWithUV((double) (f11 - par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 - par5 * f10 + par7 * f10), (double) f7, (double) f8); tess.addVertexWithUV((double) (f11 + par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 + par5 * f10 + par7 * f10), (double) f6, (double) f8); tess.addVertexWithUV((double) (f11 + par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 + par5 * f10 - par7 * f10), (double) f6, (double) f9); tess.draw(); Hope this code helps anyone who gets this problem in the future... -
[SOLVED] Particle Rendering - not facing the player
yolp900 replied to yolp900's topic in Modder Support
Is there a demonstration in vanilla or forge code for rotating the quads? I've tried to implement my own way to move the tesselator and it just stays on its axis... I don't think I'm the only one who got this problem, am I? -
[SOLVED] Particle Rendering - not facing the player
yolp900 replied to yolp900's topic in Modder Support
Thank you! I didn't think it has to do with rotating the quads since I thought that all particles do it automaticly... My bad... Thanks again! I'll definitely look at your code, it seems very useful! (I'm new to minecraft modding, and sort-of new to java, so every help I get means a lot ) -
While creating a mod I've tried to create a costum particle effect. The particle currently is just a texture that has movement and lifespan. The problem I've came up to is: I one is looking at the particle from the North/South (z axis) then it renders correctly. If one looks at the particle from the West/East (x axis) you can barely see anything. as if it's rendering only to the z axis. Vanilla particles don't do that, as they face the player at all times. A visual representation of the problem: North/South: http://pasteboard.co/1L2QwVO.png - You can see the "Pie" Fine... West/East: http://pasteboard.co/1L6DRE9.png - You can barely see anything, since this is not perfectly West/East view. Something in between: http://pasteboard.co/1L3VPES.png - You can clearly see that the particle is flat and only renders on one axis. Is there any way of rendering the particle on more than one axis? Here's my code: http://pastebin.com/p2CYGMKH Thank you in advance! yolp900