Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

 

The essence of this code, when any player appears at coordinates 120 x 20 at z and at any height, he will be teleported 2 blocks back at x and z coordinates and will write a message that other players cannot see in any way
 

import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.text.StringTextComponent;
//import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;


public class ClassName extends PlayerEntity{
    
    public ClassName(World p_i241920_1_, BlockPos p_i241920_2_, float p_i241920_3_, GameProfile p_i241920_4_) {
        super(p_i241920_1_, p_i241920_2_, p_i241920_3_, p_i241920_4_);
        
        
        
        Vector3d no_escape = new Vector3d(120.000, position().y, 20.000);
        Vector3d PlPos = position();
            
            if(PlPos.x == no_escape.x && PlPos.z==no_escape.z) {
            teleportTo(no_escape.x-2, no_escape.y-0, no_escape.z-2);
            sendMessage(new StringTextComponent("No way!"), getUUID());
            
            }
        }

    
    
    
    
    
    

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

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

}
 

Edited by NastyStuffy

  • Author
2 hours ago, diesieben07 said:

Why are you extending PlayerEntity? Doing so makes no sense.

Why are you doing stuff in the constructor?

1. It's more convenient for me 2.It is forbidden?

Edited by NastyStuffy

  • Author
2 hours ago, Luis_ST said:

what do you try to achieve

 

I want to create coordinates that cannot be teleported, and stand on them

Edited by NastyStuffy

  • Author
2 hours ago, Luis_ST said:

what? if you want to disable the teleporter of the player, use the EntityTeleportEvents

Using this event, you can turn off teleportation and prohibit being on the territory or on the block?

1 minute ago, NastyStuffy said:

Using this event, you can turn off teleportation

yes

1 minute ago, NastyStuffy said:

prohibit being on the territory or on the block?

use the TickEvent.Player for this,
you need to set the motion of the player to 0 if the block in his walking direction is the block he shouldn't enter

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.