Jump to content

Recommended Posts

Posted

Hello,

I've made an Entity which should be noclip but instead of being inside of a block it is glitching to the Top of blocks.

My Entity is using a Target system to go to its positions which works like the positioning system of the XP orb.

 

Here is the Code of my Entity:    http://pastebin.com/akYUhRDj

 

package busti2000.technica.entity;

import busti2000.technica.api.PipeAPI;
import busti2000.technica.tileentity.TileEntitySoulContainer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class PipeXPOrb extends Entity {

    /**
     * A constantly increasing value that RenderXPOrb uses to control the color shifting (Green / yellow)
     */
    public int xpColor;
    
    /** This is how much XP this orb has. */
    private int xpValue;
    
    private double tx;
    private double ty;
    private double tz;
    
    public boolean hasReachedTarget;
    
    private double speed = Math.random() * (0.3 - 0.1) + 0.1;

public PipeXPOrb(World par1World, double par2, double par4, double par6, int par8, double tx, double ty, double tz) {
	super(par1World);
	this.setSize(0.5F, 0.5F);
        this.setPosition(par2, par4, par6);
        this.rotationYaw = (float)(Math.random() * 360.0D);
        this.xpValue = par8;
        this.tx = tx;
        this.ty = ty;
        this.tz = tz;
        this.hasReachedTarget = false;
        this.noClip = true;
	}

    /**
     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
     * prevent them from trampling crops
     */
    protected boolean canTriggerWalking() {
        return false;
    }

public PipeXPOrb(World par1World) {
        super(par1World);
        this.setSize(0.5F, 0.5F);
        this.noClip = true;
        this.hasReachedTarget = false;
}

protected void entityInit() {}

    @SideOnly(Side.CLIENT)
    public int getBrightnessForRender(float par1)
    {
        float f1 = 0.5F;

        if (f1 < 0.0F)
        {
            f1 = 0.0F;
        }

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
        }

        int i = super.getBrightnessForRender(par1);
        int j = i & 255;
        int k = i >> 16 & 255;
        j += (int)(f1 * 15.0F * 16.0F);

        if (j > 240)
        {
            j = 240;
        }

        return j | k << 16;
    }

public void onUpdate() {

	super.onUpdate();

	if (!this.hasReachedTarget) {

		double d0 = 8.0D;
        	double d1 = (this.tx - this.posX) / d0;
        	double d2 = (this.ty - this.posY) / d0;
        	double d3 = (this.tz - this.posZ) / d0;
        	double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
        	double d5 = 1.0D - d4;
        	double d11 = (this.tx - this.posX);
        	double d12 = (this.ty - this.posY);
        	double d13 = (this.tz - this.posZ);
        	double d14 = Math.sqrt(d11 * d11 + d12 * d12 + d13 * d13);
        	
        	if (d5 > 0.0D)
        	{
            	d5 *= d5;
            	this.motionX = d1 / d4 * d5 * this.speed;
            	this.motionY = d2 / d4 * d5 * this.speed;
            	this.motionZ = d3 / d4 * d5 * this.speed;
        	}
        	if (d14 < 0.15D)	{
        		this.hasReachedTarget = true;
        		this.motionX = 0;
        		this.motionY = 0;
        		this.motionZ = 0;
        	}

	}
	        
	this.moveEntity(this.motionX, this.motionY, this.motionZ);

	this.xpColor++;

}

    /**
     * Returns the XP value of this XP orb.
     */
    public int getXpValue()
    {
        return this.xpValue;
    }
    
    @SideOnly(Side.CLIENT)
    
    /**
     * Returns a number from 1 to 10 based on how much XP this orb is worth. This is used by RenderXPOrb to determine
     * what texture to use.
     */
    public int getTextureByXP()
    {
        return this.xpValue >= 2477 ? 10 : (this.xpValue >= 1237 ? 9 : (this.xpValue >= 617 ? 8 : (this.xpValue >= 307 ? 7 : (this.xpValue >= 149 ? 6 : (this.xpValue >= 73 ? 5 : (this.xpValue >= 37 ? 4 : (this.xpValue >= 17 ? 3 : (this.xpValue >= 7 ? 2 : (this.xpValue >= 3 ? 1 : 0)))))))));
    }
    
    /**
     * If returns false, the item will not inflict any damage against entities.
     */
    public boolean canAttackWithItem()
    {
        return false;
    }
    
    /**
     * Sets the Target of the Orb
     */
    public void setTarget(double tx, double ty, double tz) {
        this.tx = tx;
        this.ty = ty;
        this.tz = tz;
        this.hasReachedTarget = false;
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
	this.xpValue = nbttagcompound.getShort("Value");
	this.tx = nbttagcompound.getDouble("tx");
	this.ty = nbttagcompound.getDouble("ty");
	this.tz = nbttagcompound.getDouble("tz");
	this.setDead();
}

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {
	nbttagcompound.setShort("Value", (short)this.xpValue);
	nbttagcompound.setDouble("tx", this.tx);
	nbttagcompound.setDouble("ty", this.ty);
	nbttagcompound.setDouble("tz", this.tz);
}

}

 

And this is the Register code:

 

EntityRegistry.registerModEntity(PipeXPOrb.class, "PipeXPOrb", 1, this, 50, 1, true);

 

 

Thank you for any Help.

 

Busti

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

I'm just replying because I need to fix this Problem. It's my main Problem right now and I've been searching for a solution for a month now.

Please Help!

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

It doesn't work but it actually helped a bit. I've also tried to make the Entity move manual by just doing this:

this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;

this.setPosition(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

but this doesn't work either so the Problem is not caused by noclip. It seems that my Entity is trying to go out of any bounding box but I couldn't find the code that is causing this.

I need to fix this because I need to make an Entity render inside of a Tube. I've already got the system for the tubes working and it is also working fine without the glitch when I don't register the Entity.

 

If you know what is causing this of if you had or still have the same problem please reply to this thread, anything could be helpful.

 

Busti

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

I've tried to override move entity to move it just with position updates but it seems theat this is a render issue. I discoverd that its position is right but it seems that the renderer has a pushOutOf blocks function too.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.