Jump to content

monkeysHK

Members
  • Posts

    18
  • Joined

  • Last visited

Recent Profile Visitors

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

monkeysHK's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello. I am trying to find a method to intercept the behaviour of CTRL + Middle Click (pick block with NBT) on a vanilla block, and change the item being pushed into the player's inventory. Is it possible? [Accepting solutions for versions 1.18.2 or 1.19.2.]
  2. Oh that's what I need. Now it worked & thanks again!
  3. How can I get Minecraft's dispatcher?
  4. Hello. I want to register a command class. This is how I did it and doesn't work. private static final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>(); @SubscribeEvent public static void serverStarting(FMLServerStartingEvent event) { ConfigCommand.register(dispatcher); } What is the right way to register the command?
  5. Ok, I tried that a few more ways, but the only way worked is to replace blendColor with the depreciated color4f. (Not sure if that's the best way to go for but that worked) Thank you @ChampionAsh5357 for all the suggestions/help private static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = new RenderState.TransparencyState("translucent_transparency", () -> { RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); }, () -> { RenderSystem.disableBlend(); RenderSystem.defaultBlendFunc(); }); TRANSLUCENT_TRANSPARENCY.setupRenderState(); RenderSystem.color4f(1f, 1f, 1f, 0.3f); matrixStack.translate(instru_pos[currentNbo.ordinal()][0], instru_pos[currentNbo.ordinal()][1], 0); matrixStack.scale((255/20f)*scale, (255/20f)*scale, (255/20f)*scale); this.blit(matrixStack, 0, 0, 0, 146, 20, 20); TRANSLUCENT_TRANSPARENCY.clearRenderState();
  6. Hi. I tried translucent_transparency. I copied code from it to setup and clear the renderstate. Still doesn't work, texture is not transparent. Am I missing something? minecraft.getTextureManager().bindTexture(TEXTURE_LOC); matrixStack.push(); { RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.blendColor(1f, 1f, 1f, 0.5f); matrixStack.translate(instru_pos[currentNbo.ordinal()][0], instru_pos[currentNbo.ordinal()][1], 0); matrixStack.scale((255/20f)*scale, (255/20f)*scale, (255/20f)*scale); this.blit(matrixStack, 0, 0, 0, 146, 20, 20); RenderSystem.disableBlend(); RenderSystem.defaultBlendFunc(); } matrixStack.pop();
  7. It was a really good reference to look at. I am trying to define a RenderState and use their constructor and their setup and clear functions. But it still wouldn't work. private static final RenderState.AlphaState HALF_ALPHA = new RenderState.AlphaState(0.5F); minecraft.getTextureManager().bindTexture(new ResourceLocation("minecraft", "textures/gui/widgets.png")); matrixStack.push(); HALF_ALPHA.setupRenderState(); { matrixStack.translate(instru_pos[currentNbo.ordinal()][0], instru_pos[currentNbo.ordinal()][1], 0); matrixStack.scale((255/20f)*scale, (255/20f)*scale, (255/20f)*scale); this.blit(matrixStack, 0, 0, 0, 146, 20, 20); } HALF_ALPHA.clearRenderState(); matrixStack.pop();
  8. Hello. I am having trouble making a picture render transparent on my Screen and I am not sure what the problem is. It renders correctly but not transparent. Here is my code in MyScreen::render Also I want to know how to remove the effect of RenderSystem afterwards for further renders. TextureManager tm = minecraft.getTextureManager(); ResourceLocation rl = new ResourceLocation("minecraft", "textures/gui/widgets.png"); tm.bindTexture(rl); matrixStack.push(); { RenderSystem.colorMask(true, true, true, true); RenderSystem.blendColor(1f, 1f, 1f, 0.5f); RenderSystem.enableBlend(); matrixStack.translate(instru_pos[currentNbo.ordinal()][0], instru_pos[currentNbo.ordinal()][1], 0); matrixStack.scale(scale, scale, scale); this.blit(matrixStack, 0, 0, 0, 146, 20, 20); } matrixStack.pop(); Any replies will be appreciated.
  9. That's exactly what I wanted to look at. (It's so obvious and I was dumb) Thanks
  10. Hello. As we can look at the declaration of blocks in Blocks.java, I want to know if forge has a place to store vanilla BlockItem declarations (for each of their vanilla blocks), or where they initialize.
  11. Oh yes that was exactly the problem. Spent a little more time on documentation and figured it out. Thank you so much! Code that works. @Mod.EventBusSubscriber(modid = nbaddons.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class Registration { public static final DeferredRegister<Block> VANILLA_BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "minecraft"); public static RegistryObject<Block> NOTEBLOCK = VANILLA_BLOCKS.register( "note_block", () -> new NBTNoteBlock(AbstractBlock.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.8F))); public static final DeferredRegister<TileEntityType<?>> TILE_ENTITIES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, nbaddons.MOD_ID); public static RegistryObject<TileEntityType<NoteBlockTileEntity>> NOTEBLOCK_TE = TILE_ENTITIES.register( "note_block", () -> TileEntityType.Builder.create(NoteBlockTileEntity::new, Blocks.NOTE_BLOCK).build(null)); public static void register() { VANILLA_BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); TILE_ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus()); } }
  12. Oops... I omitted the class because I thought I would not need it for the discussion. Here is the full Registration.java. public static final DeferredRegister<Block> VANILLA_BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "minecraft"); public static RegistryObject<Block> NOTEBLOCK = VANILLA_BLOCKS.register( "note_block", () -> new NBTNoteBlock(AbstractBlock.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.8F))); public static final DeferredRegister<TileEntityType<?>> TILE_ENTITIES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, nbaddons.MOD_ID); public static RegistryObject<TileEntityType<?>> NOTEBLOCK_TE = Registration.TILE_ENTITIES.register( "note_block", () -> NoteBlockTileEntity.register("note_block", TileEntityType.Builder.create(NoteBlockTileEntity::new, Blocks.NOTE_BLOCK))); public static void register() { VANILLA_BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); TILE_ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus()); } NoteBlockTileEntity.java:53 (I copied some lines from TileEntityType::register) public static <T extends TileEntity> TileEntityType<T> register(String key, TileEntityType.Builder<T> builder) { Type<?> type = Util.attemptDataFix(TypeReferences.BLOCK_ENTITY, key); return Registry.register(Registry.BLOCK_ENTITY_TYPE, key, builder.build(type)); }
  13. Still getting the same error. New Registration.java public static final DeferredRegister<Block> VANILLA_BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "minecraft"); public static final RegistryObject<Block> NOTEBLOCK = Registration.VANILLA_BLOCKS.register( "note_block", () -> new NBTNoteBlock(AbstractBlock.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.8F))); public static void register() { VANILLA_BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); } Full Stacktrace: [20:48:27] [Render thread/ERROR] [minecraft/Util]: No data fixer registered for note_block [20:48:27] [Render thread/ERROR] [ne.mi.fm.ja.FMLModContainer/]: Exception caught during firing event: Can not register to a locked registry. Modder should use Forge Register methods. Index: 2 Listeners: 0: NORMAL 1: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@260f306 handleEvent(Lnet/minecraftforge/event/RegistryEvent$Register;)V 2: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@70ea9d57 handleEvent(Lnet/minecraftforge/event/RegistryEvent$Register;)V java.lang.IllegalStateException: Can not register to a locked registry. Modder should use Forge Register methods. at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:56) at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:72) at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:40) at net.minecraft.util.registry.Registry.register(Registry.java:474) at net.minecraft.util.registry.Registry.register(Registry.java:470) at com.mhk.nbaddons.blocks.NoteBlockTileEntity.register(NoteBlockTileEntity.java:53) at com.mhk.nbaddons.setup.Registration.lambda$static$1(Registration.java:30) at net.minecraftforge.registries.DeferredRegister.lambda$register$0(DeferredRegister.java:124) at net.minecraftforge.registries.DeferredRegister.addEntries(DeferredRegister.java:200) at net.minecraftforge.registries.DeferredRegister.access$000(DeferredRegister.java:61) at net.minecraftforge.registries.DeferredRegister$EventDispatcher.handleEvent(DeferredRegister.java:172) at net.minecraftforge.eventbus.ASMEventHandler_1_EventDispatcher_handleEvent_Register.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:120) at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:121) at java.util.concurrent.CompletableFuture$AsyncRun.run$$$capture(CompletableFuture.java:1640) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java) at net.minecraftforge.fml.ModWorkManager$SyncExecutor.driveOne(ModWorkManager.java:56) at net.minecraftforge.fml.ModWorkManager$DrivenExecutor.drive(ModWorkManager.java:40) at net.minecraftforge.fml.ModLoader.waitForTransition(ModLoader.java:243) at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:230) at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:196) at net.minecraftforge.fml.client.ClientModLoader.lambda$begin$1(ClientModLoader.java:103) at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:123) at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:103) at net.minecraft.client.Minecraft.<init>(Minecraft.java:442) at net.minecraft.client.main.Main.main(Main.java:149) 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.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105)
  14. Hello. I have been trying to register my own class NBTNoteBlock to the block registry with key note_block in "minecraft" but I got an error. I don't know what was wrong. It would be appreciated if someone could provide a fix. Code is provided below. Error I got was: [16:41:11] [Render thread/ERROR] [minecraft/Util]: No data fixer registered for note_block [16:41:11] [Render thread/ERROR] [ne.mi.fm.ja.FMLModContainer/]: Exception caught during firing event: Can not register to a locked registry. Modder should use Forge Register methods. First few lines in the main mod file: // The value here should match an entry in the META-INF/mods.toml file @Mod("nbaddons") public class nbaddons { // Directly reference a log4j logger. public static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "nbaddons"; public nbaddons() { Registration.register(); // <-- Registers stuff, see Registration.java // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } ... First few lines in Registration.java @Mod.EventBusSubscriber(modid = nbaddons.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class Registration { public static final DeferredRegister<Block> VANILLA_BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "minecraft"); public static void register() { VANILLA_BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); NBTNoteBlock.register(); // <-- The block class itself. See NBTNoteBlock.java ... First few lines in NBTNoteBlock.java public class NBTNoteBlock extends NoteBlock { //public static Block NOTEBLOCK; public static final RegistryObject<Block> NOTEBLOCK = Registration.VANILLA_BLOCKS.register( "note_block", () -> new NBTNoteBlock(AbstractBlock.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.8F))); public NBTNoteBlock(Properties properties) { super(properties); } public static void register() {}; // <-- register() is called just to initialize the constant NOTEBLOCK, as mentioned in the tutorial I watched.
  15. My goal is to add NBT tags on picking up note block (ctrl+middle click in creative mode like for chest containing items, where it will show "+NBT" and will have the items in it) Should I coremod to add a custom tile entity (with nbt values) to the vanilla note block?
×
×
  • Create New...

Important Information

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