Everything posted by Draco18s
- Lasers? Lasers.
-
[1.7.10] Including a jar inside of my mod
Ha, love the url. Don't think I've noticed that before.
-
[1.8] Plantdrops
If you have your own custom crop block, you do not need events. Events is how you affect other mod's blocks (and in some cases, vanilla blocks). If you have your own block all you have to do is override the function getDrops* and not call super() and then only add the items you want to add. *Double check which function creates the seed stacks in BlockCrops, that's the one you want.
-
[1.8] custom tool effectiveness
Where do you have this code? What's the context? What you're doing is entirely possible, but you can't just insert random code into random places and expect it to make sense.
-
[1.7.10] Hand held item that emit light
You could make a block that has Material.Water and renders like water for when the player is under water. For things like tall grass and reeds you can check the block just above the player (to see if it is air) and place there instead of directly where the player's head is. Also, it's a good idea to not update the light's position very often. In the mod I have that does this I only move the light source if the player is about 5 or more blocks away from the current light source (and store the coordinates of said lightsource in the item). That way the engine isn't getting hit with lighting updates every tick. As you're underwater you'll have to experiment with how much distance you'll allow between the player's current position and the lightsource's, but it'll likely be 2 blocks.
-
[1.7.10] How to know if a block was placed by the player or by the generator?
There's also onBlockPlacedByPlayer(...)
-
Lasers? Lasers.
If its already tessellating, then drop the "start" and "end" bits. Magic.
-
[1.7.10] Get item and color from tool material...
Note: Some tool materials don't have a repair stack specified for a reason. I know that in my artifacts mod my armor items have a tool material that is used for the initiation of the item class, but it's not actually used in any meaningful way because 1) the durability data (etc) is all handled by nbt, including effective material 2) the repair item is based off that nbt data as well. Iron items are repaired using a special item crafted with an iron ingot to make the item actually used by the anvil. Other mods might do other things, such as materials that CANNOT be repaired.
-
NBT request, and saving/ loading private data
Just as a pre-emptive warning: These events do not fire in a consistent* way and these events are asynchronous, meaning that any data structures you use to track data will need to be thread-safe or you'll get concurrent modification errors. *By which I mean "use this for X and that for Y." There are two Save events fired when a chunk unloads, called from different points in the code. One of those points is after a chunk has been marked as unloaded and will see the chunk removed from memory. The other is simply a write-to-disk pass and the chunk may or may not be on its way to being unloaded. The best way I've found to handle clearing data from ram for when a chunk unloads is to use the Save event and check if(!chunk.isLoaded) Likewise, the Unload event doesn't give you access to the chunk NBT to save anything.
-
New Crash
You're in the wrong forum. This board is for people who make mods.
-
[1.8]Crafting Table Checking
Again, this is because that's not how the vanilla crafting table works. The vanilla crafting table assumes stack sizes of 1, so when the SIZE of the stack changes it doesn't bother updating matches(), because vanilla does not care about stack size.
-
changing texture based on tileentity time of day
Noted. I wrote that code months ago and whatever reference I had did it that way and I never tried using the registerIcons method for it. Sigh. That check handles a portion of the code. In my case it makes it select an odd numbered item out of a list, rather than an even one. Learn 2 Java
-
changing texture based on tileentity time of day
Ah, I have inadvertently mislead you. The object passed to that getIcon method, the IBlockAccess is not a World at all, but a ChunkCache. While a ChunkCache object has a World property, it is private. Instead, you will need to do something a little more clever. You will need to make a TextureAtlas class. There's a second reason too. The icon won't update just because it went from "night" to "day." You'd also have to tell the game to re-render the blocks. Fortunately a TextureAtlas can solve both of these problems. Here is a TextureAtlas I use. It does something very similar, but with a different time scale. It is up to you to rewrite this class for your needs. It's a simple class, really. package com.draco18s.wildlife.client; import com.draco18s.wildlife.WildlifeEventHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureUtil; @SideOnly(Side.CLIENT) public class TextureCalendar extends TextureAtlasSprite { public TextureCalendar(String par1Str) { super(par1Str); } public void updateAnimation() { if (!this.framesTextureData.isEmpty()) { Minecraft minecraft = Minecraft.getMinecraft(); int i = frameCounter; if (minecraft.theWorld != null && minecraft.thePlayer != null) { i = (int) ((minecraft.theWorld.getWorldTime() % WildlifeEventHandler.yearLength)/(WildlifeEventHandler.yearLength/4)); i*=2; if(minecraft.theWorld.provider.isHellWorld) { //Hell does not have day or night, you will want to do something else here. //Look at the TextureClock class in vanilla i++; } } if (i != this.frameCounter) { this.frameCounter = i; TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); } } } } You will also need to register an event handler: public class ClientEventHandler { @SubscribeEvent @SideOnly(Side.CLIENT) public void registerTextures(TextureStitchEvent.Pre event) { if(event.map.getTextureType() == 1 ) { //change these to point to your own variables and texture strings. The two strings should be identical. event.map.setTextureEntry("wildlife:season_calendar", ClientProxy.calendar = new TextureCalendar("wildlife:season_calendar")); } } } Finally, your getIcon and registerIcon methods: @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister iconReg) { itemIcon = ClientProxy.calendar; } @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int par1) { return ClientProxy.calendar; }
-
[1.7.10] Special caracter don't work in minecraft
Save your lang file as UTF-8, not ascii.
-
changing texture based on tileentity time of day
And what happened?
-
Check if block is next to another block with power
You put it where it needs to go. The question you need to ask yourself is: When do I want to do this?
-
[1.8]Disable shading on blocks
GL11.glDisable(GL11.GL_LIGHTING); inside your block class is going to do jack shit other than crash a dedicated server. To do what you want, you need to create a custom renderer class for your block.
-
Minecraft Load Custom Mod: Error.setTextureName(Ljava/lang/String;)
"Slowly and painfully" There might be a tool out there that will do it automatically, but you can do a find-replace-all in files and manually translate SRG names to MCP by looking them up in the mappings. Those are stored at: ~\.gradle\caches\minecraft\net\minecraftforge\forge\1.7.10-10.13.2.1291\unpacked\conf Where ~ is your user directory. In that folder will be two csv files: fields.csv and methods.csv
-
[1.8]Problems with HashMap[SOLVED]
Not really. Block and Item ID limits are still the same as ever. They are? Ok. One of those "it's 5am, I can't sleep, and digging around in the code requires moving and effort."
-
changing texture based on tileentity time of day
getWorldTime() returns the total amount of time since the world's creation. There's a comment buried deep on the long that is returned which says that it is clamped 0-23999, but that's wrong. If you do a project-wide search for where that value is set and modified, you will find no such modulation.
-
Lasers? Lasers.
tess.addVertex(...); The tessellator (and thereby GL) is in quad drawing mode. So it expects a multiple of four vertices arranged clockwise around the surface normal. I chose quads because while there is a line mode (two verts) you don't have control over the thickness of that line. It would be 1 pixel thick, always.
-
[1.8] Check if player is looking at the moon, whilst holding an item
Its centered on the player. It's only a fake dome. You can see this when flying up, or rather, being blasted by TNT or teleporting into the sky thousands or even millions of blocks.
-
[1.8]Problems with HashMap[SOLVED]
"All that stuff" is an in-line Hash(int) function. The point of it is to effectively generate a pseudorandom number with your data as the seed. It works better than id + meta*500 because the ID can be larger than 500. ID=500, meta=0 will have the same "hash" as ID=0,meta=1. This makes your hash range very limited. You should go back to what you had before. Your new Equals() method looks fine, though. Note: A.equals(B) => a.hashCode() == b.hashCode() a.hashCode() == b.hashCode() =/> A.equals(B) Hint: ItemIds can get very very large, very very quickly. 1.6 had a block array that stored up to 4096 block IDs, each of which had an item ID that matched. 1.7 is effectively unlimited.
-
Lasers? Lasers.
If it looks like solid beams, then it is most likely done using direct GL calls. Which aren't that difficult, really. Its just a matter of knowing the two end points and drawing a line. You'll have to escuse this lump of code, its stolen from my own purposes and some of it is useless to you. I trimmed what I know is, but there are likely lingering references. I call this function from a DrawBlockHighlightEvent event, but I am specifically interested in the block the player is looking at. //draw a line between two blocks private void drawLine(Vec3 blockA, Vec3 blockB) { Tessellator tess = Tessellator.instance; tess.startDrawing(7);//quads tess.setBrightness(15728880); tess.setColorOpaque_F(1F, 0F, 0F);//red Vec3 recLong = blockA.subtract(blockB); Vec3 perpendicular = Vec3.createVectorHelper(recLong.zCoord, recLong.yCoord, -recLong.xCoord); perpendicular = perpendicular.normalize(); float Width = 1f/16f; Vec3 R1 = blockA.subtract(blockB); Vec3 R2 = blockA.subtract(blockB); Vec3 R3 = blockA.subtract(blockB); Vec3 R4 = blockA.subtract(blockB); R1.xCoord = blockA.xCoord + perpendicular.xCoord * Width; R1.zCoord = blockA.zCoord + perpendicular.zCoord * Width; R2.xCoord = blockA.xCoord - perpendicular.xCoord * Width; R2.zCoord = blockA.zCoord - perpendicular.zCoord * Width; R1.yCoord = blockA.yCoord - 0.01; R2.yCoord = blockA.yCoord - 0.01; R3.xCoord = blockB.xCoord + perpendicular.xCoord * Width; R3.zCoord = blockB.zCoord + perpendicular.zCoord * Width; R4.xCoord = blockB.xCoord - perpendicular.xCoord * Width; R4.zCoord = blockB.zCoord - perpendicular.zCoord * Width; R3.yCoord = blockB.yCoord + 0.75; R4.yCoord = blockB.yCoord + 0.75; tess.addVertex(R1.xCoord + 0.5, R1.yCoord, R1.zCoord + 0.5); tess.addVertex(R3.xCoord + 0.5, R3.yCoord, R3.zCoord + 0.5); tess.addVertex(R4.xCoord + 0.5, R4.yCoord, R4.zCoord + 0.5); tess.addVertex(R2.xCoord + 0.5, R2.yCoord, R2.zCoord + 0.5); tess.draw(); }
-
changing texture based on tileentity time of day
Idiot.* 1) Use the method that has a world passed to it. You should never use Minecraft.getMinecraft(). It happens to be safe here do to the SideOnly annotation, but it is still a bad idea. public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) 2) "it returns false" makes no sense for a method that returns IIcon. You meant that isDaytime is returning false. You never once mentioned using this method. 3) world.getTotalWorldTime() I would have to look, but isDaytime might not be useful client side. I so know that total world time will work though, as it (or at least the variable that method returns) is used by getMoonPhase, which is a client side method. *sorry, I'm a bit grumpier than usual. I can't sleep and it's 5am. You posted half intelligible gibberish, played the pronoun game, and forced me to ask for clarification rather than posing what you meant (with code!) the first time.
IPS spam blocked by CleanTalk.