Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

DarkLions

Members
  • Joined

  • Last visited

Everything posted by DarkLions

  1. So I have found out what the problem was. The Overworlddimension has overwrite the defaultBlock value. Because the value is in the constructor defined, I can‘t change it directly. or is impossible to change. The best is I just create a custom Dimension and settings. Thank you for your support :D
  2. Thanks for your reply. The code is seperated from the main class and it will called if the "FMLLoadCompleteEvent" is fired. I have tried (Class GenClass = GenerationSettings.class) seem also not working. So have tried to implement the ObfuscationReflectionHelper, but I get the same issue. It isn't changing anything. I'm not sure, if it is because I call a newInstance for the object. the code in his own class: (only changed the class.getDeclaredField to ObfuscationReflection) package com.darklions.testmod.world.gen; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import com.darklions.testmod.objects.items.StickOfDebug; import net.minecraft.block.Blocks; import net.minecraft.world.gen.GenerationSettings; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; public class VanillaGenSettingsOverride { public static void overrideSettings() { try { Class<?> GenClass = GenerationSettings.class; //used this method instead of GenClass.getDeclaredField Field defaultBlockField = ObfuscationReflectionHelper.findField(GenClass, "defaultBlock"); GenerationSettings gen = (GenerationSettings) GenClass.newInstance(); Field modifiers = Field.class.getDeclaredField("modifiers"); modifiers.setAccessible(true); modifiers.setInt(defaultBlockField, defaultBlockField.getModifiers() & ~Modifier.FINAL); defaultBlockField.set(gen, Blocks.DIAMOND_BLOCK.getDefaultState()); //this give me the diamond_block value StickOfDebug.s = new String(defaultBlockField.get(gen).toString()); } catch(Exception e) { StickOfDebug.s = new String(e.toString()); } } } @SubscribeEvent public static void loadCompleteEvent(FMLLoadCompleteEvent event) { CustomOreGen.setupOverWorldOreGeneration(); CustomOreGen.setupEndOreGeneration(); CustomOreGen.setupNetherOreGeneration(); CustomWorldCarverGen.setupEndCarverGeneration(); VanillaGenSettingsOverride.overrideSettings(); } And this is in the main class.
  3. (I apologize for bad english) Hello, I have tried to overwrite the vanilla GenerationSettings using Java.Reflection. Settings override class: (This code will run, if the LoadCompleteEvent fire) public static void overrideSettings() { try { Class<?> GenClass = Class.forName("net.minecraft.world.gen.GenerationSettings"); Field defaultBlockField = GenClass.getDeclaredField("defaultBlock"); GenerationSettings gen = (GenerationSettings) GenClass.newInstance(); defaultBlockField.setAccessible(true); Field modifiers = Field.class.getDeclaredField("modifiers"); modifiers.setAccessible(true); modifiers.setInt(defaultBlockField, defaultBlockField.getModifiers() & ~Modifier.FINAL); defaultBlockField.set(gen, Blocks.DIAMOND_BLOCK.getDefaultState()); StickOfDebug.s = new String(defaultBlockField.get(gen).toString()); } catch(Exception e) { StickOfDebug.s = new String(e.toString()); } } The Field with the "defaultBlock" have been successfully overwritten and the field give me the diamond_block and I don't get any exception. But when I generate a new world, the defaultBlock is still stone_block. If I using the my Debug_Stick, the GenerationSettings still give me the stone_block value back. The debug stick class: public class StickOfDebug extends Item { public static String s = ""; public StickOfDebug(Properties properties) { super(properties); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if(worldIn.isRemote) { return ActionResult.resultPass(itemstack); } else { playerIn.sendMessage(new StringTextComponent(s)); try { Class<?> genClass = Class.forName("net.minecraft.world.gen.GenerationSettings"); GenerationSettings gen = (GenerationSettings) genClass.newInstance(); Field field = genClass.getDeclaredField("defaultBlock"); field.setAccessible(true); playerIn.sendMessage(new StringTextComponent(field.get(gen).toString())); } catch (Exception e) { e.printStackTrace(); } return ActionResult.resultSuccess(itemstack); } } } I would appreciate if someone could help me.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.