Jump to content

Problem with making a configuration file!


sartharis

Recommended Posts

So I made a config file using a few tutorials, but it doesn't seem to work. It appears and everything, but when I change the numbers, nothing changes.

 

Here are the two files:

 

mod_Goblins (Only the important part shown):

 

 static
   {
   GOBLINmodHelper.initProps();
}

  //Blocks---------------------------------------------------------------------------------------------------------------------------------
   //public static final Block fireplace = new GOBLINBlockFireplace(200, 0).setHardness(1F).setResistance(1F).setBlockName("fireplace");
   public static final Block MobGSpawner = new GOBLINBlockMobGSpawner(GOBLINmodHelper.MobGSpawnerBlockID, 0, GOBLINmodHelper.SpawnerRandSpawnrate1).setHardness(4F).setResistance(1F).setBlockName("BlockMobGSpawner");
   public static final Block MobGRSpawner = new GOBLINBlockMobGRSpawner(GOBLINmodHelper.MobGRSpawnerBlockID, 0,GOBLINmodHelper.SpawnerRandSpawnrate2).setHardness(4F).setResistance(1F).setBlockName("BlockMobGRSpawner");
   public static final Block MobGMSpawner = new GOBLINBlockMobGMSpawner(GOBLINmodHelper.MobGMSpawnerBlockID, 0, GOBLINmodHelper.SpawnerRandSpawnrate3).setHardness(4F).setResistance(1F).setBlockName("BlockMobGMSpawner");      
   public static final Block VillageSpawn = new GOBLINBlockVillageSpawn (GOBLINmodHelper.VillageSpawnBlockID,1).setHardness(0.1F).setResistance(1F).setBlockName("VillageSpawn").setLightValue(0.65F);
   public static final Block ETNT = new GOBLINBlockETNT (GOBLINmodHelper.ETNTBlockID,2).setHardness(0.0F).setBlockName("ETNT").setLightValue(0.65F);
   public static final Block MTNT = new GOBLINBlockMTNT (GOBLINmodHelper.MTNTBlockID,5).setHardness(0.0F).setBlockName("MTNT").setLightValue(0.8F);
   public static final Block totemR = new GOBLINBlockTotemR (GOBLINmodHelper.totemRBlockID,.setHardness(3.5F).setResistance(20F).setBlockName("totemR").setLightValue(0.65F);
   public static final Block totemB = new GOBLINBlockTotemB (GOBLINmodHelper.totemBBlockID,10).setHardness(3.5F).setResistance(20F).setBlockName("totemB").setLightValue(0.5F);
   public static final Block totemG = new GOBLINBlockTotemG (GOBLINmodHelper.totemGBlockID,12).setHardness(3.5F).setResistance(20F).setBlockName("totemG").setLightValue(0.5F);
   public static final Block totemY = new GOBLINBlockTotemY (GOBLINmodHelper.totemYBlockID,14).setHardness(3.5F).setResistance(20F).setBlockName("totemY").setLightValue(0.65F);
   public static final Block gobDrum = new GOBLINBlockGobDrum (GOBLINmodHelper.gobDrumBlockID).setHardness(0.8F).setBlockName("gobDrum").setRequiresSelfNotify();
   public static final Block gobStone = new GOBLINBlockGobStone(GOBLINmodHelper.gobStoneBlockID,16).setHardness(1.5F).setResistance(10F).setBlockName("gobStone");
   //public static final Block gobSlabStone = new BlockGobSlabStone(213, 0).setHardness(2.0F).setResistance(10F).setBlockName("gobSlabStone");
   public static final Block gobSlabWood = new GOBLINBlockGobSlabWood(GOBLINmodHelper.gobSlabWoodBlockID, 17).setHardness(2.0F).setResistance(10F).setBlockName("gobSlabWood");
    

 

And GOBLINmodHelper:

 

package net.minecraft.src;
import java.io.File;
import java.io.IOException;

import net.minecraft.client.Minecraft;
import net.minecraft.src.forge.Configuration;

public class GOBLINmodHelper {

    public static void initProps()
    {

        File file = new File(Minecraft.getMinecraftDir() + "/config/GoblinsConfig");
        file.mkdir();
        File newFile = new File(Minecraft.getMinecraftDir() + "/config/GoblinsConfig/GoblinsConfig.cfg");

        try
        {
            newFile.createNewFile();
            System.out.println("Successfully created/read Integer.parseInt(configuration file");
        }
        catch (IOException e)
        {
            System.out.println("Could not create Integer.parseInt(configuration file for mod_HelloWorld. Reason:");
            System.out.println(e);
        }

        Configuration configuration = new Configuration(newFile);

       configuration.load();
   
                MobGSpawnerBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner 1 ID ", Configuration.CATEGORY_BLOCK, 201).value );
			MobGRSpawnerBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner 2 ID ",Configuration.CATEGORY_BLOCK, 202).value );
			MobGMSpawnerBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner 3 ID ",Configuration.CATEGORY_BLOCK, 203).value );
			VillageSpawnBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Village Spawner ID ",Configuration.CATEGORY_BLOCK, 204).value );
			ETNTBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Enchanted TNT ID ",Configuration.CATEGORY_BLOCK, 205).value );
			MTNTBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Arcane TNT ID ",Configuration.CATEGORY_BLOCK, 206).value );
			totemRBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Red Totem ID ",Configuration.CATEGORY_BLOCK, 207).value );
			totemBBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Blue Totem ID ",Configuration.CATEGORY_BLOCK, 208).value );
			totemGBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Green Totem ID ",Configuration.CATEGORY_BLOCK, 209).value );
			totemYBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Yellow Totem ID ",Configuration.CATEGORY_BLOCK, 210).value );
			gobDrumBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Drum ID ",Configuration.CATEGORY_BLOCK, 211).value );
			gobStoneBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Stone ID ",Configuration.CATEGORY_BLOCK, 212).value );
			gobSlabWoodBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Wood Slab ID ",Configuration.CATEGORY_BLOCK, 213).value );

                swordFireShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Flame Blade ID ", Configuration.CATEGORY_ITEM, 348).value );
			GoblinFleshShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Flesh ID ", Configuration.CATEGORY_ITEM, 349).value );
			bombShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Bomb ID ", Configuration.CATEGORY_ITEM, 350).value );
			staffBlueShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Arcane Staff ID ", Configuration.CATEGORY_ITEM, 351).value );
			staffNatureShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Scepter of Life ID ", Configuration.CATEGORY_ITEM, 352).value );
			ShurikenShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Shuriken ID ", Configuration.CATEGORY_ITEM, 353).value );
			arrowGShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Nature Arrow ID ", Configuration.CATEGORY_ITEM, 354).value );
			arrowRShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Explosive Arrow ID ", Configuration.CATEGORY_ITEM, 355).value );
			arrowYShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Lighting Arrow ID ", Configuration.CATEGORY_ITEM, 356).value );
			crystalBShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Blue Crystal ID ", Configuration.CATEGORY_ITEM, 357).value );
			crystalRShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Red Crystal ID ", Configuration.CATEGORY_ITEM, 358).value );
			crystalGShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Green Crystal ID ", Configuration.CATEGORY_ITEM, 359).value );
			crystalYShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Yellow Crystal ID ", Configuration.CATEGORY_ITEM, 360).value );
			powderRShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Red Powder ID ", Configuration.CATEGORY_ITEM, 361).value );
			powderBShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Blue Powder ID ", Configuration.CATEGORY_ITEM, 362).value );
			powderYShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Yellow Powder ID ", Configuration.CATEGORY_ITEM, 363).value );
			powderGShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Green Powder ID ", Configuration.CATEGORY_ITEM, 364).value );
			katanaSwordShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Katana ID ", Configuration.CATEGORY_ITEM, 365).value );
			staffTeleportShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Teleportation Staff ID ", Configuration.CATEGORY_ITEM, 366).value );
			staffLightningShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Lightning Staff ID ", Configuration.CATEGORY_ITEM, 367).value );
			ectoplasmShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Ectoplasm ID ", Configuration.CATEGORY_ITEM, 368).value );
			GoblinBowShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Bow ID ", Configuration.CATEGORY_ITEM, 369).value );

			GoblinRandSpawnrate1 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawnrate How often should goblins spawn in the wild ", Configuration.CATEGORY_GENERAL, 1).value );
			GoblinRandSpawnrate2 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawnrate min goblins in group but is often much less foor some reason ", Configuration.CATEGORY_GENERAL, 10).value );
			GoblinRandSpawnrate3 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawnrate max goblins in group but is often much less foor some reason ", Configuration.CATEGORY_GENERAL, 25).value );

			SpawnerRandSpawnrate1 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner Delay ", Configuration.CATEGORY_GENERAL, 280).value );
			SpawnerRandSpawnrate2 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Rider and Direwolf Spawner Delay ", Configuration.CATEGORY_GENERAL, 230).value );
			SpawnerRandSpawnrate3 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Miner Spawner Delay ", Configuration.CATEGORY_GENERAL, 180).value );

                VillageSpawnrate = Integer.parseInt(configuration.getOrCreateIntProperty("Village Spawnrate ", Configuration.CATEGORY_GENERAL, 36).value );				

        configuration.save();
    }


    
    static int MobGSpawnerBlockID;
    static int MobGRSpawnerBlockID;
    static int MobGMSpawnerBlockID;
    static int VillageSpawnBlockID; 
    static int ETNTBlockID; 
    static int MTNTBlockID; 
    static int totemRBlockID; 
    static int totemBBlockID; 
    static int totemGBlockID; 
    static int totemYBlockID ;
static int gobDrumBlockID ;
static int gobStoneBlockID ;
static int gobSlabWoodBlockID ;

    static int swordFireShiftedIndex;
static int GoblinFleshShiftedIndex;
    static int bombShiftedIndex;
static int staffBlueShiftedIndex;
static int staffNatureShiftedIndex;
static int ShurikenShiftedIndex;
static int arrowGShiftedIndex;
static int arrowRShiftedIndex;
static int arrowYShiftedIndex;
static int crystalBShiftedIndex;
static int crystalRShiftedIndex;
static int crystalGShiftedIndex;
static int crystalYShiftedIndex;
static int powderRShiftedIndex;
static int powderBShiftedIndex;
static int powderYShiftedIndex;
static int powderGShiftedIndex;
static int katanaSwordShiftedIndex;
static int staffTeleportShiftedIndex;
static int staffLightningShiftedIndex;
static int ectoplasmShiftedIndex;
static int GoblinBowShiftedIndex;
   
    static int GoblinRandSpawnrate1;
static int GoblinRandSpawnrate2;
static int GoblinRandSpawnrate3;

    static int SpawnerRandSpawnrate1;
static int SpawnerRandSpawnrate2;
static int SpawnerRandSpawnrate3;

    static int VillageSpawnrate;
} 

Link to comment
Share on other sites

Not only is your variable naming horrible, your code placement is horrible.

Anyways Why are you initalizing everything in the static initalizer?

Move it to load or modsloaded like a good boy.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

You didn't have to reply. You could ignore my post and someone else would solve my problem. Instead, you chose not to solve my problem, but to write un-constructive critiscism about my code. And to top that off, you didn't solve the problem either. When I posted my problem on the minecraft forum, I got an immediate fix (I asked here first, because I thought people who go on this forum all use and know how to use Forge). I assume you just wanted to offend me for no reason.

 

I don't understand what inclined you to post this. Is it that I put my question in a wrong section, and you wanted to insult me because of that? Or are you a dick to everyone who has a problem? Now, if you wrote some constructive critiscism ("like, your variable naming is bad because x", instead of "it sucks because I said so"), I wouldn't care that much, because I would learn something new.

 

Also, why did you write : "Move it to load or modsloaded like a good boy." Just because you wrote some API, doesn't mean you are better than the people who have problems here.

 

Don't get me wrong, I don't want to start a flame war (I'm deleting my account after this, because I sure I won't get any support here). I just want you to realize that you are a dick.

Link to comment
Share on other sites

You didn't have to reply. You could ignore my post and someone else would solve my problem. Instead, you chose not to solve my problem, but to write un-constructive critiscism about my code. And to top that off, you didn't solve the problem either. When I posted my problem on the minecraft forum, I got an immediate fix (I asked here first, because I thought people who go on this forum all use and know how to use Forge). I assume you just wanted to offend me for no reason.

 

I don't understand what inclined you to post this. Is it that I put my question in a wrong section, and you wanted to insult me because of that? Or are you a dick to everyone who has a problem? Now, if you wrote some constructive critiscism ("like, your variable naming is bad because x", instead of "it sucks because I said so"), I wouldn't care that much, because I would learn something new.

 

Also, why did you write : "Move it to load or modsloaded like a good boy." Just because you wrote some API, doesn't mean you are better than the people who have problems here.

 

Don't get me wrong, I don't want to start a flame war (I'm deleting my account after this, because I sure I won't get any support here). I just want you to realize that you are a dick.

 

Someone doesn't have a thick skin.

 

His reply did tell you EXACTLY how to fix it - you were initialising the blocks before the ID's had even had chance to be read. He did solve your problem, you just chose to ignore that part just because you felt his tongue in cheek reply was insulting you.

Link to comment
Share on other sites

And this ladies and gentlemen is how you get banned!

Quit being a insufferable twat, as they said I DID help you and give you the answer.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have a block already registered in my mod, which I have used in some worlds. The problem arises when in code, I add a property called CURRENT_AGE, when running Minecraft it freezes. In the console it doesn't appear any excpetion except that it stays in this phase: [Render thread/DEBUG] [ne.mi.co.ca.CapabilityManager/CAPABILITIES]: Attempting to automatically register: Lnet/minecraftforge/items/IItemHandler; Does anyone have an idea what it could be? I show the block and its registration public class SoulLichenBlock extends MultifaceBlock implements SimpleWaterloggedBlock, EntityBlock { public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final IntegerProperty SKILL_LEVEL = IntegerProperty.create("soullichen_level", 0, 30); public static final DirectionProperty FACE = DirectionProperty.create("soullichen_face"); public static final DirectionProperty DIRECTION = DirectionProperty.create("soullichen_direction"); public static final IntegerProperty CURRENT_AGE = BlockStateProperties.AGE_25; private final MultifaceSpreader spreader = new MultifaceSpreader(this); private final MultifaceSpreader.DefaultSpreaderConfig config = new MultifaceSpreader.DefaultSpreaderConfig(this); private LivingEntity owner; //private static final Integer MAX_AGE = 25; public SoulLichenBlock(Properties properties) { super(properties); this.registerDefaultState(this .defaultBlockState() .setValue(WATERLOGGED, Boolean.FALSE) .setValue(SKILL_LEVEL, 0) .setValue(FACE, Direction.DOWN) .setValue(DIRECTION, Direction.DOWN) .trySetValue(CURRENT_AGE, 0) ); } public static ToIntFunction<BlockState> emission(int p_181223_) { return (p_181221_) -> MultifaceBlock.hasAnyFace(p_181221_) ? p_181223_ : 0; } public static boolean hasFace(BlockState p_153901_, @NotNull Direction p_153902_) { BooleanProperty booleanproperty = getFaceProperty(p_153902_); return p_153901_.hasProperty(booleanproperty) && p_153901_.getValue(booleanproperty); } protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block, BlockState> stateDefinition) { stateDefinition.add(WATERLOGGED).add(SKILL_LEVEL).add(FACE).add(DIRECTION).add(CURRENT_AGE); super.createBlockStateDefinition(stateDefinition); } public @NotNull BlockState updateShape(BlockState p_153302_, @NotNull Direction p_153303_, @NotNull BlockState p_153304_, @NotNull LevelAccessor p_153305_, @NotNull BlockPos p_153306_, @NotNull BlockPos p_153307_) { if (p_153302_.getValue(WATERLOGGED)) { p_153305_.scheduleTick(p_153306_, Fluids.WATER, Fluids.WATER.getTickDelay(p_153305_)); } return super.updateShape(p_153302_, p_153303_, p_153304_, p_153305_, p_153306_, p_153307_); } @SuppressWarnings("deprecation") public @NotNull FluidState getFluidState(BlockState fluidState) { return fluidState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(fluidState); } public boolean propagatesSkylightDown(BlockState p_181225_, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos) { return p_181225_.getFluidState().isEmpty(); } public @NotNull MultifaceSpreader getSpreader() { return this.spreader; } public Optional<MultifaceSpreader.SpreadPos> spreadFromRandomFaceTowardRandomDirection( BlockState p_221620_, LevelAccessor p_221621_, BlockPos p_221622_, RandomSource p_221623_, int skillPoints, int age) { return Direction.allShuffled(p_221623_).stream().filter((p_221680_) -> { return this.config.canSpreadFrom(p_221620_, p_221680_); }).map((p_221629_) -> { return this.spreadFromFaceTowardRandomDirection(p_221620_, p_221621_, p_221622_, p_221629_, p_221623_, false, skillPoints, age); }).filter(Optional::isPresent).findFirst().orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardRandomDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, RandomSource randomSource, boolean aBoolean, int skillPoints, int age) { return Direction.allShuffled(randomSource).stream().map((direction) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, aBoolean, skillPoints, age)) .filter(Optional::isPresent) .findFirst() .orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, Direction direction, boolean aBoolean, int skillPoints, int age) { //DevilRpg.LOGGER.debug("BEGIN ==================================== spreadFromFaceTowardDirection skillPoints {}", skillPoints); return skillPoints < 0 ? Optional.empty() : getSpreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, this::canSpreadInto) .flatMap((spreadPos) -> { //DevilRpg.LOGGER.debug("END ================================ spreadFromFaceTowardDirection spreadPos {}", spreadPos); return this.spreadToFace(levelAccessor, spreadPos, aBoolean, skillPoints, direction, age); }); } public boolean canSpreadInto(BlockGetter p_221685_, BlockPos p_221686_, MultifaceSpreader.SpreadPos p_221687_) { BlockState blockstate = p_221685_.getBlockState(p_221687_.pos()); return this.stateCanBeReplaced(p_221685_, p_221686_, p_221687_.pos(), p_221687_.face(), blockstate) && isValidStateForPlacement(p_221685_, blockstate, p_221687_.pos(), p_221687_.face()); } protected boolean stateCanBeReplaced(BlockGetter p_221688_, BlockPos p_221689_, BlockPos p_221690_, Direction p_221691_, BlockState p_221692_) { return p_221692_.isAir() || p_221692_.is(this) || p_221692_.is(Blocks.WATER) && p_221692_.getFluidState().isSource(); } public Optional<MultifaceSpreader.SpreadPos> getSpreadFromFaceTowardDirection(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, Direction face, Direction direction, MultifaceSpreader.SpreadPredicate spreadPredicate) { //DevilRpg.LOGGER.debug("--- getSpreadFromFaceTowardDirection direction.getAxis() == face.getAxis(): {}", direction.getAxis() == face.getAxis()); ArrayList<Direction> directions = new ArrayList<>(); directions.add(direction); if (direction.getAxis() == face.getAxis()) { if (direction.getAxis().isHorizontal()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isVertical()).collect(Collectors.toCollection(ArrayList::new)); } if (direction.getAxis().isVertical()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isHorizontal()).collect(Collectors.toCollection(ArrayList::new)); } } for (Direction directionElement : directions) { /*DevilRpg.LOGGER.debug("--->> getSpreadFromFaceTowardDirection config.isOtherBlockValidAsSource(blockState) {} || " + "hasFace(blockState, face) {} && " + "!hasFace(blockState, direction) {}", config.isOtherBlockValidAsSource(blockState), hasFace(blockState, face), !hasFace(blockState, directionElement));*/ if (config.isOtherBlockValidAsSource(blockState) || hasFace(blockState, face) && !hasFace(blockState, directionElement)) { for (MultifaceSpreader.SpreadType multifacespreader$spreadtype : config.getSpreadTypes()) { MultifaceSpreader.SpreadPos multifacespreader$spreadpos = multifacespreader$spreadtype.getSpreadPos(blockPos, directionElement, face); //DevilRpg.LOGGER.debug("--- test SpreadPos: {} direction {} face {} ", multifacespreader$spreadpos, directionElement, face); if (spreadPredicate.test(blockGetter, blockPos, multifacespreader$spreadpos)) { //DevilRpg.LOGGER.debug("--- spreadPredicate success:"); return Optional.of(multifacespreader$spreadpos); } } } } return Optional.empty(); } public boolean isValidStateForPlacement(@NotNull BlockGetter blockGetter, @NotNull BlockState blockState, @NotNull BlockPos blockPos, @NotNull Direction face) { //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 1st condition: {} && ({} || {})", this.isFaceSupported(face), !blockState.is(this), !hasFace(blockState, face)); if (this.isFaceSupported(face) && (!blockState.is(this) || !hasFace(blockState, face))) { BlockPos blockpos = blockPos.relative(face); //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 2nd condition: canAttachTo {} ", secondCondition); return canAttachTo(blockGetter, face, blockpos, blockGetter.getBlockState(blockpos)); } else { return false; } } @Nullable public BlockState getStateForPlacement(@NotNull BlockState blockState, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos, @NotNull Direction face, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("--- getStateForPlacement"); boolean isNotValidStateForPlacement = !this.isValidStateForPlacement(blockGetter, blockState, blockPos, face); //DevilRpg.LOGGER.debug("------- isNotValidStateForPlacement: {}", isNotValidStateForPlacement); if (isNotValidStateForPlacement) { return null; } else { BlockState blockstate; if (blockState.is(this)) { blockstate = blockState; } else if (this.isWaterloggable() && blockState.getFluidState().isSourceOfType(Fluids.WATER)) { blockstate = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, Boolean.TRUE); } else { blockstate = this.defaultBlockState(); } //DevilRpg.LOGGER.debug("------- getStateForPlacement -> blockStateResult "); return blockstate .setValue(getFaceProperty(face), Boolean.TRUE) .setValue(SKILL_LEVEL, skillPoints).setValue(FACE, face) .setValue(DIRECTION, direction) .setValue(CURRENT_AGE,age) ; } } public Optional<MultifaceSpreader.SpreadPos> spreadToFace(LevelAccessor levelAccessor, MultifaceSpreader.SpreadPos spreadPos, boolean p_221596_, int skillPoints, Direction direction, int age) { BlockState blockstate = levelAccessor.getBlockState(spreadPos.pos()); //DevilRpg.LOGGER.debug("---> spreadToFace blockstate{} direction: {}", blockstate, direction); return this.placeBlock(levelAccessor, spreadPos, blockstate, p_221596_, skillPoints, direction, age) ? Optional.of(spreadPos) : Optional.empty(); } public boolean placeBlock(LevelAccessor p_221702_, MultifaceSpreader.SpreadPos p_221703_, BlockState p_221704_, boolean p_221705_, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("---> placeBlock {} direction {} ", p_221703_, direction); BlockState blockstate = this.getStateForPlacement(p_221704_, p_221702_, p_221703_.pos(), p_221703_.face(), skillPoints, direction, age); if (blockstate != null) { if (p_221705_) { p_221702_.getChunk(p_221703_.pos()).markPosForPostprocessing(p_221703_.pos()); } //DevilRpg.LOGGER.debug("------> setBlock"); return p_221702_.setBlock(p_221703_.pos(), blockstate, 2); } else { return false; } } public long spreadFromFaceTowardAllDirections( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, boolean aBoolean, int skillPoints, int age) { return Direction.stream().map((p_221656_) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, p_221656_, aBoolean, skillPoints, age)) .filter(Optional::isPresent).count(); } private boolean isWaterloggable() { return this.stateDefinition.getProperties().contains(BlockStateProperties.WATERLOGGED); } @Override public void setPlacedBy(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull BlockState blockState, @Nullable LivingEntity livingEntity, @NotNull ItemStack itemStack) { super.setPlacedBy(level, blockPos, blockState, livingEntity, itemStack); this.setOwner(livingEntity); } public LivingEntity getOwner() { return this.owner; } private void setOwner(LivingEntity livingEntity) { this.owner = livingEntity; } @Deprecated @Override public void entityInside(@NotNull BlockState blockState, @NotNull Level level, @NotNull BlockPos blockPos, @NotNull Entity entity) { if (entity instanceof LivingEntity /*&& entity.getType() != EntityType.BEE*/ && entity.getType() != ModEntities.LICHEN_SEEDBALL.get()) { entity.makeStuckInBlock(blockState, new Vec3(0.8D, 0.75D, 0.8D)); if (!level.isClientSide /*&& (entity.xOld != entity.getX() || entity.zOld != entity.getZ())*/) { // double d0 = Math.abs(entity.getX() - entity.xOld); // double d1 = Math.abs(entity.getZ() - entity.zOld); // if (d0 >= (double) 0.003F || d1 >= (double) 0.003F) { entity.hurt(level.damageSources().playerAttack((Player) owner), 1.0F); // Aplicar aceleración al movimiento double speedBoost = -0.4; // Ajusta este valor según lo rápido que quieras que sea el impulso double motionX = entity.getX() - entity.xOld; double motionZ = entity.getZ() - entity.zOld; double speed = Math.sqrt(motionX * motionX + motionZ * motionZ); //if (speed > 0.0) { entity.setDeltaMovement(entity.getDeltaMovement().multiply( (motionX / speed) * speedBoost, 0.0, (motionZ / speed) * speedBoost )); // } //} } } } @Nullable @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return ModEntityBlocks.SOUL_LICHEN_ENTITY_BLOCK.get().create(pos, state); } @Nullable @Override public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, @NotNull BlockState blockState, @NotNull BlockEntityType<T> type) { return level.isClientSide ? null : (alevel, pos, aBlockstate, blockEntity) -> { if (blockEntity instanceof SoulLichenBlockEntity soulLichenBlockEntity && alevel.getGameTime() % 5 == 0) { soulLichenBlockEntity.tick(blockState, (ServerLevel) alevel, pos, alevel.getRandom()); //DevilRpg.LOGGER.info("-------->tick. this: {}", this.getClass().getSimpleName()); } }; } }   This is the registration:   public final class ModBlocks { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, DevilRpg.MODID); ... public static final RegistryObject<SoulLichenBlock> SOUL_LICHEN_BLOCK = BLOCKS.register("soullichen", () -> new SoulLichenBlock( Block.Properties.copy(Blocks.GLOW_LICHEN).lightLevel(SoulLichenBlock.emission(7)).randomTicks() )); }  
    • If you are using AMD/ATI, check for driver updates on their website - do not update via system
    • Hi, Create a new class that extends "Block" class and you need json for it in resources/assets/modid/blockstates directory and resources/assets/modid/models. You can generate json for it using a tool like misodes model generator. Here, atleast, are blocks explained at forge docs.  Don't forge to look at vanilla code, like Magma Block is a good reference if you're trying a "green fire block".  Modid should be replaced with your actual forge mod namespace!
    • Hi my game crash with exit code 1 forge 1.19.2 java 17.02 no mods installed, i tried with forge 1.20 and same error. Vanilla version function. This is the link for the log of launch of forge 1.20 https://pastebin.com/jxqTeZkN
    • I have no idea - it is still the same issue - but idk which mod Maybe panorama_screens
  • Topics

×
×
  • Create New...

Important Information

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