Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.1] Teleport with Armor set equipped


Recommended Posts

Hello, I'm new to modding and trying to make an armor set that when equipped you can teleport a short distance similar to chorus fruit, but I cant find anything online to help and I'm not sure what I would need to use. 

Any Help would be Appreciated.

Link to comment
Share on other sites

12 hours ago, Silent_snowy said:

Hello, I'm new to modding and trying to make an armor set that when equipped you can teleport a short distance similar to chorus fruit, but I cant find anything online to help and I'm not sure what I would need to use. 

Any Help would be Appreciated.

when exactly should the player wearing the armor be teleported?

  • if the player equip the armor
  • if the player sneak & wearing the armor?

for the teleport you can look into the ChorusFruitItem class

Link to comment
Share on other sites

Posted (edited)
On 7/29/2021 at 4:47 AM, Luis_ST said:

when exactly should the player wearing the armor be teleported?

I was kind of thinking when the player is wearing the armor and has the chorus fruit in their inventory they could press a key bind and be teleported.

Edited by Silent_snowy
Link to comment
Share on other sites

Posted (edited)
On 7/31/2021 at 12:47 AM, poopoodice said:

ClientTickEvent -> check for key bind and is valid (has chorus fruit, is wearing the armour) -> send a packet to the server -> check if it's valid again -> perform tp

Hi thanks for you help could you tell me if I'm on the right track?

Quote

@SubscribeEvent public void onClientTick(TickEvent.PlayerTickEvent event) {

PlayerEntity player = event.player;

if (player.inventory.armorItemInSlot(0).getItem() == RegistryHandler.ENDERIRON_CHESTPLATE.get());

if (player.inventory.mainInventory.contains(Items.CHORUS_FRUIT)); } }

And if I am on the right track how would I add in the Key bind check and Teleport?

Edited by Silent_snowy
Link to comment
Share on other sites

You should be using ClientTickEvent, since keybinding is only on client. The you need to check for phase otherwise it will be triggered twice a tick (I'm not sure which one is better, start or end), and also it's probably better to use PlayerEntity#getItemStackFromSlot here, for armour checking

39 minutes ago, Silent_snowy said:

if (player.inventory.armorItemInSlot(0).getItem() == RegistryHandler.ENDERIRON_CHESTPLATE.get());

I'm sure that the first slot is not gonna be the place for a chestplate, so use the method above.

 

39 minutes ago, Silent_snowy said:

if (player.inventory.mainInventory.contains(Items.CHORUS_FRUIT)); } }

Main inventory does not contain other storages like main/off hand, so you can either loop through the player's all items yourself, or use IInventory#hasAny.

 

About key bindings you can save your own instance of KeyBinding in a static final field (check GameSettings.java), and then check if it is pressed like how Minecraft does in Minecraft#processKeybinds.

 

Packets:

https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/

 

Finally you are going to check all the stuff again (armour equipped, has the chorus fruit...) when the packet is received on the server, then process the tp (have a look at the chorus fruit , or maybe Enderman).

 

 

Edited by poopoodice
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.

Guest
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • just want to know if it's possible to show people's session id's when they join your minecraft server  
    • I am currently working on a mod that needs to listen to player connect/disconnect events.  I am currently subscribing to both ServerDisconnectionFromClientEvent and PlayerLoggedOutEvent.  For the most part, when the server is running normally the PlayerLoggedOutEvent is called. I haven't really found much on the ServerDisconnectionFromClientEvent, but my testing would suggest that this event is only raised when the server itself has an issue and forces the clients to disconnect - rather than the clients themselves disconnecting when they think the server is no longer responding. It just seems like sometimes during my testing when I let the debugger just sit there awhile (simulating the server not responding) the PlayerLoggedOutEvent is raised and other times ServerDisconnectionFromClientEvent Here is my understanding of the events: PlayerLoggedOutEvent is raised when a player manually returns to main menu, or when the client believes the server is not responding. ServerDisconnectionFromClientEvent is raised when the server has an issue and is forcing players to disconnect.  I'm not sure if it is always the case that the server is closing after this event, or if it can happen on an otherwise healthy server, like maybe there was some issue sending packets to the client and the server doesn't think the client is there. I'm not sure if my understanding is correct.  I would like to have test cases for both events with several clients connected to the server, as I need to make sure that my code is working properly no matter the order in which people disconnect.  Some players cause effects on disconnecting, and some don't, so it's quite important to know if the logic is working properly in BOTH events. Can anyone enlighten me on when exactly each event is raised, and how to force ServerDisconnectionFromClientEvent to be raised?
    • There isnt a way for me to qccess vampire GUI and settings says nothing, the button the click to get into gui from inventory just isnt there. Is there a way to fix this
    • I've been trying to sort this out for a few days but unfortunately I've had no success. I was wondering if anyone has figured out how to add xp drops to an ore for 1.17.1. Anyone help would be appreciated, thanks!
    • JVM info: Oracle Corporation - 1.8.0_281 - 25.281-b09 java.net.preferIPv4Stack=true Found java version 1.8.0_281 Extracting main jar:   Extracted successfully Considering minecraft server jar java.net.UnknownHostException: launchermeta.mojang.com     at java.net.AbstractPlainSocketImpl.connect(Unknown Source)     at java.net.PlainSocketImpl.connect(Unknown Source)     at java.net.SocksSocketImpl.connect(Unknown Source)     at java.net.Socket.connect(Unknown Source)     at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)     at sun.net.NetworkClient.doConnect(Unknown Source)     at sun.net.www.http.HttpClient.openServer(Unknown Source)     at sun.net.www.http.HttpClient.openServer(Unknown Source)     at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)     at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)     at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)     at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)     at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)     at java.net.HttpURLConnection.getResponseCode(Unknown Source)     at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)     at net.minecraftforge.installer.DownloadUtils.getConnection(DownloadUtils.java:203)     at net.minecraftforge.installer.DownloadUtils.downloadManifest(DownloadUtils.java:267)     at net.minecraftforge.installer.json.Util.getVanillaVersion(Util.java:62)     at net.minecraftforge.installer.actions.ServerInstall.run(ServerInstall.java:70)     at net.minecraftforge.installer.InstallerPanel.run(InstallerPanel.java:428)     at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:170)     at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:143) Failed to download version manifest, can not find server jar URL.  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.