mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
update mappings, add extra javadocs/deprecations, migrate to Mixin Accessors where applicable
This commit is contained in:
parent
9a88c48a30
commit
598f00488f
16 changed files with 63 additions and 94 deletions
|
@ -38,7 +38,7 @@ minecraft {
|
|||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$mcVersion"
|
||||
mappings "net.fabricmc:yarn:$mcVersion.5"
|
||||
mappings "net.fabricmc:yarn:$mcVersion.13"
|
||||
modCompile "net.fabricmc:fabric-loader:0.3.6.107"
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,17 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
// TODO: javadocs
|
||||
/**
|
||||
* Registry for server->client entity tracking values.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EntityTrackingRegistry {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* @deprecated Should be hidden; will be removed in 0.3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
public static class Entry {
|
||||
private final int trackingDistance;
|
||||
private final int updateIntervalTicks;
|
||||
|
@ -60,6 +68,10 @@ public class EntityTrackingRegistry {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Should be hidden; will be removed in 0.3.0.
|
||||
*/
|
||||
@Deprecated
|
||||
public Entry get(EntityType type) {
|
||||
return entries.get(type);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,13 @@ import org.apache.logging.log4j.Logger;
|
|||
|
||||
import java.util.function.Function;
|
||||
|
||||
// TODO: javadocs
|
||||
/**
|
||||
* Extended version of {@link EntityType.Builder} with added registration for
|
||||
* server->client entity tracking values.
|
||||
*
|
||||
* @param <T> Entity class.
|
||||
*/
|
||||
// TODO more javadocs
|
||||
public class FabricEntityTypeBuilder<T extends Entity> {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final EntityCategory category;
|
||||
|
|
|
@ -21,8 +21,10 @@ import io.netty.util.concurrent.GenericFutureListener;
|
|||
import net.fabricmc.fabric.api.event.network.S2CPacketTypeCallback;
|
||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.fabricmc.fabric.mixin.networking.MixinClientPlayNetworkHandler;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.packet.CustomPayloadS2CPacket;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -94,4 +96,8 @@ public class ClientSidePacketRegistryImpl extends PacketRegistryImpl implements
|
|||
protected void onReceivedUnregisterPacket(PacketContext context, Collection<Identifier> ids) {
|
||||
S2CPacketTypeCallback.UNREGISTERED.invoker().accept(ids);
|
||||
}
|
||||
|
||||
public final boolean accept(CustomPayloadS2CPacket packet, PacketContext context) {
|
||||
return accept(packet.getChannel(), context, packet.getData());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,16 @@ import net.fabricmc.fabric.api.event.network.C2SPacketTypeCallback;
|
|||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.fabricmc.fabric.api.server.PlayerStream;
|
||||
import net.fabricmc.fabric.mixin.networking.CustomPayloadC2SPacketAccessor;
|
||||
import net.fabricmc.fabric.mixin.networking.MixinServerPlayNetworkHandler;
|
||||
import net.fabricmc.loader.FabricLoader;
|
||||
import net.minecraft.client.network.packet.CustomPayloadS2CPacket;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
|
||||
import net.minecraft.server.network.packet.LoginQueryResponseC2SPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
|
@ -39,6 +43,9 @@ import java.util.WeakHashMap;
|
|||
public class ServerSidePacketRegistryImpl extends PacketRegistryImpl implements ServerSidePacketRegistry {
|
||||
private final WeakHashMap<PlayerEntity, Collection<Identifier>> playerPayloadIds = new WeakHashMap<>();
|
||||
|
||||
public void onQueryResponse(LoginQueryResponseC2SPacket packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerReceive(PlayerEntity player, Identifier id) {
|
||||
Collection<Identifier> ids = playerPayloadIds.get(player);
|
||||
|
@ -95,4 +102,9 @@ public class ServerSidePacketRegistryImpl extends PacketRegistryImpl implements
|
|||
protected void onReceivedUnregisterPacket(PacketContext context, Collection<Identifier> ids) {
|
||||
C2SPacketTypeCallback.UNREGISTERED.invoker().accept(context.getPlayer(), ids);
|
||||
}
|
||||
|
||||
public final boolean accept(CustomPayloadC2SPacket packet, PacketContext context) {
|
||||
CustomPayloadC2SPacketAccessor accessor = ((CustomPayloadC2SPacketAccessor) packet);
|
||||
return accept(accessor.getChannel(), context, accessor.getData());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.impl.tools;
|
||||
|
||||
public interface MiningToolDelegate {
|
||||
float getBlockBreakingSpeed();
|
||||
}
|
|
@ -39,6 +39,7 @@ public abstract class MixinEntityTracker implements EntityTrackerStreamAccessor
|
|||
@Shadow
|
||||
public abstract void add(Entity var1, int var2, int var3, boolean var4);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Inject(at = @At("HEAD"), method = "add", cancellable = true)
|
||||
public void add(Entity entity, CallbackInfo info) {
|
||||
if (entity != null) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MixinMinecraftServer {
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;method_3791(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run")
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run")
|
||||
public void afterSetupServer(CallbackInfo info) {
|
||||
ServerStartCallback.EVENT.invoker().onStartServer((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
|
|
@ -14,16 +14,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.impl.network;
|
||||
package net.fabricmc.fabric.mixin.networking;
|
||||
|
||||
import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
/**
|
||||
* Helper interface containing getters for SPacketCustomPayload
|
||||
* Helper interface containing getters for CustomPayloadC2SPacket
|
||||
* which were omitted from the compiled game.
|
||||
*/
|
||||
@Mixin(CustomPayloadC2SPacket.class)
|
||||
public interface CustomPayloadC2SPacketAccessor {
|
||||
@Accessor
|
||||
Identifier getChannel();
|
||||
@Accessor
|
||||
PacketByteBuf getData();
|
||||
}
|
|
@ -23,7 +23,6 @@ import net.fabricmc.fabric.api.network.PacketContext;
|
|||
import net.fabricmc.fabric.impl.network.ClientSidePacketRegistryImpl;
|
||||
import net.fabricmc.fabric.impl.network.PacketRegistryImpl;
|
||||
import net.fabricmc.fabric.impl.network.PacketTypes;
|
||||
import net.minecraft.class_2901;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
|
@ -64,7 +63,7 @@ public abstract class MixinClientPlayNetworkHandler implements PacketContext {
|
|||
|
||||
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true)
|
||||
public void onCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo info) {
|
||||
if (((ClientSidePacketRegistryImpl) ClientSidePacketRegistry.INSTANCE).accept(packet.getChannel(), this, packet.getData())) {
|
||||
if (((ClientSidePacketRegistryImpl) ClientSidePacketRegistry.INSTANCE).accept(packet, this)) {
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.networking;
|
||||
|
||||
import net.fabricmc.fabric.impl.network.CustomPayloadC2SPacketAccessor;
|
||||
import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(CustomPayloadC2SPacket.class)
|
||||
public class MixinCustomPayloadC2SPacket implements CustomPayloadC2SPacketAccessor {
|
||||
@Shadow
|
||||
private Identifier channel;
|
||||
@Shadow
|
||||
private PacketByteBuf data;
|
||||
|
||||
@Override
|
||||
public Identifier getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketByteBuf getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
|
@ -19,7 +19,6 @@ package net.fabricmc.fabric.mixin.networking;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.fabricmc.fabric.impl.network.CustomPayloadC2SPacketAccessor;
|
||||
import net.fabricmc.fabric.impl.network.ServerSidePacketRegistryImpl;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
@ -42,9 +41,7 @@ public class MixinServerPlayNetworkHandler implements PacketContext {
|
|||
|
||||
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true)
|
||||
public void onCustomPayload(CustomPayloadC2SPacket packet, CallbackInfo info) {
|
||||
CustomPayloadC2SPacketAccessor accessor = ((CustomPayloadC2SPacketAccessor) packet);
|
||||
|
||||
if (((ServerSidePacketRegistryImpl) ServerSidePacketRegistry.INSTANCE).accept(accessor.getChannel(), this, accessor.getData())) {
|
||||
if (((ServerSidePacketRegistryImpl) ServerSidePacketRegistry.INSTANCE).accept(packet, this)) {
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package net.fabricmc.fabric.mixin.resources;
|
|||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys;
|
||||
import net.minecraft.client.audio.SoundLoader;
|
||||
import net.minecraft.client.font.FontRendererManager;
|
||||
import net.minecraft.client.font.FontManager;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.client.render.block.BlockRenderManager;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
|
@ -40,7 +40,7 @@ import java.util.Collections;
|
|||
public class MixinKeyedResourceReloadListener {
|
||||
@Mixin({
|
||||
/* public */
|
||||
SoundLoader.class, FontRendererManager.class, BakedModelManager.class, LanguageManager.class, TextureManager.class,
|
||||
SoundLoader.class, FontManager.class, BakedModelManager.class, LanguageManager.class, TextureManager.class,
|
||||
/* private */
|
||||
WorldRenderer.class, BlockRenderManager.class, ItemRenderer.class
|
||||
})
|
||||
|
@ -73,7 +73,7 @@ public class MixinKeyedResourceReloadListener {
|
|||
|
||||
if (self instanceof SoundLoader) {
|
||||
fabric_id = ResourceReloadListenerKeys.SOUNDS;
|
||||
} else if (self instanceof FontRendererManager) {
|
||||
} else if (self instanceof FontManager) {
|
||||
fabric_id = ResourceReloadListenerKeys.FONTS;
|
||||
} else if (self instanceof BakedModelManager) {
|
||||
fabric_id = ResourceReloadListenerKeys.MODELS;
|
||||
|
|
|
@ -16,18 +16,12 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.tools;
|
||||
|
||||
import net.fabricmc.fabric.impl.tools.MiningToolDelegate;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(MiningToolItem.class)
|
||||
public class MixinMiningToolItem implements MiningToolDelegate {
|
||||
@Shadow
|
||||
protected float blockBreakingSpeed;
|
||||
|
||||
@Override
|
||||
public float getBlockBreakingSpeed() {
|
||||
return blockBreakingSpeed;
|
||||
}
|
||||
public interface MiningToolItemAccessor {
|
||||
@Accessor
|
||||
float getBlockBreakingSpeed();
|
||||
}
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.tools;
|
||||
|
||||
import net.fabricmc.fabric.impl.tools.MiningToolDelegate;
|
||||
import net.fabricmc.fabric.impl.tools.ToolManager;
|
||||
import net.fabricmc.fabric.api.util.TriState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -44,10 +43,10 @@ public abstract class MixinItemStack {
|
|||
|
||||
@Inject(at = @At("HEAD"), method = "getBlockBreakingSpeed", cancellable = true)
|
||||
public void getBlockBreakingSpeed(BlockState state, CallbackInfoReturnable<Float> info) {
|
||||
if (this.getItem() instanceof MiningToolDelegate) {
|
||||
if (this.getItem() instanceof MiningToolItemAccessor) {
|
||||
TriState triState = ToolManager.handleIsEffectiveOn((ItemStack) (Object) this, state);
|
||||
if (triState != TriState.DEFAULT) {
|
||||
info.setReturnValue(triState.get() ? ((MiningToolDelegate) this.getItem()).getBlockBreakingSpeed() : 1.0F);
|
||||
info.setReturnValue(triState.get() ? ((MiningToolItemAccessor) this.getItem()).getBlockBreakingSpeed() : 1.0F);
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"item.MixinAbstractFurnaceBlockEntity",
|
||||
"itemgroup.MixinItemGroup",
|
||||
"misc.MixinCrashReport",
|
||||
"networking.MixinCustomPayloadC2SPacket",
|
||||
"networking.CustomPayloadC2SPacketAccessor",
|
||||
"networking.MixinServerPlayNetworkHandler",
|
||||
"registry.MixinBootstrap",
|
||||
"registry.MixinIdList",
|
||||
|
@ -31,8 +31,8 @@
|
|||
"resources.MixinKeyedResourceReloadListener$Server",
|
||||
"resources.MixinMinecraftServer",
|
||||
"resources.MixinReloadableResourceManagerImpl",
|
||||
"tools.MixinItemStack",
|
||||
"tools.MixinMiningToolItem"
|
||||
"tools.MiningToolItemAccessor",
|
||||
"tools.MixinItemStack"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue