Jump to content

Recommended Posts

Posted

Hey I have two problems, both very weird.

 

1) I have a custom arrow(basically copypasta from vanilla arrow) but it has buggy movement, like when I fire it, it will fire, hit something, then move a block back. Its probably a client/server issue(but isnt position handled by client?) or the way I register it. I dont think you need to see my code cos its copypasta but if you want it, ask. But here is how I register it :

EntityRegistry.registerModEntity(AC_EntityIceShard.class, "IceShard", 5, MainRegistry.instance, 128, 10, true);

and heres a picture on how it looks:

Sh6yrVl.jpg

 

2) The icon texture on my custom furnace is backwards, no idea how to fix.

heres the block code, if you need any more, ask.

 

package arcticraft.blocks;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.Icon;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.minecraftforge.common.ForgeDirection;

import net.minecraftforge.common.RotationHelper;

import arcticraft.main.MainRegistry;

import arcticraft.tile_entities.AC_TileEntityArcticFurnace;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class AC_BlockACFurnace extends BlockContainer

{

 

/**

* Is the random generator used by furnace to drop the inventory contents in

* random directions.

*/

private final Random furnaceRand = new Random();

 

/** True if this is an active furnace, false if idle */

private final boolean isActive;

 

/**

* This flag is used to prevent the furnace inventory to be dropped upon

* block removal, is used internally when the furnace block changes from

* idle to active and vice-versa.

*/

private static boolean keepFurnaceInventory = false;

@SideOnly(Side.CLIENT)

private Icon furnaceIconTop;

@SideOnly(Side.CLIENT)

private Icon furnaceIconFront;

private Icon sideIcon;

private Icon furnaceIconFrontOn;

 

public AC_BlockACFurnace(int par1, boolean par2)

{

super(par1, Material.rock);

this.isActive = par2;

}

 

@Override

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)

{

int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

 

if(l == 0)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2);

}

 

if(l == 1)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2);

}

 

if(l == 2)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);

}

 

if(l == 3)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2);

}

 

if(par6ItemStack.hasDisplayName())

{

((AC_TileEntityArcticFurnace) par1World.getBlockTileEntity(par2, par3, par4)).getInvName();

}

}

 

 

public Icon getIcon(int par1, int par2)

{

return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.sideIcon : this.isActive ? this.furnaceIconFrontOn : this.furnaceIconFront));

}

 

@SideOnly(Side.CLIENT)

/**

* When this method is called, your block should register all the icons it needs with the given IconRegister. This

* is the only chance you get to register icons.

*/

public void registerIcons(IconRegister par1IconRegister)

{

this.sideIcon = par1IconRegister.registerIcon("ac:ac_furnace_side");

this.furnaceIconFront = par1IconRegister.registerIcon("ac:ac_furnace_front_off");

this.furnaceIconTop = par1IconRegister.registerIcon("ac:ac_furnace_top");

this.furnaceIconFrontOn = par1IconRegister.registerIcon("ac:ac_furnace_front_on");

}

 

/**

* Returns the ID of the items to drop on destruction.

*/

public int idDropped(int par1, Random par2Random, int par3)

{

return AC_Block.arcticFurnaceIdle.blockID;

}

 

/**

* Called upon block activation (right click on the block.)

*/

@Override

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t)

{

TileEntity tile_entity = world.getBlockTileEntity(x, y, z);

 

if(tile_entity == null || player.isSneaking())

{

 

return false;

}

 

player.openGui(MainRegistry.instance, 0, world, x, y, z);

 

return true;

}

 

/**

* Update which block ID the furnace is using depending on whether or not it

* is burning

*/

public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4)

{

int l = par1World.getBlockMetadata(par2, par3, par4);

TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);

keepFurnaceInventory = true;

 

if(par0)

{

par1World.setBlock(par2, par3, par4, AC_Block.arcticFurnaceBurning.blockID);

}

else

{

par1World.setBlock(par2, par3, par4, AC_Block.arcticFurnaceIdle.blockID);

}

 

keepFurnaceInventory = false;

par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);

 

if(tileentity != null)

{

tileentity.validate();

par1World.setBlockTileEntity(par2, par3, par4, tileentity);

}

}

 

@SideOnly(Side.CLIENT)

/**

* A randomly called display update to be able to add particles or other items for display

*/

public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

{

if(this.isActive)

{

int l = par1World.getBlockMetadata(par2, par3, par4);

float f = (float) par2 + 0.5F;

float f1 = (float) par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;

float f2 = (float) par4 + 0.5F;

float f3 = 0.52F;

float f4 = par5Random.nextFloat() * 0.6F - 0.3F;

 

if(l == 4)

{

par1World.spawnParticle("smoke", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D);

par1World.spawnParticle("flame", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D);

}

else if(l == 5)

{

par1World.spawnParticle("smoke", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D);

par1World.spawnParticle("flame", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D);

}

else if(l == 2)

{

par1World.spawnParticle("smoke", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D);

par1World.spawnParticle("flame", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D);

}

else if(l == 3)

{

par1World.spawnParticle("smoke", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D);

par1World.spawnParticle("flame", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D);

}

}

}

 

/**

* Returns a new instance of a block's tile entity class. Called on placing

* the block.

*/

public TileEntity createNewTileEntity(World par1World)

{

return new AC_TileEntityArcticFurnace();

}

 

/**

* ejects contained items into the world, and notifies neighbours of an

* update, as appropriate

*/

public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)

{

if(! keepFurnaceInventory)

{

AC_TileEntityArcticFurnace tileentityarcticfurnace = (AC_TileEntityArcticFurnace) par1World.getBlockTileEntity(par2, par3, par4);

 

if(tileentityarcticfurnace != null)

{

for(int j1 = 0; j1 < tileentityarcticfurnace.getSizeInventory(); ++j1)

{

ItemStack itemstack = tileentityarcticfurnace.getStackInSlot(j1);

 

if(itemstack != null)

{

float f = this.furnaceRand.nextFloat() * 0.8F + 0.1F;

float f1 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;

float f2 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;

 

while(itemstack.stackSize > 0)

{

int k1 = this.furnaceRand.nextInt(21) + 10;

 

if(k1 > itemstack.stackSize)

{

k1 = itemstack.stackSize;

}

 

itemstack.stackSize -= k1;

EntityItem entityitem = new EntityItem(par1World, (double) ((float) par2 + f), (double) ((float) par3 + f1), (double) ((float) par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));

 

if(itemstack.hasTagCompound())

{

entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());

}

 

float f3 = 0.05F;

entityitem.motionX = (double) ((float) this.furnaceRand.nextGaussian() * f3);

entityitem.motionY = (double) ((float) this.furnaceRand.nextGaussian() * f3 + 0.2F);

entityitem.motionZ = (double) ((float) this.furnaceRand.nextGaussian() * f3);

par1World.spawnEntityInWorld(entityitem);

}

}

}

 

par1World.func_96440_m(par2, par3, par4, par5);

}

}

 

super.breakBlock(par1World, par2, par3, par4, par5, par6);

}

 

/**

* If this returns true, then comparators facing away from this block will

* use the value from getComparatorInputOverride instead of the actual

* redstone signal strength.

*/

public boolean hasComparatorInputOverride()

{

return true;

}

 

/**

* If hasComparatorInputOverride returns true, the return value from this is

* used instead of the redstone signal strength when this block inputs to a

* comparator.

*/

public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)

{

return Container.calcRedstoneFromInventory((IInventory) par1World.getBlockTileEntity(par2, par3, par4));

}

}

 

 

 

screenshot:

lNr6vZx.png

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



×
×
  • Create New...

Important Information

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