Jump to content

Thornack

Members
  • Posts

    629
  • Joined

  • Last visited

Posts posted by Thornack

  1. Not sure which tools you are referring to, but the latest 1.7.10 forge works and you can setup a dev environment even today still. But you have to use a forked repo of forge and gradle to do that. Java 1.7 and Java 1.8 still work as well. I am also happy to help.

     

    Is there a way we can create a section in the forum for legacy versions? For large legacy mods, Minecraft's constant version updates are too large of a workload to keep up with. There are some good stable legacy versions  that are a blast to mod and I think it's worth it.

     

    Sorry people demand things, I try to come at it from the perspective of, they just want to learn while having fun.

  2. Hi there its me.

    I used to be quite active on here back in the days of Minecraft 1.7.10. How far things have come.

    Minecraft modding was my way to learn Java.I literally knew 0 java but messing with Minecraft inspired me to learn.

    It was excellent and I am grateful to this forum for the endless help with all of my niche questions/issues. So in the spirit of maintaining the past, keeping it alive so to speak, I have come back on here to ask for legacy forge version support.

    I have recently come back to modding Minecraft 1.7.10, and yes it is still possible even in 2024 but it takes a lot to get the dev environment set up and all that, and am working on my massive mod that I never released. So I am hoping to engage the right people on here to rally for legacy forge version support for dev environment setup with gradle and to maintain it.

    Is it possible to get support for legacy versions, why or why not? I think it should be. The old minecraft has a lot to offer still.

    I know there used to be a lot of 1.7.10 mods that were fantastic back then and many were never updated to newer versions due to the insane workload it takes to keep up with their release schedule. But at least for me, its a ton of fun these days and I am a lot better at Java and OOP. 

    Hoping to bring that to more people and see if its possible to at least maintain the dev environment side of the legacy forge versions into the future.

    @diesieben thoughts? I miss your snarky comments and condescending remarks from years ago. They made me a better programmer because I wanted to prove you wrong. Very grateful to you. 

  3. I have noticed that you cannot install successfully downloaded older src from versions of Forge (from like 1.7.10) and use maven to set up a dev environment which means that effectively you cannot mod older minecraft versions. The build script appears to fail when gradlew is executed due to the external repo's no longer being valid. The message states could not resolve all dependencies, where you get a status code from server 501 https required. Is there a workaround? (and I know the versions are no longer supported but for someone wanting to edit an old mod of mine for an old version of minecraft is it possible?

  4. [SOLVED]

     

    For some reason I had a string that was somehow being deleted right before the NBT data was being saved. So when I tried using it to send a message to the player the string did not exist and this seemed to cause the crash and only happen sometimes. Really weird but meh its fixed

  5. Hi Everyone,

     

    Once in a while when I test my mod I get a [Netty Client IO #5/ERROR]

    any ideas what might cause this?

     

    The console says the following:

     

    [Netty Client IO #5/ERROR] [FML]: NetworkDispatcher exception
    io.netty.handler.timeout.ReadTimeoutException
    [23:29:02] [Client thread/INFO] [FML]: Applying holder lookups
    [23:29:02] [Client thread/INFO] [FML]: Holder lookups applied

  6. Hey everyone so this is the solution to this problem.

     

    To disable the dropping of items via mouse drag you have to override the #mouseMovedOrUp() method (not the mouse clicked method) like so

     

     

      @Override
        protected void mouseMovedOrUp(int mousePosX, int mousePosY, int movedOrUp){
        	if(mousePosX < this.guiLeft || mousePosX > this.guiLeft + this.guiWidth{
        	   return;
        	} else if (mousePosY < this.guiTop || mousePosY > this.guiTop + this.guiHeight){
        	          return;
        		} else{
        				super.mouseMovedOrUp(mousePosX,mousePosY,movedOrUp);
        			}
        }
    

     

     

     

    To disable the dropping of items via the "Q" Key (or whichever key this functionality gets bound to) use the following in your gui class

     

     

    @Override
    protected void keyTyped(char key, int event){
       	  
       if (event == 1 || event == this.mc.gameSettings.keyBindInventory.getKeyCode())
           {
               this.mc.thePlayer.closeScreen();
           }
           this.checkHotbarKeys(key);
       }
    

     

     

     

    and it works :)

    • Like 1
  7. For the mouse drag I tried the following - I created an imaginary barrier and using the draw method just reset the mouse mosition if it goes outside my guis bounds. However it isnt foolproof the player can still try and succeed at dropping the item by dragging the mouse fast. - need a better way to do this still

     

    @Override
    protected void drawGuiContainerBackgroundLayer(float x, int y, int z) {
    	int mousePosX = Mouse.getEventX() * this.width / this.mc.displayWidth;
    	int mousePosY = Mouse.getEventY() * this.height / this.mc.displayHeight;
    	if(mousePosX < 140){
    		Mouse.setCursorPosition(140 * this.mc.displayWidth/this.width, Mouse.getEventY());
    	}
    	if (mousePosX > 284){
    		Mouse.setCursorPosition(284 * this.mc.displayWidth/this.width, Mouse.getEventY());
    	}
    	if(mousePosY < 58){
    		Mouse.setCursorPosition(Mouse.getEventX(), 58 * this.mc.displayHeight/this.height);
    	}
    	if(mousePosY > 190){
    		Mouse.setCursorPosition(Mouse.getEventX(), 190 * this.mc.displayHeight/this.height);
    	}
    
    //Rest of drawing code
    }
    

     

  8. @Override
    protected void keyTyped(char key, int event){
      
       if (event == 1 || event == this.mc.gameSettings.keyBindInventory.getKeyCode())
           {
               this.mc.thePlayer.closeScreen();
           }
    
           this.checkHotbarKeys(key);
       }
    

     

    To disable the dropping of items from my gui inventory using the "Q" keyboard Key, I overrode the keyTyped method and changed it to the code above so that the "Q" key cannot be used to drop items. Still have no idea how to disable dropping items via mouse drag though. Any ideas are helpful

  9. Key is pressed

    public class KeyMiney extends KeyBinding
    {
    private static int index= 1;	
    
    public KeyMiney()
    {
    	super("key.keyMoney", Keyboard.KEY_M, "key.categories.custommod");
    }
    
    @SubscribeEvent
    public void keyDown(InputEvent.KeyInputEvent event)
    {
    	if (isPressed())  {
    		PacketOverlord.sendToServer(new PacketC2SMineyKeyPressed());
    		}
    }
    }
    

     

    that key press sends a packet to server which then sends a packet back to client that opens the gui

    public class PacketC2SMineyKeyPressed extends AbstractMessageToServer<PacketC2SMineyKeyPressed> {
    public PacketC2SMineyKeyPressed() {}
    
    @Override
    protected void read(PacketBuffer buffer) throws IOException {
    }
    
    @Override
    protected void write(PacketBuffer buffer) throws IOException {
    }
    
    @Override
    public void process(EntityPlayer player, Side side) {
    		PacketOverlord.sendTo(new PacketS2COpenMineyGui((EntityPlayer) player, (int)player.posX, (int)player.posY, (int)player.posZ),(EntityPlayerMP) player);
    }
    
    }
    

     

    packet that actually opens the gui client side

    public class PacketS2COpenMineyGui extends AbstractMessageToClient<PacketS2COpenMineyGui> {
    int xPos;
    int yPos;
    int zPos;
    
    public PacketS2COpenMineyGui() {}
    public PacketS2COpenMineyGui(EntityPlayer player, int xPos, int yPos, int zPos) {
    
    	this.xPos = xPos;
    	this.yPos = yPos;
    	this.zPos = zPos;
    
    }
    
    @Override
    protected void read(PacketBuffer buffer) throws IOException {
    xPos = buffer.readInt();
    yPos = buffer.readInt();
    zPos = buffer.readInt();
    
    }
    
    @Override
    protected void write(PacketBuffer buffer) throws IOException {
    	buffer.writeInt(xPos);
    	buffer.writeInt(yPos);
    	buffer.writeInt(zPos);
    }
    
    @Override
    public void process(EntityPlayer player, Side side) {
    
       if(player.worldObj.isRemote){ //player is only the client side player here using if(!player.worldObj.isRemote) does not work nothing is called
    
        player.openGui(CustomMod.instance, 9, player.worldObj, xPos, yPos, zPos);
       }
       }
       }
    
    

  10. Hi everyone,

     

    I have created a gui where I have the players inventory and a custom inventory. I have run into the problem where If I click on an item which is inside a player inventory slot I cant seem to move it to my other inventory slots (not even from one player inventory slot to the next) and Im not sure what the issue is? here is my code:

     

    Gui class

     

     

    @SideOnly(Side.CLIENT)
    public class GuiPlayerMiney extends InventoryEffectRenderer
    {
        private GuiTextField mineyDepositTextField;
        private static ContainerMiney containerMiney;
        
        private ArrayList<GuiTextField> editControls = new ArrayList<GuiTextField>();
        private static final ResourceLocation guiTexture = new ResourceLocation("custommod:textures/gui/MineyGui.png");
        private boolean wasInitialized;	
       
        private Point lastClick = new Point();
        private Rectangle guiRect = new Rectangle(0,0, 256, 256); // initialized for relative coord system so that the GUI can be resized as the screen is resized
        private Rectangle guiCoords = new Rectangle(256/2 + -88,256/2 - 83, 256, 256);
        private final Rectangle textureCoords = new Rectangle(0, 0, 256, 256);
        private static final int TEXTURE_SIZE = 256;
        
       
      	public GuiPlayerMiney(InventoryPlayer invPlayer, InventoryMiney invMiney){
    	super(new ContainerMiney(invPlayer,invMiney));
          	this.wasInitialized = false;
        }
    
        /**
         * Adds the buttons (and other controls) to the screen in question.
         */
        @Override
        public void initGui()
        {	super.initGui();
        	  
            if(this.wasInitialized)
            	return;
            this.wasInitialized = true;
            
            //edit controls
            this.editControls.clear();
            this.mineyDepositTextField = new GuiTextField(fontRendererObj, 100, 70, 50, 12);
            this.editControls.add(mineyDepositTextField);
           
        }
    
        @Override
    public boolean doesGuiPauseGame(){
    	return false;
    }
        
        @Override
        public void onGuiClosed(){ }
    
           
        @Override
        protected void mouseClicked(int x, int y, int event){
            super.mouseClicked(x, y, event);
            lastClick.x = x;
        	lastClick.y = y;
        	screenToRelativeCoordinates(lastClick, guiRect);
        	
            for(GuiTextField textBox : this.editControls){
            	textBox.mouseClicked(x, y, event);
            }
        }
        
       @Override
    protected void keyTyped(char key, int event){
        	super.keyTyped(key, event);
        	for(GuiTextField textBox : this.editControls){
            	textBox.textboxKeyTyped(key, event);
        	}
    }
    
              
        private void sendUpdateToSpawner(TileEntitySpawner spawner){
        	int withdrawAmount = this.getTextboxValue(this.mineyDepositTextField.getText());
        	
        }
        
        //checks the string to see if it is an integer
        private boolean validateTextboxInt(String s){
        	int val = 0;
        	try{
        		val = Integer.valueOf(s);
        	}
        	catch(NumberFormatException e){
        		return false;
        	}
        	
        	return true;
        }
        
        private int getTextboxValue(String s){
        	if(validateTextboxInt(s)){
        		return Integer.valueOf(s);
        	}
        	return 0;
        }
        
        
    
        @Override
    protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_){
    	int fontColor = 0x404040;	//RGB value of the text color
    }
        
    @Override
    protected void drawGuiContainerBackgroundLayer(float x, int y, int z) {
    
    	this.mc.getTextureManager().bindTexture(guiTexture);
    
    	this.guiRect.x = (this.width - this.guiRect.width) / 2;
      		this.guiRect.y = (this.height - this.guiRect.height) / 2;
        	this.mc.getTextureManager().bindTexture(guiTexture);	//draws the dirt background texture
        	this.drawTexturedRect(this.guiRect, guiCoords, textureCoords, this.TEXTURE_SIZE);
        	
        	final String withdraw = "Withdraw";
            this.drawString(this.fontRendererObj, withdraw, this.width/2 - 80, this.height/2 - 74, 0xFFFFFF);
            
        	final String deposit = "Deposit";
            this.drawString(this.fontRendererObj, deposit, this.width/2 - 77,  this.height/2 - 26, 0xFFFFFF);
          
            final String total = "Total Miney";
            this.drawString(this.fontRendererObj, total, this.width/2 +9, this.height/2 - 78, 0xFFFFFF);
            
            final String miney = "" + (BattlePlayerProperties.get(Minecraft.getMinecraft().thePlayer).getMineyTotal() - this.getTextboxValue(this.mineyDepositTextField.getText()));
            this.drawString(this.fontRendererObj, miney, (this.width/2 + 12) + 50/2 - this.fontRendererObj.getStringWidth(miney)/2, this.height/2 - 66, 0xFFFFFF);
          
            
            //draw edit controls
            for(GuiTextField textBox : this.editControls){
            	textBox.width = 45;
            	textBox.xPosition = this.width/2 -81;		//so it stays in the same position when gui is scaled
            	textBox.yPosition = this.height/2 -64;
            	textBox.drawTextBox();
            }
    
    
    }
    
    private void drawTexturedRect(Rectangle guiRect, Rectangle drawRect, Rectangle textureRect, int textureSize){
    	double textureScale = 1.0 / textureSize;
    	double z = (double) this.zLevel;
    
    	//x, y coords of the four corners of the rectangle on the screen
    	double x0, x1, y0, y1;	
    	x0 = (double) drawRect.x + guiRect.x;
    	y0 = (double) drawRect.y  + guiRect.y;
    	x1 = (double)(drawRect.x + drawRect.width  + guiRect.x);
    	y1 = (double)(drawRect.y + drawRect.height  + guiRect.y);
    
    	//texture coordinates
    	double u0, v0, u1, v1;
    	u0 = textureRect.x * textureScale;
    	v0 = (double) textureRect.y * textureScale;
    	u1 = (double) (textureRect.x + textureRect.width) * textureScale;
    	v1 = (double) (textureRect.y + textureRect.height) * textureScale;
    
    	Tessellator tessellator = Tessellator.instance;
    	tessellator.startDrawingQuads();
    	tessellator.addVertexWithUV(x0, y1, z, u0, v1);	//bottom left
    	tessellator.addVertexWithUV(x1, y1, z, u1, v1);	//bottom right
    	tessellator.addVertexWithUV(x1, y0, z, u1, v0);	//top right
    	tessellator.addVertexWithUV(x0, y0, z, u0, v0);	//top left
    	tessellator.draw();
    }
    
      protected void screenToRelativeCoordinates(Point p, Rectangle guiRect){
        	p.x -= guiRect.x;
        	p.y -= guiRect.y;
        }
    }
    

     

     

     

    Container Class

     

     

    public class ContainerMiney extends Container
    {   
        private final int slotCols = 9;
        private int slotRows;
    private InventoryMiney inventoryMiney;
    
    public ContainerMiney(IInventory playerInventory, InventoryMiney inventoryMiney){
    
    		this.inventoryMiney = inventoryMiney;
            this.slotRows = inventoryMiney.getSizeInventory() / this.slotCols;
            inventoryMiney.openInventory();
            
           
            int j;
            int k;
            
            //Miney Inventory
            this.addSlotToContainer(new Slot(inventoryMiney, 0, 56 , 17));
            this.addSlotToContainer(new Slot(inventoryMiney, 1, 56 , 53));
    
            //player's inventory
            for (j = 0; j < 3; ++j){
                for (k = 0; k < 9; ++k){
                	this.addSlotToContainer(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18));
                }
            }
            //player's hotbar
            for (j = 0; j < 9; ++j){
            	this.addSlotToContainer(new Slot(playerInventory, j, 8 + j * 18, 142));
            }
        }
    
        /**
         * Called when the container is closed.
         */
        public void onContainerClosed(EntityPlayer player)
        {
            super.onContainerClosed(player);
            this.inventoryMiney.saveInventoryToPlayer(player);
          
        }
        
        @Override
        public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
        {
            ItemStack itemstack = null;
            Slot slot = (Slot)this.inventorySlots.get(par2);
    
            if (slot != null && slot.getHasStack())
            {
                ItemStack itemstack1 = slot.getStack();
                itemstack = itemstack1.copy();
    
                if (par2 < this.slotRows * 9)
                {
                    if (!this.mergeItemStack(itemstack1, this.slotRows * 9, this.inventorySlots.size(), true))
                    {
                        return null;
                    }
                }
                else if (!this.mergeItemStack(itemstack1, 0, this.slotRows * 9, false))
                {
                    return null;
                }
    
                if (itemstack1.stackSize == 0)
                {
                    slot.putStack((ItemStack)null);
                }
                else
                {
                    slot.onSlotChanged();
                }
            }
    
            return itemstack;
        }
    
    @Override
    public boolean canInteractWith(EntityPlayer p_75145_1_) {
    	return true;
    }
        
    }
    

     

     

     

    Inventory Class

     

     

    public class InventoryMiney implements IInventory //extends InventoryBasic
    {
    private final int INV_SIZE = 2;
        private ItemStack[] inventory = new ItemStack[iNV_SIZE];
    
        public InventoryMiney(){
            //super("container.miney", false, 27);
        }
    
        //loads the player's PC inventory from NBT data
        public void loadInventoryFromPlayer(EntityPlayer player){
        	NBTTagCompound nbtCompound = player.getEntityData();
        	if(nbtCompound != null){
        		NBTTagList nbtTagList = nbtCompound.getTagList("custommod_Miney", 10);
        		this.loadInventoryFromNBT(nbtTagList);
        	}
        }
        
        //save the player's PC inventory to NBT
        public void saveInventoryToPlayer(EntityPlayer player){
        	NBTTagCompound nbtCompound = player.getEntityData();
        	NBTTagList nbtTagList = this.saveInventoryToNBT();
        	nbtCompound.setTag("custommod_Miney", nbtTagList);
        }
        
        //load,save to NBT copied from minecraft chest code
        public void loadInventoryFromNBT(NBTTagList par1NBTTagList)
        {
            int i;
    
            for (i = 0; i < this.getSizeInventory(); ++i)
            {
                this.setInventorySlotContents(i, (ItemStack)null);
            }
    
            for (i = 0; i < par1NBTTagList.tagCount(); ++i)
            {
                NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i);
                int j = nbttagcompound.getByte("Slot") & 255;
    
                if (j >= 0 && j < this.getSizeInventory())
                {
                    this.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound));
                }
            }
        }
    
        //load,save to NBT copied from minecraft chest code
        public NBTTagList saveInventoryToNBT()
        {
            NBTTagList nbttaglist = new NBTTagList();
    
            for (int i = 0; i < this.getSizeInventory(); ++i)
            {
                ItemStack itemstack = this.getStackInSlot(i);
    
                if (itemstack != null)
                {
                    NBTTagCompound nbttagcompound = new NBTTagCompound();
                    nbttagcompound.setByte("Slot", (byte)i);
                    itemstack.writeToNBT(nbttagcompound);
                    nbttaglist.appendTag(nbttagcompound);
                }
            }
            return nbttaglist;
        }
    
        /**
         * Do not make give this method the name canInteractWith because it clashes with Container
         */
        @Override
        public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer){
            return true;
        }
    
        
        
        @Override
        public void markDirty(){
        	//if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0)
        	//	this.inventory[i] = null;
        }
    
        @Override
        public void openInventory(){}
        
        @Override
        public void closeInventory(){}
    
    @Override
    public int getSizeInventory() {
    	return this.INV_SIZE;
    }
    
    @Override
    public ItemStack getStackInSlot(int slot) {
    	return this.inventory[slot];
    }
    
    @Override
    public ItemStack decrStackSize(int slot, int count) {
    	if (this.inventory[slot] != null)
            {
                ItemStack itemstack;
    
                if (this.inventory[slot].stackSize <= count)
                {
                    itemstack = this.inventory[slot];
                    this.inventory[slot] = null;
                    this.markDirty();
                    return itemstack;
                }
                else
                {
                    itemstack = this.inventory[slot].splitStack(count);
    
                    if (this.inventory[slot].stackSize == 0){
                        this.inventory[slot] = null;
                    }
    
                    this.markDirty();
                    return itemstack;
                }
            }
            else
            {
                return null;
            }
    }
    
    @Override
    public ItemStack getStackInSlotOnClosing(int slot) {
    	if (this.inventory[slot] != null){
                ItemStack itemstack = this.inventory[slot];
                this.inventory[slot] = null;
                return itemstack;
            }
            else{
                return null;
            }
    }
    
    @Override
    public void setInventorySlotContents(int slot, ItemStack itemStack) {
    	this.inventory[slot] = itemStack;
    
            if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()){
            	itemStack.stackSize = this.getInventoryStackLimit();
            }
    
            this.markDirty();
    }
    
    @Override
    public String getInventoryName() {
    	return "container.miney";
    }
    
    @Override
    public boolean hasCustomInventoryName() {
    	return false;
    }
    
    @Override
    public int getInventoryStackLimit() {
    	return 64;
    }
    
    @Override
    public boolean isItemValidForSlot(int var1, ItemStack var2) {
    	return true;
    }
    }
    

     

     

     

    gui Handler class (I removed the other guis cause I have alot of them in there this is just the stuff pertaining to my custom one with the mouse issues)

     

     

    
    public static final int PLAYER_MINEY_GUI_ID = 9;
    
    
    @Override
    public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
           
            if(guiId == PLAYER_MINEY_GUI_ID){
            	InventoryMiney inventoryMiney = new InventoryMiney();
            	inventoryMiney.loadInventoryFromPlayer(player);
    		return new ContainerMiney(player.inventory, inventoryMiney);
    	}
            return null;
    }
    
    @Override
    public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {		
    	if (guiId == PLAYER_MINEY_GUI_ID){
            	InventoryMiney inventoryMiney = new InventoryMiney();
            	inventoryMiney.loadInventoryFromPlayer(player);
            	return new GuiPlayerMiney(player.inventory, inventoryMiney);
            }
            return null;
    }	
    }
    
    

    [/spoiler

  11. Hi everyone,

     

    I am trying to add slots to a gui that the player can open anytime. The purpose of this gui will be so that the player can convert the amount of currency called "Miney" he stored in his ieep to coin items or vice versa (kinda like a deposit/withdrawal system)

     

    I have run into a problem however. I cant seem to get my inventory slots to align with the gui "slots". When the game is resized they end up in the incorrect spot. Anyone know how to fix this? My gui is centered and resizes correctly it seems. It is basically the same shape as the default vanilla furnace gui (same size too and has the players inventory as in the vanilla gui). I cant get the slots to stay aligned with the gui on game resize. Anyone know what the issue is and how to solve this?

     

    GuiClass

     

     

    @SideOnly(Side.CLIENT)
    public class GuiPlayerMiney extends InventoryEffectRenderer
    {
        private GuiTextField mineyDepositTextField;
        private static ContainerMiney containerMiney;
        
        private ArrayList<GuiTextField> editControls = new ArrayList<GuiTextField>();
        private static final ResourceLocation guiTexture = new ResourceLocation("custommod:textures/gui/MineyGui.png");
        private boolean wasInitialized;	
        private static final int TEXTURE_SIZE = 256;
       
      	public GuiPlayerMiney(InventoryPlayer inv){
    	super(new ContainerMiney(inv));
          	this.wasInitialized = false;
        }
    
        /**
         * Adds the buttons (and other controls) to the screen in question.
         */
        @Override
        public void initGui()
        {
        	  
            if(this.wasInitialized)
            	return;
            this.wasInitialized = true;
            
            //edit controls
            this.editControls.clear();
            this.mineyDepositTextField = new GuiTextField(fontRendererObj, 100, 70, 50, 12);
            this.editControls.add(mineyDepositTextField);
           
        }
    
        @Override
    public boolean doesGuiPauseGame(){
    	return false;
    }
        
        @Override
        public void onGuiClosed(){ }
    
           
        @Override
        protected void mouseClicked(int x, int y, int event){
            super.mouseClicked(x, y, event);
            for(GuiTextField textBox : this.editControls){
            	textBox.mouseClicked(x, y, event);
        	}
        }
        
        @Override
        protected void mouseMovedOrUp(int mouseX, int mouseY, int event){
        	super.mouseMovedOrUp(mouseX, mouseY, event);
        }
        
        @Override
    protected void keyTyped(char key, int event){
        	super.keyTyped(key, event);
        	for(GuiTextField textBox : this.editControls){
            	textBox.textboxKeyTyped(key, event);
        	}
    }
    
              
        private void sendUpdateToSpawner(TileEntitySpawner spawner){
        	int withdrawAmount = this.getTextboxValue(this.mineyDepositTextField.getText());
        	
        }
        
        //checks the string to see if it is an integer
        private boolean validateTextboxInt(String s){
        	int val = 0;
        	try{
        		val = Integer.valueOf(s);
        	}
        	catch(NumberFormatException e){
        		return false;
        	}
        	
        	return true;
        }
        
        private int getTextboxValue(String s){
        	if(validateTextboxInt(s)){
        		return Integer.valueOf(s);
        	}
        	return 0;
        }
    
        @Override
    protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_){
    	int fontColor = 0x404040;	//RGB value of the text color
    }
        
    @Override
    protected void drawGuiContainerBackgroundLayer(float x, int y, int z) {
    
    	this.mc.getTextureManager().bindTexture(guiTexture);
    
    	int xPos = (this.width - this.xSize) / 2;
        int yPos = (this.height - this.ySize) / 2;
    	this.drawTexturedModalRect(xPos, yPos, 0, 0, this.xSize, this.ySize);
        	
        	
           	final String withdraw = "Withdraw";
            this.drawString(this.fontRendererObj, withdraw, this.width/2 - 82, this.height/2 - 74, 0xFFFFFF);
            
        	final String deposit = "Deposit";
            this.drawString(this.fontRendererObj, deposit, this.width/2 - 77,  this.height/2 - 26, 0xFFFFFF);
          
            final String total = "Total Miney";
            this.drawString(this.fontRendererObj, total, this.width/2 +10, this.height/2 - 78, 0xFFFFFF);
            
            final String miney = "" + (BattlePlayerProperties.get(Minecraft.getMinecraft().thePlayer).getMineyTotal() - this.getTextboxValue(this.mineyDepositTextField.getText()));
            this.drawString(this.fontRendererObj, miney, (this.width/2 + 12) + 50/2 - this.fontRendererObj.getStringWidth(miney)/2, this.height/2 - 66, 0xFFFFFF);
          
            
            //draw edit controls
            for(GuiTextField textBox : this.editControls){
            	textBox.width = 45;
            	textBox.xPosition = this.width/2 -82;		//so it stays in the same position when gui is scaled
            	textBox.yPosition = this.height/2 -64;
            	textBox.drawTextBox();
            }
    
    
    }
    }
    

     

     

     

    ContainerClass

     

     

    
    public class ContainerMiney extends Container
    {   
        private final int slotCols = 9;
        private int slotRows;
    
    public ContainerMiney(IInventory playerInventory){
           
            int i;
    
            for (i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
                }
            }
    
            for (i = 0; i < 9; ++i)
            {
                this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 179));
            }
        }
    
    
        /**
         * Called when the container is closed.
         */
        public void onContainerClosed(EntityPlayer player)
        {
            super.onContainerClosed(player);
        }
        
        @Override
        public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
        {
            ItemStack itemstack = null;
            Slot slot = (Slot)this.inventorySlots.get(par2);
    
            if (slot != null && slot.getHasStack())
            {
                ItemStack itemstack1 = slot.getStack();
                itemstack = itemstack1.copy();
    
                if (par2 < this.slotRows * 9)
                {
                    if (!this.mergeItemStack(itemstack1, this.slotRows * 9, this.inventorySlots.size(), true))
                    {
                        return null;
                    }
                }
                else if (!this.mergeItemStack(itemstack1, 0, this.slotRows * 9, false))
                {
                    return null;
                }
    
                if (itemstack1.stackSize == 0)
                {
                    slot.putStack((ItemStack)null);
                }
                else
                {
                    slot.onSlotChanged();
                }
            }
    
            return itemstack;
        }
        
        
    
    @Override
    public boolean canInteractWith(EntityPlayer var1) {
    	return true;
    }
    }
    

     

     

  12. (special thanks to parzivail who figured this out)

     

    Hi everyone, lets say you want to change the camera to be farther back because you have a large entity or whatever and you want it in frame. The way to do this that I now know of is as follows: (if you know of a better way to alter the camera in 1.7.10 please post the full solution below)!

     

    1) create a copy of EntityRenderer class but call it your own, for the purposes of this walkthrough ill call it ReplacementEntityRenderer

     

    2) make ReplacementEntityRenderer extend EntityRenderer and make sure it implements IResourceManagerReloadListener

     

    3) create method inside ReplacementEntityRenderer that does the following:

     

    public void setThirdPersonDistance(float distance)
        {
        	this.thirdPersonDistanceTemp = this.thirdPersonDistance = distance;
        }
    

     

    4) inside ClientProxy -> set minecrafts entity renderer instance to use yours instead like so:

    Minecraft.getMinecraft().entityRenderer = new ReplacementEntityRenderer(Minecraft.getMinecraft(), Minecraft.getMinecraft().getResourceManager());
    

     

    5) whenever you want to change the render distance (use  the client side only render events such as RenderGameOverlayEvent.Pre, RenderGameOverlayEvent.Post, RenderPlayerEvent.Pre, RenderPlayerEvent.Post, call the set setThirdPersonDistance() method

     

    ((ReplacementEntityRenderer)Minecraft.getMinecraft().entityRenderer).setThirdPersonDistance(10);
    

     

    and voila if done correctly you will have set the render distance to 10

     

    The default 3rd Person Render Distance seems to be 4.

     

    You can now generate getters and setters for any of the variables and control the camera (I believe)

     

×
×
  • Create New...

Important Information

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