Migration complete

This commit is contained in:
Aleksey 2021-04-17 00:26:35 +03:00
parent 2a8853d615
commit 81edbacc12
25 changed files with 173 additions and 172 deletions

View file

@ -38,9 +38,9 @@ public abstract class ChorusFlowerBlockMixin extends Block {
super(settings);
}
@Shadow
@Final
private ChorusPlantBlock plantBlock;
@Shadow
private ChorusPlantBlock plant;
@Inject(method = "canSurvive", at = @At("HEAD"), cancellable = true)
private void be_canSurvive(BlockState state, LevelReader world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
@ -59,10 +59,10 @@ public abstract class ChorusFlowerBlockMixin extends Block {
if (i < 5) {
this.placeGrownFlower(world, up, i + 1);
if (GeneratorOptions.changeChorusPlant()) {
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.defaultBlockState().setValue(ChorusPlantBlock.UP, true).setValue(ChorusPlantBlock.DOWN, true).setValue(BlocksHelper.ROOTS, true));
BlocksHelper.setWithoutUpdate(world, pos, plant.defaultBlockState().setValue(ChorusPlantBlock.UP, true).setValue(ChorusPlantBlock.DOWN, true).setValue(BlocksHelper.ROOTS, true));
}
else {
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.defaultBlockState().setValue(ChorusPlantBlock.UP, true).setValue(ChorusPlantBlock.DOWN, true));
BlocksHelper.setWithoutUpdate(world, pos, plant.defaultBlockState().setValue(ChorusPlantBlock.UP, true).setValue(ChorusPlantBlock.DOWN, true));
}
info.cancel();
}

View file

@ -44,12 +44,31 @@ public abstract class ChorusPlantBlockMixin extends Block {
builder.add(BlocksHelper.ROOTS);
}
}
@Inject(method = "getStateForPlacement", at = @At("RETURN"), cancellable = true)
private void be_getStateForPlacement(BlockGetter world, BlockPos pos, CallbackInfoReturnable<BlockState> info) {
private void be_getStateForPlacement(BlockPlaceContext ctx, CallbackInfoReturnable<BlockState> info) {
BlockPos pos = ctx.getClickedPos();
Level world = ctx.getLevel();
BlockState plant = info.getReturnValue();
if (ctx.canPlace() && plant.is(Blocks.CHORUS_PLANT) && world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
if (GeneratorOptions.changeChorusPlant()) {
info.setReturnValue(plant.setValue(BlocksHelper.ROOTS, true).setValue(BlockStateProperties.DOWN, true));
}
else {
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true));
}
info.cancel();
}
}
@Inject(method = "Lnet/minecraft/world/level/block/ChorusPlantBlock;getStateForPlacement" +
"(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)" +
"Lnet/minecraft/world/level/block/state/BlockState;",
at = @At("RETURN"), cancellable = true)
private void be_getStateForPlacement(BlockGetter blockGetter, BlockPos blockPos, CallbackInfoReturnable<BlockState> info) {
BlockState plant = info.getReturnValue();
if (plant.is(Blocks.CHORUS_PLANT)) {
if (world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
if (blockGetter.getBlockState(blockPos.below()).is(EndTags.END_GROUND)) {
if (GeneratorOptions.changeChorusPlant()) {
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true).setValue(BlocksHelper.ROOTS, true));
}
@ -99,20 +118,4 @@ public abstract class ChorusPlantBlockMixin extends Block {
info.cancel();
}
}
@Inject(method = "getStateForPlacement", at = @At("RETURN"), cancellable = true)
private void be_getStateForPlacement(BlockPlaceContext ctx, CallbackInfoReturnable<BlockState> info) {
BlockPos pos = ctx.getClickedPos();
Level world = ctx.getLevel();
BlockState plant = info.getReturnValue();
if (ctx.canPlace() && plant.is(Blocks.CHORUS_PLANT) && world.getBlockState(pos.below()).is(EndTags.END_GROUND)) {
if (GeneratorOptions.changeChorusPlant()) {
info.setReturnValue(plant.setValue(BlocksHelper.ROOTS, true).setValue(BlockStateProperties.DOWN, true));
}
else {
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true));
}
info.cancel();
}
}
}

View file

@ -13,13 +13,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CraftingMenu.class)
public abstract class CraftingMenuMixin {
@Shadow
@Final
private ContainerLevelAccess context;
@Shadow
private ContainerLevelAccess access;
@Inject(method = "stillValid", at = @At("HEAD"), cancellable = true)
private void be_stillValid(Player player, CallbackInfoReturnable<Boolean> info) {
if (context.evaluate((world, pos) -> {
if (access.evaluate((world, pos) -> {
return world.getBlockState(pos).getBlock() instanceof CraftingTableBlock;
}, true)) {
info.setReturnValue(true);

View file

@ -22,20 +22,20 @@ import ru.betterend.registry.EndTags;
@Mixin(EnchantmentMenu.class)
public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
@Shadow
@Final
@Shadow
private Container enchantSlots;
@Shadow
@Final
@Shadow
private ContainerLevelAccess access;
@Shadow
@Final
@Shadow
private Random random;
@Shadow
@Final
@Shadow
private DataSlot enchantmentSeed;
@Shadow
@ -95,36 +95,36 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
}
}
this.random.setSeed((long) this.enchantmentSeed.get());
random.setSeed(enchantmentSeed.get());
for (j = 0; j < 3; ++j) {
this.costs[j] = EnchantmentHelper.getEnchantmentCost(this.random, j, i, itemStack);
this.enchantClue[j] = -1;
this.levelClue[j] = -1;
if (this.costs[j] < j + 1) {
this.costs[j] = 0;
costs[j] = EnchantmentHelper.getEnchantmentCost(this.random, j, i, itemStack);
enchantClue[j] = -1;
levelClue[j] = -1;
if (costs[j] < j + 1) {
costs[j] = 0;
}
}
for (j = 0; j < 3; ++j) {
if (this.costs[j] > 0) {
List<EnchantmentInstance> list = this.generateEnchantments(itemStack, j, this.costs[j]);
List<EnchantmentInstance> list = this.getEnchantmentList(itemStack, j, this.costs[j]);
if (list != null && !list.isEmpty()) {
EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(list.size()));
this.enchantClue[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment);
this.levelClue[j] = enchantmentLevelEntry.level;
enchantClue[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment);
levelClue[j] = enchantmentLevelEntry.level;
}
}
}
this.broadcastChanges();
broadcastChanges();
});
}
else {
for (int i = 0; i < 3; ++i) {
this.costs[i] = 0;
this.enchantClue[i] = -1;
this.levelClue[i] = -1;
costs[i] = 0;
enchantClue[i] = -1;
levelClue[i] = -1;
}
}
info.cancel();
@ -132,7 +132,7 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
}
@Shadow
private List<EnchantmentInstance> generateEnchantments(ItemStack stack, int slot, int level) {
private List<EnchantmentInstance> getEnchantmentList(ItemStack stack, int slot, int level) {
return null;
}
}

View file

@ -24,45 +24,45 @@ public abstract class EntityMixin implements TeleportingEntity {
@Shadow
public boolean removed;
@Shadow
public Level world;
public Level level;
@Final
@Shadow
public abstract void detach();
public abstract void unRide();
@Shadow
public abstract Vec3 getVelocity();
public abstract Vec3 getDeltaMovement();
@Shadow
public abstract EntityType<?> getType();
@Shadow
protected abstract PortalInfo getTeleportTarget(ServerLevel destination);
protected abstract PortalInfo findDimensionEntryPoint(ServerLevel destination);
private BlockPos exitPos;
@Inject(method = "changeDimension", at = @At("HEAD"), cancellable = true)
public void be_changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
if (!removed && be_canTeleport() && world instanceof ServerLevel) {
this.detach();
this.world.getProfiler().push("changeDimension");
this.world.getProfiler().push("reposition");
PortalInfo teleportTarget = this.getTeleportTarget(destination);
if (!removed && be_canTeleport() && level instanceof ServerLevel) {
unRide();
level.getProfiler().push("changeDimension");
level.getProfiler().push("reposition");
PortalInfo teleportTarget = findDimensionEntryPoint(destination);
if (teleportTarget != null) {
this.world.getProfiler().popPush("reloading");
Entity entity = this.getType().create(destination);
level.getProfiler().popPush("reloading");
Entity entity = getType().create(destination);
if (entity != null) {
entity.restoreFrom(Entity.class.cast(this));
entity.moveTo(teleportTarget.pos.x, teleportTarget.pos.y, teleportTarget.pos.z, teleportTarget.yRot, entity.xRot);
entity.setDeltaMovement(teleportTarget.speed);
destination.addFromAnotherDimension(entity);
}
this.removed = true;
this.world.getProfiler().pop();
((ServerLevel) world).resetEmptyTime();
removed = true;
level.getProfiler().pop();
((ServerLevel) level).resetEmptyTime();
destination.resetEmptyTime();
this.world.getProfiler().pop();
this.be_resetExitPos();
level.getProfiler().pop();
be_resetExitPos();
info.setReturnValue(entity);
}
}
@ -71,7 +71,7 @@ public abstract class EntityMixin implements TeleportingEntity {
@Inject(method = "findDimensionEntryPoint", at = @At("HEAD"), cancellable = true)
protected void be_findDimensionEntryPoint(ServerLevel destination, CallbackInfoReturnable<PortalInfo> info) {
if (be_canTeleport()) {
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yRot, xRot));
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getDeltaMovement(), yRot, xRot));
}
}

View file

@ -23,7 +23,7 @@ public abstract class LivingEntityMixin {
this.lastAttacker = source.getEntity();
}
@ModifyArg(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;knockback(FDD)V"))
@ModifyArg(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;knockback(FDD)V"))
private float be_increaseKnockback(float value, double x, double z) {
if (lastAttacker != null && lastAttacker instanceof LivingEntity) {
LivingEntity attacker = (LivingEntity) lastAttacker;

View file

@ -18,7 +18,7 @@ public abstract class PlayerAdvancementsMixin {
@Inject(method = "award", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/PlayerAdvancements;grant(Lnet/minecraft/server/level/ServerPlayer;)V",
target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V",
shift = Shift.AFTER))
public void be_award(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> info) {
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.invoker().onAdvancementComplete(player, advancement, criterionName);

View file

@ -25,7 +25,7 @@ import com.google.gson.JsonElement;
import ru.betterend.recipe.EndRecipeManager;
@Mixin(RecipeManager.class)
public class RecipeManagerMixin {
public abstract class RecipeManagerMixin {
@Shadow
private Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes;
@ -35,7 +35,7 @@ public class RecipeManagerMixin {
}
@Shadow
private <C extends Container, T extends Recipe<C>> Map<ResourceLocation, Recipe<C>> getAllOfType(RecipeType<T> type) {
private <C extends Container, T extends Recipe<C>> Map<ResourceLocation, Recipe<C>> byType(RecipeType<T> type) {
return null;
}
@ -47,7 +47,7 @@ public class RecipeManagerMixin {
*/
@Overwrite
public <C extends Container, T extends Recipe<C>> Optional<T> getRecipeFor(RecipeType<T> type, C inventory, Level world) {
Collection<Recipe<C>> values = getAllOfType(type).values();
Collection<Recipe<C>> values = byType(type).values();
List<Recipe<C>> list = new ArrayList<Recipe<C>>(values);
list.sort((v1, v2) -> {
boolean b1 = v1.getId().getNamespace().equals("minecraft");

View file

@ -57,14 +57,14 @@ public abstract class ServerPlayerMixin extends Player implements TeleportingEnt
super(world, pos, yaw, profile);
}
@Inject(method = "createEndSpawnPlatform", at = @At("HEAD"), cancellable = true)
@Inject(method = "createEndPlatform", at = @At("HEAD"), cancellable = true)
private void be_createEndSpawnPlatform(ServerLevel world, BlockPos centerPos, CallbackInfo info) {
if (!GeneratorOptions.generateObsidianPlatform()) {
info.cancel();
}
}
@Inject(method = "getTeleportTarget", at = @At("HEAD"), cancellable = true)
@Inject(method = "findDimensionEntryPoint", at = @At("HEAD"), cancellable = true)
protected void be_getTeleportTarget(ServerLevel destination, CallbackInfoReturnable<PortalInfo> info) {
if (be_canTeleport()) {
info.setReturnValue(new PortalInfo(new Vec3(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getDeltaMovement(), yRot, xRot));
@ -74,43 +74,43 @@ public abstract class ServerPlayerMixin extends Player implements TeleportingEnt
@Inject(method = "changeDimension", at = @At("HEAD"), cancellable = true)
public void be_changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
if (be_canTeleport() && level instanceof ServerLevel) {
this.isChangingDimension = true;
ServerLevel serverWorld = this.getLevel();
isChangingDimension = true;
ServerLevel serverWorld = getLevel();
LevelData worldProperties = destination.getLevelData();
ServerPlayer player = ServerPlayer.class.cast(this);
this.connection.send(new ClientboundRespawnPacket(destination.dimensionType(), destination.dimension(), BiomeManager.obfuscateSeed(destination.getSeed()),
connection.send(new ClientboundRespawnPacket(destination.dimensionType(), destination.dimension(), BiomeManager.obfuscateSeed(destination.getSeed()),
gameMode.getGameModeForPlayer(),gameMode.getPreviousGameModeForPlayer(), destination.isDebug(), destination.isFlat(), true));
this.connection.send(new ClientboundChangeDifficultyPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
PlayerList playerManager = this.server.getPlayerList();
connection.send(new ClientboundChangeDifficultyPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
PlayerList playerManager = server.getPlayerList();
playerManager.sendPlayerPermissionLevel(player);
serverWorld.removePlayerImmediately(player);
this.removed = false;
PortalInfo teleportTarget = this.findDimensionEntryPoint(destination);
removed = false;
PortalInfo teleportTarget = findDimensionEntryPoint(destination);
if (teleportTarget != null) {
serverWorld.getProfiler().push("moving");
serverWorld.getProfiler().pop();
serverWorld.getProfiler().push("placing");
this.setLevel(destination);
setLevel(destination);
destination.addDuringPortalTeleport(player);
this.setRot(teleportTarget.yRot, teleportTarget.xRot);
this.moveTo(teleportTarget.pos.x, teleportTarget.pos.y, teleportTarget.pos.z);
setRot(teleportTarget.yRot, teleportTarget.xRot);
moveTo(teleportTarget.pos.x, teleportTarget.pos.y, teleportTarget.pos.z);
serverWorld.getProfiler().pop();
this.triggerDimensionChangeTriggers(serverWorld);
this.gameMode.setLevel(destination);
this.connection.send(new ClientboundPlayerAbilitiesPacket(this.abilities));
triggerDimensionChangeTriggers(serverWorld);
gameMode.setLevel(destination);
connection.send(new ClientboundPlayerAbilitiesPacket(abilities));
playerManager.sendLevelInfo(player, destination);
playerManager.sendAllPlayerInfo(player);
for (MobEffectInstance statusEffectInstance : this.getActiveEffects()) {
this.connection.send(new ClientboundUpdateMobEffectPacket(getId(), statusEffectInstance));
for (MobEffectInstance statusEffectInstance : getActiveEffects()) {
connection.send(new ClientboundUpdateMobEffectPacket(getId(), statusEffectInstance));
}
this.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
lastSentExp = -1;
lastSentHealth = -1.0F;
lastSentFood = -1;
}
this.be_resetExitPos();
be_resetExitPos();
info.setReturnValue(player);
}
}

View file

@ -17,14 +17,14 @@ import ru.betterend.util.TagHelper;
@Mixin(TagLoader.class)
public class TagLoaderMixin {
@Shadow
private String entryType;
private String directory;
@Inject(method = "prepare", at = @At("RETURN"), cancellable = true)
public void be_prepareReload(ResourceManager manager, Executor executor, CallbackInfoReturnable<CompletableFuture<Map<ResourceLocation, Tag.Builder>>> info) {
CompletableFuture<Map<ResourceLocation, Tag.Builder>> future = info.getReturnValue();
info.setReturnValue(CompletableFuture.supplyAsync(() -> {
Map<ResourceLocation, Tag.Builder> map = future.join();
TagHelper.apply(entryType, map);
TagHelper.apply(directory, map);
return map;
}, executor));
}