Jump to content

1.12 Vanishing painting clone basics


Stroam

Recommended Posts

So I'm making a painting clone that vanishes after a certain time. I modified the vanilla class but I'm having a very difficult time figuring out how register this with forge so that it shows up. Examples I've looked at are depreciated and the vanilla classes are don't really help with that as far as I know. Here's what I got so far. I know Render needs to shed some code but this was first pass through and didn't want to break anything I needed.  

Spoiler

Entity

Spoiler


public class EntityVanishingPainting extends EntityHanging{
	
	private static final DataParameter<Integer> DURATION = EntityDataManager.<Integer>createKey(EntityVanishingPainting.class,
			DataSerializers.VARINT);
	
	private int duration;
	private int tickCounter1;

	public EntityVanishingPainting(World worldIn)
    {
        super(worldIn);
        this.duration = 80;
        this.setSize(0.5F, 0.5F);
    }

    public EntityVanishingPainting(World worldIn, BlockPos pos, EnumFacing facing)
    {
        super(worldIn, pos);
        this.updateFacingWithBoundingBox(facing);
    }
    
    @Override
    protected void entityInit()
    {
        this.dataManager.register(DURATION, Integer.valueOf(80));
    }
    
    /**
     * Called to update the entity's position/logic.
     */
    @Override
    public void onUpdate()
    {
    	
    	this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;

        if (this.tickCounter1++ == 20 && !this.world.isRemote)
        {
            this.tickCounter1 = 0;

            if (!this.isDead && !this.onValidSurface())
            {
                this.setDead();
                this.onBroken((Entity)null);
            }
        }

        --this.duration;

        if (this.duration <= 0)
        {
            this.setDead();

            if (!this.world.isRemote)
            {
                this.burnUp();
            }
        }
        else
        {
            this.handleWaterMovement();
            this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
        }
    }

	@Override
	public int getWidthPixels() {
		return 6;
	}

	@Override
	public int getHeightPixels() {
		return 12;
	}

	@Override
	public void onBroken(Entity brokenEntity) {
		if (this.world.getGameRules().getBoolean("doEntityDrops"))
        {
			this.playSound(SoundEvents.ENTITY_PAINTING_BREAK, 1.0F, 1.0F);
			
			if (brokenEntity instanceof EntityPlayer)
            {
				EntityPlayer entityplayer = (EntityPlayer)brokenEntity;

                if (entityplayer.capabilities.isCreativeMode)
                {
                    return;
                }
            }
			this.setDead();
			this.burnUp();
            //this.entityDropItem(new ItemStack(this), 0.0F);
        }
	}

	@Override
	public void playPlaceSound() {
		this.playSound(SoundEvents.ENTITY_PAINTING_PLACE, 1.0F, 1.0F);
		
	}
	
	private void burnUp()
	{
		world.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, 0, 0, 0, new int[0]);
	}
	
	@Override
	public void writeEntityToNBT(NBTTagCompound compound)
    {
        compound.setShort("DURATION", (short)this.getDuration());
    }
	
	@Override
	public void readEntityFromNBT(NBTTagCompound compound)
	{
		this.setDuration(compound.getShort("DURATION"));
	}
	
	public void setDuration(int time) 
	{
		this.dataManager.set(DURATION, Integer.valueOf(time));
	}
	
	public void notifyDataMangerChange(DataParameter<?> key)
	{
		if (DURATION.equals(key))
		{
			this.duration = this.getDurationDataManger();
		}
	}
	
	/**
	 * Gets the duration from the data manager
	 */
	public int getDurationDataManger() 
	{
		return ((Integer)this.dataManager.get(DURATION)).intValue();
	}

	public int getDuration() 
	{
		return this.duration;
	}
	
	

}

 

Render

Spoiler


@SideOnly(Side.CLIENT)
public class RenderVanishingPainting extends Render<EntityVanishingPainting>
{
	 private static final ResourceLocation KRISTOFFER_VanishingPainting_TEXTURE = new ResourceLocation("textures/entity/papertalisman.png");

	    public RenderVanishingPainting(RenderManager renderManagerIn)
	    {
	        super(renderManagerIn);
	    }

	    /**
	     * Renders the desired {@code T} type Entity.
	     */
	    public void doRender(EntityVanishingPainting entity, double x, double y, double z, float entityYaw, float partialTicks)
	    {
	        GlStateManager.pushMatrix();
	        GlStateManager.translate(x, y, z);
	        GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F);
	        GlStateManager.enableRescaleNormal();
	        this.bindEntityTexture(entity);
	        float f = 0.0625F;
	        GlStateManager.scale(0.0625F, 0.0625F, 0.0625F);

	        if (this.renderOutlines)
	        {
	            GlStateManager.enableColorMaterial();
	            GlStateManager.enableOutlineMode(this.getTeamColor(entity));
	        }

	        this.renderVanishingPainting(entity, 6, 12, 6, 3); //width height starting x and y positions

	        if (this.renderOutlines)
	        {
	            GlStateManager.disableOutlineMode();
	            GlStateManager.disableColorMaterial();
	        }

	        GlStateManager.disableRescaleNormal();
	        GlStateManager.popMatrix();
	        super.doRender(entity, x, y, z, entityYaw, partialTicks);
	    }

	    /**
	     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
	     */
	    protected ResourceLocation getEntityTexture(EntityVanishingPainting entity)
	    {
	        return KRISTOFFER_VanishingPainting_TEXTURE;
	    }

	    private void renderVanishingPainting(EntityVanishingPainting VanishingPainting, int width, int height, int textureU, int textureV)
	    {
	        float f = (float)(-width) / 2.0F;
	        float f1 = (float)(-height) / 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 i = 0; i < width / 16; ++i)
	        {
	            for (int j = 0; j < height / 16; ++j)
	            {
	                float f15 = f + (float)((i + 1) * 16);
	                float f16 = f + (float)(i * 16);
	                float f17 = f1 + (float)((j + 1) * 16);
	                float f18 = f1 + (float)(j * 16);
	                this.setLightmap(VanishingPainting, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F);
	                float f19 = (float)(textureU + width - i * 16) / 256.0F;
	                float f20 = (float)(textureU + width - (i + 1) * 16) / 256.0F;
	                float f21 = (float)(textureV + height - j * 16) / 256.0F;
	                float f22 = (float)(textureV + height - (j + 1) * 16) / 256.0F;
	                Tessellator tessellator = Tessellator.getInstance();
	                BufferBuilder bufferbuilder = tessellator.getBuffer();
	                bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex((double)f20, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex((double)f19, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex((double)f19, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex((double)f20, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.75D, 0.0D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.8125D, 0.0D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.8125D, 0.0625D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.75D, 0.0625D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex(0.75D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.75D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.75D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex(0.75D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.751953125D, 0.0D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.751953125D, 0.0625D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex(0.751953125D, 0.0625D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex(0.751953125D, 0.0D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex(0.751953125D, 0.0D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex(0.751953125D, 0.0625D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.751953125D, 0.0625D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.751953125D, 0.0D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                tessellator.draw();
	            }
	        }
	    }

	    private void setLightmap(EntityVanishingPainting VanishingPainting, float p_77008_2_, float p_77008_3_)
	    {
	        int i = MathHelper.floor(VanishingPainting.posX);
	        int j = MathHelper.floor(VanishingPainting.posY + (double)(p_77008_3_ / 16.0F));
	        int k = MathHelper.floor(VanishingPainting.posZ);
	        EnumFacing enumfacing = VanishingPainting.facingDirection;

	        if (enumfacing == EnumFacing.NORTH)
	        {
	            i = MathHelper.floor(VanishingPainting.posX + (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.WEST)
	        {
	            k = MathHelper.floor(VanishingPainting.posZ - (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.SOUTH)
	        {
	            i = MathHelper.floor(VanishingPainting.posX - (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.EAST)
	        {
	            k = MathHelper.floor(VanishingPainting.posZ + (double)(p_77008_2_ / 16.0F));
	        }

	        int l = this.renderManager.world.getCombinedLight(new BlockPos(i, j, k), 0);
	        int i1 = l % 65536;
	        int j1 = l / 65536;
	        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1);
	        GlStateManager.color(1.0F, 1.0F, 1.0F);
	    }
}

 

 

 

I think I've solved it thanks to

 @Choonster files on github : github.com

 

need to time to verify

 

Edited by Stroam
update

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

Oh. Hanging entities. Vanilla made those a pain in the ass because EntityHanging itself is responsible for deciding which entity actually gets spawned. 

 

You're better off replicating (virtually) all of EntityHanging for your painting clone.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh ho! Thanks for the info. 

I'm having such a difficult time trying to do things right with all the changes. I will do as you suggest and report back about 6 hours. The setup Choonster has and all the questions about registering things on this forum is making me change the basic mod template structure I've been using for a long time.

 

plus it's tea time.

Edited by Stroam

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

Update. Been trying a new approach and it hasn't worked out.

Spoiler

EntityVanishingPainting

Spoiler



public class EntityVanishingPainting extends EntityAttachable{
	
	private static final DataParameter<Integer> DURATION = EntityDataManager.<Integer>createKey(EntityVanishingPainting.class,
			DataSerializers.VARINT);
	
	private int duration;
	private int tickCounter1;

	public EntityVanishingPainting(World worldIn)
    {
        super(worldIn);
        this.duration = 80;
        this.setSize(0.5F, 0.5F);
    }

    public EntityVanishingPainting(World worldIn, BlockPos pos, EnumFacing facing)
    {
        super(worldIn, pos);
        this.updateFacingWithBoundingBox(facing);
    }
    
    @Override
    protected void entityInit()
    {
        this.dataManager.register(DURATION, Integer.valueOf(80));
    }
    
    /**
     * Called to update the entity's position/logic.
     */
    @Override
    public void onUpdate()
    {
    	
    	this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;

        if (this.tickCounter1++ == 20 && !this.world.isRemote)
        {
            this.tickCounter1 = 0;

            if (!this.isDead && !this.onValidSurface())
            {
                this.setDead();
                this.onBroken((Entity)null);
            }
        }

        --this.duration;

        if (this.duration <= 0)
        {
            this.setDead();

            if (!this.world.isRemote)
            {
                this.burnUp();
            }
        }
        else
        {
            this.handleWaterMovement();
            this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
        }
    }

	@Override
	public int getWidthPixels() {
		return 6;
	}

	@Override
	public int getHeightPixels() {
		return 12;
	}

	@Override
	public void onBroken(Entity brokenEntity) {
		if (this.world.getGameRules().getBoolean("doEntityDrops"))
        {
			this.playSound(SoundEvents.ENTITY_PAINTING_BREAK, 1.0F, 1.0F);
			
			if (brokenEntity instanceof EntityPlayer)
            {
				EntityPlayer entityplayer = (EntityPlayer)brokenEntity;

                if (entityplayer.capabilities.isCreativeMode)
                {
                    return;
                }
            }
			this.setDead();
			this.burnUp();
            //this.entityDropItem(new ItemStack(this), 0.0F);
        }
	}

	@Override
	public void playPlaceSound() {
		this.playSound(SoundEvents.ENTITY_PAINTING_PLACE, 1.0F, 1.0F);
		
	}
	
	private void burnUp()
	{
		world.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, 0, 0, 0, new int[0]);
	}
	
	@Override
	public void writeEntityToNBT(NBTTagCompound compound)
    {
        compound.setShort("DURATION", (short)this.getDuration());
    }
	
	@Override
	public void readEntityFromNBT(NBTTagCompound compound)
	{
		this.setDuration(compound.getShort("DURATION"));
	}
	
	public void setDuration(int time) 
	{
		this.dataManager.set(DURATION, Integer.valueOf(time));
	}
	
	public void notifyDataMangerChange(DataParameter<?> key)
	{
		if (DURATION.equals(key))
		{
			this.duration = this.getDurationDataManger();
		}
	}
	
	/**
	 * Gets the duration from the data manager
	 */
	public int getDurationDataManger() 
	{
		return ((Integer)this.dataManager.get(DURATION)).intValue();
	}

	public int getDuration() 
	{
		return this.duration;
	}

}

 

EntityAttachable

Spoiler


public abstract class EntityAttachable extends Entity{
	
	private static final Predicate<Entity> IS_HANGING_ENTITY = new Predicate<Entity>()
    {
        public boolean apply(@Nullable Entity entity)
        {
            return entity instanceof EntityAttachable;
        }
    };
    private int tickCounter1;
    protected BlockPos hangingPosition;
    /** The direction the entity is facing */
    @Nullable
    public EnumFacing facingDirection;

    public EntityAttachable(World worldIn)
    {
        super(worldIn);
        this.setSize(0.5F, 0.5F);
    }

    public EntityAttachable(World worldIn, BlockPos hangingPositionIn)
    {
        this(worldIn);
        this.hangingPosition = hangingPositionIn;
    }

    protected void entityInit()
    {
    }

    /**
     * Updates facing and bounding box based on it
     */
    protected void updateFacingWithBoundingBox(EnumFacing facingDirectionIn)
    {
        Validate.notNull(facingDirectionIn);
        Validate.isTrue(facingDirectionIn.getAxis().isHorizontal());
        this.facingDirection = facingDirectionIn;
        this.rotationYaw = (float)(this.facingDirection.getHorizontalIndex() * 90);
        this.prevRotationYaw = this.rotationYaw;
        this.updateBoundingBox();
    }

    /**
     * Updates the entity bounding box based on current facing
     */
    protected void updateBoundingBox()
    {
        if (this.facingDirection != null)
        {
            double d0 = (double)this.hangingPosition.getX() + 0.5D;
            double d1 = (double)this.hangingPosition.getY() + 0.5D;
            double d2 = (double)this.hangingPosition.getZ() + 0.5D;
            double d3 = 0.46875D;
            double d4 = this.offs(this.getWidthPixels());
            double d5 = this.offs(this.getHeightPixels());
            d0 = d0 - (double)this.facingDirection.getFrontOffsetX() * 0.46875D;
            d2 = d2 - (double)this.facingDirection.getFrontOffsetZ() * 0.46875D;
            d1 = d1 + d5;
            EnumFacing enumfacing = this.facingDirection.rotateYCCW();
            d0 = d0 + d4 * (double)enumfacing.getFrontOffsetX();
            d2 = d2 + d4 * (double)enumfacing.getFrontOffsetZ();
            this.posX = d0;
            this.posY = d1;
            this.posZ = d2;
            double d6 = (double)this.getWidthPixels();
            double d7 = (double)this.getHeightPixels();
            double d8 = (double)this.getWidthPixels();

            if (this.facingDirection.getAxis() == EnumFacing.Axis.Z)
            {
                d8 = 1.0D;
            }
            else
            {
                d6 = 1.0D;
            }

            d6 = d6 / 32.0D;
            d7 = d7 / 32.0D;
            d8 = d8 / 32.0D;
            this.setEntityBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8));
        }
    }

    private double offs(int p_190202_1_)
    {
        return p_190202_1_ % 32 == 0 ? 0.5D : 0.0D;
    }

    /**
     * Called to update the entity's position/logic.
     */
    public void onUpdate()
    {
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;

        if (this.tickCounter1++ == 100 && !this.world.isRemote)
        {
            this.tickCounter1 = 0;

            if (!this.isDead && !this.onValidSurface())
            {
                this.setDead();
                this.onBroken((Entity)null);
            }
        }
    }

    /**
     * checks to make sure painting can be placed there
     */
    public boolean onValidSurface()
    {
        if (!this.world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty())
        {
            return false;
        }
        else
        {
            int i = Math.max(1, this.getWidthPixels() / 16);
            int j = Math.max(1, this.getHeightPixels() / 16);
            BlockPos blockpos = this.hangingPosition.offset(this.facingDirection.getOpposite());
            EnumFacing enumfacing = this.facingDirection.rotateYCCW();
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

            for (int k = 0; k < i; ++k)
            {
                for (int l = 0; l < j; ++l)
                {
                    int i1 = (i - 1) / -2;
                    int j1 = (j - 1) / -2;
                    blockpos$mutableblockpos.setPos(blockpos).move(enumfacing, k + i1).move(EnumFacing.UP, l + j1);
                    IBlockState iblockstate = this.world.getBlockState(blockpos$mutableblockpos);

                    if (iblockstate.isSideSolid(this.world, blockpos$mutableblockpos, this.facingDirection))
                        continue;

                    if (!iblockstate.getMaterial().isSolid() && !BlockRedstoneDiode.isDiode(iblockstate))
                    {
                        return false;
                    }
                }
            }

            return this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), IS_HANGING_ENTITY).isEmpty();
        }
    }

    /**
     * Returns true if other Entities should be prevented from moving through this Entity.
     */
    public boolean canBeCollidedWith()
    {
        return true;
    }

    /**
     * Called when a player attacks an entity. If this returns true the attack will not happen.
     */
    public boolean hitByEntity(Entity entityIn)
    {
        return entityIn instanceof EntityPlayer ? this.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)entityIn), 0.0F) : false;
    }

    /**
     * Gets the horizontal facing direction of this Entity.
     */
    public EnumFacing getHorizontalFacing()
    {
        return this.facingDirection;
    }

    /**
     * Called when the entity is attacked.
     */
    public boolean attackEntityFrom(DamageSource source, float amount)
    {
        if (this.isEntityInvulnerable(source))
        {
            return false;
        }
        else
        {
            if (!this.isDead && !this.world.isRemote)
            {
                this.setDead();
                this.setBeenAttacked();
                this.onBroken(source.getTrueSource());
            }

            return true;
        }
    }

    /**
     * Tries to move the entity towards the specified location.
     */
    public void move(MoverType type, double x, double y, double z)
    {
        if (!this.world.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D)
        {
            this.setDead();
            this.onBroken((Entity)null);
        }
    }

    /**
     * Adds to the current velocity of the entity.
     */
    public void addVelocity(double x, double y, double z)
    {
        if (!this.world.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D)
        {
            this.setDead();
            this.onBroken((Entity)null);
        }
    }

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    public void writeEntityToNBT(NBTTagCompound compound)
    {
        compound.setByte("Facing", (byte)this.facingDirection.getHorizontalIndex());
        BlockPos blockpos = this.getHangingPosition();
        compound.setInteger("TileX", blockpos.getX());
        compound.setInteger("TileY", blockpos.getY());
        compound.setInteger("TileZ", blockpos.getZ());
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    public void readEntityFromNBT(NBTTagCompound compound)
    {
        this.hangingPosition = new BlockPos(compound.getInteger("TileX"), compound.getInteger("TileY"), compound.getInteger("TileZ"));
        this.updateFacingWithBoundingBox(EnumFacing.getHorizontal(compound.getByte("Facing")));
    }

    public abstract int getWidthPixels();

    public abstract int getHeightPixels();

    /**
     * Called when this entity is broken. Entity parameter may be null.
     */
    public abstract void onBroken(@Nullable Entity brokenEntity);

    public abstract void playPlaceSound();

    /**
     * Drops an item at the position of the entity.
     */
    public EntityItem entityDropItem(ItemStack stack, float offsetY)
    {
        EntityItem entityitem = new EntityItem(this.world, this.posX + (double)((float)this.facingDirection.getFrontOffsetX() * 0.15F), this.posY + (double)offsetY, this.posZ + (double)((float)this.facingDirection.getFrontOffsetZ() * 0.15F), stack);
        entityitem.setDefaultPickupDelay();
        this.world.spawnEntity(entityitem);
        return entityitem;
    }

    protected boolean shouldSetPosAfterLoading()
    {
        return false;
    }

    /**
     * Sets the x,y,z of the entity from the given parameters. Also seems to set up a bounding box.
     */
    public void setPosition(double x, double y, double z)
    {
        this.hangingPosition = new BlockPos(x, y, z);
        this.updateBoundingBox();
        this.isAirBorne = true;
    }

    public BlockPos getHangingPosition()
    {
        return this.hangingPosition;
    }

    /**
     * Transforms the entity's current yaw with the given Rotation and returns it. This does not have a side-effect.
     */
    @SuppressWarnings("incomplete-switch")
    public float getRotatedYaw(Rotation transformRotation)
    {
        if (this.facingDirection != null && this.facingDirection.getAxis() != EnumFacing.Axis.Y)
        {
            switch (transformRotation)
            {
                case CLOCKWISE_180:
                    this.facingDirection = this.facingDirection.getOpposite();
                    break;
                case COUNTERCLOCKWISE_90:
                    this.facingDirection = this.facingDirection.rotateYCCW();
                    break;
                case CLOCKWISE_90:
                    this.facingDirection = this.facingDirection.rotateY();
            }
        }

        float f = MathHelper.wrapDegrees(this.rotationYaw);

        switch (transformRotation)
        {
            case CLOCKWISE_180:
                return f + 180.0F;
            case COUNTERCLOCKWISE_90:
                return f + 90.0F;
            case CLOCKWISE_90:
                return f + 270.0F;
            default:
                return f;
        }
    }

    /**
     * Transforms the entity's current yaw with the given Mirror and returns it. This does not have a side-effect.
     */
    public float getMirroredYaw(Mirror transformMirror)
    {
        return this.getRotatedYaw(transformMirror.toRotation(this.facingDirection));
    }

    /**
     * Called when a lightning bolt hits the entity.
     */
    public void onStruckByLightning(EntityLightningBolt lightningBolt)
    {
    }

}

 

RenderVanishingPainting

Spoiler



@SideOnly(Side.CLIENT)
public class RenderTempVanishingPainting extends Render<EntityVanishingPainting>
{
	 //private static final ResourceLocation KRISTOFFER_TempAntiMobSpawn_TEXTURE = new ResourceLocation("textures/entity/papertalisman.png");
	private final ResourceLocation entityTexture;
	
	    public RenderTempVanishingPainting(final RenderManager renderManagerIn, final ResourceLocation entityTexture)
	    {
	        super(renderManagerIn);
	        this.entityTexture = entityTexture;
	    }
	    
	    protected ResourceLocation getEntityTexture(final EntityVanishingPainting entity)
	    {
	    	return entityTexture;
	    }

	    /**
	     * Renders the desired {@code T} type Entity.
	     */
	    public void doRender(EntityVanishingPainting entity, double x, double y, double z, float entityYaw, float partialTicks)
	    {
	        GlStateManager.pushMatrix();
	        GlStateManager.translate(x, y, z);
	        GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F);
	        GlStateManager.enableRescaleNormal();
	        this.bindEntityTexture(entity);
	        float f = 0.0625F;
	        GlStateManager.scale(0.0625F, 0.0625F, 0.0625F);

	        if (this.renderOutlines)
	        {
	            GlStateManager.enableColorMaterial();
	            GlStateManager.enableOutlineMode(this.getTeamColor(entity));
	        }

	        this.renderTempAntiMobSpawn(entity, 6, 12, 6, 3); //width height starting x and y positions

	        if (this.renderOutlines)
	        {
	            GlStateManager.disableOutlineMode();
	            GlStateManager.disableColorMaterial();
	        }

	        GlStateManager.disableRescaleNormal();
	        GlStateManager.popMatrix();
	        super.doRender(entity, x, y, z, entityYaw, partialTicks);
	    }

	    private void renderTempAntiMobSpawn(EntityVanishingPainting TempAntiMobSpawn, int width, int height, int textureU, int textureV)
	    {
	        float f = (float)(-width) / 2.0F;
	        float f1 = (float)(-height) / 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 i = 0; i < width / 16; ++i)
	        {
	            for (int j = 0; j < height / 16; ++j)
	            {
	                float f15 = f + (float)((i + 1) * 16);
	                float f16 = f + (float)(i * 16);
	                float f17 = f1 + (float)((j + 1) * 16);
	                float f18 = f1 + (float)(j * 16);
	                this.setLightmap(TempAntiMobSpawn, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F);
	                float f19 = (float)(textureU + width - i * 16) / 256.0F;
	                float f20 = (float)(textureU + width - (i + 1) * 16) / 256.0F;
	                float f21 = (float)(textureV + height - j * 16) / 256.0F;
	                float f22 = (float)(textureV + height - (j + 1) * 16) / 256.0F;
	                Tessellator tessellator = Tessellator.getInstance();
	                BufferBuilder bufferbuilder = tessellator.getBuffer();
	                bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex((double)f20, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex((double)f19, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex((double)f19, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex((double)f20, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.75D, 0.0D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.8125D, 0.0D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.8125D, 0.0625D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.75D, 0.0625D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex(0.75D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.75D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.75D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex(0.75D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.751953125D, 0.0D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.751953125D, 0.0625D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex(0.751953125D, 0.0625D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex(0.751953125D, 0.0D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex(0.751953125D, 0.0D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex(0.751953125D, 0.0625D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.751953125D, 0.0625D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.751953125D, 0.0D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                tessellator.draw();
	            }
	        }
	    }

	    private void setLightmap(EntityVanishingPainting TempAntiMobSpawn, float p_77008_2_, float p_77008_3_)
	    {
	        int i = MathHelper.floor(TempAntiMobSpawn.posX);
	        int j = MathHelper.floor(TempAntiMobSpawn.posY + (double)(p_77008_3_ / 16.0F));
	        int k = MathHelper.floor(TempAntiMobSpawn.posZ);
	        EnumFacing enumfacing = TempAntiMobSpawn.facingDirection;

	        if (enumfacing == EnumFacing.NORTH)
	        {
	            i = MathHelper.floor(TempAntiMobSpawn.posX + (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.WEST)
	        {
	            k = MathHelper.floor(TempAntiMobSpawn.posZ - (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.SOUTH)
	        {
	            i = MathHelper.floor(TempAntiMobSpawn.posX - (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.EAST)
	        {
	            k = MathHelper.floor(TempAntiMobSpawn.posZ + (double)(p_77008_2_ / 16.0F));
	        }

	        int l = this.renderManager.world.getCombinedLight(new BlockPos(i, j, k), 0);
	        int i1 = l % 65536;
	        int j1 = l / 65536;
	        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1);
	        GlStateManager.color(1.0F, 1.0F, 1.0F);
	    }
}

 

ItemAttachableEntity

Spoiler


public class ItemAttachableEntity extends Item
{
    private final Class <? extends EntityAttachable > hangingEntityClass;

    public ItemAttachableEntity(Class <? extends EntityAttachable > entityClass)
    {
        this.hangingEntityClass = entityClass;
        this.setCreativeTab(Apotropaic.creativeTab);
    }

    /**
     * Called when a Block is right-clicked with this Item
     */
    public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        ItemStack itemstack = player.getHeldItem(hand);
        BlockPos blockpos = pos.offset(facing);

        if (facing != EnumFacing.DOWN && facing != EnumFacing.UP && player.canPlayerEdit(blockpos, facing, itemstack))
        {
            EntityAttachable entityhanging = this.createEntity(worldIn, blockpos, facing);

            if (entityhanging != null && entityhanging.onValidSurface())
            {
                if (!worldIn.isRemote)
                {
                    entityhanging.playPlaceSound();
                    worldIn.spawnEntity(entityhanging);
                }

                itemstack.shrink(1);
            }

            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }

    @Nullable
    private EntityAttachable createEntity(World worldIn, BlockPos pos, EnumFacing clickedSide)
    {
        if (this.hangingEntityClass == EntityPainting.class)
        {
            return new EntityPainting(worldIn, pos, clickedSide);
        }
        else
        {
            return this.hangingEntityClass == EntityItemFrame.class ? new EntityItemFrame(worldIn, pos, clickedSide) : null;
        }
    }
}

 

ModItem

Spoiler


@ObjectHolder(Apotropaic.MOD_ID)
public class ModItems {
	
	public static final ItemAttachableEntity ATTACHABLE = new ItemAttachableEntity(EntityVanishingPainting.class);


	/**
	 * Initialise this mod's {@link Item}s with any post-registration data.
	 */
	public static void initialiseItems() {
		
	}

	@Mod.EventBusSubscriber
	public static class RegistrationHandler {
		public static final Set<Item> ITEMS = new HashSet<>();

		/**
		 * Register this mod's {@link Item}s.
		 *
		 * @param event The event
		 */
		@SubscribeEvent
		public static void registerItems(final RegistryEvent.Register<Item> event) {
			final Item[] items = {
					ATTACHABLE,
			};

			final IForgeRegistry<Item> registry = event.getRegistry();

			for (final Item item : items) {
				registry.register(item);
				ITEMS.add(item);
			}
		}
	}
}

 

 

Currently the new issue is Attempted to register a entry with a null name: I'm trying to figure that out. It's a strange setup that Chroonster has.

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

5 minutes ago, Stroam said:

Currently the new issue is Attempted to register a entry with a null name: I'm trying to figure that out. It's a strange setup that Chroonster has.

 

You need to set the registry name of an IForgeRegistryEntry before registering it. I do this in the constructors of my Items/Blocks.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Thank you very much. Saved me a bit of time searching all around. I'm now closer than ever!

currently the two issues I have:

Spoiler

Exception loading model for variant apotropaic:painting#inventory for item "apotropaic:painting"

caused by apotropaic:models/item/painting.json

Exception loading model for variant apotropaic:painting#inventory for item "apotropaic:painting", blockstate location exception: 

Which is because I have yet to setup the model, jsons, or texture file which is what I'll be tackling first.

the second is when ever I try to place the untextured block all I get is smoke particles. I think I know the general area that resides in. 

 

 

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

Alright I have not progressed at all. Minecraft no longer gives me errors but I have failed to be able to get an icon, get a painting, place a painting.

I've tried these json configurations and I put them in the models.item folder.

Spoiler

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "items/painting"
    },
    "display": {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}

 

Spoiler

{
    "parent": "item/generated",
    "textures": {
        "layer0": "items/painting"
    }
}

I have a the same painting.png as the vanilla one in textures.items

I also created textures.paintings folder like they have in vanilla and it has the same png

What am I doing wrong. If you need any further files let me know.

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

There aren't any model errors in the log.

 

What does the item render as? Where are you registering the model? Post your code.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

code

Spoiler

itemApotropaic

Spoiler


public class ItemApotropaic extends Item {
	public ItemApotropaic(final String itemName) {
		setItemName(this, itemName);
		setCreativeTab(Apotropaic.creativeTab);
	}

	/**
	 * Set the registry name of {@code item} to {@code itemName} and the unlocalised name to the full registry name.
	 *
	 * @param item     The item
	 * @param itemName The item's name
	 */
	public static void setItemName(final Item item, final String itemName) {
		item.setRegistryName(Apotropaic.MOD_ID, itemName);
		item.setUnlocalizedName(item.getRegistryName().toString());
	}
}

 

itemAttachableEntity

Spoiler


public class ItemAttachableEntity extends Item
{
    private final Class <? extends EntityAttachable > AttachableEntityClass;

    public ItemAttachableEntity(Class <? extends EntityAttachable > entityClass, final String itemName)
    {
        this.AttachableEntityClass = entityClass;
        ItemApotropaic.setItemName(this, itemName);
        this.setCreativeTab(Apotropaic.creativeTab);
    }

    /**
     * Called when a Block is right-clicked with this Item
     */
    public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        ItemStack itemstack = player.getHeldItem(hand);
        BlockPos blockpos = pos.offset(facing);

        if (facing != EnumFacing.DOWN && facing != EnumFacing.UP && player.canPlayerEdit(blockpos, facing, itemstack))
        {
            EntityAttachable EntityAttachable = this.createEntity(worldIn, blockpos, facing);

            if (EntityAttachable != null && EntityAttachable.onValidSurface())
            {
                if (!worldIn.isRemote)
                {
                    EntityAttachable.playPlaceSound();
                    worldIn.spawnEntity(EntityAttachable);
                }

                itemstack.shrink(1);
            }

            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }

    @Nullable
    private EntityAttachable createEntity(World worldIn, BlockPos pos, EnumFacing clickedSide)
    {
        //if (this.AttachableEntityClass == EntityVanishingPainting.class)
        
        return new EntityVanishingPainting(worldIn, pos, clickedSide);
    }
}

 

entityAttachable

Spoiler



public abstract class EntityAttachable extends Entity{
	
	private static final Predicate<Entity> IS_HANGING_ENTITY = new Predicate<Entity>()
    {
        public boolean apply(@Nullable Entity entity)
        {
            return entity instanceof EntityAttachable;
        }
    };
    private int tickCounter1;
    protected BlockPos hangingPosition;
    /** The direction the entity is facing */
    @Nullable
    public EnumFacing facingDirection;

    public EntityAttachable(World worldIn)
    {
        super(worldIn);
        this.setSize(0.5F, 0.5F);
    }

    public EntityAttachable(World worldIn, BlockPos hangingPositionIn)
    {
        this(worldIn);
        this.hangingPosition = hangingPositionIn;
    }

    protected void entityInit()
    {
    }

    /**
     * Updates facing and bounding box based on it
     */
    protected void updateFacingWithBoundingBox(EnumFacing facingDirectionIn)
    {
        Validate.notNull(facingDirectionIn);
        Validate.isTrue(facingDirectionIn.getAxis().isHorizontal());
        this.facingDirection = facingDirectionIn;
        this.rotationYaw = (float)(this.facingDirection.getHorizontalIndex() * 90);
        this.prevRotationYaw = this.rotationYaw;
        this.updateBoundingBox();
    }

    /**
     * Updates the entity bounding box based on current facing
     */
    protected void updateBoundingBox()
    {
        if (this.facingDirection != null)
        {
            double d0 = (double)this.hangingPosition.getX() + 0.5D;
            double d1 = (double)this.hangingPosition.getY() + 0.5D;
            double d2 = (double)this.hangingPosition.getZ() + 0.5D;
            double d3 = 0.46875D;
            double d4 = this.offs(this.getWidthPixels());
            double d5 = this.offs(this.getHeightPixels());
            d0 = d0 - (double)this.facingDirection.getFrontOffsetX() * 0.46875D;
            d2 = d2 - (double)this.facingDirection.getFrontOffsetZ() * 0.46875D;
            d1 = d1 + d5;
            EnumFacing enumfacing = this.facingDirection.rotateYCCW();
            d0 = d0 + d4 * (double)enumfacing.getFrontOffsetX();
            d2 = d2 + d4 * (double)enumfacing.getFrontOffsetZ();
            this.posX = d0;
            this.posY = d1;
            this.posZ = d2;
            double d6 = (double)this.getWidthPixels();
            double d7 = (double)this.getHeightPixels();
            double d8 = (double)this.getWidthPixels();

            if (this.facingDirection.getAxis() == EnumFacing.Axis.Z)
            {
                d8 = 1.0D;
            }
            else
            {
                d6 = 1.0D;
            }

            d6 = d6 / 32.0D;
            d7 = d7 / 32.0D;
            d8 = d8 / 32.0D;
            this.setEntityBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8));
        }
    }

    private double offs(int p_190202_1_)
    {
        return p_190202_1_ % 32 == 0 ? 0.5D : 0.0D;
    }

    /**
     * Called to update the entity's position/logic.
     */
    public void onUpdate()
    {
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;

        if (this.tickCounter1++ == 100 && !this.world.isRemote)
        {
            this.tickCounter1 = 0;

            if (!this.isDead && !this.onValidSurface())
            {
                this.setDead();
                this.onBroken((Entity)null);
            }
        }
    }

    /**
     * checks to make sure painting can be placed there
     */
    public boolean onValidSurface()
    {
        if (!this.world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty())
        {
            return false;
        }
        else
        {
            int i = Math.max(1, this.getWidthPixels() / 16);
            int j = Math.max(1, this.getHeightPixels() / 16);
            BlockPos blockpos = this.hangingPosition.offset(this.facingDirection.getOpposite());
            EnumFacing enumfacing = this.facingDirection.rotateYCCW();
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

            for (int k = 0; k < i; ++k)
            {
                for (int l = 0; l < j; ++l)
                {
                    int i1 = (i - 1) / -2;
                    int j1 = (j - 1) / -2;
                    blockpos$mutableblockpos.setPos(blockpos).move(enumfacing, k + i1).move(EnumFacing.UP, l + j1);
                    IBlockState iblockstate = this.world.getBlockState(blockpos$mutableblockpos);

                    if (iblockstate.isSideSolid(this.world, blockpos$mutableblockpos, this.facingDirection))
                        continue;

                    if (!iblockstate.getMaterial().isSolid() && !BlockRedstoneDiode.isDiode(iblockstate))
                    {
                        return false;
                    }
                }
            }

            return this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), IS_HANGING_ENTITY).isEmpty();
        }
    }

    /**
     * Returns true if other Entities should be prevented from moving through this Entity.
     */
    public boolean canBeCollidedWith()
    {
        return true;
    }

    /**
     * Called when a player attacks an entity. If this returns true the attack will not happen.
     */
    public boolean hitByEntity(Entity entityIn)
    {
        return entityIn instanceof EntityPlayer ? this.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)entityIn), 0.0F) : false;
    }

    /**
     * Gets the horizontal facing direction of this Entity.
     */
    public EnumFacing getHorizontalFacing()
    {
        return this.facingDirection;
    }

    /**
     * Called when the entity is attacked.
     */
    public boolean attackEntityFrom(DamageSource source, float amount)
    {
        if (this.isEntityInvulnerable(source))
        {
            return false;
        }
        else
        {
            if (!this.isDead && !this.world.isRemote)
            {
                this.setDead();
                this.setBeenAttacked();
                this.onBroken(source.getTrueSource());
            }

            return true;
        }
    }

    /**
     * Tries to move the entity towards the specified location.
     */
    public void move(MoverType type, double x, double y, double z)
    {
        if (!this.world.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D)
        {
            this.setDead();
            this.onBroken((Entity)null);
        }
    }

    /**
     * Adds to the current velocity of the entity.
     */
    public void addVelocity(double x, double y, double z)
    {
        if (!this.world.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D)
        {
            this.setDead();
            this.onBroken((Entity)null);
        }
    }

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    public void writeEntityToNBT(NBTTagCompound compound)
    {
        compound.setByte("Facing", (byte)this.facingDirection.getHorizontalIndex());
        BlockPos blockpos = this.getHangingPosition();
        compound.setInteger("TileX", blockpos.getX());
        compound.setInteger("TileY", blockpos.getY());
        compound.setInteger("TileZ", blockpos.getZ());
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    public void readEntityFromNBT(NBTTagCompound compound)
    {
        this.hangingPosition = new BlockPos(compound.getInteger("TileX"), compound.getInteger("TileY"), compound.getInteger("TileZ"));
        this.updateFacingWithBoundingBox(EnumFacing.getHorizontal(compound.getByte("Facing")));
    }

    public abstract int getWidthPixels();

    public abstract int getHeightPixels();

    /**
     * Called when this entity is broken. Entity parameter may be null.
     */
    public abstract void onBroken(@Nullable Entity brokenEntity);

    public abstract void playPlaceSound();

    /**
     * Drops an item at the position of the entity.
     */
    public EntityItem entityDropItem(ItemStack stack, float offsetY)
    {
        EntityItem entityitem = new EntityItem(this.world, this.posX + (double)((float)this.facingDirection.getFrontOffsetX() * 0.15F), this.posY + (double)offsetY, this.posZ + (double)((float)this.facingDirection.getFrontOffsetZ() * 0.15F), stack);
        entityitem.setDefaultPickupDelay();
        this.world.spawnEntity(entityitem);
        return entityitem;
    }

    protected boolean shouldSetPosAfterLoading()
    {
        return false;
    }

    /**
     * Sets the x,y,z of the entity from the given parameters. Also seems to set up a bounding box.
     */
    public void setPosition(double x, double y, double z)
    {
        this.hangingPosition = new BlockPos(x, y, z);
        this.updateBoundingBox();
        this.isAirBorne = true;
    }

    public BlockPos getHangingPosition()
    {
        return this.hangingPosition;
    }

    /**
     * Transforms the entity's current yaw with the given Rotation and returns it. This does not have a side-effect.
     */
    @SuppressWarnings("incomplete-switch")
    public float getRotatedYaw(Rotation transformRotation)
    {
        if (this.facingDirection != null && this.facingDirection.getAxis() != EnumFacing.Axis.Y)
        {
            switch (transformRotation)
            {
                case CLOCKWISE_180:
                    this.facingDirection = this.facingDirection.getOpposite();
                    break;
                case COUNTERCLOCKWISE_90:
                    this.facingDirection = this.facingDirection.rotateYCCW();
                    break;
                case CLOCKWISE_90:
                    this.facingDirection = this.facingDirection.rotateY();
            }
        }

        float f = MathHelper.wrapDegrees(this.rotationYaw);

        switch (transformRotation)
        {
            case CLOCKWISE_180:
                return f + 180.0F;
            case COUNTERCLOCKWISE_90:
                return f + 90.0F;
            case CLOCKWISE_90:
                return f + 270.0F;
            default:
                return f;
        }
    }

    /**
     * Transforms the entity's current yaw with the given Mirror and returns it. This does not have a side-effect.
     */
    public float getMirroredYaw(Mirror transformMirror)
    {
        return this.getRotatedYaw(transformMirror.toRotation(this.facingDirection));
    }

    /**
     * Called when a lightning bolt hits the entity.
     */
    public void onStruckByLightning(EntityLightningBolt lightningBolt)
    {
    }

}

 

entityvanishingpainting

Spoiler


public class EntityVanishingPainting extends EntityAttachable{
	
	private static final DataParameter<Integer> DURATION = EntityDataManager.<Integer>createKey(EntityVanishingPainting.class,
			DataSerializers.VARINT);
	
	private int duration;
	private int tickCounter1;

	public EntityVanishingPainting(World worldIn)
    {
        super(worldIn);
        this.duration = 80;
        this.setSize(0.5F, 0.5F);
    }

    public EntityVanishingPainting(World worldIn, BlockPos pos, EnumFacing facing)
    {
        super(worldIn, pos);
        this.updateFacingWithBoundingBox(facing);
    }
    
    @Override
    protected void entityInit()
    {
        this.dataManager.register(DURATION, Integer.valueOf(80));
    }
    
    /**
     * Called to update the entity's position/logic.
     */
    @Override
    public void onUpdate()
    {
    	
    	this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;

        if (this.tickCounter1++ == 20 && !this.world.isRemote)
        {
            this.tickCounter1 = 0;

            if (!this.isDead && !this.onValidSurface())
            {
                this.setDead();
                this.onBroken((Entity)null);
            }
        }

        --this.duration;

        if (this.duration <= 0)
        {
            this.setDead();

            if (!this.world.isRemote)
            {
                this.burnUp();
            }
        }
        else
        {
            this.handleWaterMovement();
            //this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
        }
    }

	@Override
	public int getWidthPixels() {
		return 6;
	}

	@Override
	public int getHeightPixels() {
		return 12;
	}

	@Override
	public void onBroken(Entity brokenEntity) {
		if (this.world.getGameRules().getBoolean("doEntityDrops"))
        {
			this.playSound(SoundEvents.ENTITY_PAINTING_BREAK, 1.0F, 1.0F);
			
			if (brokenEntity instanceof EntityPlayer)
            {
				EntityPlayer entityplayer = (EntityPlayer)brokenEntity;

                if (entityplayer.capabilities.isCreativeMode)
                {
                    return;
                }
            }
			this.setDead();
			this.burnUp();
            //this.entityDropItem(new ItemStack(this), 0.0F);
        }
	}

	@Override
	public void playPlaceSound() {
		this.playSound(SoundEvents.ENTITY_PAINTING_PLACE, 1.0F, 1.0F);
		
	}
	
	private void burnUp()
	{
		world.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, 0, 0, 0, new int[0]);
	}
	
	@Override
	public void writeEntityToNBT(NBTTagCompound compound)
    {
        compound.setShort("DURATION", (short)this.getDuration());
    }
	
	@Override
	public void readEntityFromNBT(NBTTagCompound compound)
	{
		this.setDuration(compound.getShort("DURATION"));
	}
	
	public void setDuration(int time) 
	{
		this.dataManager.set(DURATION, Integer.valueOf(time));
	}
	
	public void notifyDataMangerChange(DataParameter<?> key)
	{
		if (DURATION.equals(key))
		{
			this.duration = this.getDurationDataManger();
		}
	}
	
	/**
	 * Gets the duration from the data manager
	 */
	public int getDurationDataManger() 
	{
		return ((Integer)this.dataManager.get(DURATION)).intValue();
	}

	public int getDuration() 
	{
		return this.duration;
	}
	
	

}

 

renderVanishingpainting

Spoiler


@SideOnly(Side.CLIENT)
public class RenderVanishingPainting extends Render<EntityVanishingPainting>
{
	 //private static final ResourceLocation KRISTOFFER_TempAntiMobSpawn_TEXTURE = new ResourceLocation("textures/entity/papertalisman.png");
	private final ResourceLocation entityTexture;
	
	    public RenderVanishingPainting(final RenderManager renderManagerIn, final ResourceLocation entityTexture)
	    {
	        super(renderManagerIn);
	        this.entityTexture = entityTexture;
	    }
	    
	    protected ResourceLocation getEntityTexture(final EntityVanishingPainting entity)
	    {
	    	return entityTexture;
	    }

	    /**
	     * Renders the desired {@code T} type Entity.
	     */
	    public void doRender(EntityVanishingPainting entity, double x, double y, double z, float entityYaw, float partialTicks)
	    {
	        GlStateManager.pushMatrix();
	        GlStateManager.translate(x, y, z);
	        GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F);
	        GlStateManager.enableRescaleNormal();
	        this.bindEntityTexture(entity);
	        float f = 0.0625F;
	        GlStateManager.scale(0.0625F, 0.0625F, 0.0625F);

	        if (this.renderOutlines)
	        {
	            GlStateManager.enableColorMaterial();
	            GlStateManager.enableOutlineMode(this.getTeamColor(entity));
	        }

	        this.renderTempAntiMobSpawn(entity, 6, 12, 6, 3); //width height starting x and y positions

	        if (this.renderOutlines)
	        {
	            GlStateManager.disableOutlineMode();
	            GlStateManager.disableColorMaterial();
	        }

	        GlStateManager.disableRescaleNormal();
	        GlStateManager.popMatrix();
	        super.doRender(entity, x, y, z, entityYaw, partialTicks);
	    }

	    private void renderTempAntiMobSpawn(EntityVanishingPainting TempAntiMobSpawn, int width, int height, int textureU, int textureV)
	    {
	        float f = (float)(-width) / 2.0F;
	        float f1 = (float)(-height) / 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 i = 0; i < width / 16; ++i)
	        {
	            for (int j = 0; j < height / 16; ++j)
	            {
	                float f15 = f + (float)((i + 1) * 16);
	                float f16 = f + (float)(i * 16);
	                float f17 = f1 + (float)((j + 1) * 16);
	                float f18 = f1 + (float)(j * 16);
	                this.setLightmap(TempAntiMobSpawn, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F);
	                float f19 = (float)(textureU + width - i * 16) / 256.0F;
	                float f20 = (float)(textureU + width - (i + 1) * 16) / 256.0F;
	                float f21 = (float)(textureV + height - j * 16) / 256.0F;
	                float f22 = (float)(textureV + height - (j + 1) * 16) / 256.0F;
	                Tessellator tessellator = Tessellator.getInstance();
	                BufferBuilder bufferbuilder = tessellator.getBuffer();
	                bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex((double)f20, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex((double)f19, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex((double)f19, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex((double)f20, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.75D, 0.0D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.8125D, 0.0D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.8125D, 0.0625D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.75D, 0.0625D).normal(0.0F, 0.0F, 1.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex(0.75D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.75D, 0.001953125D).normal(0.0F, 1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.75D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex(0.8125D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex(0.75D, 0.001953125D).normal(0.0F, -1.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, 0.5D).tex(0.751953125D, 0.0D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, 0.5D).tex(0.751953125D, 0.0625D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f18, -0.5D).tex(0.751953125D, 0.0625D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f15, (double)f17, -0.5D).tex(0.751953125D, 0.0D).normal(-1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, -0.5D).tex(0.751953125D, 0.0D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, -0.5D).tex(0.751953125D, 0.0625D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f18, 0.5D).tex(0.751953125D, 0.0625D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                bufferbuilder.pos((double)f16, (double)f17, 0.5D).tex(0.751953125D, 0.0D).normal(1.0F, 0.0F, 0.0F).endVertex();
	                tessellator.draw();
	            }
	        }
	    }

	    private void setLightmap(EntityVanishingPainting TempAntiMobSpawn, float p_77008_2_, float p_77008_3_)
	    {
	        int i = MathHelper.floor(TempAntiMobSpawn.posX);
	        int j = MathHelper.floor(TempAntiMobSpawn.posY + (double)(p_77008_3_ / 16.0F));
	        int k = MathHelper.floor(TempAntiMobSpawn.posZ);
	        EnumFacing enumfacing = TempAntiMobSpawn.facingDirection;

	        if (enumfacing == EnumFacing.NORTH)
	        {
	            i = MathHelper.floor(TempAntiMobSpawn.posX + (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.WEST)
	        {
	            k = MathHelper.floor(TempAntiMobSpawn.posZ - (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.SOUTH)
	        {
	            i = MathHelper.floor(TempAntiMobSpawn.posX - (double)(p_77008_2_ / 16.0F));
	        }

	        if (enumfacing == EnumFacing.EAST)
	        {
	            k = MathHelper.floor(TempAntiMobSpawn.posZ + (double)(p_77008_2_ / 16.0F));
	        }

	        int l = this.renderManager.world.getCombinedLight(new BlockPos(i, j, k), 0);
	        int i1 = l % 65536;
	        int j1 = l / 65536;
	        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1);
	        GlStateManager.color(1.0F, 1.0F, 1.0F);
	    }
}

 

ModItems

Spoiler


@ObjectHolder(Apotropaic.MOD_ID)
public class ModItems {
	
	public static final ItemAttachableEntity ATTACHABLE = new ItemAttachableEntity(EntityVanishingPainting.class, "painting");


	/**
	 * Initialise this mod's {@link Item}s with any post-registration data.
	 */
	public static void initialiseItems() {
		
	}

	@Mod.EventBusSubscriber
	public static class RegistrationHandler {
		public static final Set<Item> ITEMS = new HashSet<>();

		/**
		 * Register this mod's {@link Item}s.
		 *
		 * @param event The event
		 */
		@SubscribeEvent
		public static void registerItems(final RegistryEvent.Register<Item> event) {
			final Item[] items = {
					ATTACHABLE,
			};

			final IForgeRegistry<Item> registry = event.getRegistry();

			for (final Item item : items) {
				registry.register(item);
				ITEMS.add(item);
			}
		}
	}
}

 

ModEntities

Spoiler


public class ModEntities {
	public static void registerEntities() {
		registerEntity(EntityVanishingPainting.class, "paper_talisman", 64, 20, false);
	}

	public static void addSpawns() {
		
	}

	/**
	 * Get an array of {@link Biome}s with the specified {@link BiomeDictionary.Type}.
	 *
	 * @param type The Type
	 * @return An array of Biomes
	 */
	private static Biome[] getBiomes(final BiomeDictionary.Type type) {
		return BiomeDictionary.getBiomes(type).toArray(new Biome[0]);
	}


	/**
	 * Add a spawn list entry for {@code classToAdd} in each {@link Biome} with an entry for {@code classToCopy} using the same weight and group count.
	 *
	 * @param classToAdd         The class to add spawn entries for
	 * @param creatureTypeToAdd  The EnumCreatureType to add spawn entries for
	 * @param classToCopy        The class to copy spawn entries from
	 * @param creatureTypeToCopy The EnumCreatureType to copy spawn entries from
	 */
	private static void copySpawns(final Class<? extends EntityLiving> classToAdd, final EnumCreatureType creatureTypeToAdd, final Class<? extends EntityLiving> classToCopy, final EnumCreatureType creatureTypeToCopy) {
		for (final Biome biome : ForgeRegistries.BIOMES) {
			biome.getSpawnableList(creatureTypeToCopy).stream()
					.filter(entry -> entry.entityClass == classToCopy)
					.findFirst()
					.ifPresent(spawnListEntry ->
							biome.getSpawnableList(creatureTypeToAdd).add(new Biome.SpawnListEntry(classToAdd, spawnListEntry.itemWeight, spawnListEntry.minGroupCount, spawnListEntry.maxGroupCount))
					);
		}
	}

	private static int entityID = 0;

	/**
	 * Register an entity with the specified tracking values.
	 *
	 * @param entityClass          The entity's class
	 * @param entityName           The entity's unique name
	 * @param trackingRange        The range at which MC will send tracking updates
	 * @param updateFrequency      The frequency of tracking updates
	 * @param sendsVelocityUpdates Whether to send velocity information packets as well
	 */
	private static void registerEntity(final Class<? extends Entity> entityClass, final String entityName, final int trackingRange, final int updateFrequency, final boolean sendsVelocityUpdates) {
		final ResourceLocation registryName = new ResourceLocation(Apotropaic.MOD_ID, entityName);
		EntityRegistry.registerModEntity(registryName, entityClass, registryName.toString(), entityID++, Apotropaic.instance, trackingRange, updateFrequency, sendsVelocityUpdates);
	}

	/**
	 * Register an entity with the specified tracking values and spawn egg colours.
	 *
	 * @param entityClass          The entity's class
	 * @param entityName           The entity's unique name
	 * @param trackingRange        The range at which MC will send tracking updates
	 * @param updateFrequency      The frequency of tracking updates
	 * @param sendsVelocityUpdates Whether to send velocity information packets as well
	 * @param eggPrimary           The spawn egg's primary (background) colour
	 * @param eggSecondary         The spawn egg's secondary (foreground) colour
	 */
	private static void registerEntity(final Class<? extends Entity> entityClass, final String entityName, final int trackingRange, final int updateFrequency, final boolean sendsVelocityUpdates, final int eggPrimary, final int eggSecondary) {
		final ResourceLocation registryName = new ResourceLocation(Apotropaic.MOD_ID, entityName);
		EntityRegistry.registerModEntity(registryName, entityClass, registryName.toString(), entityID++, Apotropaic.instance, trackingRange, updateFrequency, sendsVelocityUpdates, eggPrimary, eggSecondary);
	}
}

 

ModRenderers

Spoiler


public class ModRenderers {
	public static void register() {
		RenderingRegistry.registerEntityRenderingHandler(EntityVanishingPainting.class, renderManager -> new RenderVanishingPainting(renderManager, new ResourceLocation(Apotropaic.MOD_ID, "textures/entity/mod_arrow.png")));
	}

}

 

Apotropaic

Spoiler


@Mod(modid = Apotropaic.MOD_ID, name = Apotropaic.MOD_NAME, acceptedMinecraftVersions = "[1.12]",useMetadata = false, 
dependencies = Reference.DEPENDENCIES)
public class Apotropaic
{
	public static final String MOD_ID = "apotropaic";
	public static final String MOD_NAME = "Ouroboros Apotropaic";

	public static final CreativeTabApotropaic creativeTab = new CreativeTabApotropaic();
	
	@SidedProxy(clientSide = "com.stroam.apotropaic.proxy.ClientProxy", serverSide = "com.stroam.apotropaic.proxy.ServerProxy")
	public static IProxy proxy;
	
	@Instance
	public static Apotropaic instance;
	
	public static SimpleNetworkWrapper network;

	public Apotropaic() {}
	
	static {
		FluidRegistry.enableUniversalBucket(); //must be called before preInit
	}

	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		com.stroam.apotropaic.Logger.setLogger(event.getModLog());
	
		network = NetworkRegistry.INSTANCE.newSimpleChannel(Apotropaic.MOD_ID);

		ModItems.initialiseItems();
		ModEntities.registerEntities();
		
		proxy.preInit();
	}

	@EventHandler
	public void init(final FMLInitializationEvent event) {

		proxy.init();
	}

	@EventHandler
	public void postInit(final FMLPostInitializationEvent event) {

		proxy.postInit();

	}



}

 

 

 

 

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

Where do you call ModRenderers.register from? Where do you register your item models?

 

Post a screenshot of the item.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

ModRenderers is called from preInit in ClientProxy

ModModelManager calls the item models

 

I'm going to take the time to make a git repo for this real quick. Thanks for the help. I hope this makes it go quicker.

 

I've identified an issue with the item models. I'd like to see if I can solve it first before uploading. 

I have an icon!!! ...but it still doesn't do anything except play the placePainting noise.

I'm almost there. Just need it to make an actual painting which I think I've got a clue where I need to do some changes. Also it's not listening to my en_us.lang and I don't know why. Github repo

Edited by Stroam

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

Fixed the .lang file

I fixed what I thought was causing the issue with placing the painting and it didn't work. So now I'm tired and clueless. The repo is up to date from the last post. Going to sleep on in and come back on it in the morning.

Edited by Stroam

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

32 minutes ago, Stroam said:

I fixed what I thought was causing the issue with placing the painting and it didn't work. So now I'm tired and clueless. The en_us.lang I know is and easy fix but I can't for the life of me figure it out. The repo is up to date. Going to keep beating my head against the wall till I pass out or it starts working. If I don't reply withing 15 minutes of a post, assume I passed out.

 

You have two lang files, but neither is correct. You have one with the right name in the wrong location and one with the wrong name in the right location.


The correct location and name is assets/<modid>/lang/en_us.lang (when you have a pack.mcmeta file with pack_format set to 3).

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

1 minute ago, Choonster said:

 

You have two lang files, but neither is correct. You have one with the correct name in the wrong location and one with the wrong name in the correct location.


The correct location and name is assets/<modid>/lang/en_us.lang (when you have a pack.mcmeta file with pack_format set to 3).

Thanks. Just figured it out. Didn't know about the pack.meta stuff though. Still not getting it to place the painting but everything else is working. I'm going to tear into it again tomorrow.

You don't need to point out what's wrong with the programmer. I already know. Now what's wrong with the code?

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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