Jump to content

Recommended Posts

Posted

I got this when I closed my GUI.

 

 

[10:59:23] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: ---- Minecraft Crash Report ----

// I just don't know what went wrong :(

 

Time: 07/07/15 10:59

Description: Updating screen events

 

java.util.ConcurrentModificationException

at com.google.common.collect.HashBiMap$Itr.checkForConcurrentModification(HashBiMap.java:339)

at com.google.common.collect.HashBiMap$Itr.hasNext(HashBiMap.java:345)

at net.minecraft.client.audio.SoundManager.resumeAllSounds(SoundManager.java:483)

at net.minecraft.client.audio.SoundHandler.resumeSounds(SoundHandler.java:261)

at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:988)

at net.minecraft.client.Minecraft.setIngameFocus(Minecraft.java:1431)

at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:989)

at com.fredtargaryen.floocraft.client.gui.GuiTeleport.actionPerformed(GuiTeleport.java:119)

at com.fredtargaryen.floocraft.client.gui.GuiTeleport.actionPerformed(GuiTeleport.java:153)

at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:510)

at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:602)

at com.fredtargaryen.floocraft.client.gui.GuiTeleport.handleMouseInput(GuiTeleport.java:243)

at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:571)

 

 

But here's the GuiTeleport file:

 

 

package com.fredtargaryen.floocraft.client.gui;

import com.fredtargaryen.floocraft.DataReference;
import com.fredtargaryen.floocraft.FloocraftBase;
import com.fredtargaryen.floocraft.network.PacketHandler;
import com.fredtargaryen.floocraft.network.messages.MessageFireplaceList;
import com.fredtargaryen.floocraft.network.messages.MessageFireplaceListRequest;
import com.fredtargaryen.floocraft.network.messages.MessageTeleportEntity;
import com.fredtargaryen.floocraft.proxy.ClientProxy;
import com.google.common.collect.Lists;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSlot;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@SideOnly(Side.CLIENT)
public class GuiTeleport extends GuiScreen
{
/** The title string that is displayed in the top-centre of the screen. */ protected String screenTitle = "===Choose a destination===";
private String status;

//"Go!".
private GuiButton goBtn;
//"Cancel"
private GuiButton cancelBtn;

private List<String> placenamelist = new ArrayList<String>();
private List<Integer> xcoordlist = new ArrayList<Integer>();
private List<Integer> ycoordlist = new ArrayList<Integer>();
private List<Integer> zcoordlist = new ArrayList<Integer>();
private List<Boolean> enabledlist = new ArrayList<Boolean>();

private boolean receivedLists;

private PlaceList scrollWindow;

private int initX, initY, initZ;

public GuiTeleport(int x, int y, int z)
{
this.initX = x;
this.initY = y;
this.initZ = z;
this.refresh();
}

/** * Adds the buttons (and other controls) to the screen in question. */ public void initGui()
{
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
GuiButton refreshButton = new GuiButton(-2, this.width - 100, 0, 98, 20, "Refresh");
refreshButton.enabled = false;
this.buttonList.add(this.goBtn = new GuiButton(-3, this.width / 2 - 100, this.height / 4 + 144, 98, 20, "Go!"));
this.goBtn.enabled = false;
this.buttonList.add(this.cancelBtn = new GuiButton(-1, this.width / 2 + 2, this.height / 4 + 144, 98, 20, "Cancel"));
if (receivedLists)
{
refreshButton.enabled = true;
this.scrollWindow = new PlaceList();
}
this.buttonList.add(refreshButton);
}

/** * Called when the screen is unloaded. Used to disable keyboard repeat events */ public void onGuiClosed()
{
ClientProxy proxy = (ClientProxy) FloocraftBase.proxy;
Keyboard.enableRepeatEvents(false);
proxy.overrideTicker.start();
}

/** * Called from the main game loop to update the screen. */ public void updateScreen()
{
super.updateScreen();
if (!this.receivedLists)
{
this.status = "Loading...";
}
else //if the lists were received...
{
//if they are empty...
if (this.placenamelist.size() == 0) {
this.status = "No places found";
} else {
this.status = "";
}
}
}

/** * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). */ protected void actionPerformed(GuiButton par1GuiButton)
{
if (par1GuiButton.enabled)
{
//Cancel
if (par1GuiButton.id == -1)
{
((ClientProxy) FloocraftBase.proxy).overrideTicker.start();
this.mc.displayGuiScreen(null);
}
//Refresh
else if(par1GuiButton.id == -2)
{
this.refresh();
}
//Go!
else if(par1GuiButton.id == -3)
{
int initX = this.initX;
int initY = this.initY;
int initZ = this.initZ;
int destX = xcoordlist.get(this.scrollWindow.getSelectedElement());
int destY = ycoordlist.get(this.scrollWindow.getSelectedElement());
int destZ = zcoordlist.get(this.scrollWindow.getSelectedElement());
try
{
if(!(initX == destX && initY == destY && initZ == destZ))
{
MessageTeleportEntity m = new MessageTeleportEntity();
m.initX = initX;
m.initY = initY;
m.initZ = initZ;
m.destX = destX;
m.destY = destY;
m.destZ = destZ;
PacketHandler.INSTANCE.sendToServer(m);
}
}
catch(Exception e)
{
e.printStackTrace();
}
this.actionPerformed(GuiTeleport.this.cancelBtn);
}
}
}

/** * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). */ protected void keyTyped(char par1, int par2)
{
if (par2 == 1)
{
this.actionPerformed(this.cancelBtn);
}
}

/** * Draws the screen and all the components in it. */ @Override
@SideOnly(Side.CLIENT)
public void drawScreen(int mousex, int mousey, float partialticks)
{
this.drawCenteredString(this.fontRendererObj,
this.status,
this.width / 2,
this.height / 4 + 48,
13158600);
GL11.glPushMatrix();
GL11.glTranslatef((float) (this.width / 2), 0.0F, 50.0F);
float f1 = 93.75F;
GL11.glScalef(-f1, -f1, -f1);
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
GL11.glPopMatrix();
if (this.scrollWindow != null) {
this.scrollWindow.drawScreen(mousex, mousey, partialticks);
}
this.drawCenteredString(this.fontRendererObj,
this.screenTitle,
this.width / 2,
15,
16777215);
super.drawScreen(mousex, mousey, partialticks);
}

private void refresh()
{
this.placenamelist.clear();
this.xcoordlist.clear();
this.ycoordlist.clear();
this.zcoordlist.clear();
this.enabledlist.clear();
this.receivedLists = false;
this.initGui();
PacketHandler.INSTANCE.sendToServer(new MessageFireplaceListRequest());
}

public void onMessageReceived(MessageFireplaceList m)
{
try
{
this.placenamelist = m.placenamelist;
this.xcoordlist = m.xcoordlist;
this.ycoordlist = m.ycoordlist;
this.zcoordlist = m.zcoordlist;
this.enabledlist = m.enabledlist;
this.receivedLists = true;
}
catch(Exception ex)
{
ex.printStackTrace();
}
this.initGui();
}

/** * Returns true if this GUI should pause the game when it is displayed in single-player */ @Override
public boolean doesGuiPauseGame()
{
return false;
}

@Override
public void handleMouseInput()
{
try
{
this.scrollWindow.handleMouseInput();
super.handleMouseInput();
}
catch(IOException e)
{
e.printStackTrace();
}
}

@SideOnly(Side.CLIENT)
class PlaceList extends GuiSlot
{
private final java.util.List l = Lists.newArrayList();
private static final String __OBFID = "CL_00000699";

public PlaceList()
{
super(GuiTeleport.this.mc, GuiTeleport.this.width, GuiTeleport.this.height, 32, GuiTeleport.this.height - 65 + 4, 18);
this.setShowSelectionBox(true);
}

protected int getSize()
{
return GuiTeleport.this.placenamelist.size();
}

/** * The element in the slot that was clicked, boolean for whether it was double clicked or not */ protected void elementClicked(int id, boolean isDoubleClick, int mousex, int mousey)
{
GuiTeleport.this.goBtn.enabled = GuiTeleport.this.enabledlist.get(id);
}

/** * Returns true if the element passed in is currently selected */ protected boolean isSelected(int id)
{
return id == this.selectedElement;
}

/** * Return the height of the content being scrolled */ @Override
protected int getContentHeight()
{
return this.getSize() * 18;
}

@Override
protected void drawBackground(){}

@Override
protected void drawSlot(int id, int p_148126_2_, int p_148126_3_, int p_148126_4_, int p_148126_6_, int p_148126_7_)
{
GuiTeleport.this.drawCenteredString(GuiTeleport.this.fontRendererObj, GuiTeleport.this.placenamelist.get(id), this.width / 2, p_148126_3_ + 1, GuiTeleport.this.enabledlist.get(id) ? 65280 : 16711680);
}

@Override
public void drawScreen(int i, int j, float f)
{
super.drawScreen(i, j, f);
this.flooverlayBackground(0, this.top);
this.flooverlayBackground(this.bottom, this.height);
}
/** * Overlays the background to hide scrolled items */ private void flooverlayBackground(int p_148136_1_, int p_148136_2_)
{
WorldRenderer wr = Tessellator.getInstance().getWorldRenderer();
GuiTeleport.this.mc.getTextureManager().bindTexture(DataReference.TP_BACKGROUND);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
wr.startDrawingQuads();
wr.addVertexWithUV((double)this.left, (double)p_148136_2_, 0.0D, 0.0D, (double)((float)p_148136_2_ / f));
wr.addVertexWithUV((double)(this.left + this.width), (double)p_148136_2_, 0.0D, (double)((float)this.width / f), (double)((float)p_148136_2_ / f));
wr.addVertexWithUV((double) (this.left + this.width), (double) p_148136_1_, 0.0D, (double) ((float) this.width / f), (double) ((float)p_148136_1_ / f));
wr.addVertexWithUV((double) this.left, (double) p_148136_1_, 0.0D, 0.0D, (double) ((float)p_148136_1_ / f));
Tessellator.getInstance().draw();
}

@Override
protected void drawContainerBackground(Tessellator tessellator)
{
}

public int getSelectedElement()
{
return this.selectedElement;
}
}
}

 

 

So I don't understand what I could have done wrong... Please can someone help?

 

Thanks for reading.

Posted

Are you using custom packets of some sort? You'd have to take nto account that packets are on another thread now, so you'd have to do something to make them work.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

It has nothing to do with sounds, at least not directly - ConcurrentModificationException happens when a single object is being modified from more than one place at the same time. This can happen especially easily with Collections (e.g. List), for example, even something as simple as the following might throw a CoMod:

List<String> list = new ArrayList<String>();
list.add("One");
list.add("Two");
for (String s : list) {
list.remove(s);
}

It only gets more likely if you have the same object being manipulated from more places, especially if you start involving other threads, and the same strategies apply for dealing with it.

 

In your particular case, your crash log pointed to #actionPerformed in your GUI class, instigated by a mouse click: com.fredtargaryen.floocraft.client.gui.GuiTeleport.actionPerformed(GuiTeleport.java:119)

 

I would look through all of the code that you call before and after that section, as well as if you have any other code operating on these (e.g. a tick handler) to see if you are modifying Collections somewhere, as that is probably the most common cause of CoMod exceptions.

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

    • I know that this may be a basic question, but I am very new to modding. I am trying to have it so that I can create modified Vanilla loot tables that use a custom enchantment as a condition (i.e. enchantment present = item). However, I am having trouble trying to implement this; the LootItemRandomChanceWithEnchantedBonusCondition constructor needs a Holder<Enchantment> and I am unable to use the getOrThrow() method on the custom enchantment declared in my mod's enchantments class. Here is what I have so far in the GLM:   protected void start(HolderLookup.Provider registries) { HolderLookup.RegistryLookup<Enchantment> registrylookup = registries.lookupOrThrow(Registries.ENCHANTMENT); LootItemRandomChanceWithEnchantedBonusCondition lootItemRandomChanceWithEnchantedBonusCondition = new LootItemRandomChanceWithEnchantedBonusCondition(0.0f, LevelBasedValue.perLevel(0.07f), registrylookup.getOrThrow(*enchantment here*)); this.add("nebu_from_deepslate", new AddItemModifier(new LootItemCondition[]{ LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.DEEPSLATE).build(), LootItemRandomChanceCondition.randomChance(0.25f).build(), lootItemRandomChanceWithEnchantedBonusCondition }, OrichalcumItems.NEBU.get())); }   Inserting Enchantments.[vanilla enchantment here] actually works but trying to declare an enchantment from my custom enchantments class as [mod enchantment class].[custom enchantment] does not work even though they are both a ResourceKey and are registered in Registries.ENCHANTMENT. Basically, how would I go about making it so that a custom enchantment declared as a ResourceKey<Enchantment> of value ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath([modid], [name])), declared in a seperate enchantments class, can be used in the LootItemRandomChanceWithEnchantedBonusCondition constructor as a Holder? I can't use getOrThrow() because there is no level or block entity/entity in the start() method and it is running as datagen. It's driving me nuts.
    • Hi here is an update. I was able to fix the code so my mod does not crash Minecraft. Please understand that I am new to modding but I honestly am having a hard time understanding how anyone can get this to work without having extensive programming and debugging experience as well as searching across the Internet, multiple gen AI bots (claude, grok, openai), and examining source code hidden in the gradle directory and in various github repositories. I guess I am wrong because clearly there are thousands of mods so maybe I am just a newbie. Ok, rant over, here is a step by step summary so others can save the 3 days it took me to figure this out.   1. First, I am using forge 54.1.0 and Minecraft 1.21.4 2. I am creating a mod to add a shotgun to Minecraft 3. After creating the mod and compiling it, I installed the .jar file to the proper directory in Minecraft and used 1.21.4-forge-54.1.0 4. The mod immediately crashed with the error: Caused by: java.lang.NullPointerException: Item id not set 5. Using the stack trace, I determined that the Exception was being thrown from the net.minecraft.world.item.Item.Properties class 6. It seems that there are no javadocs for this class, so I used IntelliJ which was able to provide a decompiled version of the class, which I then examined to see the source of the error. Side question: Are there javadocs? 7. This method, specifically, was the culprit: protected String effectiveDescriptionId() {      return this.descriptionId.get(Objects.requireNonNull(this.id, "Item id not set"));  } 8. Now my quest was to determine how to set this.id. Looking at the same source file, I determined there was another method:  public Item.Properties setId(ResourceKey<Item> pId) {             this.id = pId;             return this;   } 9. So now, I need to figure out how to call setId(). This required working backwards a bit. Starting from the constructor, I stubbed out the variable p which is of type Item.Properties public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); Rather than putting this all on one line, I split it up for readability like this: private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); Here is was the missing function, setId(), which takes a type of ResourceKey<Item>. My next problem is that due to the apparent lack of documentation (I tried searching the docs on this site) I could not determine the full import path to ResourceKey. I did some random searching on the Internet and stumbled across a Github repository which gave two clues: import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; Then I created the rk variable like this: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); And now putting it all together in order: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); This compiled and the mod no longer crashes. I still have more to do on it, but hopefully this will save someone hours. I welcome any feedback and if I missed some obvious modding resource or tutorial that has this information. If not, I might suggest we add it somewhere for people trying to write a mod that doesn't crash. Thank you !!!  
    • I will keep adding to this thread with more information in case anyone can help, or at the very least I can keep my troubleshooting organized. I decided to downgrade to 54.1.0 in the hopes that this would fix the issue but it didn't. At least now I am on a "recommended" version. The crash report did confirm my earlier post that the Exception is coming from effectiveDescriptionId(). I'll continue to see if I can find a way to set the ID manually.   Caused by: java.lang.NullPointerException: Item id not set         at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item$Properties.effectiveDescriptionId(Item.java:465) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item.<init>(Item.java:111) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ShotgunItem.<init>(ShotgunItem.java:19) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ModItems.lambda$static$0(ModItems.java:15) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent      
    • It just randomly stop working after a rebooted my dedicated server PLEASE HELP!   com.google.gson   Failed to start the minecraft server com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $  
  • Topics

×
×
  • Create New...

Important Information

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