Skip to content

Commit

Permalink
main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Apr 14, 2024
1 parent 452c713 commit f2d1455
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 107 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ emi = 1.0.23+1.20.2

fabricLoader = 0.15.9
fabricApi = 0.96.15+1.20.5
modMenu = 9.0.0-pre.1
modMenu = 10.0.0-alpha.3
trEnergy = 3.0.0

forge = 49.0.9
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
package mcp.mobius.waila.fabric;

import mcp.mobius.waila.service.ApiService;
import net.fabricmc.fabric.api.mininglevel.v1.MiningLevelManager;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;

public class FabricApiService extends ApiService {

@Override
public @Nullable TagKey<Block> getTierTag(Tier tier) {
return tier.getLevel() == 0 ? null : MiningLevelManager.getBlockTag(tier.getLevel());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void onInitializeClient() {

HudRenderCallback.EVENT.register(TooltipRenderer::render);
ClientTickEvents.END_CLIENT_TICK.register(client -> onClientTick());
ItemTooltipCallback.EVENT.register((stack, ctx, tooltip) -> onItemTooltip(stack, tooltip));
ItemTooltipCallback.EVENT.register((stack, ctx, flag, tooltip) -> onItemTooltip(stack, tooltip));

ClientConfigurationConnectionEvents.DISCONNECT.register((handler, client) -> client.execute(WailaClient::onServerLogout));
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> client.execute(WailaClient::onServerLogout));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;

/**
Expand Down Expand Up @@ -75,9 +72,6 @@ public interface IApiService {

<T> IInstanceRegistry<T> createInstanceRegistry(boolean reversed);

@Nullable
TagKey<Block> getTierTag(Tier tier);

List<Tier> getTiers();

<D extends IData> IData.Type<D> createDataType(ResourceLocation id);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mcp/mobius/waila/gui/hud/RayCaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class RayCaster {

public static void cast(Level world, Entity camera, Vec3 origin, Vec3 direction, float maxDistance, ObjDoubleConsumer<HitResult> results) {
public static void cast(Level world, Entity camera, Vec3 origin, Vec3 direction, double maxDistance, ObjDoubleConsumer<HitResult> results) {
var showBlock = PluginConfig.CLIENT.getBoolean(WailaConstants.CONFIG_SHOW_BLOCK);
var showFluid = PluginConfig.CLIENT.getBoolean(WailaConstants.CONFIG_SHOW_FLUID);
var showEntity = PluginConfig.CLIENT.getBoolean(WailaConstants.CONFIG_SHOW_ENTITY);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mcp/mobius/waila/gui/hud/TooltipHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void tick() {
if (camera == null) return;

var frameTime = client.getFrameTime();
var pickRange = client.gameMode.getPickRange();
var pickRange = Math.max(player.blockInteractionRange(), player.entityInteractionRange());
var results = PickerResults.get();
Vec3 castOrigin = null;
Vec3 castDirection = null;
Expand Down Expand Up @@ -97,7 +97,7 @@ public static void tick() {
}
}

private static ProcessResult redirectTarget(HitResult target, TargetRedirector redirector, Minecraft client, Player player, Vec3 castOrigin, Vec3 castDirection, float pickRange, WailaConfig.General config) {
private static ProcessResult redirectTarget(HitResult target, TargetRedirector redirector, Minecraft client, Player player, Vec3 castOrigin, Vec3 castDirection, double pickRange, WailaConfig.General config) {
if (redirector.nowhere) return ProcessResult.BREAK;
if (redirector.behind) return ProcessResult.CONTINUE;

Expand All @@ -111,7 +111,7 @@ private static ProcessResult redirectTarget(HitResult target, TargetRedirector r
castDirection, pickRange, config);
}

private static ProcessResult processTarget(HitResult target, Minecraft client, Player player, Vec3 castOrigin, Vec3 castDirection, float pickRange, WailaConfig.General config) {
private static ProcessResult processTarget(HitResult target, Minecraft client, Player player, Vec3 castOrigin, Vec3 castDirection, double pickRange, WailaConfig.General config) {
var accessor = ClientAccessor.INSTANCE;
accessor.set(client.level, player, target, client.cameraEntity, castOrigin, castDirection, pickRange, client.getFrameTime());

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/mcp/mobius/waila/gui/screen/CreditsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ private ListWidget(Minecraft client, int width, int height, int top, int itemHei
}

private void init() {
setRenderBackground(false);

var totalHeight = (children().size() - 1) * itemHeight;
if (totalHeight < height) {
setRenderHeader(true, (height - totalHeight) / 2 - getY());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public ConfigListWidget getOptions() {

if (entry.blocksClientEdit() && minecraft.getCurrentServer() != null) {
if (entry.getServerValue() == null) {
value.disable(PacketSender.c2s().canSend(VersionCommonPacket.Payload.ID)
value.disable(PacketSender.c2s().canSend(VersionCommonPacket.TYPE)
? Tl.Config.SERVER_MISSING_OPTION
: Tl.Config.SERVER_MISSING_MOD);
value.setValue(entry.getClientOnlyValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public ConfigListWidget(ConfigScreen owner, Minecraft client, int width, int hei
this.diskWriter = diskWriter;

resize(top, bottom);
setRenderBackground(false);
}

public ConfigListWidget(ConfigScreen owner, Minecraft client, int width, int height, int top, int bottom, int itemHeight) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mcp.mobius.waila.mixin;

import net.minecraft.core.Holder;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import org.jetbrains.annotations.Nullable;
Expand All @@ -11,11 +12,11 @@ public interface BeaconBlockEntityAccess {

@Nullable
@Accessor("primaryPower")
MobEffect wthit_primaryPower();
Holder<MobEffect> wthit_primaryPower();

@Nullable
@Accessor("secondaryPower")
MobEffect wthit_secondaryPower();
Holder<MobEffect> wthit_secondaryPower();

@Accessor("levels")
int wthit_levels();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
package mcp.mobius.waila.mixin;

import java.util.Optional;
import java.util.OptionalInt;

import net.minecraft.core.Direction;
import net.minecraft.world.level.block.ChiseledBookShelfBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec2;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(ChiseledBookShelfBlock.class)
public interface ChiseledBookShelfBlockAccess {

@Invoker("getRelativeHitCoordinatesForBlockFace")
static Optional<Vec2> wthit_getRelativeHitCoordinatesForBlockFace(BlockHitResult $$0, Direction $$1) {
throw new AssertionError("mixin");
}

@Invoker("getHitSlot")
static int wthit_getHitSlot(Vec2 $$0) {
throw new AssertionError("mixin");
}
OptionalInt wthit_getHitSlot(BlockHitResult $$0, BlockState $$1);

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import mcp.mobius.waila.mixed.IMixedService;
import net.minecraft.client.multiplayer.ClientConfigurationPacketListenerImpl;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.protocol.common.ClientboundUpdateTagsPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientConfigurationPacketListenerImpl.class)
public class ClientConfigurationPacketListenerImplMixin extends ClientCommonPacketListenerImplMixin {
public class ClientConfigurationPacketListenerImplMixin {

@Shadow
private RegistryAccess.Frozen receivedRegistries;
Expand All @@ -20,8 +21,8 @@ private void wthit_onServerLogin(CallbackInfo ci) {
IMixedService.INSTANCE.onServerLogin();
}

@Override
protected void wthit_onHandleUpdateTags() {
@Inject(method = "handleUpdateTags", at = @At("TAIL"))
private void wthit_onHandleUpdateTags(ClientboundUpdateTagsPacket $$0, CallbackInfo ci) {
IMixedService.INSTANCE.attachRegistryFilter(receivedRegistries);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
import mcp.mobius.waila.mixed.IMixedService;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.protocol.common.ClientboundUpdateTagsPacket;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPacketListener.class)
public class ClientPacketListenerMixin extends ClientCommonPacketListenerImplMixin {
public class ClientPacketListenerMixin {

@Shadow
@Final
private RegistryAccess.Frozen registryAccess;

@Override
protected void wthit_onHandleUpdateTags() {
@Inject(method = "handleUpdateTags", at = @At("TAIL"))
private void wthit_onHandleUpdateTags(ClientboundUpdateTagsPacket $$0, CallbackInfo ci) {
IMixedService.INSTANCE.attachRegistryFilter(registryAccess);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public final class ToolTier {
private static final Supplier<Map<ResourceLocation, String>> VANILLA_TIER_TL_KEYS = Suppliers.memoize(() -> {
var map = new HashMap<ResourceLocation, String>();
for (var tier : Tiers.values()) {
var tag = IApiService.INSTANCE.getTierTag(tier);
if (tag == null) continue;
map.put(tag.location(), tier.name().toLowerCase(Locale.ROOT));
map.put(tier.getIncorrectBlocksForDrops().location(), tier.name().toLowerCase(Locale.ROOT));
}
return map;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import mcp.mobius.waila.plugin.vanilla.provider.TrappedChestProvider;
import mcp.mobius.waila.plugin.vanilla.provider.VehicleProvider;
import net.minecraft.world.Container;
import net.minecraft.world.RandomizableContainer;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -80,7 +81,6 @@
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.material.Fluids;
Expand Down Expand Up @@ -226,7 +226,7 @@ public void register(IRegistrar registrar) {
registrar.addBlockData(FurnaceProvider.INSTANCE, AbstractFurnaceBlockEntity.class);
registrar.addBlockData(EnderChestProvider.INSTANCE, EnderChestBlockEntity.class);

registrar.addBlockData(RandomizableContainerProvider.INSTANCE, RandomizableContainerBlockEntity.class, 1100);
registrar.addBlockData(RandomizableContainerProvider.INSTANCE, RandomizableContainer.class, 1100);
registrar.addBlockData(BaseContainerProvider.INSTANCE, BaseContainerBlockEntity.class, 1200);
registrar.addBlockData(HopperContainerProvider.INSTANCE, BlockEntity.class, 1300);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import mcp.mobius.waila.api.ITooltip;
import mcp.mobius.waila.mixin.BeaconBlockEntityAccess;
import mcp.mobius.waila.plugin.vanilla.config.Options;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.chat.MutableComponent;
Expand All @@ -26,12 +27,12 @@ public enum BeaconProvider implements IBlockComponentProvider, IDataProvider<Bea

public static final IData.Type<Data> DATA = IData.createType(new ResourceLocation("beacon"));
public static final StreamCodec<RegistryFriendlyByteBuf, Data> DATA_CODEC = StreamCodec.composite(
ByteBufCodecs.registry(Registries.MOB_EFFECT), Data::primary,
ByteBufCodecs.registry(Registries.MOB_EFFECT), Data::secondary,
ByteBufCodecs.holderRegistry(Registries.MOB_EFFECT), Data::primary,
ByteBufCodecs.holderRegistry(Registries.MOB_EFFECT), Data::secondary,
Data::new);

private MutableComponent getText(MobEffect effect) {
return effect.getDisplayName().copy();
private MutableComponent getText(Holder<MobEffect> effect) {
return effect.value().getDisplayName().copy();
}

@Override
Expand Down Expand Up @@ -61,8 +62,8 @@ public void appendData(IDataWriter data, IServerAccessor<BeaconBlockEntity> acce
}

public record Data(
@Nullable MobEffect primary,
@Nullable MobEffect secondary
@Nullable Holder<MobEffect> primary,
@Nullable Holder<MobEffect> secondary
) implements IData {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import org.jetbrains.annotations.Nullable;

Expand All @@ -52,13 +51,11 @@ private void init(IBlockAccessor accessor, IPluginConfig config) {
var data = accessor.getData().get(DATA);
if (data == null) return;

var blockstate = accessor.getBlockState();
var facing = blockstate.getValue(HorizontalDirectionalBlock.FACING);
var relativeHit = ChiseledBookShelfBlockAccess.wthit_getRelativeHitCoordinatesForBlockFace(accessor.getBlockHitResult(), facing);
if (relativeHit.isEmpty()) return;
var block = ((ChiseledBookShelfBlockAccess) accessor.getBlock());
var hitSlot = block.wthit_getHitSlot(accessor.getBlockHitResult(), accessor.getBlockState());
if (hitSlot.isEmpty()) return;

var hitSlot = ChiseledBookShelfBlockAccess.wthit_getHitSlot(relativeHit.get());
hitItem = data.items.get(hitSlot);
hitItem = data.items.get(hitSlot.getAsInt());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import mcp.mobius.waila.api.IPluginConfig;
import mcp.mobius.waila.api.IServerAccessor;
import mcp.mobius.waila.api.data.ItemData;
import mcp.mobius.waila.mixin.RandomizableContainerBlockEntityAccess;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
import net.minecraft.world.RandomizableContainer;
import net.minecraft.world.level.block.entity.BlockEntity;

public enum RandomizableContainerProvider implements IDataProvider<RandomizableContainerBlockEntity> {
public enum RandomizableContainerProvider implements IDataProvider<BlockEntity> {

INSTANCE;

@Override
public void appendData(IDataWriter data, IServerAccessor<RandomizableContainerBlockEntity> accessor, IPluginConfig config) {
if (((RandomizableContainerBlockEntityAccess) accessor.getTarget()).wthit_lootTable() != null) {
public void appendData(IDataWriter data, IServerAccessor<BlockEntity> accessor, IPluginConfig config) {
if (((RandomizableContainer) accessor.getTarget()).getLootTable() != null) {
data.blockAll(ItemData.TYPE);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/resources/resources/wthit.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
"ChiseledBookShelfBlockEntityAccess",
"EntityAccess",
"NoteBlockAccess",
"RandomizableContainerBlockEntityAccess",
"ReloadableServerResourcesMixin",
"ShearableBlocksMixin"
],
"client" : [
"BossHealthOverlayAccess",
"ClientCommonPacketListenerImplMixin",
"ClientConfigurationPacketListenerImplMixin",
"ClientPacketListenerMixin",
"EditBoxAccess",
Expand Down

0 comments on commit f2d1455

Please sign in to comment.