Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12.2] Override Air


Cadiboo
 Share

Recommended Posts

How would I override Air in the block registry?

I've tried

Spoiler

@SubscribeEvent
public static void onRegisterBlocksEvent(final RegistryEvent.Register<Block> event) {

	event.getRegistry().register(

		(new BlockAir() {

			@Override
			public BlockRenderLayer getRenderLayer() {

				return airRenderLayerHook();

			}

			@Override
			public EnumBlockRenderType getRenderType(IBlockState state) {

				return airRenderTypeHook(state);

			}
		})

			.setRegistryName("minecraft:air")

			.setTranslationKey(Blocks.AIR.getTranslationKey())

	);

}

 

But I get this error

Spoiler

[14:07:50] [main/WARN] [FML]: Potentially Dangerous alternative prefix `minecraft` for name `air`, expected `nocubes`. This could be a intended override, but in most cases indicates a broken mod.
[14:07:50] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.RegistryEvent$Register@2bd20f96:
java.lang.IllegalStateException: Attemped to override already set default value. This is not allowed: The object Block{null} (name minecraft:air)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:335) ~[ForgeRegistry.class:?]
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:289) ~[ForgeRegistry.class:?]
    at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:122) ~[ForgeRegistry.class:?]
    at cadiboo.nocubes.EventSubscriber.onRegisterBlocksEvent(EventSubscriber.java:44) ~[EventSubscriber.class:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_EventSubscriber_onRegisterBlocksEvent_Register.invoke(.dynamic) ~[?:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144) ~[EventBus$1.class:?]
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:752) [GameData.class:?]
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628) [Loader.class:?]
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:246) [FMLClientHandler.class:?]
    at net.minecraft.client.Minecraft.init(Minecraft.java:513) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
[14:07:50] [main/ERROR] [FML]: Index: 2 Listeners:
[14:07:50] [main/ERROR] [FML]: 0: NORMAL
[14:07:50] [main/ERROR] [FML]: 1: net.minecraftforge.fml.common.eventhandler.EventBus$1@6f99ed9f
[14:07:50] [main/ERROR] [FML]: 2: net.minecraftforge.fml.common.eventhandler.EventBus$1@2f2c41d3
[14:07:51] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// Don't be sad. I'll do better next time, I promise!

Time: 11/25/18 2:07 PM
Description: Initializing game

java.lang.IllegalStateException: Attemped to override already set default value. This is not allowed: The object Block{null} (name minecraft:air)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:335)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:289)
    at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:122)
    at cadiboo.nocubes.EventSubscriber.onRegisterBlocksEvent(EventSubscriber.java:44)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_EventSubscriber_onRegisterBlocksEvent_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:752)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:246)
    at net.minecraft.client.Minecraft.init(Minecraft.java:513)
    at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:335)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:289)
    at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:122)
    at cadiboo.nocubes.EventSubscriber.onRegisterBlocksEvent(EventSubscriber.java:44)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_EventSubscriber_onRegisterBlocksEvent_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:752)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:246)
    at net.minecraft.client.Minecraft.init(Minecraft.java:513)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)
 

I only really need to override 1 method in BlockAir. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I don't think you are allowed to do this.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Would I be able to set the value with reflection? It's a client-side only mod and the only functionality added is allowing it to use a model

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

It might be possible with reflection, but I spent an hour and a half trying to make it work and couldn’t.

You need to modify 2 locked registries and set their default values AND register your new air block without Forge realising what your doing and marking it as an override. You have to somehow pretend that the mod registering the block is FML/null. I managed to get it almost to work (got it all the way to the resync of the registries) but gave up.

I achieved it in the way we don’t talk about, and air renders perfectly now ?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • ok, i'm not surprised i was wrong about the player, i've only ever sent in opposite direction. getSender is there and i should have checked instead of posting blindly... but how would he know the block location without including it in the message?
    • Sorry I can't find any premade tutorials for 1.17 at the moment. It really depends on the version of forge you are using. But here's the rundown: You want to look at classes such as BeaconBlock, or ChestBlock, BeaconMenu, etc. to help you with these steps, but you need to do the following: 1. Make a block extending BaseEntityBlock (BeaconBlock) 2. Make a block entity for it (BeaconBlockEntity) 3. Make a menu for it (BeaconMenu) 4. Make a screen for it (BeaconScreen) I know it's a little complex, but I'm sure you can find tutorials online, or if someone else comes in to help.
    • This usually happens because of a bad manifest (mods.toml). Can you show us what's in your src folder?
    • Don't change it, the launcher comes with it configured properly.
    • Hello all. I am trying to implement oil into my mod (I know I know, unoriginal). But I just can't seem to get it to work. (System/Minecraft information: Java 17, forge: 1.17.1-37.0.95, mappings: official) I am using DeferredRegisters. In the current configuration, the bucket doesn't do anything most of the time, the block doesn't appear and doesn't flow. I am extending "ForgeFlowingFluid". It seems in LiquidBlock there are two constructors, one deprecated taking in a Fluid, the other takes in a supplier/RegistryObject<Fluid>. Because I am using DeferredRegisters, I have to use the second one, because blocks are registered before fluids. But it seems that in the code, most of it relies on the LiquidBlock.fluid field, which never gets set in the second constructor. I tried hacking in a solution with a "Fixed" version of LiquidBlock: public class FixedLiquidBlock extends LiquidBlock { private static final List<FixedLiquidBlock> liquidBlocksNeedingFixing = new ArrayList<>(); // Check if the supplier is a registry object. If it is, and the value is not null, set the value of the fluid field, else mark it so that it gets set later. public FixedLiquidBlock(Supplier<? extends FlowingFluid> supplier, Properties properties) { super(supplier, properties); try { if (supplier instanceof RegistryObject registryObject && registryObject.get() != null) { try { Class<?> class_ = LiquidBlock.class; Field fluidField = ObfuscationReflectionHelper.findField(class_, "fluid"); fluidField.setAccessible(true); fluidField.set(this, supplier.get()); } catch (Exception e) { throw new RuntimeException(e); } } } catch (NullPointerException ignored) {} liquidBlocksNeedingFixing.add(this); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) private static class FixedLiquidBlockEvents { @SubscribeEvent(priority = EventPriority.LOWEST) // Force the event to be called last // After registration of fluids is finished, set the fluids field. public static void onFluidsRegister(RegistryEvent<Fluid> fluidRegistryEvent) { for (FixedLiquidBlock fixedLiquidBlock : liquidBlocksNeedingFixing) { try { Class<?> class_ = LiquidBlock.class; Field fluidField = ObfuscationReflectionHelper.findField(class_, "fluid"); fluidField.setAccessible(true); fluidField.set(fixedLiquidBlock, fixedLiquidBlock.getFluid()); } catch (Exception e) { throw new RuntimeException(e); } } } } } But clearly what I'm doing is stupid because it still doesn't work. I even tried without my hacky solution, and it still didn't work! Am I doing something wrong? Should I be extending something else? What else should I do?   Code for fluid, OilFluid.java:   public abstract class OilFluid extends ForgeFlowingFluid { protected OilFluid() { super(new ForgeFlowingFluid.Properties( Source::new, Flowing::new, FluidAttributes.builder( new ResourceLocation(MiniTech.MODID, "block/oil_still"), new ResourceLocation(MiniTech.MODID, "block/oil_flow") ).overlay(new ResourceLocation(MiniTech.MODID, "block/oil_overlay")) .translationKey("block." + MiniTech.MODID + ".oil") .color(0xffffff))); } public static class Flowing extends OilFluid { public Flowing() { registerDefaultState(getStateDefinition().any().setValue(LEVEL, 7)); } @Override protected void createFluidStateDefinition(StateDefinition.Builder<Fluid, FluidState> p_76476_) { super.createFluidStateDefinition(p_76476_); p_76476_.add(LEVEL); } @Override public int getAmount(FluidState p_76480_) { return p_76480_.getValue(LEVEL); } @Override public boolean isSource(FluidState p_76478_) { return false; } } public static class Source extends OilFluid { @Override public int getAmount(FluidState p_76485_) { return 8; } @Override public boolean isSource(FluidState p_76483_) { return true; } } } Code for ModBlocks.java:   public class ModBlocks { private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MiniTech.MODID); public static final RegistryObject<RefineryFurnaceBlock> REFINERY_FURNACE = BLOCKS.register("refinery_furnace", () -> new RefineryFurnaceBlock(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(3.5F).lightLevel(litBlockEmission(13)))); // Fluids public static final RegistryObject<LiquidBlock> OIL = BLOCKS.register("oil", () -> new FixedLiquidBlock(ModFluids.OIL, BlockBehaviour.Properties.of(Material.WATER).noCollission().strength(100.0F).noDrops())); public static void register(IEventBus eventBus) { BLOCKS.register(eventBus); } private static ToIntFunction<BlockState> litBlockEmission(int lightLevel) { return (blockState) -> { return blockState.getValue(BlockStateProperties.LIT) ? lightLevel : 0; }; } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.