Hellow. I am making a mod, but there are some things I can't do, and I looked them in some tuts or this Forum, but I can't find them.
So here are them:
-How to make an entity NOT to be a White Cube (I got the map.put(EntityShard.class, new RenderShard()); in the mod_ so if you want the code here it is:)
Render Shard:
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class RenderShard extends Render
{
public RenderShard()
{
}
public void renderShard(EntityShard par1EntityShard, double par2, double par4, double par6, float par8, float par9)
{
loadTexture("/Items/....png");
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef((par1EntityShard.prevRotationYaw + (par1EntityShard.rotationYaw - par1EntityShard.prevRotationYaw) * par9) - 90F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(par1EntityShard.prevRotationPitch + (par1EntityShard.rotationPitch - par1EntityShard.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
Tessellator tessellator = Tessellator.instance;
int i = 0;
float f = 0.0F;
float f1 = 0.5F;
float f2 = (float)(0 + i * 10) / 32F;
float f3 = (float)(5 + i * 10) / 32F;
float f4 = 0.0F;
float f5 = 0.15625F;
float f6 = (float)(5 + i * 10) / 32F;
float f7 = (float)(10 + i * 10) / 32F;
float f8 = 0.05625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
float f9 = (float)par1EntityShard.arrowShake - par9;
if (f9 > 0.0F)
{
float f10 = -MathHelper.sin(f9 * 3F) * f9;
GL11.glRotatef(f10, 0.0F, 0.0F, 1.0F);
}
GL11.glRotatef(45F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(f8, f8, f8);
GL11.glTranslatef(-4F, 0.0F, 0.0F);
GL11.glNormal3f(f8, 0.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-7D, -2D, -2D, f4, f6);
tessellator.addVertexWithUV(-7D, -2D, 2D, f5, f6);
tessellator.addVertexWithUV(-7D, 2D, 2D, f5, f7);
tessellator.addVertexWithUV(-7D, 2D, -2D, f4, f7);
tessellator.draw();
GL11.glNormal3f(-f8, 0.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-7D, 2D, -2D, f4, f6);
tessellator.addVertexWithUV(-7D, 2D, 2D, f5, f6);
tessellator.addVertexWithUV(-7D, -2D, 2D, f5, f7);
tessellator.addVertexWithUV(-7D, -2D, -2D, f4, f7);
tessellator.draw();
for (int j = 0; j < 4; j++)
{
GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 0.0F, f8);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-8D, -2D, 0.0D, f, f2);
tessellator.addVertexWithUV(8D, -2D, 0.0D, f1, f2);
tessellator.addVertexWithUV(8D, 2D, 0.0D, f1, f3);
tessellator.addVertexWithUV(-8D, 2D, 0.0D, f, f3);
tessellator.draw();
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
renderShard((EntityShard)par1Entity, par2, par4, par6, par8, par9);
}
}
-To know how to associate a Model class with a Render class and an Entity class of a thing that is NOT an ANIMAL.
-To know how to make a Modeled entity follow another entity Like the Fire one.
If you can't understand what I'm saying PM me or reply this topic, I'm Argentina and I don't know a lot of english. If you could help me with at least one of this topics I will be very thanked.
Well it seems you are using code from RenderArrow, this should be enough to render the entity without any Model file. You just have to specify a image/texture location, then adjust the displayed dimensions. I imagine you put dots to hide the actual texture name for some reason, if not you need to make a png at this location. You have listed:
loadTexture("/Items/....png");
Use caution when altering the RenderArrow code you copied, as some small adjustments can make the Tesselator no longer render (visibly) the texture for the entity. You will need to change each value a single increment at a time and test the outcome, then reset the value if it is not helpful.
Timers/counters are very simple to make/use. If possible, please specify how you would be using it.
Rollback Post to RevisionRollBack
Instant customizable buildings, to fill your empty world.
First of all: Thanks for replying!
Yes, I hidden the File. The code is very similar to the Arrow one, but if I put map.put(EntityShard.class, new RenderArrow()); it stills doesn't work.
The timer will be used in an Entity file. If the entity hits a Mob, it will be inmobilized for 3 seconds.
Assuming your mod_ file adds the render like this:
// After Importing Map.
import java.util.Map;
.....
// Add a renderer for shard entity.
public void addRenderer(Map map)
{
map.put(EntityShard.class, new RenderShard());
}
White texture means that MC or ML is not properly registering the entity/texture, as white texture is only seen when NO texture is found.
In the case that a texture is found but the render dimensions of the entity are not correct than the texture is invisible. This seems to be a case of missing textures, not bad code. Don't hate me for saying it, but you need to double check everything to do with the texture and texture paths.
Other than that the code looks fine.
As for the timer feature you are talking about, I will test a few things and see how it could be done. Let you know what I figure out.
Seems to be that I forgot to put the import java.util.Map;
But it still don't works, even if I change the texture for the Arrow's one.
And thanks for worrying about the Timer.
By "it still don't work" do you mean it is still rendering a white box, or is the entity invisible now? If it is invisible you have made progress.
I suggest making a second copy of entityarrow and rename as needed, and only make small changes so you can see what is happening when you do. As I stated above, changes that may seem small or insignificant can cause the entity to be invisible, meaning the shape/dimensons of the entity is beyond that of the texture or the shape has been distorted in a way that the texture can no longer be rendered on top of it.
Just make small changes until you are very familiar with what each does, and slowly bring the values back to what you actually want them to be. It is also a good idea to fill/paint the entire texture a solid color so that the texture will be visible even when the shape is wrong. The dimension-to-pixel mapping is not very straight forward, and under some conditions can only be found with many trial and error tests.
The timer should be pretty easy, something like this:
int timer = 0;
boolean mobWasStruck = false;
// In the onUpdate function, trigger a boolean to true when the mobentity is 'hit' by your entity
// then test that boolean later, when it is true you will start the timer and decrease moveSpeed.
if(mobWasStruck && timer == 0 )
{
timer++;
hitEntity.moveSpeed -= 10; // subtract 10 from original speed.
}
if(mobWasStruck && timer == 100) // about 5 seconds
{
mobWasStruck = false;
timer = 0;
hitEntity.moveSpeed += 10; // add 10 back, to return to original speed value.
}
Haven't tested it, so I can't say exactly how you should change 'hitEntity.moveSpeed' but looking through the EntityArrow and EntityMobName classes you will find how to properly call/adjust this 'speed' variable.
By "it still don't work" do you mean it is still rendering a white box, or is the entity invisible now? If it is invisible you have made progress.
I suggest making a second copy of entityarrow and rename as needed, and only make small changes so you can see what is happening when you do. As I stated above, changes that may seem small or insignificant can cause the entity to be invisible, meaning the shape/dimensons of the entity is beyond that of the texture or the shape has been distorted in a way that the texture can no longer be rendered on top of it.
Just make small changes until you are very familiar with what each does, and slowly bring the values back to what you actually want them to be. It is also a good idea to fill/paint the entire texture a solid color so that the texture will be visible even when the shape is wrong. The dimension-to-pixel mapping is not very straight forward, and under some conditions can only be found with many trial and error tests.
The timer should be pretty easy, something like this:
int timer = 0;
boolean mobWasStruck = false;
// In the onUpdate function, trigger a boolean to true when the mobentity is 'hit' by your entity
// then test that boolean later, when it is true you will start the timer and decrease moveSpeed.
if(mobWasStruck && timer == 0 )
{
timer++
hitEntity.moveSpeed -= 10; // subtract 10 from original speed.
}
if(mobWasStruck && timer == 100) // about 5 seconds
{
mobWasStruck = false;
timer = 0;
hitEntity.moveSpeed += 10; // add 10 back, to return to original speed value.
}
Haven't tested it, so I can't say exactly how you should change 'hitEntity.moveSpeed' but looking through the EntityArrow and EntityMobName classes you will find how to properly call/adjust this 'speed' variable.
Sorry for not being especific. It stills shows the white cube. So I will proove that of copying the Entity Arrow and modifying things one by one and carefully. Thanks for that.
Also thanks for the Timer. I had some code before:
//I made that if it hits an entity, it sets 'frozen' in true
if (frozen == true){
ticksFrozen ++;
if(ticksFrozen < 1200){
entity.isInWeb = true;
} else {
ticksFrozen = 0;
entity.isInWeb = false;
frozen = false;
}
}
But it didn't worked right, and I didn't know that 100 updates were like 5 seconds. Thanks.
Bump and EDIT.
Does anyone know how Damage Item inside an Item Class in (onUpdate) method?
If you put par1ItemStack.damageItem(1, par6EntityLiving); you don't have the EntityLiving, and .setItemDamage does not works.
public ExampleItem(int par1)
{
super(par1);
setMaxDamage(100);
}
.......
.......
// onUpdate 'ticks' 20 times a second, this will subtract 1 from 100 until it reaches 0. (20ticks * 5seconds) = 100 (max damage)
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean flag)
{
if(par1ItemStack.getItemDamage() > 0)
{
par1ItemStack.damageItem(1, (EntityLiving)par3Entity);
}
}
Very curious... I'm studying these things of Methods and Instances in C# but I don't know what do you mean with the parameter
(EntityLiving)par3Entity
But it works perfectly. Thanks a lot.
Do you (or someone else) know how to make the inverse? (to 'Heal'/Repair the Item in a determinated value?) I tried with itemstack.damageItem(-Number, (EntityLiving)entity);
but it doesn't work.
So here are them:
-How to make an entity NOT to be a White Cube (I got the map.put(EntityShard.class, new RenderShard()); in the mod_ so if you want the code here it is:)
Render Shard:
-To know how to associate a Model class with a Render class and an Entity class of a thing that is NOT an ANIMAL.
-To know how to make a Modeled entity follow another entity Like the Fire one.
If you can't understand what I'm saying PM me or reply this topic, I'm Argentina and I don't know a lot of english. If you could help me with at least one of this topics I will be very thanked.
Use caution when altering the RenderArrow code you copied, as some small adjustments can make the Tesselator no longer render (visibly) the texture for the entity. You will need to change each value a single increment at a time and test the outcome, then reset the value if it is not helpful.
Timers/counters are very simple to make/use. If possible, please specify how you would be using it.
Yes, I hidden the File. The code is very similar to the Arrow one, but if I put map.put(EntityShard.class, new RenderArrow()); it stills doesn't work.
The timer will be used in an Entity file. If the entity hits a Mob, it will be inmobilized for 3 seconds.
White texture means that MC or ML is not properly registering the entity/texture, as white texture is only seen when NO texture is found.
In the case that a texture is found but the render dimensions of the entity are not correct than the texture is invisible. This seems to be a case of missing textures, not bad code. Don't hate me for saying it, but you need to double check everything to do with the texture and texture paths.
Other than that the code looks fine.
As for the timer feature you are talking about, I will test a few things and see how it could be done. Let you know what I figure out.
import java.util.Map;
But it still don't works, even if I change the texture for the Arrow's one.
And thanks for worrying about the Timer.
Art by me: MrPancakeWolfie@DeviantArt
map.put(EntityShard.class, new RenderArrow(1.0F));
So what can I do to make my topics be responded? Should I wait a lot and make a new one?
The RenderArrow does not take any parameters.
Thanks for replying anyway
By "it still don't work" do you mean it is still rendering a white box, or is the entity invisible now? If it is invisible you have made progress.
I suggest making a second copy of entityarrow and rename as needed, and only make small changes so you can see what is happening when you do. As I stated above, changes that may seem small or insignificant can cause the entity to be invisible, meaning the shape/dimensons of the entity is beyond that of the texture or the shape has been distorted in a way that the texture can no longer be rendered on top of it.
Just make small changes until you are very familiar with what each does, and slowly bring the values back to what you actually want them to be. It is also a good idea to fill/paint the entire texture a solid color so that the texture will be visible even when the shape is wrong. The dimension-to-pixel mapping is not very straight forward, and under some conditions can only be found with many trial and error tests.
The timer should be pretty easy, something like this:
Haven't tested it, so I can't say exactly how you should change 'hitEntity.moveSpeed' but looking through the EntityArrow and EntityMobName classes you will find how to properly call/adjust this 'speed' variable.
Already done that. It didn't worked. I even copied a full Gui file to see if it renders the Buttons and it crashes.
Also thanks for the Timer. I had some code before:
But it didn't worked right, and I didn't know that 100 updates were like 5 seconds. Thanks.
Does anyone know how Damage Item inside an Item Class in (onUpdate) method?
If you put par1ItemStack.damageItem(1, par6EntityLiving); you don't have the EntityLiving, and .setItemDamage does not works.
*Fixed the GuiButtons problem.
(EntityLiving)par3Entity
But it works perfectly. Thanks a lot.
Do you (or someone else) know how to make the inverse? (to 'Heal'/Repair the Item in a determinated value?) I tried with
itemstack.damageItem(-Number, (EntityLiving)entity);
but it doesn't work.