• 1

    posted a message on [Not Solved] Need help with placing a fluid source block with decreased height in the world

    Hello,


    I've recently begun to get back into modding and currently I'm facing a bit of a problem. I want to make a block that can register if there's a fluid block next to it and then make a copy of the fluid on free sides of the block, but with a reduced liquid height, as if the liquid would flow through it. Currently I'm having some problems though, at the moment it does create a copy of the fluid with a reduced liquid height (on the opposite site, I've reduced it to this case atm), this liquid, however, doesn't flow. Here's a picture of the problem:

    (I'll the textures later, right now I'm just trying to get the main concept to work)


    And here's my current code:

    @Override
    	public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
        {
    		 for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    	        {
    			 
    	            if (worldIn.getBlockState(pos.offset(enumfacing)).getMaterial().isLiquid() && worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getMaterial() == Material.AIR)
    	            {
    	            	
    	            	//Block BlockFacing = worldIn.getBlockState(pos.offset(enumfacing)).getBlock();
    	            	IBlockState blockstate = worldIn.getBlockState(pos.offset(enumfacing));
    	            	int LiquidHeightInt = (int) worldIn.getBlockState(pos.offset(enumfacing)).getProperties().get(BlockLiquid.LEVEL);
    	                
    	            	if(LiquidHeightInt <= 3)
    	            	{
    	            		//sets the blockstate on the opposite side of the block to be the one of the source, but with decreased fluid level by 2
    	            		worldIn.setBlockState(pos.offset(enumfacing.getOpposite()), blockstate.cycleProperty(BlockLiquid.LEVEL).cycleProperty(BlockLiquid.LEVEL), 2);
    	            		
    	            		
    	            		//updates the neighbouring blocks so that there will be no fluid on a side of the block if the initial source has been removed
    	            		worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).neighborChanged(worldIn, pos.offset(enumfacing.getOpposite()), worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock(), pos);
    	            		
    	            	}
    	            }
    	            
    	            // TODO add cases 
    	            
    	        }
    		 
        }



    I think the problem may be that the source water block creates other water blocks, and b/c I'm not placing a source block (I mean full block), it doesn't place the other following blocks. If this is the case, I have no idea though how to fix it. I've tried looking at BlockDynamicLiquid, BlockLiquid, even the dispenser, but wasn't able to come up with a solution. Am I maybe approaching this wrong and should try to make a block that doesn't have a collision box so that a fluid can flow through it, but still somehow make it so that entities collide with it? Anyway, thanks in advance!


    (Here's the github, in case you need it: https://github.com/pcblockgermany/btoc)

    Posted in: Modification Development
  • 0

    posted a message on [Solved] Help needed with getting the liquid height of adjacent liquid blocks

    I found a solution, what I have now, for anyone who is interested, is:

    @Override
    	public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
        {
    		 for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    	        {
    
    	            if (worldIn.getBlockState(pos.offset(enumfacing)).getMaterial().isLiquid() && worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getMaterial() == Material.AIR)
    	            {
    	            	
    	            	Block BlockFacing = worldIn.getBlockState(pos.offset(enumfacing)).getBlock();
    	            	int LiquidHeightProperty = (int) worldIn.getBlockState(pos.offset(enumfacing)).getProperties().get(BlockLiquid.LEVEL);
    	               
    	                
    	            	LogHelper.info(BlockFacing);
    	            	LogHelper.info(LiquidHeightProperty);
    	            }
    	     
    	        }
    		 
        }

    If there is smth wrong with this solution, please tell me. I'm not really a professional, but I can't see anything wrong with it.

    Posted in: Modification Development
  • 0

    posted a message on [Solved] Help needed with getting the liquid height of adjacent liquid blocks

    Hello,


    I've recently begun to get back into modding and currently I'm facing a bit of a problem. I want to make a block that can register if there's a fluid block next to it and then make a copy of the fluid on the opposite side of the block, but with a reduced liquid height. But before I can do anything, i first have to get the fluid and the fluid height for each side. This is what I've come up with:

    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
        {
    		 for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    	        {
    
    	            if (worldIn.getBlockState(pos.offset(enumfacing)).getMaterial().isLiquid() && worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getMaterial() == Material.AIR)
    	            {
    	            	Block BlockFacing = worldIn.getBlockState(pos.offset(enumfacing)).getBlock();
    	                float LiquidHeight = BlockLiquid.getBlockLiquidHeight(state, worldIn, pos.offset(enumfacing));
    	            	
    	                LogHelper.info(BlockFacing);
    	            	LogHelper.info(LiquidHeight);
    	            }
    
    	            
    	        }
    		 
        }


    I can check for all the different cases later, rn I'm just working with this on case, where a block with the material liquid is on the one side, and on the side opposite is a block with the material air. However, when I try to run this, MC crashes with the following message:

    [Server thread/ERROR]: Encountered an unexpected exception
    net.minecraft.util.ReportedException: Exception while updating neighbours
     at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:835) ~[MinecraftServer.class:?]
     at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) ~[MinecraftServer.class:?]
     at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?]
     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) [MinecraftServer.class:?]
     at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
    Caused by: java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=level, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]} as it does not exist in BlockStateContainer{block=btoc:block_semipermeable, properties=[]}
     at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204) ~[BlockStateContainer$StateImplementation.class:?]
     at net.minecraft.block.BlockLiquid.getBlockLiquidHeight(BlockLiquid.java:482) ~[BlockLiquid.class:?]
     at btoc.mod.objects.blocks.BlockSemiPermeable.neighborChanged(BlockSemiPermeable.java:68) ~[BlockSemiPermeable.class:?]
     at net.minecraft.block.state.BlockStateContainer$StateImplementation.neighborChanged(BlockStateContainer.java:508) ~[BlockStateContainer$StateImplementation.class:?]
     at net.minecraft.world.World.neighborChanged(World.java:622) ~[World.class:?]
     at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:567) ~[World.class:?]
     at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:505) ~[World.class:?]
     at net.minecraft.world.World.markAndNotifyBlock(World.java:437) ~[World.class:?]
     at net.minecraft.world.World.setBlockState(World.java:417) ~[World.class:?]
     at net.minecraft.world.World.setBlockToAir(World.java:454) ~[World.class:?]
     at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:99) ~[BlockDynamicLiquid.class:?]
     at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:774) ~[WorldServer.class:?]
     at net.minecraft.world.WorldServer.tick(WorldServer.java:231) ~[WorldServer.class:?]
     at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:829) ~[MinecraftServer.class:?]
     ... 4 more

    I have tried changing some things, trying to get the metadata of the block, but I always get this message, so I tried adding the same property (as the log suggests) to the block, but I either did smth wrong, which is very likely, and/or it didn't work either.


    If anyone could help me with this, I'd be incredibly grateful, I can't really wrap my head around this one. Thank you in advance!

    Posted in: Modification Development
  • 0

    posted a message on Spawning a particle effect relative to the player

    Thank you very much! It works for me too and i understand how it works now! :D

    Posted in: Modification Development
  • 0

    posted a message on Spawning a particle effect relative to the player

    Thanks, but I'm still getting an error message that the method

    spawnParticle(EnumParticleTypes, double, double, double, double, double, double, int...)

    in the type World is not applicable for the arguments

    (String, double, double, double, int, int, int).


    If remove the " from magicCrit it says that it can't be resolved into a variable.


    Sorry for not responding that early :(

    Posted in: Modification Development
  • 0

    posted a message on Spawning a particle effect relative to the player

    First of all, thanks, but I'm still getting an error message for magicCrit, xCoord, yCoord, zCoord and p_185688_14_. They can't be resolved to a variable for magicCrit and p_185688_14_ and for the coords that they can't be resolved or that they aren't a field. :(


    xCoord, etc. also can't be found when I search for them via autocompletion :o

    Posted in: Modification Development
  • 0

    posted a message on Spawning a particle effect relative to the player

    Ok, so I adjusted the line to this:

    worldIn.spawnParticle(magicCrit, ~, ~-1, ~, 0, 0, 0, p_175688_14_);

    (If the color offset won't fit, I'll change it later)


    It's still giving me an error for the params argument. Should i set it to 0?

    Posted in: Modification Development
  • 0

    posted a message on Spawning a particle effect relative to the player

    Hello,


    I'm currently trying to get into modding and i started with a videogame abilities mod. I already finished the rocketjump, but i also want it to spawn a particle effect beneath the player. Here is my current code:

    	public ItemStack onItemRightClick(ItemStack itemStack, World worldIn, EntityPlayer player)
        {
    		if (this.ability == 0)
    		{
    		player.jump();
    		
    
    		player.addPotionEffect(new PotionEffect(23, 1, 0));
    		itemStack.damageItem(1, player);
    		player.fallDistance = 0F;
    		}
    	
    		return itemStack;
        



    I have tried looking at " worldIn.spawnParticle(particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, p_175688_14_); " but i don't really understand how i can make that work, as the coordinates have to be relative to the player. I think it could be possible by first getting the current player coordinates and then setting them as xCoord, yCoord, ... and removing 1 from the yCoord, but I don't really have a clue on how to do that.

    I also don't really understand what the last part is about.

    Maybe I'm just approaching this wrong?


    Any help is greatly appreciated!


    ~towind

    Posted in: Modification Development
  • 0

    posted a message on Too Much TNT mod (50+ TNTs)

    First of all, a very nice mod, I love it and I've been using it for what seems like ages :D


    Recently I got into modding and I wanted to recreate antoher mod which I've loved but which wasn't continued. The mod also includes various TNTs, so I've been looking for good TNT tutorials, but so far I've found none. Do you have any tips/tutorials? (I'm very motivated, so it'd be no problem if you were to give me a hard tutorial)


    Thank you very much in advance! :)

    Posted in: Minecraft Mods
  • 0

    posted a message on Help grasping blockstates and json files

    Ok, I'll have a look :)

    Posted in: Modification Development
  • 0

    posted a message on Help grasping blockstates and json files

    I encountered another problem, the item itself in the inventory is not rotated properly. I attached an image to show what I mean(ignore the purple-black block)



    mcerror

    . The button side is on the side the right blue arrow points to. So i tried changing the rotation values inside the model json for the inventory, but those didn't seem to change anything, I checked the item after each change :/



    rotation

    As I said, I'm not really good with this json system :(

    Posted in: Modification Development
  • 0

    posted a message on Help grasping blockstates and json files

    Alright, it works!

    I had to change a bit on that class, but it works! Also, the model file mustn't contain a parent AND elements.


    Thank you!

    And if you have a tutorial in which json files are explained a bit, I would be incredibly thankful :)

    Posted in: Modification Development
  • 0

    posted a message on Help grasping blockstates and json files

    Hello!

    I have a block to which I will attach a gui to (probably, might do it a bit else with items dropping onto the block), and it looks a bit like a oven. So I created the .json and the blockstate file, but it only "looks" south.

    So I took a look at the blockstate file for a furnace, as it rotates and I adjusted my blockstate file to this:

    {
        "variants": {
            "facing=north": { "model": "tm:crusher", "y": 180 },
            "facing=south": { "model": "tm:crusher" },
            "facing=west":  { "model": "tm:crusher", "y": 270 },
            "facing=east":  { "model": "tm:crusher", "y": 90 }
        }
    }

    But that gave me purle-black error texture, appearing as a full cube.

    So after the failure, i took a look at the model for the furnace too, and added "parent": "block_orientable",

    {
        "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
        "parent": "block_orientable",
        "textures": {
            "particle": "tm:blocks/clean_block",
            "0": "tm:blocks/clean_block",
            "1": "tm:blocks/crusher_front",
            "2": "tm:blocks/crusher_buttons"
        },
        "elements": [
            {
                "name": "Cube",
                "from": [ 0.0, 0.0, 0.0 ], 
                "to": [ 16.0, 16.0, 15.0 ], 
                "faces": {
                    "north": { "texture": "0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                    "east": { "texture": "0", "uv": [ 1.0, 0.0, 16.0, 16.0 ] },
                    "south": { "texture": "1", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                    "west": { "texture": "0", "uv": [ 0.0, 0.0, 15.0, 16.0 ] },
                    "up": { "texture": "0", "uv": [ 0.0, 0.0, 16.0, 15.0 ] },
                    "down": { "texture": "0", "uv": [ 0.0, 1.0, 16.0, 16.0 ] }
                }
            },
            {
                "name": "Cube",
                "from": [ 0.0, 0.0, 15.0 ], 
                "to": [ 16.0, 4.0, 16.0 ], 
                "faces": {
                    "north": { "texture": "-1", "uv": [ 0.0, 0.0, 16.0, 4.0 ] },
                    "east": { "texture": "0", "uv": [ 15.0, 12.0, 16.0, 16.0 ] },
                    "south": { "texture": "2", "uv": [ 0.0, 12.0, 16.0, 16.0 ] },
                    "west": { "texture": "0", "uv": [ 14.0, 12.0, 15.0, 16.0 ] },
                    "up": { "texture": "1", "uv": [ 0.0, 4.0, 16.0, 5.0 ] },
                    "down": { "texture": "0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }
                }
            },
            {
                "name": "Cube",
                "from": [ 0.0, 4.0, 15.0 ], 
                "to": [ 4.0, 16.0, 16.0 ], 
                "faces": {
                    "north": { "texture": "-1", "uv": [ 0.0, 0.0, 4.0, 12.0 ] },
                    "east": { "texture": "1", "uv": [ 4.0, 0.0, 5.0, 12.0 ] },
                    "south": { "texture": "2", "uv": [ 0.0, 0.0, 4.0, 12.0 ] },
                    "west": { "texture": "0", "uv": [ 15.0, 0.0, 16.0, 12.0 ] },
                    "up": { "texture": "0", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
                    "down": { "texture": "-1", "uv": [ 0.0, 0.0, 4.0, 1.0 ] }
                }
            },
            {
                "name": "Cube",
                "from": [ 12.0, 4.0, 15.0 ], 
                "to": [ 16.0, 16.0, 16.0 ], 
                "faces": {
                    "north": { "texture": "-1", "uv": [ 0.0, 0.0, 4.0, 12.0 ] },
                    "east": { "texture": "0", "uv": [ 15.0, 0.0, 16.0, 12.0 ] },
                    "south": { "texture": "2", "uv": [ 12.0, 0.0, 16.0, 12.0 ] },
                    "west": { "texture": "1", "uv": [ 4.0, 0.0, 5.0, 12.0 ] },
                    "up": { "texture": "0", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
                    "down": { "texture": "-1", "uv": [ 0.0, 0.0, 4.0, 1.0 ] }
                }
            },
            {
                "name": "Cube",
                "from": [ 4.0, 12.0, 15.0 ], 
                "to": [ 12.0, 16.0, 16.0 ], 
                "faces": {
                    "north": { "texture": "-1", "uv": [ 0.0, 0.0, 8.0, 4.0 ] },
                    "east": { "texture": "-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
                    "south": { "texture": "2", "uv": [ 4.0, 0.0, 12.0, 4.0 ] },
                    "west": { "texture": "-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
                    "up": { "texture": "0", "uv": [ 4.0, 0.0, 12.0, 1.0 ] },
                    "down": { "texture": "1", "uv": [ 4.0, 4.0, 12.0, 5.0 ] }
                }
            }
        ]
    }

    I don't really get the new system with json files, so if anybody has an idea on how to fix this, or any good tutorials about this json subject, I'm always open for suggestions!

    Any help is greatly appreciated!

    Posted in: Modification Development
  • 0

    posted a message on Item should give saturation effect when rightclicked

    Oh, I get it now! *facepalm*


    Thank you!

    Posted in: Modification Development
  • 0

    posted a message on Item should give saturation effect when rightclicked

    And how exactly would I do this? :unsure:

    player.addPotionEffect(potionEffect, 23);

    ?

    I'm sorry, I'm relatively new to java :/

    Posted in: Modification Development
  • To post a comment, please or register a new account.