Jump to content

abdmoh123

Members
  • Posts

    16
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

abdmoh123's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Yeah 'BLOCK_STRIPPING_MAP' should be obfuscated but not 'modifiers'
  2. Thank you Also, "modifiers" cannot be obfuscated probably because it's not part of forge (part of java lang); I tested it.
  3. Thanks for the help, my code seems to work now. All I need to do now is to change the variable names to the obfuscated names. Sorry for the inconvinence, but I am new to modding with forge, so please can you explain how can I find the names? Thanks
  4. Ok I changed the code for importing the values in the BLOCK_STRIPPING_MAP, but for some reason, my code causes an Illegal Access Exception. I know the reason is due to the temporary map (TEMP_BLOCK_STRIPPING_MAP), but I don't know how to fix this. I tried mutiple methods (putAll(), for loop etc.) and it still doesn't work. I even debugged it to inspect the contents of the temporary map (to see if the blocks are added to it); the blocks are successfully put. Any ideas why my code doesn't work? Thanks for the help private static Map<Block, Block> TEMP_BLOCK_STRIPPING_MAP = new HashMap<>(); private static void initMap() { Map<Block, Block> immutableMap = ObfuscationReflectionHelper.getPrivateValue(AxeItem.class, null, "BLOCK_STRIPPING_MAP"); for (Map.Entry<Block, Block> e : immutableMap.entrySet()) { TEMP_BLOCK_STRIPPING_MAP.put(e.getKey().getBlock(), e.getValue().getBlock()); } ImprovedBiomes.LOGGER.info("All items added"); } public static void registerStrippableBlocks(Block log, Block strippedLog) { try { TEMP_BLOCK_STRIPPING_MAP.put(log, strippedLog); Field field = ObfuscationReflectionHelper.findField(AxeItem.class, "BLOCK_STRIPPING_MAP"); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.set(null, TEMP_BLOCK_STRIPPING_MAP); } catch (IllegalAccessException e) { ImprovedBiomes.LOGGER.info("Illegal access"); } catch (NoSuchFieldException e) { ImprovedBiomes.LOGGER.info("No such field"); } catch (Exception e) { ImprovedBiomes.LOGGER.info("Other exception"); } }
  5. Thanks for the warning I will try to change it now.
  6. Thank you so much for the help. I used reflection to make the map accessible, then removed the final modifier from the field. After that, I just made the program refer to another map I made (to add my custom logs to the map). Here is the code I used: private static Map<Block, Block> TEMP_BLOCK_STRIPPING_MAP = new HashMap<>(); //method below adds vanilla logs to the map private static void initMap() { TEMP_BLOCK_STRIPPING_MAP.put(Blocks.OAK_WOOD, Blocks.STRIPPED_OAK_WOOD); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.OAK_LOG, Blocks.STRIPPED_OAK_LOG); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.DARK_OAK_WOOD, Blocks.STRIPPED_DARK_OAK_WOOD); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.DARK_OAK_LOG, Blocks.STRIPPED_DARK_OAK_LOG); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.ACACIA_WOOD, Blocks.STRIPPED_ACACIA_WOOD); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.ACACIA_LOG, Blocks.STRIPPED_ACACIA_LOG); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.BIRCH_WOOD, Blocks.STRIPPED_BIRCH_WOOD); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.BIRCH_LOG, Blocks.STRIPPED_BIRCH_LOG); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.JUNGLE_WOOD, Blocks.STRIPPED_JUNGLE_WOOD); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.JUNGLE_LOG, Blocks.STRIPPED_JUNGLE_LOG); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.SPRUCE_WOOD, Blocks.STRIPPED_SPRUCE_WOOD); TEMP_BLOCK_STRIPPING_MAP.put(Blocks.SPRUCE_LOG, Blocks.STRIPPED_SPRUCE_LOG); } //this method allows me to add new logs to the map public static void registerStrippableBlocks(Block log, Block strippedLog) { try { TEMP_BLOCK_STRIPPING_MAP.put(log, strippedLog); Field field = AxeItem.class.getDeclaredField("BLOCK_STRIPPING_MAP"); field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); field.set(null, TEMP_BLOCK_STRIPPING_MAP); } catch (IllegalAccessException e) { ImprovedBiomes.LOGGER.info("Illegal argument"); } catch (NoSuchFieldException e) { ImprovedBiomes.LOGGER.info("No such field"); } catch (Exception e) { ImprovedBiomes.LOGGER.info("Other exception"); } }
  7. I looked through other mods, which use a technique similar to this. I really don't want to implement something that already exists in the game. Thanks for the idea though
  8. I am trying to add a stripped version of my custom log to my mod. Currently, I am stuck because the BLOCK_STRIPPING_MAP has protected access and is final, so I couldn't edit it (to add my custom logs). Any help on fixing this since there are no online resources to help with this (I tried looking at other mods to see how they did it, but they don't work). Thanks Here is my VanillaCompat class public class ModVanillaCompatibility { public static void init() { registerStrippableBlocks(ModBlocks.BAOBAB_LOG, ModBlocks.STRIPPED_BAOBAB_LOG); registerStrippableBlocks(ModBlocks.BAOBAB_WOOD, ModBlocks.STRIPPED_BAOBAB_WOOD); ImprovedBiomes.LOGGER.info("VanillaCompat init method registered"); } public static void registerStrippableBlocks(Block log, Block strippedLog) { AxeItem.BLOCK_STRIPPING_MAP = Maps.newHashMap(AxeItem.BLOCK_STRIPPING_MAP); AxeItem.BLOCK_STRIPPING_MAP.put(log, strippedLog); } } Ask me If I need to upload more code EDIT: Thanks to all the people who helped me my problem was solved through Reflection (see bottom of the post for the solution). EDIT2: My solution was bad, since it will not work with other mods, so I am changing it (don't use my solution).
  9. I have a question: To make biomes in the nether, do I have to create a custom world type/new nether dimension? Thanks
  10. I found GrassBlock.grow() and GrassBlock.canGrow() The first one returns a void datatype and the second one returns a boolean datatype I overridden the second method to return true, but there was no change Here is the code now: public class WarpedNylium extends GrassBlock { public WarpedNylium() { super(Properties.create(Material.ORGANIC) .sound(SoundType.STONE) .hardnessAndResistance(0.4F) .harvestTool(ToolType.PICKAXE) ); setRegistryName("warped_nylium"); } @Override public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) { return true; } } I am unsure on how to override the grow() method, since it looks complicated: public void grow(World worldIn, Random rand, BlockPos pos, BlockState state) { BlockPos blockpos = pos.up(); BlockState blockstate = Blocks.GRASS.getDefaultState(); for(int i = 0; i < 128; ++i) { BlockPos blockpos1 = blockpos; int j = 0; while(true) { if (j >= i / 16) { BlockState blockstate2 = worldIn.getBlockState(blockpos1); if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) { ((IGrowable)blockstate.getBlock()).grow(worldIn, rand, blockpos1, blockstate2); } if (!blockstate2.isAir()) { break; } BlockState blockstate1; if (rand.nextInt(8) == 0) { List<ConfiguredFeature<?>> list = worldIn.getBiome(blockpos1).getFlowers(); if (list.isEmpty()) { break; } blockstate1 = ((FlowersFeature)((DecoratedFeatureConfig)(list.get(0)).config).feature.feature).getRandomFlower(rand, blockpos1); } else { blockstate1 = blockstate; } if (blockstate1.isValidPosition(worldIn, blockpos1)) { worldIn.setBlockState(blockpos1, blockstate1, 3); } break; } blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1); if (worldIn.getBlockState(blockpos1.down()).getBlock() != this || worldIn.getBlockState(blockpos1).func_224756_o(worldIn, blockpos1)) { break; } ++j; } } } Thanks for the help Edit: I found the canSustainPlant() method but I think it could be deprecated, correct me if I am wrong
  11. I got the biomes to spawn in the overworld using the code below public static void registerBiome(Biome biome, BiomeType biomeType, Type... types) { BiomeDictionary.addTypes(biome, types); BiomeManager.addBiome(biomeType, new BiomeEntry(biome, 10)); BiomeManager.addSpawnBiome(biome); } (I forgot to use BiomeManager.addBiome()) However I want the biomes to spawn in the nether. I can't find any tutorials on this, and I prefer to not create a custom world type Any ideas on how to do this?
  12. I am creating a custom netherrack grass block (warped nylium) I would like the block to turn into netherrack after placing a block on top. I would also want grass and flowers to be placeable on it. Also, any ideas on how to make it spreadable? So far, I got the block to register with textures and everything, but I could find any tutorials on getting grass functionality for it Thanks Here is the block's class so far: public class WarpedNylium extends GrassBlock { public WarpedNylium() { super(Properties.create(Material.ORGANIC) .sound(SoundType.STONE) .hardnessAndResistance(0.4F) .harvestTool(ToolType.PICKAXE) ); setRegistryName("warped_nylium"); } }
  13. The way I registered the biome is this way (in main class) @SubscribeEvent public static void onBiomesRegistry(final RegistryEvent.Register<Biome> event) { event.getRegistry().registerAll( ModBiomes.soul_sand_valley = new SoulSandValley(), ModBiomes.warped_forest = new WarpedForest() ); ModBiomes.registerBiomes(); } This is the ModBiomes class package com.abdmoh.enderium.init; import net.minecraft.world.biome.Biome; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.common.BiomeManager; public class ModBiomes { public static Biome soul_sand_valley; public static Biome warped_forest; public static void registerBiome(Biome biome, Type... types) { BiomeDictionary.addTypes(biome, types); BiomeManager.addSpawnBiome(biome); } public static void registerBiomes() { registerBiome(soul_sand_valley, Type.NETHER, Type.SPOOKY); registerBiome(warped_forest, Type.NETHER, Type.FOREST); } }
  14. My biome class looks like this public class SoulSandValley extends Biome { public SoulSandValley() { super((new Biome.Builder()) .surfaceBuilder(SurfaceBuilder.DEFAULT, new SurfaceBuilderConfig(ModBlocks.SOULSOIL.getDefaultState(), Blocks.NETHERRACK.getDefaultState(), Blocks.NETHERRACK.getDefaultState())) .category(Category.NETHER) .precipitation(RainType.NONE) .downfall(0.0F) .depth(0.1F) .scale(0.2F) .temperature(2.0F) .waterColor(0x2debeb) .waterFogColor(0x2debeb) .parent(null) ); DefaultBiomeFeatures.addMushrooms(this); DefaultBiomeFeatures.addFossils(this); this.addCarver(Carving.AIR, createCarver(WorldCarver.HELL_CAVE, new ProbabilityConfig(0.2F))); this.addStructure(Feature.NETHER_BRIDGE, IFeatureConfig.NO_FEATURE_CONFIG); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, createDecoratedFeature(Feature.SPRING_FEATURE, new LiquidsConfig(Fluids.LAVA.getDefaultState()), Placement.COUNT_VERY_BIASED_RANGE, new CountRangeConfig(20, 8, 16, 256))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, createDecoratedFeature(Feature.NETHER_BRIDGE, IFeatureConfig.NO_FEATURE_CONFIG, Placement.NOPE, IPlacementConfig.NO_PLACEMENT_CONFIG)); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, createDecoratedFeature(Feature.NETHER_SPRING, new HellLavaConfig(false), Placement.COUNT_RANGE, new CountRangeConfig(8, 4, 8, 128))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, createDecoratedFeature(Feature.BUSH, new BushConfig(Blocks.BROWN_MUSHROOM.getDefaultState()), Placement.CHANCE_RANGE, new ChanceRangeConfig(0.5F, 0, 0, 128))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, createDecoratedFeature(Feature.BUSH, new BushConfig(Blocks.RED_MUSHROOM.getDefaultState()), Placement.CHANCE_RANGE, new ChanceRangeConfig(0.5F, 0, 0, 128))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NETHERRACK, Blocks.NETHER_QUARTZ_ORE.getDefaultState(), 14), Placement.COUNT_RANGE, new CountRangeConfig(16, 10, 20, 128))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.create("BASALT", "basalt", new BlockMatcher(ModBlocks.BASALT)), Blocks.MAGMA_BLOCK.getDefaultState(), 33), Placement.MAGMA, new FrequencyConfig(4))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, createDecoratedFeature(Feature.NETHER_SPRING, new HellLavaConfig(true), Placement.COUNT_RANGE, new CountRangeConfig(16, 10, 20, 128))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.FOSSIL, IFeatureConfig.NO_FEATURE_CONFIG, Placement.CHANCE_PASSTHROUGH, new ChanceConfig(1000))); //mob spawning this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.GHAST, 70, 4, 4)); this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.SKELETON, 100, 4, 4)); this.setRegistryName("soul_sand_valley"); } @OnlyIn(Dist.CLIENT) public int getSkyColorByTemp(float currentTemperature) { return 0x2debeb; } } The biome shows up in the game in the buffet world type, but not in the default world type
  15. Any clues on how to get a biome to generate in the nether. Also, how can I tweak the rarity of the biome. Thanks
×
×
  • Create New...

Important Information

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