Jump to content

Recommended Posts

Posted

Yeah i have problems with the fulids^^"

 

Now the flowing part and the pumping in a tank works fine.

But the fluid is not registered in the fluid dictionary

and the name will be showen as: Fluid.Animal Gas

Also the texture does not work!

 

ConfigClass (Registerring)

package speiger.src.api.common.config;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import speiger.src.api.common.blocks.BlockGas;
import speiger.src.api.common.functions.PathProxy;
import speiger.src.api.common.functions.TextureRegister;
import speiger.src.api.common.items.ItemGasAbsorber;
import speiger.src.api.common.items.ItemGasBucket;
import speiger.src.api.common.items.LiquidContainer;
import speiger.src.api.common.items.itemblocks.ItemBlockGas;
import speiger.src.api.common.lib.APIIDs;
import speiger.src.api.common.lib.APIStrings;

public class APIItemBlockConfig
{
  public static ConfigCore cc;
  public static APIItems ai;
  public static APIIDs ids;
  public static APIStrings as;
  public static TextureRegister at;
  public static boolean isBetas = true;

  public static void initialisiereItemBlocks()
  {
    
    
    
    ai.animalGas = new Fluid("Animal Gas").setGaseous(true).setDensity(1000);
    FluidRegistry.registerFluid(ai.animalGas);
  
    
    
    ai.gas = new BlockGas(cc.getBlock("block", "Gas Block", 802));
    PathProxy.registBlock(ai.gas, ItemBlockGas.class, "Schweine Furze");
    ai.animalGas.setBlockID(ai.gas);


    ai.gasBucket = new ItemGasBucket(cc.getItem("items", "Gas Bucket", 26041));
    FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(ai.animalGas, 1000), new ItemStack(APIItems.gasBucket), new ItemStack(Item.bucketEmpty)));    
    
        
    
                
    
        
    
    

    
    
    

    ai.gasAbsorber = new ItemGasAbsorber(cc.getItem("items", "Vacum Pump", 26042));
    PathProxy.registItem(ai.gasAbsorber, "Gas Pumpe");

    

    ai.gasCell = new LiquidContainer(cc.getItem("items", "Gas Cell", 26043), "Gas Cell", at.gasZelle, 64, "Animal Gas", 1000);
    PathProxy.registItem(ai.gasCell, "Gas Zelle");

    ai.compressedGasCell = new LiquidContainer(cc.getItem("items", "Compressed Gas Cell", 26044), "Compressed Gas Cell", at.bigGasCell, 64, "Animal Gas", 5000);
    PathProxy.registItem(ai.compressedGasCell, "Komprimierte Gas Celle");

    ai.gasCan = new LiquidContainer(cc.getItem("items", "Gas Can", 26045), "Gas Can", at.gasCan, 64, "Animal Gas", 1000);
    PathProxy.registItem(ai.gasCan, "Gas Kanne");

    ai.compressedGasCan = new LiquidContainer(cc.getItem("items", "Compressed Gas Can", 26046), "Compressed Gas Can", at.bigGasCan, 64, "Animal Gas", 5000);
    PathProxy.registItem(ai.compressedGasCan, "Komprimierte Gas Kanne");
    
    
    
  }
}

 

Block Class

package speiger.src.api.common.blocks;

import java.util.Collection;
import java.util.Iterator;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import speiger.src.api.common.config.APIItems;
import speiger.src.api.common.functions.TextureRegister;
import speiger.src.api.common.functions.WorldReading;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockGas extends Block implements IFluidBlock
{

public Random rand = new Random();

public BlockGas(int par1)
{
	super(par1, APIItems.GasMaterial);
	this.setTickRandomly(true);
	this.disableStats();
	this.setHardness(100F);
	this.setLightOpacity(3);
}




@Override
public boolean canCollideCheck(int par1, boolean par2)
{
	return false;
}


    public void setBlockBoundsForItemRender()
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

public boolean isBlockSolid(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
	return false;
}




@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
	return true;
}


@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
	super.updateTick(par1World, par2, par3, par4, par5Random);
	this.notifyNeighbors(par1World, par2, par3, par4);
	if(!par1World.isRemote)
	{
		flowing(par1World, par2, par3, par4);
		removeBlock(par1World, par2, par3, par4);
	}

	par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate(par1World));
}


private void removeBlock(World par1, int par2, int par3, int par4)
{
	if(par3 >= 149)
	{
		if(par1.getRainStrength(1.0F) > 0.2D)
		{
			par1.setBlock(par2, par3, par4, 0);
		}
	}

}





@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
	super.onEntityCollidedWithBlock(par1World, par2, par3, par4, par5Entity);
	if(par5Entity instanceof EntityLiving)
	{
		EntityLiving el = (EntityLiving) par5Entity;
		Collection<PotionEffect> potion = el.getActivePotionEffects();
		int i = 0;
		if(!potion.isEmpty())
		{
			Iterator between = potion.iterator();
			while(between.hasNext())
			{
				PotionEffect current = (PotionEffect) between.next();
				if(current.getPotionID() == Potion.confusion.id)
				{
					i = current.getDuration();
				}
			}



		}
		if(rand.nextInt(20) == 0)
		{
			el.addPotionEffect(new PotionEffect(Potion.confusion.id, i+10, 3));
		}
	}
}


public void flowing(World par0, int par1, int par2, int par3)
{



}














public void onBlockAdded(World world, int i, int j, int k)
    {        
        world.scheduleBlockUpdate(i, j, k, blockID, tickRate(world));
    }


@Override
public int tickRate(World par1World)
{
	return 5;
}


public void notifyNeighbors(World world, int i, int j, int k)
{
	world.notifyBlocksOfNeighborChange(i, j, k, blockID);
	world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
        world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
        world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
        world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
        world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
        world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
}

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
    return null;
}

    public boolean renderAsNormalBlock()
    {
        return false;
    }


    public boolean isOpaqueCube()
    {
        return false;
    }



//	@Override
//    public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1, int par2, int par3, int par4)
//    {
//		return null;
//    }

float[] biggnis = new float[]{0.0F, 0.1F, 0.2F, 0.3F, 0.4F, 0.5F, 0.6F, 0.7F, 0.8F, 0.9F, 0.95F, 0.96F};

    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    {
        int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
   
        float var8 = 1.0F;
        if(var5 == 0)
        {
        	   this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, var8, 1.0F);
        }
        else
        {
        	   this.setBlockBounds(0.0F, biggnis[var5], 0.0F, 1.0F, var8, 1.0F);
        }
     
    }

    private Icon[] gas = new Icon[6];

    

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
	for(int i = 0;i<gas.length;i++)
	{
		gas[i] = par1IconRegister.registerIcon(TextureRegister.gasTextures[i]);
	}
}




@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5)
{
	return gas[par5];
}



@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
	return gas[par1];
}



@Override
public Fluid getFluid()
{
	return APIItems.animalGas;
}



@Override
public FluidStack drain(World world, int x, int y, int z, boolean doDrain) 
{
	int meta = world.getBlockMetadata(x, y, z);
	int backMeta = 10 - meta;
	FluidStack gas = new FluidStack(APIItems.animalGas, 100*backMeta);


	if(doDrain)
	{
		world.setBlockToAir(x, y, z);
	}
	return gas.copy();
}



@Override
public boolean canDrain(World world, int x, int y, int z) 
{
	return true;
}






  
    

}

 

So what i am doing wrong?

a view things before! i need this block class for my fluid because its my custom movement^^"

 

Thanks for reading and i hope you have a solve/idea.

 

Posted

You wouldn't be the first who use static incorrectly. Like trying to register a Fluid before the corresponding Block exist.

Check that you are doing things in the correct order.

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

    • You will find the crash-report or log in your minecraft directory (crash-report or logs folder)
    • Use a modpack which is using these 2 mods as working base:   https://www.curseforge.com/minecraft/modpacks/life-in-the-village-3
    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
  • Topics

×
×
  • Create New...

Important Information

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