Error: Illegal Start of Expression

Started by Timelord_10 on Sun, 12/10/2017 - 00:08

Topic category: Help with modding (Java Edition)

Last seen on 20:38, 15. Aug 2020
Joined Mar 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Error: Illegal Start of Expression
Sun, 12/10/2017 - 00:08

I'm making a mod that requires a Forge block, and this Forge opens a GUI on right click that can turn Iron to Forged Iron, Gold to Forged Gold, and Steel to Forged Steel. However when I recompiled I got this error code:

:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:128: error: illegal start of expression
:compileJava FAILED
.decrStackSize(0, 1);
^
BUILD FAILED
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forg: error: illegal start of expression
eGUI.java:136.decrStackSize(2, 1);
Total time: 9.916 secs
^
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:140: error: illegal start of expression
.setInventorySlotContents(1, new ItemStack(mcreator_forgedIron.block, 1));
^
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:191: error: illegal start of expression
.decrStackSize(5, 1);
^
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:199: error: illegal start of expression
.decrStackSize(6, 1);
^
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:203: error: illegal start of expression
.setInventorySlotContents(4, new ItemStack(mcreator_forgedSteel.block, 1));
^
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:254: error: illegal start of expression
.decrStackSize(7, 1);
^
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:262: error: illegal start of expression
.decrStackSize(9, 1);
^
C:\Pylo\MCreator176\forge\build\sources\main\java\mod\mcreator\mcreator_forgeGUI.java:266: error: illegal start of expression
.setInventorySlotContents(8, new ItemStack(mcreator_forgedGold.block, 1));
^
9 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
C:\Pylo\MCreator176\forge>
Task completed with return code 0 in 10578 milliseconds

 

I haven't done any custom coding yet, so that's not the issue. Anyone run into this problem before and knows how to fix it? Any help is appreciated!

Last seen on 22:42, 16. Jul 2019
Joined Sep 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Please paste your code so I…
Sun, 12/10/2017 - 00:26

Please paste your code so I can try to help

Last seen on 20:38, 15. Aug 2020
Joined Mar 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Here you go, k6u…
Sun, 12/10/2017 - 02:37

Here you go, k6u.

import org.lwjgl.opengl.GL11;
import org.lwjgl.input.Keyboard;

import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;

import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.item.ItemStack;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Container;
import net.minecraft.init.Items;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.Minecraft;

import java.util.Random;

@SuppressWarnings("unchecked")

public class mcreator_forgeGUI {

    public static Object instance;

    public static int GUIID = 2;

    public mcreator_forgeGUI() {
    }

    public void load(FMLInitializationEvent event) {
    }

    public void registerRenderers() {
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
    }

    public static IInventory inherited;

    public static class GuiContainerMod extends Container {

        World world = null;
        EntityPlayer entity = null;
        int i, j, k;

        public GuiContainerMod (World world, int i, int j, int k, EntityPlayer player){
            
            this.world = world;
            this.entity = player;
            this.i = i;
            this.j = j;
            this.k = k;
            
            TileEntity ent = world.getTileEntity(new BlockPos(i,j,k));
if( ent != null && (ent instanceof mcreator_forge.TileEntityCustom))
inherited = (IInventory)ent;
else
inherited = new InventoryBasic("", true, 9);

this.addSlotToContainer(new Slot(inherited, 0, 20, 14){
public boolean isItemValid(ItemStack stack){return ((stack != null)&&stack.getItem()==Items.IRON_INGOT );}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

if(true){
mcreator_VarList%MAINMODNAME%.Iron = true;
}

}}
});
this.addSlotToContainer(new Slot(inherited, 1, 40, 35){
public boolean isItemValid(ItemStack stack){return false;}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

}}
});
this.addSlotToContainer(new Slot(inherited, 2, 20, 53){
public boolean isItemValid(ItemStack stack){return ((stack != null)&&stack.getItem()==Items.COAL );}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

if(mcreator_VarList%MAINMODNAME%.Iron){

if(true){
.decrStackSize(0, 1);
}

if(true){
mcreator_VarList%MAINMODNAME%.Iron = false;
}

if(true){
.decrStackSize(2, 1);
}

if(true){
.setInventorySlotContents(1, new ItemStack(mcreator_forgedIron.block, 1));
}

}

}}
});
this.addSlotToContainer(new Slot(inherited, 4, 100, 34){
public boolean isItemValid(ItemStack stack){return false;}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

}}
});
this.addSlotToContainer(new Slot(inherited, 5, 80, 14){
public boolean isItemValid(ItemStack stack){return ((stack != null)&&stack.getItem()==mcreator_steelIngot.block );}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

if(true){
mcreator_VarList%MAINMODNAME%.Steel = true;
}

}}
});
this.addSlotToContainer(new Slot(inherited, 6, 80, 54){
public boolean isItemValid(ItemStack stack){return ((stack != null)&&stack.getItem()==Items.COAL );}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

if(mcreator_VarList%MAINMODNAME%.Steel){

if(true){
.decrStackSize(5, 1);
}

if(true){
mcreator_VarList%MAINMODNAME%.Steel = false;
}

if(true){
.decrStackSize(6, 1);
}

if(true){
.setInventorySlotContents(4, new ItemStack(mcreator_forgedSteel.block, 1));
}

}

}}
});
this.addSlotToContainer(new Slot(inherited, 7, 136, 14){
public boolean isItemValid(ItemStack stack){return ((stack != null)&&stack.getItem()==Items.GOLD_INGOT );}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

if(true){
mcreator_VarList%MAINMODNAME%.Gold = true;
}

}}
});
this.addSlotToContainer(new Slot(inherited, 8, 157, 33){
public boolean isItemValid(ItemStack stack){return false;}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

}}
});
this.addSlotToContainer(new Slot(inherited, 9, 136, 54){
public boolean isItemValid(ItemStack stack){return ((stack != null)&&stack.getItem()==Items.COAL );}
public void onSlotChanged(){
super.onSlotChanged();if(getHasStack()){
EntityPlayer entity = Minecraft.getMinecraft().player;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = server.worlds[0];

if(mcreator_VarList%MAINMODNAME%.Gold){

if(true){
.decrStackSize(7, 1);
}

if(true){
mcreator_VarList%MAINMODNAME%.Gold = false;
}

if(true){
.decrStackSize(9, 1);
}

if(true){
.setInventorySlotContents(8, new ItemStack(mcreator_forgedGold.block, 1));
}

}

}}
});
bindPlayerInventory(player.inventory);

        }

        @Override
        public boolean canInteractWith(EntityPlayer player) {
            return true;
        }

        protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
            int i;
            int j;

            for (i = 0; i < 3; ++i) {
                for (j = 0; j < 9; ++j) {
                    this.addSlotToContainer(new Slot(inventoryPlayer, j + (i + 1) * 9, 0 + 8 + j * 18, 0 + 84 + i * 18));
                }
            }

            for (i = 0; i < 9; ++i) {
                this.addSlotToContainer(new Slot(inventoryPlayer, i, 0 + 8 + i * 18, 0 + 142));
            }
        }

        @Override
        public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
            ItemStack itemstack = null;
            Slot slot = (Slot) this.inventorySlots.get(index);

            if (slot != null && slot.getHasStack()) {
                ItemStack itemstack1 = slot.getStack();
                itemstack = itemstack1.copy();

                if (index < 9) {
                    if (!this.mergeItemStack(itemstack1, 9, (45 - 9), true)) {// fixes
                                                                                // shiftclick
                                                                                // error
                        return null;
                    }
                } else if (!this.mergeItemStack(itemstack1, 0, 9, false)) {
                    return null;
                }

                if (itemstack1.getCount() == 0) {
                    slot.putStack((ItemStack) null);
                } else {
                    slot.onSlotChanged();
                }

                if (itemstack1.getCount() == itemstack.getCount()) {
                    return null;
                }

                slot.onTake(playerIn, itemstack1);
            }

            return itemstack;
        }

        public void onContainerClosed(EntityPlayer playerIn) {
            super.onContainerClosed(playerIn);

        }
    }

    public static class GuiWindow extends GuiContainer {

        int i = 0;
        int j = 0;
        int k = 0;
        EntityPlayer entity = null;

        public GuiWindow(World world, int i, int j, int k, EntityPlayer entity) {
            super(new GuiContainerMod(world, i, j, k, entity));
            this.i = i;
            this.j = j;
            this.k = k;
            this.entity = entity;
            this.xSize = 176;
            this.ySize = 166;
        }

        private static final ResourceLocation texture = new ResourceLocation("forgegui.png");

        @Override
        protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            this.drawDefaultBackground();

            this.mc.renderEngine.bindTexture(texture);
            int k = (this.width - this.xSize) / 2;
            int l = (this.height - this.ySize) / 2;
            this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);

            zLevel = 100.0F;

        }

        @Override
        protected void mouseClicked(int par1, int par2, int par3) throws java.io.IOException {
            super.mouseClicked(par1, par2, par3);

        }

        @Override
        public void updateScreen() {
            super.updateScreen();
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;

        }

        @Override
        protected void keyTyped(char par1, int par2) throws java.io.IOException {

            super.keyTyped(par1, par2);

        }

        @Override
        protected void drawGuiContainerForegroundLayer(int par1, int par2) {
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;

        }

        @Override
        public void onGuiClosed() {
            super.onGuiClosed();
            Keyboard.enableRepeatEvents(false);
        }

        @Override
        public void initGui() {
            super.initGui();
            this.guiLeft = (this.width - 176) / 2;
            this.guiTop = (this.height - 166) / 2;
            Keyboard.enableRepeatEvents(true);
            this.buttonList.clear();
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;

        }

        @Override
        protected void actionPerformed(GuiButton button) {
            MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
            World world = server.worlds[0];

        }

        @Override
        public boolean doesGuiPauseGame() {
            return false;
        }

    }

}