Jump to content

[1.7.2]Item turned 90 degrees in inventory


arktheoverlord

Recommended Posts

I have just started on writing a mod that is adding a custom furnace. After following the tutorial twice, the item in the inventory  keeps facing the wrong way. I've been facing this problem for about two days now and it's starting to annoy me greatly.

 

This is my code:

package net.twp.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.twp.ArkTWP;
import net.twp.registry.BlockRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockAlloyFurnace extends BlockContainer{

private final boolean isActive;
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;

public BlockAlloyFurnace(boolean isActive) {
	super(Material.iron);
	this.isActive = isActive;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister){
	this.blockIcon = iconRegister.registerIcon(ArkTWP.modID + ":AlloyFurnaceSide");
	this.iconFront = iconRegister.registerIcon(ArkTWP.modID + ":" + (this.isActive ? "AlloyFurnaceActive" : "AlloyFurnaceIdle"));
	this.iconTop = iconRegister.registerIcon(ArkTWP.modID + ":AlloyFurnaceTop"); 
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
	//return meta == 0 && side == 3 ? this.iconFront : (side == meta ? this.iconFront: this.blockIcon);
	return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : (side != metadata ? this.blockIcon : this.iconFront));
}

public Item getItemDropped(World world, int x, int y, int z){
	return Item.getItemFromBlock(ArkTWP.AlloyFurnaceIdle);
}

@Override
public void onBlockAdded(World world, int x, int y, int z){
	super.onBlockAdded(world, x, y, z);
	this.setDefaultDirection(world, x, y, z);
}

private void setDefaultDirection(World world, int x, int y, int z) {
	if(!world.isRemote){
		Block b1 = world.getBlock(x, y, z - 1);
		Block b2 = world.getBlock(x, y, z + 1);
		Block b3 = world.getBlock(x - 1, y, z);
		Block b4 = world.getBlock(x + 1, y, z);
		byte b0 = 3;
		if(b1.isNormalCube() && !b2.isNormalCube()){
			b0 = 3;
		}
		if(b2.isNormalCube() && !b1.isNormalCube()){
			b0 = 2;
		}
		if(b3.isNormalCube() && !b4.isNormalCube()){
			b0 = 5;
		}
		if(b4.isNormalCube() && !b3.isNormalCube()){
			b0 = 4;
		}

		world.setBlockMetadataWithNotify(x, y, z, b0, 2);
	}
}

@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return null;
}

@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityPlayer, ItemStack itemStack){
	int l = MathHelper.floor_double((double)(entityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

	if(l == 0){
		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
	}
	if(l == 1){
		world.setBlockMetadataWithNotify(x, y, z, 5, 2);
	}
	if(l == 2){
		world.setBlockMetadataWithNotify(x, y, z, 3, 2);
	}
	if(l == 3){
		world.setBlockMetadataWithNotify(x, y, z, 4, 2);
	}
	if(itemStack.hasDisplayName()){
		//TODO ((TileEntityAlloyFurnace)world.getTileEntity(x, y, z).setGuiDisplayName(itemstack.getDisplyName());
                        //I have yet to get to this, this problem has been taking most of my time.
	}
}

}

Link to comment
Share on other sites

You need to make sure that if the variable "side" is equivalent to 3 you have to give back the front texture. This applies only when the block is in the inventory. In other cases, you must use the metadata. I can not tell if it is fully correct. I have just getting started.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Recently started to attempt 1.20.1 modding, in registering idle, walk and attack animations in the mob entity class i've run into two issues:   a) idle and walk animations seem to play simultaneously  + the mob itself does not seem to walk private static final EntityDataAccessor<Boolean> ATTACKING = SynchedEntityData.defineId(MugaEntity.class, EntityDataSerializers.BOOLEAN); public MugaEntity(EntityType<? extends Monster > pEntityType, Level pLevel) { super(pEntityType, pLevel); } public final AnimationState idleAnimationState = new AnimationState(); private int idleAnimationTimeout = 1; p ublic final AnimationState attackAnimationState = new AnimationState(); public int attackAnimationTimeout = 0; @Override public void tick() { super.tick(); if(this.level().isClientSide()) { setupAnimationStates(); } } private void setupAnimationStates () { if(this.idleAnimationTimeout <= 0) { this.idleAnimationTimeout = this.random.nextInt(30) + 60; this.idleAnimationState.start(this.tickCount); } else { --this.idleAnimationTimeout; } if (this.isAttacking() && attackAnimationTimeout <= 0 ) { attackAnimationTimeout = 20; attackAnimationState.start(this.tickCount); } else { --this.attackAnimationTimeout; } if(this.isAttacking()) { attackAnimationState.stop(); } } @Override protected void updateWalkAnimation(float pPartialTick) { float f; if(this.getPose() == Pose.STANDING) { f=Math.min(pPartialTick * 3.0F, 1.0F); } else { f= 0.0F; } this.walkAnimation.update(f, 0.2F); } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(ATTACKING, false); } public void setAttacking(boolean attacking) { this.entityData.set(ATTACKING, attacking); } public boolean isAttacking() { return this.entityData.get(ATTACKING); } b) the attack animation is never played on attack, despite being registered  @Override public void setupAnim(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.root().getAllParts().forEach(ModelPart::resetPose); this.animateWalk(ModAnimationDefinitions.MUGA_WALKING, limbSwing, limbSwingAmount, 1f, 1f ); this.animate(((MugaEntity)entity).idleAnimationState, ModAnimationDefinitions.MUGA_IDLE, ageInTicks, 1f); t his.animate(((MugaEntity)entity).attackAnimationState, ModAnimationDefinitions.MUGA_ATTACK, ageInTicks, 1f); }
    • Maybe there are some more broken files - check the new crash-report - the file name is mentioned in the first lines   If it is another crash, add it here
    • Thanks. Found and deleted it, but it doesn't change anything. When joining a new file is created, the screen freezes/ does not respond in typical manner and I have to close it then. I deleted it in curseforge>minecraft>instances>Modpack>saves>World>serverconfig Should I have deleted it anywhere else?
    • Do you still need help?
  • Topics

×
×
  • Create New...

Important Information

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