-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/mendedminecarts/mixin/LavaCauldronBlockMixin_TNTCartDamage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package mendedminecarts.mixin; | ||
|
||
import mendedminecarts.MendedMinecartsMod; | ||
import net.minecraft.block.LavaCauldronBlock; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.vehicle.TntMinecartEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.sound.SoundEvents; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(LavaCauldronBlock.class) | ||
public class LavaCauldronBlockMixin_TNTCartDamage { | ||
|
||
|
||
@Redirect( | ||
method = "onEntityCollision", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setOnFireFromLava()V") | ||
) | ||
private void readCustomCount(Entity entity) { | ||
if (MendedMinecartsMod.LAVA_CAULDRON_KILLS_TNT_CART.isEnabled()) { | ||
if (entity instanceof TntMinecartEntity tntCart) { | ||
this.setOnFireFromLava(tntCart); | ||
return; | ||
} | ||
} | ||
entity.setOnFireFromLava(); | ||
} | ||
|
||
private void setOnFireFromLava(TntMinecartEntity tntCart) { | ||
if (tntCart.isFireImmune()) { | ||
return; | ||
} | ||
tntCart.setOnFireFor(15); | ||
if (tntCart.damage(DamageSource.LAVA, 4.0f)) { | ||
tntCart.playSound(SoundEvents.ENTITY_GENERIC_BURN, 0.4f, 2.0f + tntCart.getWorld().random.nextFloat() * 0.4f); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters