Jump to content

how to set player immune to fire/lava?


Torojima

Recommended Posts

Since the big update to 1.3.2 I have some problems setting the fire/lava immunity status of an entity from the outside. To be exact, I would like to have a player riding a certain mob in my mod gain fire/lava immunity. Thus I have to set the player entity to immune-to-fire from the mounted entity... Does anybody have any idea how to do this?

running minecraft on Mac OS X - Sierra --- creating code since 1986 ... --- मेरा दिल भारतवासी है!

width=289 height=100http://www.arno-saxena.de/pictures/chococraft/banner_signature.png[/img]

Link to comment
Share on other sites

  • 2 weeks later...

yes, very simple, if one would not have organised ones classes in structured packets, but shoved them all into the net.minecraft.src packet. If not one has the problem of the EntityPlayer.isImmuneToFire beeing protected and only available for classes in the above mentioned packet (or classed derived from EntityPlayer). Both options are imho not very attractive. Installing a class in the net.minecraft.src packet only to gain access to the protected fields would be something on my wish-list for the used API and deriving a class from EntityPlayer proprietary only to a specific mod is again imho also not very advisable. The only option left would be reflections, but using that I always feel like a bank robber opening a save with high explosives ...

 

So I guess, my question has been asked slightly wrong. No, not the question, but the explanatory statement before. My problems do not derive from the 1.3.2 update, but from the fact that I have started to organise my code better in structured packets different to the main minecraft src packet. My question stays the same ... is there a way in forge to access this particular field (EntityPlayer.isImmuneToFire)? If not could it go into the planing to incorporate a respective access to these fields from the outside. I would like to follow a policy to not put any of my code into the minecraft core packets, but only access what is visible from the outside or through Forge. If that's not possible, I do have to fall back to the EntityPlayer derived proprietary class in my mod only to access the protected fields ...

running minecraft on Mac OS X - Sierra --- creating code since 1986 ... --- मेरा दिल भारतवासी है!

width=289 height=100http://www.arno-saxena.de/pictures/chococraft/banner_signature.png[/img]

Link to comment
Share on other sites

EntityDamageEvent, and if the conditions are right (it's a player, etc), cancel it.

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

Link to comment
Share on other sites

You can check to see if the ev.source is the right DamageSource. Then cancel it if it is.

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

Link to comment
Share on other sites

You can check to see if the ev.source is the right DamageSource. Then cancel it if it is.

 

Oh yes, I wasn't disagreeing, I was adding more info, by 'can', I mean it is possible.

 

Also I want to point out that, atleast a few forge versions ago, EntityDamageEvent returned the final damage BEFORE armor absorption would take place, before the damage actually occurs(obviously since you can cancel it). So the damage sent is not the true damage if the mob has armor.

 

Not that this would matter in this guys use, just some information to others who read this.

Link to comment
Share on other sites

in my event handler I've done the following

 

@ForgeSubscribe
public void onBurnDamage(LivingAttackEvent event)
{
    if(event.entity instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer)event.entity;
    	if(event.source.equals(DamageSource.lava) 
    	    || event.source.equals(DamageSource.inFire) 
    	    || event.source.equals(DamageSource.onFire))
    	    {
                 if(player.ridingEntity instanceof EntityChocoboPurple)
    		{
    		    event.setCanceled(true);
    		}
    	    }
       }
   }
}

 

which works fine. riding one of my mobs the player can walk through lava, without he'll get his but burned :)

running minecraft on Mac OS X - Sierra --- creating code since 1986 ... --- मेरा दिल भारतवासी है!

width=289 height=100http://www.arno-saxena.de/pictures/chococraft/banner_signature.png[/img]

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

    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • 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/  
  • Topics

×
×
  • Create New...

Important Information

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