Jump to content

Dragonisser

Forge Modder
  • Posts

    157
  • Joined

  • Last visited

Posts posted by Dragonisser

  1. Could someone explain me why my custom water loads chunks? At the updatetick method it checks if the vanilla water is next to it and replaces it with itself. Curretnly it loads every chunk while doing this and replaces everything.

     

    You can see what i mean on my Dynmap. I never went to the dark blue area.

     

    http://prwh.de:8125/?worldname=world&mapname=flat&zoom=3&x=669&y=64&z=478

     

     

    package cobaltmod.main.blocks;
    
    import java.util.Random;
    
    import cobaltmod.entity.EntityBlueSlime;
    import cobaltmod.entity.EntityCobaltGuardian;
    import cobaltmod.entity.EntityCobaltZombie;
    import cobaltmod.main.api.CMApiReplace;
    import cobaltmod.main.api.CMContent;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.DamageSource;
    import net.minecraft.util.IIcon;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.fluids.BlockFluidClassic;
    import net.minecraftforge.fluids.Fluid;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    
    public class BlockDarkWater extends BlockFluidClassic {
    
    
    public static BlockDarkWater instance;
    
    
        @SideOnly(Side.CLIENT)
        protected IIcon stillIcon;
        @SideOnly(Side.CLIENT)
        protected IIcon flowingIcon;
        
        public BlockDarkWater(Fluid fluid, Material material) {
                super(fluid, material);
                
        }
        
        @SideOnly(Side.CLIENT)
        public void registerBlockIcons(IIconRegister register) {
                stillIcon = register.registerIcon("mod_cobalt:darkwater_still");
                flowingIcon = register.registerIcon("mod_cobalt:darkwater_flow");
        }
        
        @Override
        public IIcon getIcon(int side, int meta) {
                return (side == 0 || side == 1)? stillIcon : flowingIcon;
        }
        
        
        
        @Override
        public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
                if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;
                return super.canDisplace(world, x, y, z);
        }
        
        @Override
        public boolean displaceIfPossible(World world, int x, int y, int z) {
                if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;
                return super.displaceIfPossible(world, x, y, z);
        }
        public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) 
    {
    	super.onEntityWalking(par1World, par2, par3, par4, par5Entity);
    	if(par5Entity instanceof EntityPlayer) 
    	{
    		EntityPlayer player = (EntityPlayer)par5Entity;
    	    ItemStack[] armor = player.inventory.armorInventory;
    	    if(armor[0] != null) 
    	    {	
    	    	if(armor[0].getItem() == CMContent.cobaltboots && armor[1].getItem() == CMContent.cobaltlegs && armor[2].getItem() == CMContent.cobaltplate && armor[3].getItem() == CMContent.cobalthelmet) 
    	    	{
    	    		return;
    	    	}
    	    }
    	}
    	if(par5Entity instanceof EntityItem)
    	{
    		return;
    	}
    	if(par5Entity instanceof EntityCobaltZombie)
    	{			
    		return;
    	}
    	if(par5Entity instanceof EntityCobaltGuardian)
    	{
    		return;
    	}
    	if(par5Entity instanceof EntityBlueSlime)
    	{
    		return;
    	}
    	par5Entity.attackEntityFrom(DamageSource.magic, 0.5F);
    
    }
    
        @Override
        public void updateTick(World world, int x, int y, int z, Random rand)
        {
            int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z);
            int expQuanta = -101;
    
            // check adjacent block levels if non-source
            if (quantaRemaining < quantaPerBlock)
            {
                int y2 = y - densityDir;
    
                if (world.getBlock(x,     y2, z    ) == this ||
                    world.getBlock(x - 1, y2, z    ) == this ||
                    world.getBlock(x + 1, y2, z    ) == this ||
                    world.getBlock(x,     y2, z - 1) == this ||
                    world.getBlock(x,     y2, z + 1) == this)
                {
                    expQuanta = quantaPerBlock - 1;
                }
                else
                {
                    int maxQuanta = -100;
                    maxQuanta = getLargerQuanta(world, x - 1, y, z,     maxQuanta);
                    maxQuanta = getLargerQuanta(world, x + 1, y, z,     maxQuanta);
                    maxQuanta = getLargerQuanta(world, x,     y, z - 1, maxQuanta);
                    maxQuanta = getLargerQuanta(world, x,     y, z + 1, maxQuanta);
    
                    expQuanta = maxQuanta - 1;
                }
    
                // decay calculation
                if (expQuanta != quantaRemaining)
                {
                    quantaRemaining = expQuanta;
    
                    if (expQuanta <= 0)
                    {
                        world.setBlock(x, y, z, Blocks.air);
                    }
                    else
                    {
                        world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3);
                        world.scheduleBlockUpdate(x, y, z, this, tickRate);
                        world.notifyBlocksOfNeighborChange(x, y, z, this);
                    }
                }
            }
            // This is a "source" block, set meta to zero, and send a server only update
            else if (quantaRemaining >= quantaPerBlock)
            {
                world.setBlockMetadataWithNotify(x, y, z, 0, 2);
            }
    
            // Flow vertically if possible
            if (canDisplace(world, x, y + densityDir, z))
            {
                flowIntoBlock(world, x, y + densityDir, z, 1);
                return;
            }
    
            // Flow outward if possible
            int flowMeta = quantaPerBlock - quantaRemaining + 1;
            if (flowMeta >= quantaPerBlock)
            {
                return;
            }
    
            if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z))
            {
                if (world.getBlock(x, y - densityDir, z) == this)
                {
                    flowMeta = 1;
                }
                boolean flowTo[] = getOptimalFlowDirections(world, x, y, z);
    
                if (flowTo[0]) flowIntoBlock(world, x - 1, y, z,     flowMeta);
                if (flowTo[1]) flowIntoBlock(world, x + 1, y, z,     flowMeta);
                if (flowTo[2]) flowIntoBlock(world, x,     y, z - 1, flowMeta);
                if (flowTo[3]) flowIntoBlock(world, x,     y, z + 1, flowMeta);
            }
    //        if (!world.isRemote) {
    //			for (int l = 0; l < 2; ++l) {
    //				
    //				int i1 = x + rand.nextInt(3) - 1;
    //				int j1 = y + rand.nextInt(5) - 3;
    //				int k1 = z + rand.nextInt(3) - 1;
    //				
    //				Block spreadable = world.getBlock(i1, j1, k1);
    //				
    //				if (world.getChunkFromBlockCoords(x, z).isChunkLoaded)
    //				{
    //					if (world.getBlock(j1, y - 1, k1) != CMContent.cobaltgrass)
    //					{
    //						if (CMApiReplace.map.containsKey(spreadable)) 
    //						{	
    //							world.setBlock(i1, j1, k1, CMApiReplace.map.get(spreadable));
    //						}
    //					}
    //					
    //				}
    //				
    //			}
    //		}
            
        }
        
    }
    
    

  2. I've been following this a little, I'm really new to modding, three days. I've been looking at code to see how to make a two block high torch. From what I can tell, I need to make a script to place a block after the base block is placed. If you have anything to share, I'd like to see it. I know how to set textures and register items and stuff. Just don't know how to make blocks with false tops that emit light.

     

    You dont really need to make the upper block emit the light ;) (Simply let the block you are placing emit the light. particles could also be done, if you check, if its the upper part of the plant(or torch)) When i get home, i will take a look at the DoublePlant and try to help you ^^

  3. public void spawnShockWave() {
    
    	//System.out.println("Spawned");
    
    	if (this.worldObj.getClosestVulnerablePlayerToEntity(this, 10.0D) != null) {
    		EntityLivingBase entityplayer = (EntityLivingBase) this.worldObj.getClosestVulnerablePlayerToEntity(this, 10.0D);
    
    		double x = Math.sin(entityplayer.rotationYaw * Math.PI / 180) * 1.0D;
    		double z = Math.cos(entityplayer.rotationYaw * Math.PI / 180) * 1.0D;
    		double y = 1.0D;
    
    		//System.out.println(entityplayer);
    
    		double d = Math.random();
    		if (d < 0.2) {
    			//System.out.println("PUSH");
    			entityplayer.addVelocity(x, y, z);
    		}
    
    	}
    
    }
    

     

    Well this is my attempt to push the player away from a certain entity.

     

    https://bitbucket.org/Dragonisser/cobaltmod/src/2a6e45c02444af95fc11af6b881cea78c633b164/cobaltmod/entity/EntityCobaltGuardian.java?at=master#cl-230

    It gets called where //System.out.println("FIREBALL 2"); is written.(Old code, thats why it isnt written there ^^)

     

    But nothing happens. I use the same at my windaxe:

    https://bitbucket.org/Dragonisser/cobaltmod/src/2a6e45c02444af95fc11af6b881cea78c633b164/cobaltmod/items/ItemWindAxe.java?at=master#cl-119

     

    I also tried to use EntityPlayer. I even get the variables like

     

    - entityplayer.rotationYaw

    - entityplayer

     

    but nothing happens to me.

     

     

    I added right now this "entityplayer.attackEntityFrom(DamageSource.cactus, 0.1F);" under .addVelocity() and suddenly i get thrown away.

     

    Does someone knows why it only works when i get damaged? Or did i make a stupid mistake xD?

  4. Hello, i need to increase player speed by 2. I tried using entity attributes but it's didn't anything.

    Code, which i tried to use:

    player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D);

     

    This is of/from coolAlias

     

    http://www.minecraftforge.net/forum/index.php?topic=20806.20

     

    And how i used it. Just an example :P

     

     

     

    package cobaltmod.handler.event;
    
    import java.util.UUID;
    
    import net.minecraft.entity.SharedMonsterAttributes;
    import net.minecraft.entity.ai.attributes.AttributeModifier;
    import net.minecraft.entity.ai.attributes.IAttributeInstance;
    import net.minecraft.item.ItemStack;
    import cobaltmod.main.mod_cobalt;
    import cobaltmod.main.api.CMContent;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    import cpw.mods.fml.common.gameevent.TickEvent;
    import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
    
    public class CobaltPlayerTickEventHandler {
    
    
    
    private static final UUID cobaltspeedBootsMoveBonusUUID = UUID.fromString("36A0FC05-50EB-460B-8961-615633A6D813");
    
    private static final AttributeModifier cobaltspeedBootsMoveBonus = (new AttributeModifier(cobaltspeedBootsMoveBonusUUID, "Cobalt Speed Boots Speed Bonus", mod_cobalt.forwardspeedboots, 2)).setSaved(false);
    
    @SuppressWarnings("unused")
    private boolean bootson = false;
    
    private int i = 0;
    
    @SubscribeEvent
    public void onPlayerTick(PlayerTickEvent event) {
    
    	if (event.side.isClient() && event.phase.equals(TickEvent.Phase.START))
    	{
    		IAttributeInstance movement = event.player.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    		ItemStack[] is = event.player.inventory.armorInventory;
        	
    		if (is[0] != null ) {
    
    			if (is[0].getItem() == CMContent.speedcobaltboots ) {
    
    				this.bootson = true;
    
    				if (movement.getModifier(cobaltspeedBootsMoveBonusUUID) != null) {
    					movement.removeModifier(cobaltspeedBootsMoveBonus);
    				}
    				movement.applyModifier(cobaltspeedBootsMoveBonus);
    
    		        double d0 = event.player.worldObj.rand.nextGaussian() * 0.02D;
    		        double d1 = event.player.worldObj.rand.nextGaussian() * 0.02D;
    		        double d2 = event.player.worldObj.rand.nextGaussian() * 0.02D;
    		        
    		        double dx = event.player.posX;
    		        double dy = event.player.posY - 1.7;
    		        double dz = event.player.posZ + 0.2;
    		        
    		        this.i++;
    		        
    		        if ( (!(event.player.motionZ == 0.0) || !(event.player.motionZ == 0.0)) && !event.player.isWet() && !event.player.capabilities.isCreativeMode && !event.player.isSneaking() )
    		        {
    		        	if (this.i >= 3)
    		        	{
    		        		event.player.worldObj.spawnParticle("cloud", dx, dy, dz, d0, d1, d2);
    		        		this.i = 0;
    		        	}	        	
    		        }
    		        else if (event.player.capabilities.isCreativeMode || this.i >= 10)
    		        {
    		        	this.i = 0;
    		        }
    			}	
    		}
    		else
    		{
    			if (this.bootson = true)
    			{
    				this.bootson = false;
    				movement.removeModifier(cobaltspeedBootsMoveBonus);
    			}
    		}
    	}	
        }
    }
    

     

     

  5. I got this:

     

    https://bitbucket.org/Dragonisser/cobaltmod/src/178c28c1f444b11466696e40bcbfb0f8978acf76/cobaltmod/blocks/BlockFluidDarkWater.java?at=master

     

    and this in the main:

     

    @SubscribeEvent
    @SideOnly(Side.CLIENT)
    public void textureHook(TextureStitchEvent.Post event) {
    	if (event.map.getTextureType() == 0) {
    		CMStuff.darkwater_fluid.setIcons(CMStuff.darkwater.getIcon(0, 0), CMStuff.darkwater.getIcon(1, 0));
    
    	}
    }
    

     

    Ii dont know if its necessary, because i didnt checked afterwards, but i think it was for the bc tanks

×
×
  • Create New...

Important Information

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