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

@@ -25,7 +25,7 @@ public abstract class CommandManagerMixin
private CommandDispatcher<ServerCommandSource> dispatcher;
@Inject(method = "<init>", at = @At("RETURN"))
private void onRegister(boolean boolean_1, CallbackInfo ci) {
private void onRegister(CommandManager.class_5364 arg, CallbackInfo ci) {
CarpetServer.registerCarpetCommands(this.dispatcher);
}
@@ -60,16 +60,16 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
*/
// Cancel a while statement
@Redirect(method = "run", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z"))
@Redirect(method = "method_29741", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z"))
private boolean cancelRunLoop(MinecraftServer server)
{
return false;
}
} // target run()
// Replaced the above cancelled while statement with this one
// could possibly just inject that mspt selection at the beginning of the loop, but then adding all mspt's to
// replace 50L will be a hassle
@Inject(method = "run", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
@Inject(method = "method_29741", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V"))
private void modifiedRunLoop(CallbackInfo ci)
{
@@ -1,5 +1,6 @@
package carpet.mixins;
import net.minecraft.entity.LightningEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
@@ -18,10 +19,13 @@ public class ServerWorld_scarpetEventMixin
{
@Inject(method = "tickChunk", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;addLightning(Lnet/minecraft/entity/LightningEntity;)V"
target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z",
shift = At.Shift.BEFORE,
ordinal = 1
))
private void onNaturalLightinig(WorldChunk chunk, int randomTickSpeed, CallbackInfo ci,
ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos, boolean bl2)
//ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos, boolean bl2)
ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos, boolean bl2, LightningEntity lightningEntity)
{
if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0);
}
@@ -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();
}
}
@@ -20,7 +20,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.dynamic.GlobalPos;
import net.minecraft.util.Hand;
import net.minecraft.util.dynamic.Timestamp;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.poi.PointOfInterest;
@@ -71,14 +70,14 @@ public abstract class VillagerEntity_aiMixin extends AbstractTraderEntity
time = long_2+600 - getEntityWorld().getTime();
}
boolean recentlySeen = hasSeenGolemRecently(getEntityWorld().getTime());
Optional<Timestamp> optional_11 = this.brain.getOptionalMemory(MemoryModuleType.LAST_SLEPT);
Optional<Long> optional_11 = this.brain.getOptionalMemory(MemoryModuleType.LAST_SLEPT);
//Optional<Timestamp> optional_22 = this.brain.getOptionalMemory(MemoryModuleType.LAST_WORKED_AT_POI);
//boolean work = false;
boolean sleep = false;
boolean panic = this.brain.hasActivity(Activity.PANIC);
long currentTime = this.world.getTime();
if (optional_11.isPresent()) {
sleep = (currentTime - optional_11.get().getTime()) < 24000L;
sleep = (currentTime - optional_11.get()) < 24000L;
}
//if (optional_22.isPresent()) {
// work = (currentTime - optional_22.get().getTime()) < 36000L;
@@ -1852,25 +1852,19 @@ public class CarpetExpression
tag.putString("id", entityId.toString());
Vec3d vec3d = position.vec;
if (EntityType.getId(EntityType.LIGHTNING_BOLT).equals(entityId)) {
LightningEntity lightningEntity_1 = new LightningEntity(cc.s.getWorld(), vec3d.x, vec3d.y, vec3d.z, false);
cc.s.getWorld().addLightning(lightningEntity_1);
ServerWorld serverWorld = cc.s.getWorld();
Entity entity_1 = EntityType.loadEntityWithPassengers(tag, serverWorld, (entity_1x) -> {
entity_1x.refreshPositionAndAngles(vec3d.x, vec3d.y, vec3d.z, entity_1x.yaw, entity_1x.pitch);
return !serverWorld.tryLoadEntity(entity_1x) ? null : entity_1x;
});
if (entity_1 == null) {
return LazyValue.NULL;
} else {
ServerWorld serverWorld = cc.s.getWorld();
Entity entity_1 = EntityType.loadEntityWithPassengers(tag, serverWorld, (entity_1x) -> {
entity_1x.refreshPositionAndAngles(vec3d.x, vec3d.y, vec3d.z, entity_1x.yaw, entity_1x.pitch);
return !serverWorld.tryLoadEntity(entity_1x) ? null : entity_1x;
});
if (entity_1 == null) {
return LazyValue.NULL;
} else {
if (!hasTag && entity_1 instanceof MobEntity) {
((MobEntity)entity_1).initialize(serverWorld, serverWorld.getLocalDifficulty(entity_1.getBlockPos()), SpawnReason.COMMAND, null, null);
}
Value res = new EntityValue(entity_1);
return (_c, _t) -> res;
if (!hasTag && entity_1 instanceof MobEntity) {
((MobEntity)entity_1).initialize(serverWorld, serverWorld.getLocalDifficulty(entity_1.getBlockPos()), SpawnReason.COMMAND, null, null);
}
Value res = new EntityValue(entity_1);
return (_c, _t) -> res;
}
});