Jump to content

Forge config gui


fuzzybat23

Recommended Posts

33 minutes ago, fuzzybat23 said:

Oh, the full path as it appears in the config.cfg file, then?

 

Yes.

 

17 minutes ago, fuzzybat23 said:

Ok... I did something and I have no idea what, but the game crashes as Forge begins to load.  It generates the cfg file, but it's blank.

 


net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Custom Selection Box Revised (csbr)
Caused by: net.minecraftforge.fml.common.LoaderException: java.lang.RuntimeException: Error syncing field 'Red' of class 'com.fuzzybat23.csbr.ModConfig$Frame'!
	at net.minecraftforge.common.config.ConfigManager.sync(ConfigManager.java:192)
	at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:609)
	...
Caused by: java.lang.RuntimeException: Error syncing field 'Red' of class 'com.fuzzybat23.csbr.ModConfig$Frame'!
	...
Caused by: java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 8
general.1) custom selection box frame.
        ^
	at java.util.regex.Pattern.error(Pattern.java:1955)
	at java.util.regex.Pattern.compile(Pattern.java:1700)
	at java.util.regex.Pattern.<init>(Pattern.java:1351)
	at java.util.regex.Pattern.compile(Pattern.java:1028)
	at java.lang.String.replaceFirst(String.java:2178)
	at net.minecraftforge.common.config.ConfigManager.sync(ConfigManager.java:252)
	... 45 more

 

Forge uses your category names in a regular expression (for String#replaceFirst), so they can't contain any characters that have a special meaning in regular expressions (e.g parentheses).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Well, whatever it was I did with those (), that was keeping the cycle string box from saving.  Everything in my config file saves as it should, now.  Weird.  Anyway,

 

        ConfigCategory cat = config.getCategory("general.aFrame");
        Property prop = cat.get("Red");

 

for getting the category and prop, right, if the ModConfig is structured as so

 

@Config(modid = CSBR.MODID)
@LangKey("csbr.config.title")
public class ModConfig
{
    @Name("Custom Selection Box Frame")
    @Comment("Color and opacity for custom selection box wire frame.")
    public static final Frame aFrame = new Frame();

    @Name("Custom Selection Box Cube")
    @Comment("Color and opacity for custom selection box inner cube.")
    public static final BlinkAnimation bBlink = new BlinkAnimation();

    @Name("Custom Selection Box Animation")
    @Comment({"Break animation style and toggle the depth", "buffer for the custom selection box wire frame.."})
    public static final BreakAnimation cBreak = new BreakAnimation();

    public static class Frame
    {
        @Name("1) Red")
        @Comment("Choose a value for red between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Red = 255;

        @Name("2) Green")
        @Comment("Choose a value for green between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Green = 255;

        @Name("3) Blue")
        @Comment("Choose a value for blue between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Blue = 255;

        @Name("4) Alpha Channel")
        @Comment("Choose a value for the opacity between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Alpha = 255;

        @Name("5) Wire Thickness")
        @Comment("Choose a value for the wire frame thickness between 1 and 7.")
        @RangeInt(min = 1, max = 7)
        public int Width = 2;
    }

    public static class BlinkAnimation
    {
        @Name("1) Red")
        @Comment("Choose a value for red between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Red = 255;

        @Name("2) Green")
        @Comment("Choose a value for green between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Green = 255;

        @Name("3) Blue")
        @Comment("Choose a value for blue between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Blue = 255;

        @Name("4) Alpha Channel")
        @Comment("Choose a value for the opacity between 0 and 255.")
        @RangeInt(min = 0, max = 255)
        public int Alpha = 255;
    }

    public static class BreakAnimation
    {
        @Name("2) Break Animation")
        @Comment("Break Animation")
        public enumAnimation animation = enumAnimation.NONE;

        @Name("2) Blink Animation Speed")
        @Comment("Choose how fast the custom selection box blinks.")
        @RangeInt(min = 0, max = 100)
        public int Speed = 0;

        @Name("3) Depth Buffer")
        @Comment("Enable or disable the depth buffer for the custom selection box wire frame.")
        public boolean dBuffer = false;

        public enum enumAnimation
        {
            NONE,
            SHRINK,
            DOWN,
            ALPHA
        }
    }

 

Link to comment
Share on other sites

30 minutes ago, fuzzybat23 said:

Weird.  Anyway,

 


        ConfigCategory cat = config.getCategory("general.aFrame");
        Property prop = cat.get("Red");

 

for getting the category and prop, right, if the ModConfig is structured as so

 

That looks correct, yes.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

And if I want all the props in aFrame to have the slider, I'd need to set it up more like this, right?

 

	ConfigCategory cat = config.getCategory("general.aFrame");
	Property propRed = cat.get("Red");
	Property propGreen = cat.get("Green");
	Property propBlue = cat.get("Blue");
	Property propAlpha = cat.get("Alpha");
	Property propWidth = cat.get("Width");

 

Link to comment
Share on other sites

2 minutes ago, fuzzybat23 said:

Now that we have the prop, how do we set NumberSliderEntry as its config GUI entry type?

 

Call Property#setConfigEntryClass with NumberSliderEntry.class as the argument.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

1 minute ago, fuzzybat23 said:

And if I want all the props in aFrame to have the slider, I'd need to set it up more like this, right?

 


	ConfigCategory cat = config.getCategory("general.aFrame");
	Property propRed = cat.get("Red");
	Property propGreen = cat.get("Green");
	Property propBlue = cat.get("Blue");
	Property propAlpha = cat.get("Alpha");
	Property propWidth = cat.get("Width");

 

You'll need to call Property#setConfigEntryClass on each of those Property objects, yes.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I'm going to try to get a little fancy here.  Like this, right?

        ConfigCategory cat = config.getCategory("general.aFrame");
        Property propaFrame[] = new Property[5];
        propaFrame[0] = cat.get("Red");
        propaFrame[1] = cat.get("Green");
        propaFrame[2] = cat.get("Blue");
        propaFrame[3] = cat.get("Alpha");
        propaFrame[4] = cat.get("Width");

        for(Property p:propaFrame)
        {
            p.setConfigEntryClass(GuiConfigEntries.NumberSliderEntry.class);
        }

 

Link to comment
Share on other sites

8 minutes ago, fuzzybat23 said:

I'm going to try to get a little fancy here.  Like this, right?


        ConfigCategory cat = config.getCategory("general.aFrame");
        Property propaFrame[] = new Property[5];
        propaFrame[0] = cat.get("Red");
        propaFrame[1] = cat.get("Green");
        propaFrame[2] = cat.get("Blue");
        propaFrame[3] = cat.get("Alpha");
        propaFrame[4] = cat.get("Width");

        for(Property p:propaFrame)
        {
            p.setConfigEntryClass(GuiConfigEntries.NumberSliderEntry.class);
        }

 

 

That should work, yes. You can also use ConfigCategory#getValues to get an immutable copy of the category's property names and properties (and use Map#getValues to get a collection of the Map's values) or ConfigCategory#getOrderedValues to get an ordered immutable copy of the category's properties.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Just now, fuzzybat23 said:

I don't have much experience with the immutable..  Something like this?

 


        List<Property> props = new ArrayList<Property>(cat.getOrderedValues());
        for(Property p:props)
        {
            p.setConfigEntryClass(GuiConfigEntries.NumberSliderEntry.class);
        }

 

 

You don't need to create a new List, ConfigCategory#getOrderedValues already returns a List; just iterate through it directly.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I don't suppose there's a way to get a block at the bottom, under Wire Thickness, that will change colors according to the slider values? ;D  Kind of like the chat color picker.  In that case, I'd probably drop the red green blue entirely and just go with the basic, what is it.. 16 colors that Minecraft uses?  Either way, this is exactly what I was looking for.  Thanks!  More in depth tutorials on the @config system need to me made for this reason xD 

 

I did find the source for that, too.  I guess if I went that route, it would be a cycle value button instead of a number slider.  The number slider would still be used for the animation speed, frame thickness and alpha channels, though.

 

 

/**
 * ChatColorEntry
 *
 * Provides a GuiButton that cycles through the list of chat color codes.
 */
public static class ChatColorEntry extends CycleValueEntry
{
    ChatColorEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement)
    {
        super(owningScreen, owningEntryList, configElement);
        this.btnValue.enabled = enabled();
        updateValueButtonText();
    }

    @Override
    public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partial)
    {
        this.btnValue.packedFGColour = GuiUtils.getColorCode(this.configElement.getValidValues()[currentIndex].charAt(0), true);
        super.drawEntry(slotIndex, x, y, listWidth, slotHeight, mouseX, mouseY, isSelected, partial);
    }

    @Override
    public void updateValueButtonText()
    {
        this.btnValue.displayString = I18n.format(configElement.getValidValues()[currentIndex]) + " - " + I18n.format("fml.configgui.sampletext");
    }
}

Capture.JPG

Edited by fuzzybat23
Link to comment
Share on other sites

48 minutes ago, fuzzybat23 said:

I think I see.


        for(int i = 0; i < cat.getOrderedValues().size(); i++)
        {
            cat.getOrderedValues().get(i).setConfigEntryClass(GuiConfigEntries.NumberSliderEntry.class);
        }

 

Why are you using an indexed for loop? Use a for-each/enhanced for loop like you were before, but iterate through the returned List directly instead of creating a new one.

 

Each call to ConfigCategory#getOrderedValues creates a new copy of the List, so you should call it once and store the result in a local variable rather than calling it every iteration of the loop.

 

 

33 minutes ago, fuzzybat23 said:

I don't suppose there's a way to get a block at the bottom, under Wire Thickness, that will change colors according to the slider values? ;D

 

You'd need to implement this yourself, I can't really help you with much GUI-related stuff. Using ChatColorEntry is probably easier.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

It didn't work before xD  I just tried this again and tested it and it does seem to work.  Little cleaner looking, too, I think.

        for(Property p: cat.getOrderedValues())
        {
            p.setConfigEntryClass(GuiConfigEntries.NumberSliderEntry.class);
        }

 

Anyway, yeah, I was thinking about ChatColorEntry too.  I tried to test it with the enum I already had setup.

 ConfigCategory cat2 = config.getCategory("general.custom selection box animation");
 Property prop = cat2.get("animation");
 prop.setConfigEntryClass(GuiConfigEntries.ChatColorEntry.class);

 

but all that did was throw an error.

Time: 7/15/17 9:23 AM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Custom Selection Box Revised (csbr)
Caused by: java.lang.NullPointerException
	at com.fuzzybat23.csbr.CSBR.preInit(CSBR.java:82)
	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.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:630)
	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 com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:252)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:230)
	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 com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:147)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:604)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:266)
	at net.minecraft.client.Minecraft.init(Minecraft.java:508)
	at net.minecraft.client.Minecraft.run(Minecraft.java:416)
	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:26)


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

-- System Details --
Details:
	Minecraft Version: 1.12
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_131, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 891752248 bytes (850 MB) / 1135607808 bytes (1083 MB) up to 3808428032 bytes (3632 MB)
	JVM Flags: 0 total; 
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.40 Powered by Forge 14.21.1.2387 6 mods loaded, 6 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
	UCH	minecraft{1.12} [Minecraft] (minecraft.jar) 
	UCH	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
	UCH	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.1.2387.jar) 
	UCH	forge{14.21.1.2387} [Minecraft Forge] (forgeSrc-1.12-14.21.1.2387.jar) 
	UCE	csbr{1.0} [Custom Selection Box Revised] (CSBR_main) 
	UCH	squeedometer{1.0.3} [Squeedometer] (Squeedometer-mc1.12.x-1.0.3.jar) 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 384.76' Renderer: 'GeForce GTX 770/PCIe/SSE2'
[09:23:11] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# E:\Users\RigAlpha\Documents\My Projects\Minecraft\Git\CSBR\run\.\crash-reports\crash-2017-07-15_09.23.11-client.txt

Process finished with exit code -1

 

Link to comment
Share on other sites

Instead of an Enum, I should instead use an array

@Name("2) Break Animation")
@Comment("Break Animation")
public String[] animation = new String[] {"NONE", "SHRINK", "DOWN", "ALPHA"};

 

and use GuiConfigEntries.ChatColorEntry.class on that?

Edited by fuzzybat23
Link to comment
Share on other sites

1 hour ago, fuzzybat23 said:

Caused by: java.lang.NullPointerException

at com.fuzzybat23.csbr.CSBR.preInit(CSBR.java:82)

 

Something was null on line 82 of CSBR (in the preInit method). If line 82 is the Property#setConfigEntryClass call, the Property is null. This is probably because you renamed it with @Config.Name, so it's not called animation.

 

1 hour ago, fuzzybat23 said:

Instead of an Enum, I should instead use an array


@Name("2) Break Animation")
@Comment("Break Animation")
public String[] animation = new String[] {"NONE", "SHRINK", "DOWN", "ALPHA"};

 

and use GuiConfigEntries.ChatColorEntry.class on that?

 

No. You want a single value chosen from a fixed set, so use an enum. If you wanted an arbitrary number of Strings, you'd use a String array.

 

 

I've just discovered that Property#setConfigEntryClass doesn't actually work with GuiConfigEntries.ChatColorEntry because the constructor isn't public. I'll report this shortly, so hopefully it will be fixed.

 

I've reported this here.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Well crap, this was doomed to failure from the start then xD  Hope they do get that fixed soon.  For now, I'll just keep it in the rgb slider system.  Now I need to plug in the main guts of my mod to test it out fully.  Thanks again :>  Hopefully this thread will help out anyone else looking up the annotation system.  There really should be a section in Docs detailing everything that the annotation @Config system can do.  Doesn't make sense to introduce a powerful and simple modding tool and not tell anyone about it :P

Link to comment
Share on other sites

Oh yeah!  There was one other thing I just thought of.  With the enum control (None, shrink, down, alpha)  If any but NONE are selected, how can I force it to set DepthBuffer boolean to true in real time.  Say, the cycle button is on NONE by default.  You click it to SHRINK and the button for Depth Buffer immediately greens with true being set.

Caputure 1.JPG

Capture 2.JPG

Link to comment
Share on other sites

9 hours ago, fuzzybat23 said:

There really should be a section in Docs detailing everything that the annotation @Config system can do.  Doesn't make sense to introduce a powerful and simple modding tool and not tell anyone about it :P

 

Forge is documented by the community, you can submit a Pull Request here to add/modify documentation.

 

 

9 hours ago, fuzzybat23 said:

If any but NONE are selected, how can I force it to set DepthBuffer boolean to true in real time.  Say, the cycle button is on NONE by default.  You click it to SHRINK and the button for Depth Buffer immediately greens with true being set.

 

I think you'd need to make your own IConfigEntry for this.

 

If the Depth Buffer setting is solely controlled by the Break Animation setting, is there any reason to have it user-configurable at all?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

6 minutes ago, fuzzybat23 said:

So what would this IConfigEntry look like?

 

You could copy CycleValueEntry (since you can't extend it) and override CycleValueEntry#valueButtonPressed and CycleValueEntry#setToDefault to call the super methods and then modify the Depth Buffer setting. I'm not sure exactly how you'd do this, you'd need to work this out yourself.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I suppose that when I load the values from the config file into the variables located in my main class, I could have it set the value of the config file to true if any animation is selected but NONE.  That way, no matter what is picked in the config file, for the depth buffer, it will default to having the depth buffer disabled for those animations.

public class CSBR
{
    public static float Red;
    public static float Green;
    public static float Blue;
    public static float Alpha;
    public static float Width;

    public static float bRed;
    public static float bGreen;
    public static float bBlue;
    public static float bAlpha;
    public static float Speed;

    public static int Animation;
    public static boolean DepthBuffer;

	@Mod.EventHandler
    @SideOnly(Side.CLIENT)
    public void preInit(FMLPreInitializationEvent event) throws InvocationTargetException, IllegalAccessException
    {
        Red = ModConfig.aFrame.Red;
        Green = ModConfig.aFrame.Green;
        Blue = ModConfig.aFrame.Blue;
        Alpha = ModConfig.aFrame.Alpha;
        Width = ModConfig.aFrame.Width;

        bRed = ModConfig.bBlink.Red;
        bGreen = ModConfig.bBlink.Green;
        bBlue = ModConfig.bBlink.Blue;
        bAlpha = ModConfig.bBlink.Alpha;

		ConfigCategory csba = config.getCategory("general.custom selection box animation");
        Property csba_depth_prop = csba.get("3) Depth Buffer");
        switch(ModConfig.cBreak.Animation)
        {
            case NONE:
                Animation = 0;
                break;

            case SHRINK:
			{
                Animation = 1;
				csba_depth_prop.setValue(true);
				break;

            case DOWN:
                Animation = 2;
				csba_depth_prop.setValue(true);
                break;

            case ALPHA:
                Animation = 3;
				csba_depth_prop.setValue(true);
                break;

            default:
                Animation = 0;
        }

        DepthBuffer = ModConfig.cBreak.dBuffer;
        Speed = ModConfig.cBreak.Speed;
}

 

It wouldn't change the state of the Depth Buffer button on the config screen as the animation is picked, but I don't really care about that.  As long as the internal code knows to turn it off if those animations are set is what's important.

Edited by fuzzybat23
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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