Hello. For my mod, I want to make it so that when you wear a certain armor, you light up the area around you, and when you move, the light follows. Thanks.
I've also been trying to get this to work. I tried sort of a hackish version by spawning a tiny light-emitting block at the player's postion+motion that destroys itself after a few ticks. Not very elegant, I know, but it's a workaround until the Minecraft team implements lanterns (maybe 'if' is a better word).
If you do tackle the dynamic lighting thing and get it working, please share
I've also been trying to get this to work. I tried sort of a hackish version by spawning a tiny light-emitting block at the player's postion+motion that destroys itself after a few ticks. Not very elegant, I know, but it's a workaround until the Minecraft team implements lanterns (maybe 'if' is a better word).
If you do tackle the dynamic lighting thing and get it working, please share
public BlockMagicLight(int par1)
{
super(par1, Material.air);
this.setLightValue(1.0F);
this.setBlockBounds(0.45F, 0.45F, 0.45F, 0.55F, 0.55F, 0.55F);
this.setResistance(5000.0F);
this.setBlockUnbreakable();
this.blockParticleGravity = 0.0F;
}
// can't interact with this block or place other blocks on it
@Override
public boolean isCollidable()
{
return false;
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
/**
* Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
@Override
public boolean isOpaqueCube()
{
return false;
}
/** Returns the quantity of items to drop on block destruction. */
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
/** Return whether this block can drop from an explosion. */
@Override
public boolean canDropFromExplosion(Explosion par1Explosion)
{
return false;
}
/** Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z */
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
int currentID = world.getBlockId(x, y, z);
return (world.isAirBlock(x, y, z));
}
}
Oh, this is for a permanent light block... I've got a ticking version that extends this, but this one shows how to set it so you can walk through your block, which is what you were asking about, right?
I've also been trying to get this to work. I tried sort of a hackish version by spawning a tiny light-emitting block at the player's postion+motion that destroys itself after a few ticks. Not very elegant, I know, but it's a workaround until the Minecraft team implements lanterns (maybe 'if' is a better word).
If you do tackle the dynamic lighting thing and get it working, please share
This is the solution to the problem though.
Any other solution req. massive amount of work.
Which I know you don't have time for Repxile, so this would be the solution to go for.
In anycase here's some reading material for you to read, and this you shouldn't throw into the ignore pile as you do with the other things we ask you to study http://greyminecraft...8/lighting.html
@CoolAlias:
The only "simple" way I could see of doing it otherwise would be to brute force into the lightmappings of the players surroundings and change their values temporarily. The other way I see is a complete rewrite of the light and render systems in a bigger scale than Optifine does! Which would take ages to do, if possible at all given all the other code
But I'm going to look into the brightness level and see if I could manipulate the values sent to the lightmap in some easy way but I assume ASM would be the only way to do it :S
I looked and could not find the method which would let me destroy the block from inside it's own tick function. The one function I found that might have worked required me to pass it the world, which I currently have no method of doing from that class. My solution was to use the onArmorTickUpdate to do everything for me. This seems to work much better due to immediate access to world functions and better control of when the light disappears.
The issue I now face is that the very first light block that gets placed down never gets removed. The code follows.
How about instead of making a light source, just have it give the player Night Vision?
Rollback Post to RevisionRollBack
Eons ago, there was only void. Then came the big bang. Voxels colliding with voxels, cubes with cubes. Blocks were forming, each texture unique from the rest. That was when our universe was born.
It is! Instead of creating an invisible block every tick, having it emit light, and die, only to be repeated, you can just have it give the player the effect. I had made code for something like that, but it was for 1.4, and now I can't remember where I put it. I'll make an example and have it up soon!
Eons ago, there was only void. Then came the big bang. Voxels colliding with voxels, cubes with cubes. Blocks were forming, each texture unique from the rest. That was when our universe was born.
Night vision is simpler, but not quite the same effect.
To destroy the block, in the block's updateTick method, check if the metadata == 0 and if so, world.setBlockToAir(x, y, z). World and coordinates are passed in to the method, metadata you get from world.getBlockMetadata(x, y, z).
The interesting part of this is the bug which they probably can't fix:
Notes
If you fly with lantern equipped the light will not update as fast as you travel, resulting in occasional spots of light in your trail. These will disappear if you walk over them or you load your world again. They won't cause any trouble.
This leads me to believe that they are doing something along the lines of what's been mentioned earlier
It is! Instead of creating an invisible block every tick, having it emit light, and die, only to be repeated, you can just have it give the player the effect. I had made code for something like that, but it was for 1.4, and now I can't remember where I put it. I'll make an example and have it up soon!
Have that every tick, and you, my friend, have night vision while your armor is on
Actually, somehow I did not remember there being a nightvision potion in Minecraft. After checking it's effect, this is exactly what I am looking for! Thanks!
Night vision is simpler, but not quite the same effect.
To destroy the block, in the block's updateTick method, check if the metadata == 0 and if so, world.setBlockToAir(x, y, z). World and coordinates are passed in to the method, metadata you get from world.getBlockMetadata(x, y, z).
I used metadata to store its lifespan.
I'm not seeing any way to pass the coords into the method. I can pass the world through my main class file, but because the coords change quicker than the block destroys itself, the wouldn't be correct when the block actually tried to destroy itself. The block itself has a minX maxX type of system you can get coords from, but they don't seem to work for destroying the block...
I'm going to go with the nightvision, but for future reference, I'd REALLY like to know why this code here only destroys the second and later blocks, but leaves the first one placed.
If you do tackle the dynamic lighting thing and get it working, please share
I'm going to try the light emitting block trick. Did you have to mark the block as Material.portal so it was walkable?
I might try that if I can't get this to work DrunkMafia, but it sounds like a lot more hassle.
This is the solution to the problem though.
Any other solution req. massive amount of work.
Which I know you don't have time for Repxile, so this would be the solution to go for.
In anycase here's some reading material for you to read, and this you shouldn't throw into the ignore pile as you do with the other things we ask you to study http://greyminecraft...8/lighting.html
@CoolAlias:
The only "simple" way I could see of doing it otherwise would be to brute force into the lightmappings of the players surroundings and change their values temporarily. The other way I see is a complete rewrite of the light and render systems in a bigger scale than Optifine does! Which would take ages to do, if possible at all given all the other code
But I'm going to look into the brightness level and see if I could manipulate the values sent to the lightmap in some easy way but I assume ASM would be the only way to do it :S
The issue I now face is that the very first light block that gets placed down never gets removed. The code follows.
EDIT 2: Maybe I'm just not on top of it today, but I cannot figure out how to get my block to destroy itself after a set amount of time.
It is! Instead of creating an invisible block every tick, having it emit light, and die, only to be repeated, you can just have it give the player the effect. I had made code for something like that, but it was for 1.4, and now I can't remember where I put it. I'll make an example and have it up soon!
See look:
Have that every tick, and you, my friend, have night vision while your armor is on
To destroy the block, in the block's updateTick method, check if the metadata == 0 and if so, world.setBlockToAir(x, y, z). World and coordinates are passed in to the method, metadata you get from world.getBlockMetadata(x, y, z).
I used metadata to store its lifespan.
The interesting part of this is the bug which they probably can't fix:
This leads me to believe that they are doing something along the lines of what's been mentioned earlier
Actually, somehow I did not remember there being a nightvision potion in Minecraft. After checking it's effect, this is exactly what I am looking for! Thanks!
I'm not seeing any way to pass the coords into the method. I can pass the world through my main class file, but because the coords change quicker than the block destroys itself, the wouldn't be correct when the block actually tried to destroy itself. The block itself has a minX maxX type of system you can get coords from, but they don't seem to work for destroying the block...
I'm going to go with the nightvision, but for future reference, I'd REALLY like to know why this code here only destroys the second and later blocks, but leaves the first one placed.