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;