1.16-pre1

This commit is contained in:
gnembon committed 2020-06-04 16:55:21 -03:00
1 parent 4528e7ac41
commit 6c01ae6807
7 files changed
+35 -41

No files matched your search

@@ -1,6 +1,7 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.mob.SkeletonHorseEntity;
@@ -17,39 +18,35 @@ import net.minecraft.world.LocalDifficulty;
import org.spongepowered.asm.mixin.Mixin;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(SummonCommand.class)
public class SummonCommandMixin
{
@Inject(method = "execute", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At(
@Redirect(method = "execute", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;addLightning(Lnet/minecraft/entity/LightningEntity;)V",
shift = At.Shift.BEFORE
target = "Lnet/minecraft/entity/Entity;getBlockPos()Lnet/minecraft/util/math/BlockPos;"
))
private static void addRiders(ServerCommandSource source, Identifier identifier_1, Vec3d vec3d_1, CompoundTag compoundTag_1, boolean arg4, CallbackInfoReturnable<Integer> cir, CompoundTag compoundTag_2, LightningEntity lightningEntity_1)
private static BlockPos addRiders(Entity entity)
{
// [CM] SummonNaturalLightning - if statement around
if (CarpetSettings.summonNaturalLightning && !source.getWorld().isClient)
if (CarpetSettings.summonNaturalLightning && entity instanceof LightningEntity && !entity.getEntityWorld().isClient)
{
ServerWorld world = source.getWorld();
BlockPos at = new BlockPos(vec3d_1);
LocalDifficulty localDifficulty_1 = source.getWorld().getLocalDifficulty(at);
ServerWorld world = (ServerWorld) entity.getEntityWorld();
BlockPos at = entity.getBlockPos();
LocalDifficulty localDifficulty_1 = world.getLocalDifficulty(at);
boolean boolean_2 = world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && world.random.nextDouble() < (double)localDifficulty_1.getLocalDifficulty() * 0.01D;
if (boolean_2) {
SkeletonHorseEntity skeletonHorseEntity_1 = (SkeletonHorseEntity) EntityType.SKELETON_HORSE.create(world);
skeletonHorseEntity_1.setTrapped(true);
skeletonHorseEntity_1.setBreedingAge(0);
skeletonHorseEntity_1.resetPosition(vec3d_1.x, vec3d_1.y, vec3d_1.z);
skeletonHorseEntity_1.resetPosition(entity.getX(), entity.getY(), entity.getZ());
world.spawnEntity(skeletonHorseEntity_1);
}
world.addLightning(lightningEntity_1);
source.sendFeedback(new TranslatableText("commands.summon.success", lightningEntity_1.getDisplayName()), true);
cir.setReturnValue(1);
cir.cancel();
}
return entity.getBlockPos();
}
}