Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] Custom Painting Rendering Half Block Off


gottsch
 Share

Recommended Posts

Hi.

 

I am having a rendering issue with a custom painting. I simply extended all the painting classes as vanilla as possible, just changing the texture image to use (and of course to point to my classes). However, the image always renders a half block higher than it should. If I make the wall higher, then it will climb, full blocks higher. Has anyone encountered this before? ( I found one thread for an older version, but it didn't really help me).

 

Thanks,

 

gottsch

 

MyItemHangingEntity:

 

 

public class MyItemHangingEntity extends ItemHangingEntity {

 

@SuppressWarnings("rawtypes")

public MyItemHangingEntity(Class p_i45342_1_) {

super(p_i45342_1_);

this.setCreativeTab(Treasure.treasureTab);

}

 

/**

* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return

* True if something happen and false if it don't. This is for ITEMS, not BLOCKS

*/

@Override

public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)

{

if (p_77648_7_ == 0)

{

return false;

}

else if (p_77648_7_ == 1)

{

return false;

}

else

{

int i1 = Direction.facingToDirection[p_77648_7_];

EntityHanging entityhanging = this.createHangingEntity(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, i1);

Treasure.logger.debug("My entity hanging = " + entityhanging);

if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))

{

return false;

}

else

{

if (entityhanging != null && entityhanging.onValidSurface())

{

if (!p_77648_3_.isRemote)

{

p_77648_3_.spawnEntityInWorld(entityhanging);

}

 

--p_77648_1_.stackSize;

}

 

return true;

}

}

}

 

/**

* Create the hanging entity associated to this item.

*/

private EntityHanging createHangingEntity(World p_82810_1_, int p_82810_2_, int p_82810_3_, int p_82810_4_, int p_82810_5_)

{

return (EntityHanging) new MyEntityPainting(p_82810_1_, p_82810_2_, p_82810_3_, p_82810_4_, p_82810_5_);

}

}

 

 

 

MyEntityPainting:

 

public class MyEntityPainting extends EntityPainting {

 

public MyEntityPainting(World world) {

super(world);

}

 

public MyEntityPainting(World p_i1600_1_, int p_i1600_2_, int p_i1600_3_, int p_i1600_4_, int p_i1600_5_) {

super(p_i1600_1_, p_i1600_2_, p_i1600_3_, p_i1600_4_, p_i1600_5_);

}

}

 

 

 

MyRenderPainting: (exact coopy of RenderPainting except changing the texture)

 

public class MyRenderPainting extends RenderPainting {

 

@Override

protected ResourceLocation getEntityTexture(Entity painting) {

return new ResourceLocation(Treasure.modid + ":textures/painting/paintings-16.png");

}

 

/**

* 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 func_76986_a(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(EntityPainting p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)

{

GL11.glPushMatrix();

GL11.glTranslated(p_76986_2_, p_76986_4_, p_76986_6_);

GL11.glRotatef(p_76986_8_, 0.0F, 1.0F, 0.0F);

GL11.glEnable(GL12.GL_RESCALE_NORMAL);

this.bindEntityTexture(p_76986_1_);

EntityPainting.EnumArt enumart = p_76986_1_.art;

float f2 = 0.0625F;

GL11.glScalef(f2, f2, f2);

this.func_77010_a(p_76986_1_, 16, 16, 0, 0);

GL11.glDisable(GL12.GL_RESCALE_NORMAL);

GL11.glPopMatrix();

}

 

private void func_77010_a(EntityPainting p_77010_1_, int sizeX, int sizeY, int p_77010_4_, int p_77010_5_)

{

float f = (float)(-sizeX) / 2.0F;

float f1 = (float)(-sizeY) / 2.0F;

float f2 = 0.5F;

float f3 = 0.75F;

float f4 = 0.8125F;

float f5 = 0.0F;

float f6 = 0.0625F;

float f7 = 0.75F;

float f8 = 0.8125F;

float f9 = 0.001953125F;

float f10 = 0.001953125F;

float f11 = 0.7519531F;

float f12 = 0.7519531F;

float f13 = 0.0F;

float f14 = 0.0625F;

 

for (int i1 = 0; i1 < sizeX / 16; ++i1)

{

for (int j1 = 0; j1 < sizeY / 16; ++j1)

{

float f15 = f + (float)((i1 + 1) * 16);

float f16 = f + (float)(i1 * 16);

float f17 = f1 + (float)((j1 + 1) * 16);

float f18 = f1 + (float)(j1 * 16);

this.lighting(p_77010_1_, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F);

float f19 = (float)(p_77010_4_ + sizeX - i1 * 16) / 256.0F;

float f20 = (float)(p_77010_4_ + sizeX - (i1 + 1) * 16) / 256.0F;

float f21 = (float)(p_77010_5_ + sizeY - j1 * 16) / 256.0F;

float f22 = (float)(p_77010_5_ + sizeY - (j1 + 1) * 16) / 256.0F;

Tessellator tessellator = Tessellator.instance;

tessellator.startDrawingQuads();

tessellator.setNormal(0.0F, 0.0F, -1.0F);

tessellator.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f20, (double)f21);

tessellator.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f19, (double)f21);

tessellator.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f19, (double)f22);

tessellator.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f20, (double)f22);

tessellator.setNormal(0.0F, 0.0F, 1.0F);

tessellator.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f3, (double)f5);

tessellator.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f4, (double)f5);

tessellator.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f4, (double)f6);

tessellator.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f3, (double)f6);

tessellator.setNormal(0.0F, 1.0F, 0.0F);

tessellator.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f7, (double)f9);

tessellator.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f8, (double)f9);

tessellator.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f8, (double)f10);

tessellator.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f7, (double)f10);

tessellator.setNormal(0.0F, -1.0F, 0.0F);

tessellator.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f7, (double)f9);

tessellator.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f8, (double)f9);

tessellator.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f8, (double)f10);

tessellator.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f7, (double)f10);

tessellator.setNormal(-1.0F, 0.0F, 0.0F);

tessellator.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f12, (double)f13);

tessellator.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f12, (double)f14);

tessellator.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f11, (double)f14);

tessellator.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f11, (double)f13);

tessellator.setNormal(1.0F, 0.0F, 0.0F);

tessellator.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f12, (double)f13);

tessellator.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f12, (double)f14);

tessellator.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f11, (double)f14);

tessellator.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f11, (double)f13);

tessellator.draw();

}

}

}

 

private void lighting(EntityPainting p_77008_1_, float p_77008_2_, float p_77008_3_)

{

int i = MathHelper.floor_double(p_77008_1_.posX);

int j = MathHelper.floor_double(p_77008_1_.posY + (double)(p_77008_3_ / 16.0F));

int k = MathHelper.floor_double(p_77008_1_.posZ);

 

if (p_77008_1_.hangingDirection == 2)

{

i = MathHelper.floor_double(p_77008_1_.posX + (double)(p_77008_2_ / 16.0F));

}

 

if (p_77008_1_.hangingDirection == 1)

{

k = MathHelper.floor_double(p_77008_1_.posZ - (double)(p_77008_2_ / 16.0F));

}

 

if (p_77008_1_.hangingDirection == 0)

{

i = MathHelper.floor_double(p_77008_1_.posX - (double)(p_77008_2_ / 16.0F));

}

 

if (p_77008_1_.hangingDirection == 3)

{

k = MathHelper.floor_double(p_77008_1_.posZ + (double)(p_77008_2_ / 16.0F));

}

 

int l = this.renderManager.worldObj.getLightBrightnessForSkyBlocks(i, j, k, 0);

int i1 = l % 65536;

int j1 = l / 65536;

OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1);

GL11.glColor3f(1.0F, 1.0F, 1.0F);

}

 

/**

* 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 func_76986_a(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 p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)

{

this.doRender((MyEntityPainting)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);

}

}

 

 

 

In MyMod:

 

int entityID = EntityRegistry.findGlobalUniqueEntityId();

 

EntityRegistry.registerModEntity(MyEntityPainting.class, "myEntityPainting", entityID, instance, 128, 1, true);

 

 

 

In ClientProxy:

 

RenderingRegistry.registerEntityRenderingHandler(MyEntityPainting.class, new MyRenderPainting());

 

 

Image:

width=800 height=428https://dl.dropboxusercontent.com/u/67605173/2014-11-01_20.30.44.png[/img]

Link to comment
Share on other sites

Thanks, but that line is referring to the dimensions and offset of the image to display on the painting.  The enumart is referring to a property of EntityPainting:

 

    public static enum EnumArt
    {
        Kebab("Kebab", 16, 16, 0, 0),
...

So I just used the values to always use the first image.

Link to comment
Share on other sites

Firstly, u should rename your params, it will make everything a lot easier.

Yes, I typically do.  I just threw this "basic" set of classes together to get it to work, as the actual version in my mod does the same thing.

 

And secondly, when u hover over the painting is the hitbox around the painting or is the hitbox half a block down? (Like the stone)

Good question.  I don't see the hitbox (black wireframe) even highlight when I hover over the painting.  The block's behind the painting will show their hitbox as if the painting wasn't there.

Link to comment
Share on other sites

In your item, try changing:

EntityHanging entityhanging = this.createHangingEntity(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, i1);

to

EntityHanging entityhanging = this.createHangingEntity(p_77648_3_, p_77648_4_, p_77648_5_ + 0.5, p_77648_6_, i1);

You Only Live Once, So Win At Golf.

Sorry for my English, I'm American.

Link to comment
Share on other sites

Firstly, u should rename your params, it will make everything a lot easier.

Yes, I typically do.  I just threw this "basic" set of classes together to get it to work, as the actual version in my mod does the same thing.

 

And secondly, when u hover over the painting is the hitbox around the painting or is the hitbox half a block down? (Like the stone)

Good question.  I don't see the hitbox (black wireframe) even highlight when I hover over the painting.  The block's behind the painting will show their hitbox as if the painting wasn't there.

Sorry that was my mistake, pretty sure entities don't have hit boxes

Link to comment
Share on other sites

In your item, try changing:

EntityHanging entityhanging = this.createHangingEntity(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, i1);

to

EntityHanging entityhanging = this.createHangingEntity(p_77648_3_, p_77648_4_, p_77648_5_ + 0.5, p_77648_6_, i1);

Thanks, but these params are ints, so this value will just get truncated back to the whole int value.  But for good measure, I attempted with +/-1.  The outcome was the same (just a full block in a different direction).

 

Just to make clear, the painting initially renders in the correct place, but then almost immediately shifts upwards.  If I add more block to make a higher wall, it will shift even higher depending on the way I look at it.

Link to comment
Share on other sites

  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • When i run data i get this error  Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)     at cpw.mods.bootstraplauncher@0.1.17/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) Caused by: java.lang.reflect.InvocationTargetException     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.base/java.lang.reflect.Method.invoke(Method.java:568)     at MC-BOOTSTRAP/fmlloader@1.18-38.0.16/net.minecraftforge.fml.loading.targets.ForgeDataUserdevLaunchHandler.lambda$launchService$0(ForgeDataUserdevLaunchHandler.java:41)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)     ... 7 more Caused by: net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [     fml.modloading.failedtoloadmod ]     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.waitForTransition(ModLoader.java:235)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.lambda$dispatchAndHandleError$21(ModLoader.java:200)     at java.base/java.util.Optional.ifPresent(Optional.java:178)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:200)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$11(ModLoader.java:177)     at java.base/java.lang.Iterable.forEach(Iterable.java:75)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:177)     at TRANSFORMER/forge@38.0.16/net.minecraftforge.data.loading.DatagenModLoader.begin(DatagenModLoader.java:52)     at TRANSFORMER/minecraft@1.18/net.minecraft.data.Main.main(Main.java:65)     ... 13 more Caused by: java.lang.reflect.InvocationTargetException Caused by: net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [ > Task :runData FAILED :runData (Thread[Execution worker for ':',5,main]) completed. Took 38.808 secs. Execution failed for task ':runData'. > Process 'command '/Users/YusufIsmail/Library/Java/JavaVirtualMachines/corretto-17.0.1/Contents/Home/bin/java'' finished with non-zero exit value 1   The full log is  https://gist.github.com/RealYusufIsmail/f598cbf87bee3923f665ec3ebfff1932 and the build.gradle is here https://github.com/Dungeon-Makers/Armour-and-Item/blob/V2/1.18/build.gradle
    • im trying to run a modern rlcraft server but it wont even start. this is the log C:\Users\soto5\Downloads\Modern+RLCraft+Server+Pack-1.12.2-1.5.2\Modern RLCraft Server Pack-1.12.2-1.5.1>java -Xmx4096M -Xms4096M -jar forge.jar nogui A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:567)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more    
    • Is there a way to "override" an entity's texture to something else without creating a "dummy" item when using ThrownItemRenderer? I tried creating a Renderer that extends it with a ResourceLocation override but this does not change the entity's 2D texture. Any help would be appreciated. Render class: public class BulletEntityRenderer extends ThrownItemRenderer { private static final ResourceLocation TEXTURE = new ResourceLocation(ExampleMod.MOD_ID, "textures/entity/bullet.png"); public BulletEntityRenderer(EntityRendererProvider.Context context) { super(context); } @Override public ResourceLocation getTextureLocation(Entity entity) { return TEXTURE; } } Render registry: public class ModRender { public static void registerRender() { EntityRenderers.register(ExampleMod.BULLET, BulletEntityRenderer::new); } } Entity class: public class BulletEntity extends ThrowableItemProjectile { private float damage = 12.0F; private int pierceLevel = 0; private int ticksAlive = 0; private final int lifespan = 60; public BulletEntity(EntityType<BulletEntity> type, Level world) { super(type, world); } public BulletEntity(Player player, Level world, float damage, int pierceLevel) { super(ExampleMod.BULLET, player, world); this.damage = damage; this.pierceLevel = pierceLevel; this.setNoGravity(true); } public DamageSource causeBulletDamage(BulletEntity bullet, Entity attacker) { return (new IndirectEntityDamageSource("bullet", bullet, attacker)).setProjectile(); } public void tick() { super.tick(); Vec3 vec3d = this.getDeltaMovement(); double d1 = vec3d.x; double d2 = vec3d.y; double d0 = vec3d.z; if (this.isInWater()) { this.level.addParticle(ParticleTypes.BUBBLE, this.getX(), this.getY(), this.getZ(), -d1, -d2, -d0); } else { this.level.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), -d1, -d2, -d0); } if (ticksAlive > lifespan) { this.discard(); } ticksAlive++; } @Override protected void onHitEntity(EntityHitResult hitResult) { LivingEntity target = (LivingEntity) hitResult.getEntity(); Entity shooter = getOwner(); double armor = target.getArmorValue() * (1 - (0.2 * pierceLevel)); double toughness = target.getAttribute(Attributes.ARMOR_TOUGHNESS).getValue(); float finalDamage = (float) (damage * (1 - (Math.min(20, Math.max((armor / 5), armor - ((4 * damage) / (toughness + 8))))) / 25)); target.hurt(causeBulletDamage(this, shooter).bypassArmor(), finalDamage); } @Override public Item getDefaultItem() { return ModItems.BULLET; } }
    • Which version of Forge did you use? Post debug log
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.