Jump to content

[1.12.2] [solved] Getting Tile Entity block coords from a GUI class


GooberGunter

Recommended Posts

Hey, so I'm trying to change the GUI of a custom Container based on items inside the Tile Entity, but I can't really find a good way to tell the server how to find the tile entity the player is currently accessing. One approach I had was to use the look vector but that's giving me really weird problems. Is there a better way of finding a tile entity's BlockPos from the client side?

 

Here's the GUI if you want to look at it:

Spoiler

package com.GooberGunter.GrandSorcery.client.gui;

import com.GooberGunter.GrandSorcery.GSReferences;
import com.GooberGunter.GrandSorcery.GrandSorcery;
import com.GooberGunter.GrandSorcery.common.block.ModBlocks;
import com.GooberGunter.GrandSorcery.common.block.tileentities.ExperimentTableTE;
import com.GooberGunter.GrandSorcery.common.block.tileentities.TEBase;
import com.GooberGunter.GrandSorcery.common.networking.packets.RequestPaperMessage;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.DimensionManager;

public class ExperimentGui extends GuiContainer{
	
	int size;
	private static boolean hasPaper;
	
	public ExperimentGui(Container inventorySlotsIn) {
		super(inventorySlotsIn);
		this.xSize=304;
		this.ySize=249;
		this.size=this.height;
		this.hasPaper=false;
	}

	@Override
	protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
		this.drawInteractiveGui(partialTicks, mouseX, mouseY);
	}
	
	public static void setPaper(boolean paper) {
		hasPaper=paper;
	}
	
	protected void drawInteractiveGui(float partialTicks, int mouseX, int mouseY) {
		//TODO send message requesting paper
		GrandSorcery.handler.INSTANCE.sendToServer(new RequestPaperMessage(this.getTEPos()));
		if(hasPaper==true) {
			this.mc.getTextureManager().bindTexture(new ResourceLocation(GSReferences.MODID+":"+"textures/gui/inscriber_workbench_paper.png"));
		}else {
			this.mc.getTextureManager().bindTexture(new ResourceLocation(GSReferences.MODID+":"+"textures/gui/inscriber_workbench_empty.png"));
		}
		this.drawModalRectWithCustomSizedTexture((this.width/2)-(this.xSize/2), (this.height/2)-(this.ySize/2), this.xSize, this.ySize, this.xSize, this.ySize, this.xSize, this.ySize);
	}
	
	public BlockPos getTEPos() {
		Vec3d v = Minecraft.getMinecraft().player.getLookVec();
		for(int u=0; u<9; u++) {
			v.addVector(u, u, u);
			BlockPos pos = new BlockPos(v);
			if(Minecraft.getMinecraft().world.getBlockState(pos).getBlock()==ModBlocks.wkbnch && Minecraft.getMinecraft().world.getBlockState(pos)==DimensionManager.getWorld(0).getBlockState(pos)) {
				return pos;
			}
		}
		return null;
	}

}

 

I'd rather not use the look vector if it isn't necessary. I have the feeling it's better to use vectors in motion rather than position

Edited by GooberGunter
Link to comment
Share on other sites

15 hours ago, GooberGunter said:

Hey, so I'm trying to change the GUI of a custom Container based on items inside the Tile Entity, but I can't really find a good way to tell the server how to find the tile entity the player is currently accessing. One approach I had was to use the look vector but that's giving me really weird problems. Is there a better way of finding a tile entity's BlockPos from the client side?

 

Here's the GUI if you want to look at it:

  Reveal hidden contents


package com.GooberGunter.GrandSorcery.client.gui;

import com.GooberGunter.GrandSorcery.GSReferences;
import com.GooberGunter.GrandSorcery.GrandSorcery;
import com.GooberGunter.GrandSorcery.common.block.ModBlocks;
import com.GooberGunter.GrandSorcery.common.block.tileentities.ExperimentTableTE;
import com.GooberGunter.GrandSorcery.common.block.tileentities.TEBase;
import com.GooberGunter.GrandSorcery.common.networking.packets.RequestPaperMessage;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.DimensionManager;

public class ExperimentGui extends GuiContainer{
	
	int size;
	private static boolean hasPaper;
	
	public ExperimentGui(Container inventorySlotsIn) {
		super(inventorySlotsIn);
		this.xSize=304;
		this.ySize=249;
		this.size=this.height;
		this.hasPaper=false;
	}

	@Override
	protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
		this.drawInteractiveGui(partialTicks, mouseX, mouseY);
	}
	
	public static void setPaper(boolean paper) {
		hasPaper=paper;
	}
	
	protected void drawInteractiveGui(float partialTicks, int mouseX, int mouseY) {
		//TODO send message requesting paper
		GrandSorcery.handler.INSTANCE.sendToServer(new RequestPaperMessage(this.getTEPos()));
		if(hasPaper==true) {
			this.mc.getTextureManager().bindTexture(new ResourceLocation(GSReferences.MODID+":"+"textures/gui/inscriber_workbench_paper.png"));
		}else {
			this.mc.getTextureManager().bindTexture(new ResourceLocation(GSReferences.MODID+":"+"textures/gui/inscriber_workbench_empty.png"));
		}
		this.drawModalRectWithCustomSizedTexture((this.width/2)-(this.xSize/2), (this.height/2)-(this.ySize/2), this.xSize, this.ySize, this.xSize, this.ySize, this.xSize, this.ySize);
	}
	
	public BlockPos getTEPos() {
		Vec3d v = Minecraft.getMinecraft().player.getLookVec();
		for(int u=0; u<9; u++) {
			v.addVector(u, u, u);
			BlockPos pos = new BlockPos(v);
			if(Minecraft.getMinecraft().world.getBlockState(pos).getBlock()==ModBlocks.wkbnch && Minecraft.getMinecraft().world.getBlockState(pos)==DimensionManager.getWorld(0).getBlockState(pos)) {
				return pos;
			}
		}
		return null;
	}

}

 

I'd rather not use the look vector if it isn't necessary. I have the feeling it's better to use vectors in motion rather than position

If you are good at planning the mods I would like you on my team

 
Link to comment
Share on other sites

4 hours ago, HomixHD said:

If you are good at planning the mods I would like you on my team

Similarly, if you're not, they won't.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

30 minutes ago, HomixHD said:

 

I could not contact you because he told me that my box was full

Yes, the forum is FUBAR. If you have any conversations, your inbox is considered "full."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

    • Selamat datang di INDOBET88 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor INDOBET88 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini INDOBET88.
    • Selamat datang di INDO88 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor INDO88 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini INDO88.
    • ☾☾ KLIK DAFTAR DI SINI ☽☽ ☾☾ KLIK DAFTAR DI SINI ☽☽ ☾☾ KLIK DAFTAR DI SINI ☽☽   SLOT BANK BCA merupakan situs daftar bandar judol yang deposit menggunakan bank bca hanya 1menit Langsung masuk di dalam akun anda. SLOT BANK BCA menyediakan berbagai macam game slot online terlengkap provider termasuk daftar deposit via bank bca dan semua game slot gacor maxwin terbaru 2024.    
    • Lambo77 = Depo 25 Bonus 25 ㊎  Deposit 50 Bonus 50 Kumpulan Slot Bonus New Member 100% Terbaru & Terlengkap ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ Depo 25 Bonus 25 Atau Slot Bonus New Member 100% Yang Memanjakan Member Baru & Akan Sangat Membantu Dalam Memperoleh Kemenangan,karena Deposit 25 Akan Mendapat Tambahan 25, Jadi Saldo Yang Masuk Menjadi 50k, Apalagi Situs Ini Juga Rtp Bocoran Slot Gacor Hari. Daftar Bonus : • Depo 25 Dapat 25, Deposit 25 Bonus 25 • Depo 50 Bonus 50, Deposit 50 Bonus 50 • Depo 100 Bonus 100, Deposit 100 Bonus 100 • Welcome Bonus New Member 100% • Slot Garansi Kekalahan 100% To Kecil, To Rendah, Tanpa To, Bebas Ip, Bebas Buy Spin, Gampang Menang Jackpot, Gampang Scatter, Apa Itu Depo 25 Bonus 25? Depo 25 Bonus 25 adalah situs permainan slot yang menawarkan bonus deposit sebesar 25 ribu rupiah untuk setiap deposit yang Anda lakukan sebesar 25 ribu rupiah, sehingga saldo total Anda menjadi 50 ribu rupiah. Situs ini menawarkan berbagai promo menarik, termasuk "Depo 50 Bonus 50" dan "Depo 100 Bonus 100" dengan berbagai variasi bonus dan persyaratan. Bergabunglah sekarang dan rasakan keseruan bermain dengan promo-promo menarik yang telah disiapkan khusus untuk Anda. Jangan lewatkan kesempatan ini untuk mendapatkan nilai tambahan yang menguntungkan saat mengisi ulang akun Anda. Manfaatkan sekarang juga dan raih hadiah besar dalam permainan slot dan permainan lainnya. Situs ini menawarkan berbagai kategori menarik, seperti Depo 25 Bonus 25, Depo 25 Bonus 25 to 3x, Depo 25 Bonus 25 Heylink, dan Depo 25 Bonus 25 bebas IP. Selain itu, terdapat juga opsi lain seperti tanpa to, tanpa syarat, to 1x, Depo 25 Bonus 25 di awal, dan Depo 25 Bonus 25 to 5x terbaru. Anda dapat menikmati berbagai variasi permainan yang seru di situs ini, termasuk Depo 25 Bonus 25 to 10x, slot Depo 25 Bonus 25, slot Depo 25 Bonus 25 to 5x, dan slot Depo 25 Bonus 25 tanpa to. Kami juga menyediakan pilihan slot Depo 25 Bonus 25 to kecil, bebas IP, dan di depan untuk memperkaya pengalaman bermain Anda. Bergabunglah dan rasakan keseruan bermain dengan slot Deposit 25 Bonus 25 to 3x kecil di platform kami dan temukan Bonus New Member serta berbagai kejutan menarik lainnya yang siap memanjakan Anda. Rasakan keberagaman dan kualitas permainan yang menyenangkan di situs kami, dan jangan lewatkan setiap opsi menarik yang telah kami siapkan khusus untuk Anda. Apa Itu Depo 50 Bonus 50? Depo 50 Bonus 50 merupakan bonus deposit sebesar 100% to 5x untuk setiap deposit sebesar 50 ribu rupiah yang Anda lakukan, sehingga meningkatkan peluang kemenangan Anda. Selain itu, Depo 50 Bonus 50 to 10X juga menawarkan bonus new member sebesar 100% dengan to 10x, memberikan pengalaman bermain yang lebih menguntungkan. Dengan melakukan deposit sebesar 50 ribu rupiah, Anda akan mendapatkan bonus sebesar 50 ribu rupiah, yang sebesar 100% dari deposit Anda. Oleh karena itu, total saldo Anda setelah melakukan deposit akan menjadi 100 ribu rupiah, yang meningkatkan peluang kemenangan Anda dalam permainan slot dan permainan lainnya. Depo 50 Bonus 50 to 10X menawarkan bonus new member sebesar 100% dengan to 10x, yang memberikan pengalaman bermain yang lebih menguntungkan. Dengan mengikuti promo ini, Anda akan mendapatkan lebih banyak waktu bermain dan kesempatan untuk meraih hadiah besar dalam permainan slot dan permainan lainnya. Slot new member Depo 50 Bonus 50 menawarkan bonus new member sebesar 100% yang diberikan di awal permainan. Untuk Anda yang menyukai slot dengan to kecil, cobalah keberuntungan Anda dengan Depo 50 Bonus 50 TO kecil Heylink, slot bonus new member sebesar 100% dari Heylink. Depo 50 Bonus 50 to 4x juga merupakan pilihan menarik, memberikan bonus sebesar 100% dengan to 4x. Jangan lupakan MPO Depo 50 Bonus 50, slot MPO yang menggabungkan deposit sebesar 50 dengan bonus 50 dan bebas IP.
    • Selamat datang di HOKI777 salah satu situs slot gacor gampang menang hari ini di Indonesia yang sangat menjajikan. Slot gacor adalah adalah suatu istilah yang digunakan untuk menjelaskan sebuah permainan slot gampang menang di situs slot online. Situs slot gacor HOKI777 ini bisa menjadi populer walaupun terbilang baru karena RTP slot online yang disajikan begitu tinggi. Seiring dengan perkembangan zaman situs slot gacor terbaru ini juga sudah update dari segi teknologi yang menggunakan HTML5, inilah yang membuat grafis permainan terlihat begitu modern, audio lebih jernih, dan user interface yang smooth. Tidak dipungkiri grafis yang kami memiliki sudah menarik banyak sekali pendatang baru yang ingin merasakan terbawa dalam suasana tema permainan mesin slot. Kehadiran slot gacor menjadi angin segar bagi para pecinta judi online, memberikan alternatif permainan yang seru dan menguntungkan. Tak heran jika popularitas slot gacor terus meningkat, menarik minat para pemain baru untuk mencoba peruntungan mereka di situs slot gacor hari ini HOKI777.
  • Topics

×
×
  • Create New...

Important Information

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