Jump to content

LogicTechCorp

Forge Modder
  • Posts

    260
  • Joined

  • Last visited

Posts posted by LogicTechCorp

  1. Isn't that exactly what is described in the Sub-Models section of the blockstate documentation?

    See this page for an explanation of sub-models in Forge's blockstates format.

     

    I also have an example of the format here. This is a BuildCraft-style pipe composed of two individual models: the centre cube and the side attachment. The cube is used as a base model and the side attachment is added as a sub-model rotated as necessary.

     

    I followed that but my model does not display correctly.

     

    Forge Blockstate:

    {
      "forge_marker": 1,
      "defaults": {
        "transform": "forge:default-block"
      },
      "variants": {
        "normal": [
          {
            "model": "nex:fingers_plant"
          }
        ],
        "north": {
          "true": {
            "model": "nex:fingers_plant_side"
          },
          "false": {
            "submodel": {
                "noside0": { "model": "nex:fingers_plant_noside", "weight": 6 },
                "noside1": { "model": "nex:fingers_plant_noside1" },
                "noside2": { "model": "nex:fingers_plant_noside2" },
                "noside3": { "model": "nex:fingers_plant_noside3" }
            }
          }
        },
        "east": {
          "true": {
            "model": "nex:fingers_plant_side", "y": 90, "uvlock": true
          },
          "false": {
            "submodel": {
              "noside4": { "model": "nex:fingers_plant_noside1", "y": 90, "uvlock": true },
              "noside5": { "model": "nex:fingers_plant_noside2", "y": 90, "uvlock": true },
              "noside6": { "model": "nex:fingers_plant_noside3", "y": 90, "uvlock": false },
              "nosid7": { "model": "nex:fingers_plant_noside", "weight": 6, "y": 90, "uvlock": true }
            }
          }
        },
        "south": {
          "true": {
            "model": "nex:fingers_plant_side", "y": 180, "uvlock": true
          },
          "false": {
            "submodel": {
              "noside8": { "model": "nex:fingers_plant_noside2", "y": 180, "uvlock": true },
              "noside9": { "model": "nex:fingers_plant_noside3", "y": 180, "uvlock": false },
              "noside10": { "model": "nex:fingers_plant_noside", "weight": 6, "y": 180, "uvlock": true },
              "noside11": { "model": "nex:fingers_plant_noside1", "y": 180, "uvlock": true }
            }
          }
        },
        "west": {
          "true": {
            "model": "nex:fingers_plant_side", "y": 270, "uvlock": true
          },
          "false": {
            "submodel": {
              "noside12":{ "model": "nex:fingers_plant_noside3", "y": 270, "uvlock": false },
              "noside13":{ "model": "nex:fingers_plant_noside", "weight": 6, "y": 270, "uvlock": true },
              "noside14":{ "model": "nex:fingers_plant_noside1", "y": 270, "uvlock": true },
              "noside15":{ "model": "nex:fingers_plant_noside2", "y": 270, "uvlock": true }
            }
          }
        },
        "up": {
          "true": {
            "model": "nex:fingers_plant_side", "x": 270, "uvlock": true
          },
          "false": {
            "submodel": {
              "nosidev0": { "model": "nex:fingers_plant_noside_v1", "x": 270, "uvlock": false },
              "nosidev1": { "model": "nex:fingers_plant_noside_v1", "x": 270, "y": 90, "uvlock": false },
              "nosidev2": { "model": "nex:fingers_plant_noside_v1", "x": 270, "y": 180, "uvlock": false },
              "nosidev3": { "model": "nex:fingers_plant_noside_v2", "x": 270, "uvlock": false }
            }
          }
        },
        "down": {
          "true": {
            "model": "nex:fingers_plant_side", "x": 90, "uvlock": true
          },
          "false": {
            "submodel": {
              "nosidev4": { "model": "nex:fingers_plant_noside_v1", "x": 90, "uvlock": false },
              "nosidev5": { "model": "nex:fingers_plant_noside_v1", "x": 90, "y": 180, "uvlock": false },
              "nosidev6": { "model": "nex:fingers_plant_noside_v2", "x": 90, "uvlock": false },
              "nosidev7": { "model": "nex:fingers_plant_noside_v2", "x": 90, "y": 90,  "uvlock": false }
            }
          }
        }
      }
    }
    

     

    Vanilla Blockstate:

    {
      "multipart": [
        {"when": { "north": true },
          "apply": { "model": "nex:fingers_plant_side" }
        },
        {   "when": { "east": true },
          "apply": { "model": "nex:fingers_plant_side", "y": 90, "uvlock": true }
        },
        {   "when": { "south": true },
          "apply": { "model": "nex:fingers_plant_side", "y": 180, "uvlock": true }
        },
        {   "when": { "west": true },
          "apply": { "model": "nex:fingers_plant_side", "y": 270, "uvlock": true }
        },
        {   "when": { "up": true },
          "apply": { "model": "nex:fingers_plant_side", "x": 270, "uvlock": true }
        },
        {   "when": { "down": true },
          "apply": { "model": "nex:fingers_plant_side", "x": 90, "uvlock": true }
        },
        {   "when": { "north": false },
          "apply": [
            { "model": "nex:fingers_plant_noside", "weight": 6 },
            { "model": "nex:fingers_plant_noside1" },
            { "model": "nex:fingers_plant_noside2" },
            { "model": "nex:fingers_plant_noside3" }
          ]
        },
        {   "when": { "east": false },
          "apply": [
            { "model": "nex:fingers_plant_noside1", "y": 90, "uvlock": true },
            { "model": "nex:fingers_plant_noside2", "y": 90, "uvlock": true },
            { "model": "nex:fingers_plant_noside3", "y": 90, "uvlock": false },
            { "model": "nex:fingers_plant_noside", "weight": 6, "y": 90, "uvlock": true }
          ]
        },
        {   "when": { "south": false },
          "apply": [
            { "model": "nex:fingers_plant_noside2", "y": 180, "uvlock": true },
            { "model": "nex:fingers_plant_noside3", "y": 180, "uvlock": false },
            { "model": "nex:fingers_plant_noside", "weight": 6, "y": 180, "uvlock": true },
            { "model": "nex:fingers_plant_noside1", "y": 180, "uvlock": true }
          ]
        },
        {   "when": { "west": false },
          "apply": [
            { "model": "nex:fingers_plant_noside3", "y": 270, "uvlock": false },
            { "model": "nex:fingers_plant_noside", "weight": 6, "y": 270, "uvlock": true },
            { "model": "nex:fingers_plant_noside1", "y": 270, "uvlock": true },
            { "model": "nex:fingers_plant_noside2", "y": 270, "uvlock": true }
          ]
        },
        {   "when": { "up": false },
          "apply": [
            { "model": "nex:fingers_plant_noside_v1", "x": 270, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v1", "x": 270, "y": 90, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v1", "x": 270, "y": 180, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v2", "x": 270, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v2", "x": 270, "y": 180, "uvlock": false }
          ]
        },
        {   "when": { "down": false },
          "apply": [
            { "model": "nex:fingers_plant_noside_v1", "x": 90, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v1", "x": 90, "y": 180, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v2", "x": 90, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v2", "x": 90, "y": 90,  "uvlock": false },
            { "model": "nex:fingers_plant_noside_v2", "x": 90, "y": 180, "uvlock": false },
            { "model": "nex:fingers_plant_noside_v2", "x": 90, "y": 270, "uvlock": false }
          ]
        }]
    }
    

  2. I have a vine like block that is sometimes placed wrong when they are generated.

     

    width=800 height=423https://cdn.discordapp.com/attachments/169862391947984898/194522309338464258/2016-06-20_11.39.39.png[/img]

     

    The ones on the middle bottom are just placed on air blocks. Here's the generation class:

     

    public class BiomeFeatureFrost implements IBiomeFeature
    {
        private final String name;
        private final int rarity;
    
        public BiomeFeatureFrost(String name, int rarity)
        {
            this.name = name;
            this.rarity = rarity;
        }
    
        @Override
        public boolean generate(World world, Random rand, BlockPos pos)
        {
            for(int r = 0; r < this.rarity; r++)
            {
                int x = rand.nextInt(16) + 8;
                int y = rand.nextInt(128);
                int z = rand.nextInt(16) + 8;
                BlockPos newPos = pos.add(x, y, z);
    
                for(; newPos.getY() < 128; newPos = newPos.up())
                {
                    if(world.isAirBlock(newPos))
                    {
                        for(EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL.facings())
                        {
                            if(NetherExContent.Blocks.frost.canPlaceBlockOnSide(world, newPos, enumfacing))
                            {
                                IBlockState iblockstate = NetherExContent.Blocks.frost.getDefaultState().withProperty(BlockFrost.NORTH, enumfacing == EnumFacing.NORTH).withProperty(BlockFrost.EAST, enumfacing == EnumFacing.EAST).withProperty(BlockFrost.SOUTH, enumfacing == EnumFacing.SOUTH).withProperty(BlockFrost.WEST, enumfacing == EnumFacing.WEST);
                                world.setBlockState(newPos, iblockstate, 3);
                                break;
                            }
                        }
                    }
                    else
                    {
                        newPos = newPos.add(rand.nextInt(4) - rand.nextInt(4), 0, rand.nextInt(4) - rand.nextInt(4));
                    }
                }
            }
    
            return true;
        }
    
        @Override
        public String getName()
        {
            return name;
        }
    }
    

     

    And the block class:

    public class BlockFrost extends BlockMod
    {
        public static final PropertyBool NORTH = PropertyBool.create("north");
        public static final PropertyBool EAST = PropertyBool.create("east");
        public static final PropertyBool SOUTH = PropertyBool.create("south");
        public static final PropertyBool WEST = PropertyBool.create("west");
        private static final PropertyBool UP = PropertyBool.create("up");
        private static final PropertyBool[] ALL_FACES = new PropertyBool[]{UP, NORTH, SOUTH, WEST, EAST};
        private static final AxisAlignedBB UP_AABB = new AxisAlignedBB(0.0D, 0.9375D, 0.0D, 1.0D, 1.0D, 1.0D);
        private static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0625D, 1.0D, 1.0D);
        private static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.9375D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
        private static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.0625D);
        private static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.9375D, 1.0D, 1.0D, 1.0D);
    
        public BlockFrost()
        {
            super(Material.VINE, "frost");
            this.setSoundType(SoundType.PLANT);
            this.setTickRandomly(true);
        }
    
        private static PropertyBool getPropertyFor(EnumFacing side)
        {
            switch(side)
            {
                case UP:
                    return UP;
                case NORTH:
                    return NORTH;
                case SOUTH:
                    return SOUTH;
                case EAST:
                    return EAST;
                case WEST:
                    return WEST;
                default:
                    throw new IllegalArgumentException(side + " is an invalid choice");
            }
        }
    
        private static int getNumSpreadFaces(IBlockState state)
        {
            int i = 0;
    
            for(PropertyBool propertybool : ALL_FACES)
            {
                if(state.getValue(propertybool))
                {
                    ++i;
                }
            }
    
            return i;
        }
    
        @Override
        public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
        {
            return NULL_AABB;
        }
    
        @Override
        public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
        {
            state = state.getActualState(source, pos);
            int i = 0;
            AxisAlignedBB axisalignedbb = FULL_BLOCK_AABB;
    
            if(state.getValue(UP))
            {
                axisalignedbb = UP_AABB;
                ++i;
            }
    
            if(state.getValue(NORTH))
            {
                axisalignedbb = NORTH_AABB;
                ++i;
            }
    
            if(state.getValue(EAST))
            {
                axisalignedbb = EAST_AABB;
                ++i;
            }
    
            if(state.getValue(SOUTH))
            {
                axisalignedbb = SOUTH_AABB;
                ++i;
            }
    
            if(state.getValue(WEST))
            {
                axisalignedbb = WEST_AABB;
                ++i;
            }
    
            return i == 1 ? axisalignedbb : FULL_BLOCK_AABB;
        }
    
        @Override
        public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
        {
            return state.withProperty(UP, worldIn.getBlockState(pos.up()).isBlockNormalCube());
        }
    
        @Override
        public boolean isOpaqueCube(IBlockState state)
        {
            return false;
        }
    
        @Override
        public boolean isFullCube(IBlockState state)
        {
            return false;
        }
    
        @Override
        public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos)
        {
            return true;
        }
    
        @Override
        public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
        {
            switch(side)
            {
                case UP:
                    return this.canSpreadFrostOn(worldIn.getBlockState(pos.up()));
                case NORTH:
                case SOUTH:
                case EAST:
                case WEST:
                    return this.canSpreadFrostOn(worldIn.getBlockState(pos.offset(side.getOpposite())));
                default:
                    return false;
            }
        }
    
        private boolean canSpreadFrostOn(IBlockState state)
        {
            return state.isFullCube() && state.getMaterial().blocksMovement();
        }
    
        private boolean recheckSpreadSides(World worldIn, BlockPos pos, IBlockState state)
        {
            IBlockState iblockstate = state;
    
            for(EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
            {
                PropertyBool propertybool = getPropertyFor(enumfacing);
    
                if(state.getValue(propertybool) && !this.canSpreadFrostOn(worldIn.getBlockState(pos.offset(enumfacing))))
                {
                    IBlockState iblockstate1 = worldIn.getBlockState(pos.up());
    
                    if(iblockstate1.getBlock() != this || !iblockstate1.getValue(propertybool))
                    {
                        state = state.withProperty(propertybool, false);
                    }
                }
            }
    
            if(getNumSpreadFaces(state) == 0)
            {
                return false;
            }
            else
            {
                if(iblockstate != state)
                {
                    worldIn.setBlockState(pos, state, 2);
                }
    
                return true;
            }
        }
    
        @Override
        public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
        {
            if(!worldIn.isRemote && !this.recheckSpreadSides(worldIn, pos, state))
            {
                this.dropBlockAsItem(worldIn, pos, state, 0);
                worldIn.setBlockToAir(pos);
            }
        }
    
        @Override
        public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
        {
            if(!worldIn.isRemote)
            {
                if(worldIn.rand.nextInt(4) == 0)
                {
                    int i = 4;
                    int j = 5;
                    boolean flag = false;
                    label62:
    
                    for(int k = -i; k <= i; ++k)
                    {
                        for(int l = -i; l <= i; ++l)
                        {
                            for(int i1 = -1; i1 <= 1; ++i1)
                            {
                                if(worldIn.getBlockState(pos.add(k, i1, l)).getBlock() == this)
                                {
                                    --j;
    
                                    if(j <= 0)
                                    {
                                        flag = true;
                                        break label62;
                                    }
                                }
                            }
                        }
                    }
    
                    EnumFacing enumfacing1 = EnumFacing.random(rand);
                    BlockPos blockpos2 = pos.up();
    
                    if(enumfacing1 == EnumFacing.UP && pos.getY() < 255 && worldIn.isAirBlock(blockpos2))
                    {
                        if(!flag)
                        {
                            IBlockState iblockstate2 = state;
    
                            for(EnumFacing enumfacing2 : EnumFacing.Plane.HORIZONTAL)
                            {
                                if(rand.nextBoolean() || !this.canSpreadFrostOn(worldIn.getBlockState(blockpos2.offset(enumfacing2))))
                                {
                                    iblockstate2 = iblockstate2.withProperty(getPropertyFor(enumfacing2), false);
                                }
                            }
    
                            if(iblockstate2.getValue(NORTH) || iblockstate2.getValue(EAST) || iblockstate2.getValue(SOUTH) || iblockstate2.getValue(WEST))
                            {
                                worldIn.setBlockState(blockpos2, iblockstate2, 2);
                            }
                        }
                    }
                    else if(enumfacing1.getAxis().isHorizontal() && !state.getValue(getPropertyFor(enumfacing1)))
                    {
                        if(!flag)
                        {
                            BlockPos blockpos4 = pos.offset(enumfacing1);
                            IBlockState iblockstate3 = worldIn.getBlockState(blockpos4);
                            Block block1 = iblockstate3.getBlock();
    
                            if(block1.getMaterial(iblockstate3) == Material.AIR)
                            {
                                EnumFacing enumfacing3 = enumfacing1.rotateY();
                                EnumFacing enumfacing4 = enumfacing1.rotateYCCW();
                                boolean flag1 = state.getValue(getPropertyFor(enumfacing3));
                                boolean flag2 = state.getValue(getPropertyFor(enumfacing4));
                                BlockPos blockpos = blockpos4.offset(enumfacing3);
                                BlockPos blockpos1 = blockpos4.offset(enumfacing4);
    
                                if(flag1 && this.canSpreadFrostOn(worldIn.getBlockState(blockpos)))
                                {
                                    worldIn.setBlockState(blockpos4, this.getDefaultState().withProperty(getPropertyFor(enumfacing3), true), 2);
                                }
                                else if(flag2 && this.canSpreadFrostOn(worldIn.getBlockState(blockpos1)))
                                {
                                    worldIn.setBlockState(blockpos4, this.getDefaultState().withProperty(getPropertyFor(enumfacing4), true), 2);
                                }
                                else if(flag1 && worldIn.isAirBlock(blockpos) && this.canSpreadFrostOn(worldIn.getBlockState(pos.offset(enumfacing3))))
                                {
                                    worldIn.setBlockState(blockpos, this.getDefaultState().withProperty(getPropertyFor(enumfacing1.getOpposite()), true), 2);
                                }
                                else if(flag2 && worldIn.isAirBlock(blockpos1) && this.canSpreadFrostOn(worldIn.getBlockState(pos.offset(enumfacing4))))
                                {
                                    worldIn.setBlockState(blockpos1, this.getDefaultState().withProperty(getPropertyFor(enumfacing1.getOpposite()), true), 2);
                                }
                                else if(this.canSpreadFrostOn(worldIn.getBlockState(blockpos4.up())))
                                {
                                    worldIn.setBlockState(blockpos4, this.getDefaultState(), 2);
                                }
                            }
                            else if(block1.getMaterial(iblockstate3).isOpaque() && iblockstate3.isFullCube())
                            {
                                worldIn.setBlockState(pos, state.withProperty(getPropertyFor(enumfacing1), true), 2);
                            }
                        }
                    }
                    else
                    {
                        if(pos.getY() > 1)
                        {
                            BlockPos blockpos3 = pos.down();
                            IBlockState iblockstate = worldIn.getBlockState(blockpos3);
                            Block block = iblockstate.getBlock();
    
                            if(block.getMaterial(iblockstate) == Material.AIR)
                            {
                                IBlockState iblockstate1 = state;
    
                                for(EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
                                {
                                    if(rand.nextBoolean())
                                    {
                                        iblockstate1 = iblockstate1.withProperty(getPropertyFor(enumfacing), false);
                                    }
                                }
    
                                if(iblockstate1.getValue(NORTH) || iblockstate1.getValue(EAST) || iblockstate1.getValue(SOUTH) || iblockstate1.getValue(WEST))
                                {
                                    worldIn.setBlockState(blockpos3, iblockstate1, 2);
                                }
                            }
                            else if(block == this)
                            {
                                IBlockState iblockstate4 = iblockstate;
    
                                for(EnumFacing enumfacing5 : EnumFacing.Plane.HORIZONTAL)
                                {
                                    PropertyBool propertybool = getPropertyFor(enumfacing5);
    
                                    if(rand.nextBoolean() && state.getValue(propertybool))
                                    {
                                        iblockstate4 = iblockstate4.withProperty(propertybool, true);
                                    }
                                }
    
                                if(iblockstate4.getValue(NORTH) || iblockstate4.getValue(EAST) || iblockstate4.getValue(SOUTH) || iblockstate4.getValue(WEST))
                                {
                                    worldIn.setBlockState(blockpos3, iblockstate4, 2);
                                }
                            }
                        }
                    }
                }
            }
        }
    
        @Override
        public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
        {
            IBlockState iblockstate = this.getDefaultState().withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false);
            return facing.getAxis().isHorizontal() ? iblockstate.withProperty(getPropertyFor(facing.getOpposite()), true) : iblockstate;
        }
    
        @Override
        public Item getItemDropped(IBlockState state, Random rand, int fortune)
        {
            return null;
        }
    
        @Override
        public int quantityDropped(Random random)
        {
            return 0;
        }
    
        @Override
        public IBlockState getStateFromMeta(int meta)
        {
            return this.getDefaultState().withProperty(SOUTH, (meta & 1) > 0).withProperty(WEST, (meta & 2) > 0).withProperty(NORTH, (meta & 4) > 0).withProperty(EAST, (meta &  > 0);
        }
    
        @Override
        @SideOnly(Side.CLIENT)
        public BlockRenderLayer getBlockLayer()
        {
            return BlockRenderLayer.CUTOUT;
        }
    
        @Override
        public int getMetaFromState(IBlockState state)
        {
            int i = 0;
    
            if(state.getValue(SOUTH))
            {
                i |= 1;
            }
    
            if(state.getValue(WEST))
            {
                i |= 2;
            }
    
            if(state.getValue(NORTH))
            {
                i |= 4;
            }
    
            if(state.getValue(EAST))
            {
                i |= 8;
            }
    
            return i;
        }
    
        @Override
        protected BlockStateContainer createBlockState()
        {
            return new BlockStateContainer(this, UP, NORTH, EAST, SOUTH, WEST);
        }
    
        @Override
        public IBlockState withRotation(IBlockState state, Rotation rot)
        {
            switch(rot)
            {
                case CLOCKWISE_180:
                    return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST));
                case COUNTERCLOCKWISE_90:
                    return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH));
                case CLOCKWISE_90:
                    return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH));
                default:
                    return state;
            }
        }
    
        @Override
        public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
        {
            switch(mirrorIn)
            {
                case LEFT_RIGHT:
                    return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH));
                case FRONT_BACK:
                    return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST));
                default:
                    return super.withMirror(state, mirrorIn);
            }
        }
    

  3. You need to completely replace the terrain generation then.

    You have to override the WorldProvider by modifying the

    clazz

    field in

    DimensionType.NETHER

    to your own WorldProvider. Note that this is of course incompatible with any other mod doing this.

     

    I used an AT to make the clazz field public in DimensionType. Would this be the best way to do it?

     

    DimensionType.NETHER.clazz = WorldProviderNEX.class;
    

  4. You are not supposed to modify anything. You are supposed to change the BiomeProvider. By default the nether uses a BiomeProviderSingle which always gives the same biome. You have to substitute a different one.

     

    Here is what I have been testing:

        public void onWorldLoad(WorldEvent.Load event)
        {
            World world = event.getWorld();
    
            if(world.provider instanceof WorldProviderHell)
            {
                event.getWorld().provider.biomeProvider = new BiomeProviderSingle(Biomes.FROZEN_OCEAN);
            }
        }
    

     

    Q962ox2.png

     

    It does change the biome but as you can see it still generates as a regular hell biome.

  5. Listen for WorldEvent.Load. Check if it's the nether dimension. If so, modify the biomeProvider field in the world's provider.

     

    That works correctly but the biomes still spawn as the normal Nether. To have them generate correctly, would I have to replace the ChunkProvider for the Nether?

  6. Over the summer I plan on making a new mod and I have a few questions. The mod will allow the player to "combine"* two separate tools/armors into a new tool/armor. The new tool/armor will behave as if you were using both at once.

     

    Question 1: Would using capabilities be the best way to achieve this?

    Question 2: How would I make a tool/armor material work with this system?

     

    *The player will install the two tools/armors into the new tool/armor as modules not really destroying them but containing them inside.

  7. I have an Infusion Altar TE that can infuse an item with souls. To do so, the Infusion Altar requires the surrounding Crucible TEs to have a certain SoulType amount. The Crucible can hold 64 souls and there are 5 SoulTypes, so the crucible can have a mixture of all SoulTypes with different amounts of each type. Currently this only works if the required SoulType amount is in one Crucible opposed to two or more. What would be the best way to change my current setup to allow this?

     

    Note:

    A recipe with a null SoulType will require any SoulType.

     

    Recipe Class:

    public class RecipeInfusion implements ISMRecipe
    {
        private Object input;
        private ItemStack output;
        private SoulType soulType;
        private int requiredSoulAmount;
        private String guiButtonText;
    
        private static final Map<String, List<ItemStack>> oreMap = Maps.newHashMap();
    
        public RecipeInfusion(Object input, ItemStack output, SoulType soulType, int requiredSoulAmount, String guiButtonText)
        {
            this.input = input;
            this.output = output;
            this.soulType = soulType;
            this.requiredSoulAmount = requiredSoulAmount;
            this.guiButtonText = guiButtonText;
        }
    
        public boolean matches(ItemStack stack, SoulType soulType, int soulAmount)
        {
            if(stack == null || soulType == null)
            {
                return false;
            }
            else if(this.requiredSoulAmount > soulAmount || stack.stackSize * this.requiredSoulAmount > soulAmount)
            {
                return false;
            }
            else
            {
                if(this.soulType != null)
                {
                    if(this.soulType == soulType)
                    {
                        return this.checkMatch(stack);
                    }
                }
                else
                {
                    return this.checkMatch(stack);
                }
            }
            return false;
        }
    
        private boolean checkMatch(ItemStack stack)
        {
            if(this.input instanceof Block)
            {
                return Block.getBlockFromItem(stack.getItem()) == this.input;
            }
            else if(this.input instanceof Item)
            {
                return stack.getItem() == this.input;
            }
            else
            {
                String oreDict = (String) this.input;
                return isOreDict(stack, oreDict);
            }
        }
    
        private boolean isOreDict(ItemStack stack, String entry)
        {
            if(stack == null || stack.getItem() == null)
            {
                return false;
            }
    
            List<ItemStack> ores;
    
            if(oreMap.containsKey(entry))
            {
                ores = oreMap.get(entry);
            }
            else
            {
                ores = OreDictionary.getOres(entry);
                oreMap.put(entry, ores);
            }
            for(ItemStack oreStack : ores)
            {
                ItemStack newStack = oreStack.copy();
                newStack.setItemDamage(stack.getItemDamage());
    
                if(stack.isItemEqual(newStack))
                {
                    return true;
                }
            }
            return false;
        }
    
        public Object getInput()
        {
            return this.input;
        }
    
        public ItemStack getOutput()
        {
            return this.output;
        }
    
        public SoulType getSoulType()
        {
            return this.soulType;
        }
    
        public int getRequiredSoulAmount()
        {
            return this.requiredSoulAmount;
        }
    
        public String getGuiButtonText()
        {
            return this.guiButtonText;
        }
    

     

    TileEntityInfusionAltar:

    public class TileEntityInfusionAltar extends TileEntityInventory
    {
        public TileEntityInfusionAltar()
        {
            super(1, "soul_altar");
        }
    
        private List<TileEntitySoulCrucible> getCrucibles()
        {
            List<TileEntitySoulCrucible> crucibles = Lists.newArrayList();
    
            for(int x = pos.getX() - 3; x < pos.getX() + 4; x++)
            {
                for(int y = pos.getY() - 3; y < pos.getY() + 4; y++)
                {
                    for(int z = pos.getZ() - 3; z < pos.getZ() + 4; z++)
                    {
                        TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(x, y, z));
    
                        if(tileEntity != null && tileEntity instanceof TileEntitySoulCrucible)
                        {
                            crucibles.add((TileEntitySoulCrucible) tileEntity);
                        }
                    }
                }
            }
            return crucibles;
        }
    
        public RecipeInfusion getRecipe()
        {
            RecipeInfusion recipe = null;
    
            for(TileEntitySoulCrucible crucible : this.getCrucibles())
            {
                for(SoulType soulType : crucible.getContainer().SOULS.keySet())
                {
                    for(ISMRecipe r : SoulMagicAPI.getRecipeRegistry().typeToRecipe.values())
                    {
                        if(r instanceof RecipeInfusion)
                        {
                            RecipeInfusion newRecipe = (RecipeInfusion) r;
    
                            if(newRecipe.matches(this.getStackInSlot(0), soulType, crucible.getContainer().SOULS.get(soulType)))
                            {
                                recipe = newRecipe;
                            }
                        }
                    }
                }
            }
            return recipe;
        }
    
        public void infuse()
        {
            for(TileEntitySoulCrucible crucible : this.getCrucibles())
            {
                for(SoulType soulType : crucible.getContainer().SOULS.keySet())
                {
                    SoulMagicAPI.getRecipeRegistry().typeToRecipe.values().stream().filter(r -> r instanceof RecipeInfusion).forEach(r ->
                    {
                        RecipeInfusion newRecipe = (RecipeInfusion) r;
    
                        if(newRecipe.matches(this.getStackInSlot(0), soulType, crucible.getContainer().SOULS.get(soulType)))
                        {
                            ItemStack outStack = newRecipe.getOutput();
                            outStack.stackSize = this.getStackInSlot(0).stackSize;
    
                            crucible.getContainer().remove(soulType, outStack.stackSize * newRecipe.getRequiredSoulAmount());
                            this.setInventorySlotContents(0, outStack);
                        }
                    });
                }
            }
        }
    

     

    Crucible Container:

    public class SoulContainer
    {
        private int capacity;
    
        public final Map<SoulType, Integer> SOULS = Maps.newHashMap();
    
        public SoulContainer(int capacity)
        {
            this.capacity = capacity;
        }
    
        public void add(SoulType soulType, int amount)
        {
            if(this.getSoulAmount() + amount < this.capacity)
            {
                if(!SOULS.keySet().contains(soulType))
                {
                    SOULS.put(soulType, amount);
                }
                else
                {
                    SOULS.replace(soulType, SOULS.get(soulType) + amount);
                }
            }
        }
    
        public void remove(SoulType soulType, int amount)
        {
            if(this.getSoulAmount() - amount >= 0)
            {
                if(SOULS.keySet().contains(soulType))
                {
                    if(SOULS.get(soulType) - amount > 0)
                    {
                        SOULS.replace(soulType, SOULS.get(soulType) - amount);
                    }
                    else
                    {
                        SOULS.remove(soulType);
                    }
                }
            }
        }
    
        public void readFromNBT(NBTTagCompound tag)
        {
            NBTTagList tagList = tag.getTagList("Souls", 10);
    
            for(int i = 0; i < tagList.tagCount(); i++)
            {
                NBTTagCompound soulTag = tagList.getCompoundTagAt(i);
                String soulTypeName = soulTag.getString(NBT.SOUL_TYPE);
                SoulType soulType = SoulMagicAPI.getSoulRegistry().getSoulTypeFrom(soulTypeName);
                int amount = soulTag.getInteger("SoulAmount");
                SOULS.put(soulType, amount);
            }
            this.capacity = tag.getInteger("Capacity");
        }
    
        public void writeToNBT(NBTTagCompound tag)
        {
            NBTTagList tagList = new NBTTagList();
    
            for(Map.Entry<SoulType, Integer> soul : SOULS.entrySet())
            {
                NBTTagCompound soulTag = new NBTTagCompound();
                soulTag.setString(NBT.SOUL_TYPE, soul.getKey().getName());
                soulTag.setInteger(NBT.SOUL_AMOUNT, soul.getValue());
                tagList.appendTag(soulTag);
            }
            tag.setTag("Souls", tagList);
            tag.setInteger("Capacity", this.capacity);
        }
    
        public boolean containsSoul(SoulType soulType)
        {
            return SOULS.containsKey(soulType);
        }
    
        public SoulType getRandomSoul()
        {
            Random rand = new Random();
            Object[] souls = SOULS.keySet().toArray();
            return (SoulType) souls[rand.nextInt(souls.length)];
        }
    
        public int getCapacity()
        {
            return this.capacity;
        }
    
        public int getSoulAmount()
        {
            int amount = 0;
    
            for(SoulType soulType : SOULS.keySet())
            {
                amount += SOULS.get(soulType);
            }
            return amount;
        }
    
        public int getSoulTypeAmount(SoulType soulType)
        {
            int amount = 0;
    
            for(SoulType sT : SOULS.keySet())
            {
                if(sT == soulType)
                {
                    amount += SOULS.get(soulType);
                }
            }
            return amount;
        }
    
        public void setCapacity(int capacity)
        {
            this.capacity = capacity;
        }
    

×
×
  • Create New...

Important Information

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