Jump to content

Drachenbauer

Members
  • Posts

    724
  • Joined

  • Last visited

Posts posted by Drachenbauer

  1. But i still don´t know, how to switch textures without creating a new model file?

     

    I want to use the existing sandstone stairs model, rotate it 180° for upside down and switch textures for top and bottom.

     

    for older versions, a forge blockstate json made it possible.

     

    But is it now possible witth the normal blockstate format, too?

  2. Hello

     

    At testing around with stairs-blocks, i noticed, the sandstone-stairs (red and baige) have turned their different textures with them, if used upside down.

    the rough sandstone_bottom textures are now on top of the block and the smooth sandstone_top thextures are now at the bottom.

    Is there any way to switch theese textures in the blockstates-json, without creating extra upside down models?

     

    I found this forge blockstates page:

    Forge blockstates json

    But i´m not sure, if this also works in 1.15.2.

  3. In my mods i work on increasing the number of different slabs, stairs, walls, buttons and pressureplates to match all solid 16 colors materials (concrete, wool, terracotta and glazed terracotta = 64 different textures) and most of the different stone-types (about 24 different textures).

     

    Now i have a question about stairs and buttons out of glazed terracotta (to reproduce the textures-behavior of the glazed terracotta blocks):

    They already use horizontal facing for their model-rotation.

    Maybe i can add a seccond similar blockstate (may named "texture_facing") and all needed model jsons and a blockstate-json, that provides all possible combinations of the two blockstate-sets.

    How can i make it possible to handle all theese states ingame at placing the block?

  4. Hello

    I´m creating custom pressure plates from alot of stone-Types.

    One set is made out of the 16 glzed terracottas.

    Now i want to have them rotateable to fit with the different rotations of this block.

    But they are stuck in pressed state.

    My PressurePlateBlock-class:

    Spoiler
    
    package drachenbauer32.coloredbuttonspressureplatesmod.blocks;
    
    import java.util.List;
    
    import net.minecraft.block.AbstractPressurePlateBlock;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockState;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.LivingEntity;
    import net.minecraft.entity.player.PlayerEntity;
    import net.minecraft.state.BooleanProperty;
    import net.minecraft.state.StateContainer;
    import net.minecraft.state.properties.BlockStateProperties;
    import net.minecraft.util.SoundCategory;
    import net.minecraft.util.SoundEvents;
    import net.minecraft.util.math.AxisAlignedBB;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IWorld;
    import net.minecraft.world.World;
    
    public class PressurePlateBlock extends AbstractPressurePlateBlock
    {
        public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
        
        public PressurePlateBlock(Block.Properties propertiesIn)
        {
            super(propertiesIn);
            this.setDefaultState(this.stateContainer.getBaseState().with(POWERED, Boolean.valueOf(false)));
        }
        
        protected int getRedstoneStrength(BlockState state)
        {
            return state.get(POWERED) ? 15 : 0;
        }
        
        protected BlockState setRedstoneStrength(BlockState state, int strength)
        {
            return state.with(POWERED, Boolean.valueOf(strength > 0));
        }
        
        protected void playClickOnSound(IWorld worldIn, BlockPos pos)
        {
            worldIn.playSound((PlayerEntity)null, pos, SoundEvents.BLOCK_STONE_PRESSURE_PLATE_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.6F);
        }
        
        protected void playClickOffSound(IWorld worldIn, BlockPos pos)
        {
            worldIn.playSound((PlayerEntity)null, pos, SoundEvents.BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.5F);
        }
        
        protected int computeRedstoneStrength(World worldIn, BlockPos pos)
        {
            AxisAlignedBB axisalignedbb = PRESSURE_AABB.offset(pos);
            List<? extends Entity> list = worldIn.getEntitiesWithinAABB(LivingEntity.class, axisalignedbb);
               
            if (!list.isEmpty())
            {
                for(Entity entity : list)
                {
                    if (!entity.doesEntityNotTriggerPressurePlate())
                    {
                        return 15;
                    }
                }
            }
            
            return 0;
       }
    
       protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
       {
          builder.add(POWERED);
       }
    }

    I needed to create it, because the constructor of the existing one is protected, so i cannot instantiate it for my custom pressureplates.

     

    And here is the class for the rotateable ones:

    Spoiler
    
    package drachenbauer32.coloredbuttonspressureplatesmod.blocks;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockState;
    import net.minecraft.block.HorizontalBlock;
    import net.minecraft.item.BlockItemUseContext;
    import net.minecraft.state.DirectionProperty;
    import net.minecraft.state.StateContainer;
    import net.minecraft.util.Direction;
    import net.minecraft.util.Rotation;
    
    public class RotateablePressurePlateBlock extends PressurePlateBlock
    {
        public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
        
        public RotateablePressurePlateBlock(Properties propertiesIn)
        {
            super(propertiesIn);
            this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
        }
        
        @Override
        protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
        {
            super.fillStateContainer(builder);
            builder.add(FACING);
        }
        
        @Override
        public BlockState getStateForPlacement(BlockItemUseContext context)
        {
            return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
        }
        
        @Override
        public BlockState rotate(BlockState state, Rotation rot)
        {
            return state.with(FACING, rot.rotate(state.get(FACING)));
        }
    }

    What must i change here to make it work right?

     

    Edit:

    i had to put the facing and the powered state (set to false) into the setDefaultState-line in the consturctor ff the modifyed-class, not only the facing.

    After i rompved and replaced theese presureplates in my test-world, now they work correct.

  5. I found a solution, bevore i saw your answer:

    I made my own wall-block, that extends the vanilla one and added theese functions:

        private boolean isWall(BlockState state, BlockState facingState, boolean isSolid, Direction direction)
        {
            Block block = state.getBlock();
            Block facingBlock = facingState.getBlock();
            boolean flag = (block.isIn(BlockTags.WALLS) && (block == facingBlock)) || (facingBlock instanceof FenceGateBlock && FenceGateBlock.isParallel(state, direction));
            return !cannotAttach(block) && isSolid || flag;
        }
        
        @Override
        public BlockState getStateForPlacement(BlockItemUseContext context)
        {
            IWorldReader iworldreader = context.getWorld();
            BlockPos blockpos = context.getPos();
            BlockState blockstate = iworldreader.getBlockState(blockpos);
            IFluidState ifluidstate = context.getWorld().getFluidState(blockpos);
            BlockPos blockpos1 = blockpos.north();
            BlockPos blockpos2 = blockpos.east();
            BlockPos blockpos3 = blockpos.south();
            BlockPos blockpos4 = blockpos.west();
            BlockState blockstate1 = iworldreader.getBlockState(blockpos1);
            BlockState blockstate2 = iworldreader.getBlockState(blockpos2);
            BlockState blockstate3 = iworldreader.getBlockState(blockpos3);
            BlockState blockstate4 = iworldreader.getBlockState(blockpos4);
            boolean flag1 = this.isWall(blockstate, blockstate1, blockstate1.isSolidSide(iworldreader, blockpos1, Direction.SOUTH), Direction.SOUTH);
            boolean flag2 = this.isWall(blockstate, blockstate2, blockstate2.isSolidSide(iworldreader, blockpos2, Direction.WEST), Direction.WEST);
            boolean flag3 = this.isWall(blockstate, blockstate3, blockstate3.isSolidSide(iworldreader, blockpos3, Direction.NORTH), Direction.NORTH);
            boolean flag4 = this.isWall(blockstate, blockstate4, blockstate4.isSolidSide(iworldreader, blockpos4, Direction.EAST), Direction.EAST);
            boolean flag5 = (!flag1 || flag2 || !flag3 || flag4) && (flag1 || !flag2 || flag3 || !flag4);
            return this.getDefaultState().with(UP, Boolean.valueOf(flag5 || !iworldreader.isAirBlock(blockpos.up()))).with(NORTH, Boolean.valueOf(flag1)).with(EAST, Boolean.valueOf(flag2)).with(SOUTH, Boolean.valueOf(flag3)).with(WEST, Boolean.valueOf(flag4)).with(WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER));
        }
        
        @Override
        public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos)
        {
          if (state.get(WATERLOGGED)) {
             world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
          }
    
          if (facing == Direction.DOWN) {
             return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
          } else {
             Direction direction = facing.getOpposite();
             boolean flag1 = facing == Direction.NORTH ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(NORTH);
             boolean flag2 = facing == Direction.EAST ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(EAST);
             boolean flag3 = facing == Direction.SOUTH ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(SOUTH);
             boolean flag4 = facing == Direction.WEST ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(WEST);
             boolean flag5 = (!flag1 || flag2 || !flag3 || flag4) && (flag1 || !flag2 || flag3 || !flag4);
             return state.with(UP, Boolean.valueOf(flag5 || !world.isAirBlock(currentPos.up()))).with(NORTH, Boolean.valueOf(flag1)).with(EAST, Boolean.valueOf(flag2)).with(SOUTH, Boolean.valueOf(flag3)).with(WEST, Boolean.valueOf(flag4));
          }
       }

    the first one bases on a function, that still has the SRC-name in the vanilla-class.

    It checfs for blocks in the walls-tag and fencegates.

    i made it compare the type of wall, too and renamed it more clear.

    so i also copyed and overrided the two functions, wich call it, too, and modifyed them to use my new function.

  6. Hello

     

    I´m creating a slab out of glazed terracotta and want to make it show the following placing-behavior:

    it should show a horizontal rotated model matching to the player´s view-direction, combined with the common way to choose up or down or double-slab-variant.

    My blockstate-json is ready (It holds all possible combinations of direction and slab-type = 12 variants).

    But i have a problem with the new class, that extends SlabBlock.

    How must i setup the getStateForPlacement function for this?

     

    Edit:

    I founfd the solution:

    At fitst i applied the horizontal rotation, as i did it as the only blockstate in another mod.

    Now i found out, that i hat to copx the content of getStateForPlacement and added the rotation to the two blockstate-defiition-lines in there.

    Now it works.

     

    But now i have a question about stairs out of glazed terracotta:

    Is there any way for the player to choose model-rotation and texture rotation separate?

    It maybe able to add more model jsons to cover all combinations of shape and texture-rotation (24 models instead of 3) and apply them all to different blockstate-combinations in the blockstate-json.

    But i´m not sure, how the player can handle all theese variants ingame...

    Ani idea?

  7. You don´t have to create your own StairsBlockClass.

    in 1.15.2 this works fine for a StairsBlock out of the vanilla yellow_concrete:

    public static final RegistryObject<Block> YELLOW_CONCRETE_STAIRS = BLOCKS.register("yellow_concrete_stairs", () -> new StairsBlock(YELLOW_CONCRETE, Block.Properties.create(
                            Material.ROCK, MaterialColor.YELLOW).sound(SoundType.STONE).lightValue(0).hardnessAndResistance(1.8F)));

    It uses a seccond constructor in the vanilla StairsBlock-class, that wants a blockstate in a supplier as the first content..

    So i created suppliers, wich contain the blockstates of the different vanilla concrete blocks.

     

    I only create a custom SlabBlock-class (that extends the vanilla one) for my glazed terracotta slabs to make them rotatable north, east, south and west (for texture-patterns).

     

    Maybe this is helpful for 1.14 too.

    edit:

    i noticed, the seccond constructor there is new in 1.15.

  8. Hello

     

    i have seen a mod, that has a block, that rotates the gravitx direction towards it.

    It´s called a "gravity-core-block"

    If the player is near it´s side, the player-model rotates horizontal with the feet to the block and if not creative-mode-flying, the payer is pulled to the block by a gravity effect.

    If under the block, the same effect appears upside doen.

    Maybe the same happens with entities.

     

    How can i code this effect?

     

    An how can i make an option, that changes the strength of gravity (reduced gravity = jumping higher and falling slower, negative gravity = hovering up and hanging under the ceiling like a helium filled balloon)?

  9. Now i noticed, there seems to be a slightly different shader, if the color comes from a texture pnr or from a colorvalue-number in the code:

    2020-04-13_18_20_22.png.df1ed41520fea61350e81624b9243e35.png

    The leather-armour is dyed with the new shade of pink, i gave with my mod-code.

    And in my skin png (Stella from Angry Birds) i used the same color value for the pink color.

    So i wonder, why it looks different on almost horizontal surfaces (like the character´s face, if looking upward, like in the upper picture or the top of the body-ModelBox)

    2020-04-13_18_20_09.png.4a8025ec457fd6ba4e31a56d9ed3c401.png

    in this more vertical orientation, you can see, that the lighter pink in the middie of th helmet-front is exctly the same as at the face of the character.

    And directly below the head, you can see the different shading between body and armour again

     

    another sample:

    bed and banner

    2020-04-13_18_38_44.png.f8e35ebff50f5b384ba2b7a26a75185f.png

    In this bed-texture png i also used the same shade of pink and the banner get´s it´s color from my mod-code.

    both models are TileEntity models

    The same difference at the horizontal surfaces (the narrow top of the banner looks closer to white, than the top of the bed).

     

    Why it makes a difference there, if the color comes from the texture or from a value in the code?

  10. Now i finally found the solution:

    i remembered, that there is a calculation for colorComponentValues.

    i placed it in a function in my main-class and passed the result of this function into another reflection-line for each color, that uses the field colorComponentValues.

    now the game-stuff appears in the new colors.

  11. i decided to watch a video, how to use the debugger, than try this, and than tell more here.

    Like the guy in the video, i made a breakpoint at the first one of theese lines and clicked the debug-button, but it does not stop there.

     

    in other mods, other code, located in common-setup and client-registries is executed.

    So i´m wondering about this.

  12. I made a test, but the banners, sheeps and other stuff still appear in old colors.

    I tried the code in common-setup and client-registries in my main-class, both the same.

     

    Now my lines look like this:

            ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.RED, 0xff0000, "field_193351_w"); //colorvalue
            ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.RED, 0xff0000, "field_196067_y"); //fireworkColor
            ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.RED, 0xff0000, "field_218390_z"); //textColor

    Such a stack for each color.

     

    And for the material-color, i found out, that the colors there are such class-instances, zoo.

    So i was able to make this:

    ObfuscationReflectionHelper.setPrivateValue(MaterialColor.class, MaterialColor.RED, 0xff0000, "field_76291_p");//colorvalue

    also for all theese 16 colors and terracotta-colors. (there are some more values, but i don´t want to change them.)

     

    What do i miss, to get this stuff to work?

  13. Now i have theese lines for all 15 colors.

     

    Is this all i need to show all this stuff in the new colors?

     

    Now i found the class MaterialColors, where i als want to change fields now.

    What must i put there as the class-instance?

     

    Edit:

    The colors of banners and stuff are not changed now.

    What else must i do, to make it work?

  14. In my lines there i use the clear names DyeColor and WHITE.

    I taught, maybe i have to use the SRG-Names for theese things, too, in the positions for class and instance in the code-line...

     

    But maybe not, because it don´t want theese names as a string, like the fieldname.

     

    Another thing, yout discord-link stucks on connecting (a black page with a rotating discord-logo)...

  15.         ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.WHITE, 16777215, "colorvalue");
            ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.WHITE, 16777215, "fireworkColor");
            ObfuscationReflectionHelper.setPrivateValue(DyeColor.class, DyeColor.WHITE, 16777215, "textColor");

    Is this the way to do it?

     

    To repeat for all 16 colors.

×
×
  • Create New...

Important Information

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