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

@ -27,7 +27,7 @@ import ru.betterend.interfaces.AnvilScreenHandlerExtended;
public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
@Shadow
private EditBox nameField;
private EditBox name;
private final List<AbstractWidget> be_buttons = Lists.newArrayList();
private AnvilScreenHandlerExtended anvilHandler;
@ -37,24 +37,24 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
super(handler, playerInventory, title, texture);
}
@Inject(method = "setup", at = @At("TAIL"))
@Inject(method = "subInit", at = @At("TAIL"))
protected void be_setup(CallbackInfo info) {
this.be_buttons.clear();
int x = (width - imageWidth) / 2;
int y = (height - imageHeight) / 2;
this.anvilHandler = (AnvilScreenHandlerExtended) this.menu;
this.be_buttons.add(new Button(x + 8, y + 45, 15, 20, new TextComponent("<"), (b) -> be_previousRecipe()));
this.be_buttons.add(new Button(x + 154, y + 45, 15, 20, new TextComponent(">"), (b) -> be_nextRecipe()));
anvilHandler = (AnvilScreenHandlerExtended) menu;
be_buttons.clear();
be_buttons.add(new Button(x + 8, y + 45, 15, 20, new TextComponent("<"), (b) -> be_previousRecipe()));
be_buttons.add(new Button(x + 154, y + 45, 15, 20, new TextComponent(">"), (b) -> be_nextRecipe()));
}
@Inject(method = "renderForeground", at = @At("TAIL"))
@Inject(method = "renderFg", at = @At("TAIL"))
protected void be_renderForeground(PoseStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
this.be_buttons.forEach(button -> {
button.render(matrices, mouseX, mouseY, delta);
});
}
@Inject(method = "onSlotUpdate", at = @At("HEAD"), cancellable = true)
@Inject(method = "slotChanged", at = @At("HEAD"), cancellable = true)
public void be_onSlotUpdate(AbstractContainerMenu handler, int slotId, ItemStack stack, CallbackInfo info) {
AnvilScreenHandlerExtended anvilHandler = (AnvilScreenHandlerExtended) handler;
if (anvilHandler.be_getCurrentRecipe() != null) {
@ -63,7 +63,7 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
} else {
this.be_buttons.forEach(button -> button.visible = false);
}
this.nameField.setValue("");
this.name.setValue("");
info.cancel();
} else {
this.be_buttons.forEach(button -> button.visible = false);
@ -71,11 +71,11 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
}
private void be_nextRecipe() {
this.anvilHandler.be_nextRecipe();
anvilHandler.be_nextRecipe();
}
private void be_previousRecipe() {
this.anvilHandler.be_previousRecipe();
anvilHandler.be_previousRecipe();
}
@Override
@ -85,7 +85,7 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
if (elem.visible && elem.mouseClicked(mouseX, mouseY, button)) {
if (minecraft.gameMode != null) {
int i = be_buttons.indexOf(elem);
this.minecraft.gameMode.handleInventoryButtonClick(menu.containerId, i);
minecraft.gameMode.handleInventoryButtonClick(menu.containerId, i);
return true;
}
}

View file

@ -34,13 +34,13 @@ public class BackgroundRendererMixin {
private static long time;
@Shadow
private static float red;
private static float fogRed;
@Shadow
private static float green;
private static float fogGreen;
@Shadow
private static float blue;
private static float fogBlue;
@Inject(method = "render", at = @At("RETURN"))
@Inject(method = "setupColor", at = @At("RETURN"))
private static void be_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) {
long l = Util.getMillis() - time;
time += l;
@ -56,18 +56,18 @@ public class BackgroundRendererMixin {
skip = effect != null && effect.getDuration() > 0;
}
if (!skip) {
red *= 4;
green *= 4;
blue *= 4;
fogRed *= 4;
fogGreen *= 4;
fogBlue *= 4;
}
}
BackgroundInfo.red = red;
BackgroundInfo.green = green;
BackgroundInfo.blue = blue;
BackgroundInfo.red = fogRed;
BackgroundInfo.green = fogGreen;
BackgroundInfo.blue = fogBlue;
}
@Inject(method = "applyFog", at = @At("HEAD"), cancellable = true)
@Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
private static void be_fogDensity(Camera camera, FogRenderer.FogMode fogType, float viewDistance, boolean thickFog, CallbackInfo info) {
Entity entity = camera.getEntity();
Biome biome = entity.level.getBiome(entity.blockPosition());

View file

@ -26,7 +26,7 @@ public class BiomeColorsMixin {
private static final Point[] OFFSETS;
private static final boolean HAS_SODIUM;
@Inject(method = "getWaterColor", at = @At("RETURN"), cancellable = true)
@Inject(method = "getAverageWaterColor", at = @At("RETURN"), cancellable = true)
private static void be_getWaterColor(BlockAndTintGetter world, BlockPos pos, CallbackInfoReturnable<Integer> info) {
if (ClientOptions.useSulfurWaterColor()) {
BlockAndTintGetter view = HAS_SODIUM ? Minecraft.getInstance().level : world;

View file

@ -18,18 +18,18 @@ import ru.betterend.client.gui.BlockSignEditScreen;
public class ClientPlayNetworkHandlerMixin
{
@Shadow
private Minecraft client;
private Minecraft minecraft;
@Shadow
private ClientLevel world;
private ClientLevel level;
@Inject(method = "onSignEditorOpen", at = @At(value = "HEAD"), cancellable = true)
@Inject(method = "handleOpenSignEditor", at = @At(value = "HEAD"), cancellable = true)
public void be_openSignEditor(ClientboundOpenSignEditorPacket packet, CallbackInfo info) {
PacketUtils.ensureRunningOnSameThread(packet, ClientPacketListener.class.cast(this), client);
BlockEntity blockEntity = world.getBlockEntity(packet.getPos());
PacketUtils.ensureRunningOnSameThread(packet, ClientPacketListener.class.cast(this), minecraft);
BlockEntity blockEntity = level.getBlockEntity(packet.getPos());
if (blockEntity instanceof ESignBlockEntity) {
ESignBlockEntity sign = (ESignBlockEntity) blockEntity;
client.setScreen(new BlockSignEditScreen(sign));
minecraft.setScreen(new BlockSignEditScreen(sign));
info.cancel();
}
}

View file

@ -12,12 +12,10 @@ import ru.betterend.recipe.builders.AlloyingRecipe;
@Mixin(ClientRecipeBook.class)
public abstract class ClientRecipeBookMixin {
@Inject(method = "getGroupForRecipe", at = @At("HEAD"), cancellable = true)
private static void be_getGroupForRecipe(Recipe<?> recipe, CallbackInfoReturnable<RecipeBookCategories> cinfo) {
if (recipe instanceof AlloyingRecipe) {
cinfo.setReturnValue(RecipeBookCategories.BLAST_FURNACE_MISC);
} else if (recipe instanceof BetterEndRecipe) {
cinfo.setReturnValue(RecipeBookCategories.UNKNOWN);
@Inject(method = "getCategory", at = @At("HEAD"), cancellable = true)
private static void be_getGroupForRecipe(Recipe<?> recipe, CallbackInfoReturnable<RecipeBookCategories> info) {
if (recipe instanceof BetterEndRecipe) {
info.setReturnValue(RecipeBookCategories.UNKNOWN);
}
}
}

View file

@ -9,5 +9,5 @@ import net.minecraft.client.renderer.block.model.BlockModelDefinition;
@Mixin(BlockModelDefinition.Context.class)
public interface ContextGsonAccessor {
@Accessor
public Gson getGson();
Gson getGson();
}

View file

@ -19,7 +19,7 @@ public abstract class EnchantingTableBlockMixin extends Block {
super(settings);
}
@Inject(method = "randomDisplayTick", at = @At(value = "TAIL"))
@Inject(method = "animateTick", at = @At(value = "TAIL"))
private void be_onRandomDisplayTick(BlockState state, Level world, BlockPos pos, Random random, CallbackInfo info) {
for (int px = -2; px <= 2; ++px) {
for (int pz = -2; pz <= 2; ++pz) {

View file

@ -29,21 +29,21 @@ public class MinecraftClientMixin {
public LocalPlayer player;
@Shadow
public Screen currentScreen;
@Shadow
public Screen screen;
@Final
public Gui inGameHud;
@Shadow
public ClientLevel world;
@Shadow
public Gui gui;
@Shadow
public ClientLevel level;
@Final
@Shadow
private BlockColors blockColors;
@Shadow
@Final
@Shadow
private ItemColors itemColors;
@Inject(method = "<init>*", at = @At("TAIL"))
@ -57,15 +57,15 @@ public class MinecraftClientMixin {
});
}
@Inject(method = "getMusicType", at = @At("HEAD"), cancellable = true)
@Inject(method = "getSituationalMusic", at = @At("HEAD"), cancellable = true)
private void be_getEndMusic(CallbackInfoReturnable<Music> info) {
if (!(this.currentScreen instanceof WinScreen) && this.player != null) {
if (!(this.screen instanceof WinScreen) && this.player != null) {
if (this.player.level.dimension() == Level.END) {
if (this.inGameHud.getBossOverlay().shouldPlayMusic() && MHelper.lengthSqr(this.player.getX(), this.player.getZ()) < 250000) {
if (this.gui.getBossOverlay().shouldPlayMusic() && MHelper.lengthSqr(this.player.getX(), this.player.getZ()) < 250000) {
info.setReturnValue(Musics.END_BOSS);
}
else {
Music sound = (Music) this.world.getBiomeManager().getNoiseBiomeAtPosition(this.player.blockPosition()).getBackgroundMusic().orElse(Musics.END);
Music sound = (Music) this.level.getBiomeManager().getNoiseBiomeAtPosition(this.player.blockPosition()).getBackgroundMusic().orElse(Musics.END);
info.setReturnValue(sound);
}
info.cancel();

View file

@ -29,7 +29,7 @@ public class ModelLoaderMixin {
@Shadow
private ResourceManager resourceManager;
@Inject(method = "loadModelFromJson", at = @At("HEAD"), cancellable = true)
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
private void be_loadModelPattern(ResourceLocation id, CallbackInfoReturnable<BlockModel> info) {
if (id.getNamespace().equals(BetterEnd.MOD_ID)) {
ResourceLocation modelId = new ResourceLocation(id.getNamespace(), "models/" + id.getPath() + ".json");
@ -40,7 +40,7 @@ public class ModelLoaderMixin {
model.name = id.toString();
info.setReturnValue(model);
} catch (Exception ex) {
String data[] = id.getPath().split("/");
String[] data = id.getPath().split("/");
if (data.length > 1) {
ResourceLocation itemId = new ResourceLocation(id.getNamespace(), data[1]);
Optional<Block> block = Registry.BLOCK.getOptional(itemId);
@ -63,7 +63,7 @@ public class ModelLoaderMixin {
}
}
private BlockModel be_getModel(String data[], ResourceLocation id, Patterned patterned) {
private BlockModel be_getModel(String[] data, ResourceLocation id, Patterned patterned) {
String pattern;
if (id.getPath().contains("item")) {
pattern = patterned.getModelPattern(id.getPath());
@ -81,7 +81,7 @@ public class ModelLoaderMixin {
}
@ModifyVariable(method = "loadModel", ordinal = 2, at = @At(value = "INVOKE"))
public ResourceLocation be_SwitchModel(ResourceLocation id) {
public ResourceLocation be_switchModel(ResourceLocation id) {
if (GeneratorOptions.changeChorusPlant() && id.getNamespace().equals("minecraft") && id.getPath().startsWith("blockstates/") && id.getPath().contains("chorus") && !id.getPath().contains("custom_")) {
id = new ResourceLocation(id.getPath().replace("chorus", "custom_chorus"));
}

View file

@ -16,7 +16,7 @@ import ru.betterend.patterns.BlockPatterned;
@Mixin(BlockModelDefinition.class)
public abstract class ModelVariantMapMixin {
@Inject(method = "deserialize", at = @At("HEAD"), cancellable = true)
@Inject(method = "fromStream", at = @At("HEAD"), cancellable = true)
private static void be_deserializeBlockState(BlockModelDefinition.Context context, Reader reader, CallbackInfoReturnable<BlockModelDefinition> info) {
Block block = context.getDefinition().any().getBlock();
if (block instanceof BlockPatterned) {

View file

@ -17,20 +17,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.betterend.client.ClientOptions;
@Mixin(MusicManager.class)
public class MusicTrackerMixin {
@Shadow
public abstract class MusicTrackerMixin {
@Final
private Minecraft client;
@Shadow
private Minecraft minecraft;
@Final
@Shadow
private Random random;
@Shadow
private SoundInstance current;
private SoundInstance currentMusic;
@Shadow
private int timeUntilNextSong;
private int nextSongDelay;
private static float volume = 1;
private static float srcVolume = 0;
@ -39,16 +39,16 @@ public class MusicTrackerMixin {
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
public void be_onTick(CallbackInfo info) {
if (ClientOptions.blendBiomeMusic()) {
Music musicSound = client.getSituationalMusic();
Music musicSound = minecraft.getSituationalMusic();
if (be_checkNullSound(musicSound) && volume > 0 && be_isInEnd() && be_shouldChangeSound(musicSound)) {
if (volume > 0) {
if (srcVolume < 0) {
srcVolume = current.getVolume();
srcVolume = currentMusic.getVolume();
}
if (current instanceof AbstractSoundInstance) {
((AbstractSoundInstanceAccessor) current).setVolume(volume);
if (currentMusic instanceof AbstractSoundInstance) {
((AbstractSoundInstanceAccessor) currentMusic).setVolume(volume);
}
client.getSoundManager().updateSourceVolume(current.getSource(), current.getVolume() * volume);
minecraft.getSoundManager().updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * volume);
long t = System.currentTimeMillis();
if (volume == 1 && time == 0) {
time = t;
@ -64,12 +64,12 @@ public class MusicTrackerMixin {
volume = 1;
time = 0;
srcVolume = -1;
this.client.getSoundManager().stop(this.current);
this.timeUntilNextSong = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
this.current = null;
this.minecraft.getSoundManager().stop(this.currentMusic);
this.nextSongDelay = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
this.currentMusic = null;
}
if (this.current == null && this.timeUntilNextSong-- <= 0) {
this.play(musicSound);
if (this.currentMusic == null && this.nextSongDelay-- <= 0) {
this.startPlaying(musicSound);
}
info.cancel();
}
@ -80,11 +80,11 @@ public class MusicTrackerMixin {
}
private boolean be_isInEnd() {
return client.level != null && client.level.dimension().equals(Level.END);
return minecraft.level != null && minecraft.level.dimension().equals(Level.END);
}
private boolean be_shouldChangeSound(Music musicSound) {
return current != null && !musicSound.getEvent().getLocation().equals(this.current.getLocation()) && musicSound.replaceCurrentMusic();
return currentMusic != null && !musicSound.getEvent().getLocation().equals(this.currentMusic.getLocation()) && musicSound.replaceCurrentMusic();
}
private boolean be_checkNullSound(Music musicSound) {
@ -92,5 +92,5 @@ public class MusicTrackerMixin {
}
@Shadow
public void play(Music type) {}
public abstract void startPlaying(Music type);
}

View file

@ -23,7 +23,7 @@ public abstract class NamespaceResourceManagerMixin {
@Shadow
public abstract Resource getResource(ResourceLocation id);
@Inject(method = "getAllResources", cancellable = true, at = @At(
@Inject(method = "getResources", cancellable = true, at = @At(
value = "NEW",
target = "java/io/FileNotFoundException",
shift = Shift.BEFORE))

View file

@ -62,14 +62,14 @@ public class WorldRendererMixin {
@Shadow
@Final
private Minecraft client;
private Minecraft minecraft;
@Shadow
@Final
private TextureManager textureManager;
@Shadow
private ClientLevel world;
private ClientLevel level;
@Shadow
private int ticks;
@ -92,7 +92,7 @@ public class WorldRendererMixin {
@Inject(method = "renderSky", at = @At("HEAD"), cancellable = true)
private void be_renderBetterEndSky(PoseStack matrices, float tickDelta, CallbackInfo info) {
if (ClientOptions.isCustomSky() && client.level.effects().skyType() == DimensionSpecialEffects.SkyType.END) {
if (ClientOptions.isCustomSky() && minecraft.level.effects().skyType() == DimensionSpecialEffects.SkyType.END) {
time = (ticks % 360000) * 0.000017453292F;
time2 = time * 2;
time3 = time * 3;

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));
}