Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockEntityMixin",
"BlockViewMixin"
"BlockViewMixin",
"WorldViewMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
2 changes: 1 addition & 1 deletion fabric-events-interaction-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
archivesBaseName = "fabric-events-interaction-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
moduleDependencies(project, ['fabric-api-base', 'fabric-networking-api-v1'])
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 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.event.interaction;

import org.spongepowered.asm.mixin.Mixin;

import net.fabricmc.fabric.impl.networking.UntrackedNetworkHandler;

// Connector: This class exists to implement UntrackedNetworkHandler for Forge's FakePlayerNetHandler
// to ensure Fabric's instanceof check would work
@SuppressWarnings("UnstableApiUsage")
@Mixin(targets = "net.minecraftforge.common.util.FakePlayer$FakePlayerNetHandler")
public class FakePlayerNetHandlerMixin implements UntrackedNetworkHandler {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"package": "net.fabricmc.fabric.mixin.event.interaction",
"compatibilityLevel": "JAVA_16",
"mixins": [
"FakePlayerNetHandlerMixin",
"ServerPlayerInteractionManagerMixin"
],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"depends": {
"fabricloader": ">=0.4.0",
"fabric-api-base": "*",
"fabric-networking-api-v1": "*",
"minecraft": ">=1.15-alpha.19.37.a"
},
"entrypoints": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 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.networking;

// An internal marker interface used by the fake player API to prevent the network addon from being tracked.
public interface UntrackedNetworkHandler {
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.fabricmc.fabric.impl.networking.AbstractChanneledNetworkAddon;
import net.fabricmc.fabric.impl.networking.ChannelInfoHolder;
import net.fabricmc.fabric.impl.networking.NetworkingImpl;
import net.fabricmc.fabric.impl.networking.UntrackedNetworkHandler;
import net.fabricmc.fabric.mixin.networking.accessor.CustomPayloadC2SPacketAccessor;
import net.fabricmc.fabric.mixin.networking.accessor.ServerPlayNetworkHandlerAccessor;

Expand All @@ -49,8 +50,10 @@ public ServerPlayNetworkAddon(ServerPlayNetworkHandler handler, MinecraftServer
// Must register pending channels via lateinit
this.registerPendingChannels((ChannelInfoHolder) this.connection);

// Register global receivers and attach to session
this.receiver.startSession(this);
if (!(handler instanceof UntrackedNetworkHandler)) {
// Register global receivers and attach to session
this.receiver.startSession(this);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import net.fabricmc.fabric.impl.networking.DisconnectPacketSource;
import net.fabricmc.fabric.impl.networking.NetworkHandlerExtensions;
import net.fabricmc.fabric.impl.networking.UntrackedNetworkHandler;
import net.fabricmc.fabric.impl.networking.server.ServerPlayNetworkAddon;

// We want to apply a bit earlier than other mods which may not use us in order to prevent refCount issues
Expand All @@ -52,8 +53,11 @@ abstract class ServerPlayNetworkHandlerMixin implements NetworkHandlerExtensions
@Inject(method = "<init>", at = @At("RETURN"))
private void initAddon(CallbackInfo ci) {
this.addon = new ServerPlayNetworkAddon((ServerPlayNetworkHandler) (Object) this, this.server);
// A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field
this.addon.lateInit();

if (!(this instanceof UntrackedNetworkHandler)) {
// A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field
this.addon.lateInit();
}
}

@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,30 @@

package net.fabricmc.fabric.mixin.object.builder;

import java.util.stream.Stream;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Cancellable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.random.Random;
import net.minecraft.registry.DefaultedRegistry;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerType;

@Mixin(TradeOffers.TypeAwareBuyForOneEmeraldFactory.class)
public abstract class TradeOffersTypeAwareBuyForOneEmeraldFactoryMixin {
/**
* Vanilla will check the "VillagerType -> Item" map in the stream and throw an exception for villager types not specified in the map.
* This breaks any and all custom villager types.
* We want to prevent this default logic so modded villager types will work.
* So we return an empty stream so an exception is never thrown.
*/
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/registry/DefaultedRegistry;stream()Ljava/util/stream/Stream;"), require = 0)
private <T> Stream<T> disableVanillaCheck(DefaultedRegistry<VillagerType> instance) {
return Stream.empty();
}

/**
* To prevent "item" -> "air" trades, if the result of a type aware trade is air, make sure no offer is created.
* To prevent crashes due to passing a {@code null} item to a {@link TradeOffer}, return a {@code null} trade offer
* early before {@code null} is passed to the constructor.
*/
@Inject(method = "create", at = @At(value = "NEW", target = "net/minecraft/village/TradeOffer"), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true, require = 0)
private void failOnNullItem(Entity entity, Random random, CallbackInfoReturnable<TradeOffer> cir, ItemStack buyingItem) {
if (buyingItem.isEmpty()) { // Will return true for an "empty" item stack that had null passed in the ctor
cir.setReturnValue(null); // Return null to prevent creation of empty trades
@ModifyExpressionValue(
method = "create",
at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;")
)
private Object failOnNullItem(Object item, @Cancellable CallbackInfoReturnable<TradeOffer> cir) {
if (item == null) {
cir.setReturnValue(null);
}

return item;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"FabricMC"
],
"depends": {
"fabricloader": ">=0.8.2",
"fabricloader": ">=0.16.10",
"fabric-api-base": "*"
},
"description": "Builders for objects vanilla has locked down.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 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.test.object.builder;

import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.test.TestContext;
import net.minecraft.util.math.random.Random;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerType;

//import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;

public class EmptyTypeAwareBuyForOneEmeraldTradeOfferGameTest {
// @GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testEmptyTypeAwareTradeOffer(@NotNull TestContext context) {
VillagerEntity villager = new VillagerEntity(EntityType.VILLAGER, context.getWorld(), VillagerType.PLAINS);

// Create a type-aware trade offer with no villager types specified
TradeOffers.Factory typeAwareFactory = new TradeOffers.TypeAwareBuyForOneEmeraldFactory(1, 12, 5, ImmutableMap.of());
// Create an offer with that factory to ensure it doesn't crash when a villager type is missing from the map
typeAwareFactory.create(villager, Random.create());

context.complete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"net.fabricmc.fabric.test.object.builder.client.TealSignClientTest"
],
"fabric-gametest": [
"net.fabricmc.fabric.test.object.builder.ObjectBuilderGameTest"
"net.fabricmc.fabric.test.object.builder.ObjectBuilderGameTest",
"net.fabricmc.fabric.test.object.builder.EmptyTypeAwareBuyForOneEmeraldTradeOfferGameTest"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static void onInitializeServer(ServerStartingEvent event) {
}

private static void testTranslationLoaded() {
testTranslationLoaded("item.minecraft.potato", "Potato"); // Test that vanilla translation loads
testTranslationLoaded("text.fabric-resource-loader-v0-testmod.server.lang.override", "Vanilla override test");
testTranslationLoaded("pack.source.fabricmod", "Fabric mod");
testTranslationLoaded("text.fabric-resource-loader-v0-testmod.server.lang.test0", "Test from fabric-resource-loader-v0-testmod");
testTranslationLoaded("text.fabric-resource-loader-v0-testmod.server.lang.test1", "Test from fabric-resource-loader-v0-testmod-test1");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"text.fabric-resource-loader-v0-testmod.server.lang.override": "Vanilla override test"
}
112 changes: 56 additions & 56 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,72 @@ org.gradle.jvmargs=-Xmx3500M
org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true

version=0.92.2
version=0.92.6
minecraft_version=1.20.1
yarn_version=+build.1
loader_version=0.14.21
loader_version=0.16.10
installer_version=0.11.1

prerelease=false

# Do not manually update, use the bumpversions task:
fabric-api-base-version=0.4.31
fabric-api-lookup-api-v1-version=1.6.36
fabric-biome-api-v1-version=13.0.13
fabric-block-api-v1-version=1.0.11
fabric-block-view-api-v2-version=1.0.1
fabric-blockrenderlayer-v1-version=1.1.41
fabric-command-api-v1-version=1.2.34
fabric-command-api-v2-version=2.2.13
fabric-commands-v0-version=0.2.51
fabric-containers-v0-version=0.1.64
fabric-content-registries-v0-version=4.0.11
fabric-crash-report-info-v1-version=0.2.19
fabric-data-attachment-api-v1-version=1.0.0
fabric-data-generation-api-v1-version=12.3.4
fabric-dimensions-v1-version=2.1.54
fabric-entity-events-v1-version=1.6.0
fabric-events-interaction-v0-version=0.6.2
fabric-events-lifecycle-v0-version=0.2.63
fabric-game-rule-api-v1-version=1.0.40
fabric-gametest-api-v1-version=1.2.13
fabric-item-api-v1-version=2.1.28
fabric-item-group-api-v1-version=4.0.12
fabric-key-binding-api-v1-version=1.0.37
fabric-keybindings-v0-version=0.2.35
fabric-lifecycle-events-v1-version=2.2.22
fabric-loot-api-v2-version=1.2.1
fabric-loot-tables-v1-version=1.1.45
fabric-message-api-v1-version=5.1.9
fabric-mining-level-api-v1-version=2.1.50
fabric-model-loading-api-v1-version=1.0.3
fabric-models-v0-version=0.4.2
fabric-networking-api-v1-version=1.3.11
fabric-networking-v0-version=0.3.51
fabric-object-builder-api-v1-version=11.1.3
fabric-particles-v1-version=1.1.2
fabric-recipe-api-v1-version=1.0.21
fabric-registry-sync-v0-version=2.3.3
fabric-renderer-api-v1-version=3.2.1
fabric-renderer-indigo-version=1.5.2
fabric-renderer-registries-v1-version=3.2.46
fabric-rendering-data-attachment-v1-version=0.3.37
fabric-rendering-fluids-v1-version=3.0.28
fabric-rendering-v0-version=1.1.49
fabric-rendering-v1-version=3.0.8
fabric-resource-conditions-api-v1-version=2.3.8
fabric-resource-loader-v0-version=0.11.10
fabric-screen-api-v1-version=2.0.8
fabric-screen-handler-api-v1-version=1.3.30
fabric-sound-api-v1-version=1.0.13
fabric-transfer-api-v1-version=3.3.5
fabric-transitive-access-wideners-v1-version=4.3.1
fabric-convention-tags-v1-version=1.5.5
fabric-client-tags-api-v1-version=1.1.2
fabric-api-base-version=0.4.32
fabric-api-lookup-api-v1-version=1.6.37
fabric-biome-api-v1-version=13.0.14
fabric-block-api-v1-version=1.0.12
fabric-block-view-api-v2-version=1.0.3
fabric-blockrenderlayer-v1-version=1.1.42
fabric-command-api-v1-version=1.2.35
fabric-command-api-v2-version=2.2.14
fabric-commands-v0-version=0.2.52
fabric-containers-v0-version=0.1.67
fabric-content-registries-v0-version=4.0.13
fabric-crash-report-info-v1-version=0.2.20
fabric-data-attachment-api-v1-version=1.0.2
fabric-data-generation-api-v1-version=12.3.7
fabric-dimensions-v1-version=2.1.55
fabric-entity-events-v1-version=1.6.1
fabric-events-interaction-v0-version=0.6.5
fabric-events-lifecycle-v0-version=0.2.64
fabric-game-rule-api-v1-version=1.0.41
fabric-gametest-api-v1-version=1.2.15
fabric-item-api-v1-version=2.1.29
fabric-item-group-api-v1-version=4.0.14
fabric-key-binding-api-v1-version=1.0.38
fabric-keybindings-v0-version=0.2.36
fabric-lifecycle-events-v1-version=2.2.23
fabric-loot-api-v2-version=1.2.3
fabric-loot-tables-v1-version=1.1.47
fabric-message-api-v1-version=5.1.10
fabric-mining-level-api-v1-version=2.1.52
fabric-model-loading-api-v1-version=1.0.4
fabric-models-v0-version=0.4.3
fabric-networking-api-v1-version=1.3.14
fabric-networking-v0-version=0.3.54
fabric-object-builder-api-v1-version=11.1.5
fabric-particles-v1-version=1.1.3
fabric-recipe-api-v1-version=1.0.24
fabric-registry-sync-v0-version=2.3.6
fabric-renderer-api-v1-version=3.2.2
fabric-renderer-indigo-version=1.5.3
fabric-renderer-registries-v1-version=3.2.47
fabric-rendering-data-attachment-v1-version=0.3.39
fabric-rendering-fluids-v1-version=3.0.29
fabric-rendering-v0-version=1.1.50
fabric-rendering-v1-version=3.0.9
fabric-resource-conditions-api-v1-version=2.3.9
fabric-resource-loader-v0-version=0.11.12
fabric-screen-api-v1-version=2.0.9
fabric-screen-handler-api-v1-version=1.3.33
fabric-sound-api-v1-version=1.0.14
fabric-transfer-api-v1-version=3.3.6
fabric-transitive-access-wideners-v1-version=4.3.2
fabric-convention-tags-v1-version=1.5.6
fabric-client-tags-api-v1-version=1.1.3

# FFAPI Properties
loom.platform=forge
forge_version=1.20.1-47.3.27
forge_version=1.20.1-47.4.6
pack_format=15
forgified_version=1.11.12
forge_fabric_loader_version=2.6.0+0.15.0+1.20.1
Loading
Loading