Jump to content

[1.7.2] Damage after Portal


delpi

Recommended Posts

I'm having an odd issue.  Sometimes when I go through my custom portals, the player immediately take damage like something hit me.  The player jumps with knockback and this sometimes lands in lava or a long fall. 

 

i've looked at the destination and the player is arriving inside the center of the portal block, not in one of the frame blocks.

 

 

Anyone had experience with this?

 

 

Part of code actually moving the player.

 

 

 

        playerMP.motionX = playerMP.motionY = playerMP.motionZ = 0.0D;

        playerMP.fallDistance = 0.0F;

        playerMP.setPositionAndRotation(dx, dy, dz, entity.rotationYaw, entity.rotationPitch);

       

        // Set Dimension

        playerMP.mcServer.getConfigurationManager().transferPlayerToDimension(playerMP, dimension, this);

 

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

I think the problem is, that you moves the position of the player BEFORE transferring dimension.

It would probably cause some issues, like on the case that teleport to the position is invalid.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

I tried it after and it did nothing.  The player kept the same coordinates from the old dimension.

 

Do I have to delay the movement request a tick or something?

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity entity)
    {
    	if ((entity.ridingEntity == null)&& (entity.riddenByEntity == null) && ((entity instanceof EntityPlayerMP))) 
    	{
		EntityPlayerMP thePlayer = (EntityPlayerMP) entity;
		if (thePlayer.timeUntilPortal > 0) 
		{
			thePlayer.timeUntilPortal = 10;
		}
		else if (thePlayer.dimension != mod_cobalt.cobaltdimension) 
		{
			thePlayer.timeUntilPortal = 10;
			thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, mod_cobalt.cobaltdimension, new TeleporterCobalt(thePlayer.mcServer.worldServerForDimension(mod_cobalt.cobaltdimension)));
		} 
		else 
		{
			thePlayer.timeUntilPortal = 10;
			thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, new TeleporterCobalt(thePlayer.mcServer.worldServerForDimension(0)));
		}
		if (entity instanceof EntityPlayer) 
		{
			EntityPlayer entityplayer = (EntityPlayer) entity;
			entityplayer.addStat(mod_cobalt.cobaltachiev14, 1);
		}
	}
    }

 

You need also a custom Teleporter

 

 

Maybe this will help ya ^^ I can send you my whole dimension/Portal code if doesn't work.

Link to comment
Share on other sites

Dragonisser,

I've got a custom Teleporter.  That line of code is from it. 

 

I just pulled out the lines of code that impact where the playere is at and when they transfer.

 

It works great.  I even have the screen wobble with the right colors for my portal colors and entry timers working perfectly.

 

The only problem is that about every other time, the player acts like he got hit with damage, jumps and makes the hurt noise.  No damage received though.  Sometimes this moves him out into lava though.

 

I'm teleporting him into the east most or north most portal block.  I'm starting to wonder if I should teleport him to the open air spot just outside the portal block.  Thoughts?

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

As far down the rabbit hole as I went, I don't think I can.  It won't be compatiable.

 

I tested on normal portals that it didn't occur.  It doesn't.  I tracked the code all the way through from vanilla entering a portal to being in the new dimension.  I 'think' i'm duplicating it in the exact same order.

 

It really does seem to be that some of the time (with no pattern I can see), it decides a portal block is solid and should hurt you.

 

As I type that, it gives me an idea.  Before shifting the landing spot, I'm going to watch the damage event and see if it is showing anything.  Maybe that will shed some light.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

WOOTA!!!!!!

 

Fixed it.

 

This may be difficult to follow, but I'll give it a shot.  i was shifting the player to the center of the portal block by adding 0.5x and 0.5z.  For some reason this made the player register a collision with the portal frame.  The player can stand there just fine without damage, but if he teleports there, oh hell.  Not sure how that makes sense, but its is reality.

 

So I did a little checking on position to make sure I moved the player to the exact spot between the end of one portal block and the start of the next.  BINGO!  No more issue.

 

Thanks everyone for the help.

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

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

    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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