Update
This commit is contained in:
@@ -2,6 +2,8 @@ package systems.brn.tweaks.mixin;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -13,11 +15,9 @@ import static systems.brn.tweaks.Tweaks.Enderpearl_Damage;
|
||||
public class DontHurtMePearlMixin {
|
||||
|
||||
@Redirect(method = "onCollision(Lnet/minecraft/util/hit/HitResult;)V",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/Entity;damage(Lnet/minecraft/entity/damage/DamageSource;F)Z"))
|
||||
private boolean redirectDamage(Entity entity, DamageSource source, float amount) {
|
||||
World world = entity.getWorld();
|
||||
entity.damage(source, world.getGameRules().getInt(Enderpearl_Damage));
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;damage(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/damage/DamageSource;F)Z"))
|
||||
private boolean redirectDamage(ServerPlayerEntity entity, ServerWorld world, DamageSource source, float amount) {
|
||||
entity.damage(world, source, world.getGameRules().getInt(Enderpearl_Damage));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package systems.brn.tweaks.mixin;
|
||||
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -12,22 +13,28 @@ import static systems.brn.tweaks.Tweaks.Entity_Portal_Cooldown;
|
||||
|
||||
@Mixin(net.minecraft.entity.Entity.class)
|
||||
public class JustTeleportAlreadyMixin {
|
||||
@Shadow private World world;
|
||||
@Shadow
|
||||
private World world;
|
||||
|
||||
@Inject(method = "getDefaultPortalCooldown",
|
||||
at = @At(value = "RETURN"),
|
||||
cancellable = true)
|
||||
private void getDefaultPortalCooldown(CallbackInfoReturnable<Integer> cir) {
|
||||
cir.setReturnValue(world.getGameRules().getInt(Entity_Portal_Cooldown));
|
||||
if (world instanceof ServerWorld sWorld) {
|
||||
cir.setReturnValue(sWorld.getGameRules().getInt(Entity_Portal_Cooldown));
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private int portalCooldown;
|
||||
|
||||
@Inject(method = "tickPortalCooldown", at = @At(value = "RETURN"))
|
||||
private void tickPortalCooldown(CallbackInfo ci) {
|
||||
int maxCooldown = world.getGameRules().getInt(Entity_Portal_Cooldown);
|
||||
if (portalCooldown > maxCooldown) {
|
||||
portalCooldown = maxCooldown;
|
||||
if (world instanceof ServerWorld sWorld) {
|
||||
int maxCooldown = sWorld.getGameRules().getInt(Entity_Portal_Cooldown);
|
||||
if (portalCooldown > maxCooldown) {
|
||||
portalCooldown = maxCooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/main/resources/assets/icon.png
Normal file
BIN
src/main/resources/assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Reference in New Issue
Block a user