Skip to content

Commit

Permalink
Merge branch '1.20.3' into client-block-break
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 authored Oct 11, 2023
2 parents b972aab + 13986bf commit cfcf0e9
Show file tree
Hide file tree
Showing 89 changed files with 181 additions and 616 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.fabricmc.fabric.test.lookup;

import com.mojang.serialization.MapCodec;
import org.jetbrains.annotations.Nullable;

import net.minecraft.block.BlockState;
Expand All @@ -31,6 +32,11 @@ public ChuteBlock(Settings settings) {
super(settings);
}

@Override
protected MapCodec<? extends BlockWithEntity> getCodec() {
throw new UnsupportedOperationException("not implemented yet");
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.fabricmc.fabric.test.lookup;

import com.mojang.serialization.MapCodec;
import org.jetbrains.annotations.Nullable;

import net.minecraft.block.BlockState;
Expand All @@ -28,6 +29,11 @@ public CobbleGenBlock(Settings settings) {
super(settings);
}

@Override
protected MapCodec<? extends BlockWithEntity> getCodec() {
throw new UnsupportedOperationException("not implemented yet");
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
* Provides methods for modifying biomes. To create an instance, call
* {@link BiomeModifications#create(Identifier)}.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*
* @see BiomeModifications
*/
public class BiomeModification {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@

/**
* Allows {@link Biome} properties to be modified.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public interface BiomeModificationContext {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
* Provides an API to modify Biomes after they have been loaded and before they are used in the World.
*
* <p>Any modifications made to biomes will not be available for use in the demo level.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public final class BiomeModifications {
private BiomeModifications() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

/**
* Provides several convenient biome selectors that can be used with {@link BiomeModifications}.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public final class BiomeSelectors {
private BiomeSelectors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* <li>Replacements (removal + add) in biomes</li>
* <li>Generic post-processing of biomes</li>
* </ol>
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public enum ModificationPhase {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

/**
* API that exposes the internals of Minecraft's nether biome code.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public final class NetherBiomes {
private NetherBiomes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
/**
* API that exposes some internals of the minecraft default biome source for The End.
*
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
* Because of the volatility of world generation in Minecraft 1.16, this API is marked experimental
* since it is likely to change in future Minecraft versions.
*/
public final class TheEndBiomes {
private TheEndBiomes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package net.fabricmc.fabric.mixin.biome;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;

Expand All @@ -33,11 +31,10 @@
public class BiomeSourceMixin {
@Redirect(method = "getBiomes", at = @At(value = "INVOKE", target = "Ljava/util/function/Supplier;get()Ljava/lang/Object;"))
private Object getBiomes(Supplier<Set<RegistryEntry<Biome>>> instance) {
var biomes = new HashSet<>(instance.get());
fabric_modifyBiomeSet(biomes);
return Collections.unmodifiableSet(biomes);
return fabric_modifyBiomeSet(instance.get());
}

protected void fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
protected Set<RegistryEntry<Biome>> fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
return biomes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package net.fabricmc.fabric.mixin.biome;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.function.Supplier;

Expand Down Expand Up @@ -108,14 +110,18 @@ private void getWeightedEndBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseU
}

@Override
protected void fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
protected Set<RegistryEntry<Biome>> fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
if (!hasCheckedForModifiedSet) {
hasCheckedForModifiedSet = true;
biomeSetModified = !overrides.get().customBiomes.isEmpty();
}

if (biomeSetModified) {
biomes.addAll(overrides.get().customBiomes);
var modifiedBiomes = new LinkedHashSet<>(biomes);
modifiedBiomes.addAll(overrides.get().customBiomes);
return Collections.unmodifiableSet(modifiedBiomes);
}

return biomes;
}
}
2 changes: 1 addition & 1 deletion fabric-biome-api-v1/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
],
"accessWidener" : "fabric-biome-api-v1.accesswidener",
"custom": {
"fabric-api:module-lifecycle": "experimental"
"fabric-api:module-lifecycle": "stable"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void testEntitySelector(TestContext context) {

context.expectEntitiesAround(EntityType.CREEPER, BlockPos.ORIGIN, 3, 2.0);
MinecraftServer server = context.getWorld().getServer();
int result = server.getCommandManager().executeWithPrefix(server.getCommandSource(), command);
context.assertTrue(result == 2, "Expected 2 entities killed, got " + result);
server.getCommandManager().executeWithPrefix(server.getCommandSource(), command);
//context.assertTrue(result == 2, "Expected 2 entities killed, got " + result);
context.expectEntitiesAround(EntityType.CREEPER, BlockPos.ORIGIN, 1, 2.0);
context.complete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
* A provider to help with data-generation of dynamic registry objects,
* such as biomes, features, or message types.
*/
@ApiStatus.Experimental
public abstract class FabricDynamicRegistryProvider implements DataProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(FabricDynamicRegistryProvider.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package net.fabricmc.fabric.impl.event.interaction;
package net.fabricmc.fabric.impl.event.interaction.client;

import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldView;

/**
* Convenience interface for blocks that want more stack picking context than what
* {@link Block#getPickStack(BlockView, BlockPos, BlockState)} provides.
* {@link Block#getPickStack(WorldView, BlockPos, BlockState)} provides.
*
* <p>The hit result is guaranteed to be a {@link BlockHitResult} that did not miss.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.network.packet.c2s.common.SyncedClientOptions;
import net.minecraft.scoreboard.AbstractTeam;
import net.minecraft.scoreboard.Team;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
Expand Down Expand Up @@ -126,7 +126,7 @@ public boolean isInvulnerableTo(DamageSource damageSource) {

@Nullable
@Override
public AbstractTeam getScoreboardTeam() {
public Team getScoreboardTeam() {
// Scoreboard team is checked using the gameprofile name by default, which we don't want.
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void interactItem(ServerPlayerEntity player, World world, ItemStack stack
}
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V"), method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockState state, BlockEntity entity, Block block) {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/block/BlockState;"), method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockEntity entity, Block block, BlockState state) {
boolean result = PlayerBlockBreakEvents.BEFORE.invoker().beforeBlockBreak(this.world, this.player, pos, state, entity);

if (!result) {
Expand All @@ -116,7 +116,7 @@ private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, Block
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBroken(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V"), method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILHARD)
private void onBlockBroken(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockState state, BlockEntity entity, Block block, boolean b1) {
private void onBlockBroken(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockEntity entity, Block block, BlockState state, boolean bl) {
PlayerBlockBreakEvents.AFTER.invoker().afterBlockBreak(this.world, this.player, pos, state, entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"net.fabricmc.fabric.impl.event.interaction.InteractionEventsRouter"
],
"client": [
"net.fabricmc.fabric.impl.event.interaction.InteractionEventsRouterClient"
"net.fabricmc.fabric.impl.event.interaction.client.InteractionEventsRouterClient"
]
},
"description": "Events for player interaction with blocks and entities.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"main": [
"net.fabricmc.fabric.test.event.interaction.AttackBlockTests",
"net.fabricmc.fabric.test.event.interaction.PlayerBreakBlockTests",
"net.fabricmc.fabric.test.event.interaction.PlayerPickBlockTests",
"net.fabricmc.fabric.test.event.interaction.UseEntityTests"
],
"fabric-gametest": [
"net.fabricmc.fabric.test.event.interaction.FakePlayerTests"
],
"client": [
"net.fabricmc.fabric.test.client.event.interaction.ClientPreAttackTests",
"net.fabricmc.fabric.test.client.event.interaction.ClientPlayerBlockBreakTests"
"net.fabricmc.fabric.test.client.event.interaction.ClientPreAttackTests",
"net.fabricmc.fabric.test.client.event.interaction.PlayerPickBlockTests"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
* limitations under the License.
*/

package net.fabricmc.fabric.test.event.interaction;
package net.fabricmc.fabric.test.client.event.interaction;

import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Hand;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockApplyCallback;

public class PlayerPickBlockTests implements ModInitializer {
public class PlayerPickBlockTests implements ClientModInitializer {
@Override
public void onInitialize() {
public void onInitializeClient() {
ClientPickBlockApplyCallback.EVENT.register((player, result, stack) -> {
if (player.getStackInHand(Hand.MAIN_HAND).getItem() == Items.DIAMOND) {
return new ItemStack(Items.OBSIDIAN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* This class allows the entries of {@linkplain ItemGroup item groups} to be modified by the events in {@link ItemGroupEvents}.
*/
@ApiStatus.Experimental
public class FabricItemGroupEntries implements ItemGroup.Entries {
private final ItemGroup.DisplayContext context;
private final List<ItemStack> displayStacks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void onGameJoin(GameJoinS2CPacket packet, CallbackInfo ci) {
}
}

// Called when the client disconnects from a server.
// Called when the client disconnects from a server or enters reconfiguration.
@Inject(method = "clearWorld", at = @At("HEAD"))
private void onClearWorld(CallbackInfo ci) {
// If a world already exists, we need to unload all (block)entities in the world.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ private LootTableEvents() {
}
});

/**
* This event can be used for post-processing after all loot tables have been loaded and modified by Fabric.
*/
public static final Event<Loaded> ALL_LOADED = EventFactory.createArrayBacked(Loaded.class, listeners -> (resourceManager, lootManager) -> {
for (Loaded listener : listeners) {
listener.onLootTablesLoaded(resourceManager, lootManager);
}
});

public interface Replace {
/**
* Replaces loot tables.
Expand Down Expand Up @@ -116,4 +125,14 @@ public interface Modify {
*/
void modifyLootTable(ResourceManager resourceManager, LootManager lootManager, Identifier id, LootTable.Builder tableBuilder, LootTableSource source);
}

public interface Loaded {
/**
* Called when all loot tables have been loaded and {@link LootTableEvents#REPLACE} and {@link LootTableEvents#MODIFY} have been invoked.
*
* @param resourceManager the server resource manager
* @param lootManager the loot manager
*/
void onLootTablesLoaded(ResourceManager resourceManager, LootManager lootManager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ private void applyLootTableEvents(ResourceManager resourceManager, LootManager l
});

this.keyToValue = newTables.build();
LootTableEvents.ALL_LOADED.invoker().onLootTablesLoaded(resourceManager, lootManager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,13 @@ public void onInitialize() {
tableBuilder.modifyPools(poolBuilder -> poolBuilder.with(ItemEntry.builder(Items.EMERALD)));
}
});

LootTableEvents.ALL_LOADED.register((resourceManager, lootManager) -> {
LootTable blackWoolTable = lootManager.getLootTable(Blocks.BLACK_WOOL.getLootTableId());

if (blackWoolTable == LootTable.EMPTY) {
throw new AssertionError("black wool loot table should not be empty");
}
});
}
}
2 changes: 1 addition & 1 deletion fabric-message-api-v1/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
}
],
"custom": {
"fabric-api:module-lifecycle": "experimental"
"fabric-api:module-lifecycle": "stable"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package net.fabricmc.fabric.api.client.networking.v1;

import org.jetbrains.annotations.ApiStatus;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientConfigurationNetworkHandler;
import net.minecraft.util.Identifier;
Expand All @@ -28,7 +26,6 @@
/**
* Offers access to events related to the configuration connection to a server on a logical client.
*/
@ApiStatus.Experimental
public final class ClientConfigurationConnectionEvents {
/**
* Event indicating a connection entering the CONFIGURATION state, ready for registering channel handlers.
Expand Down
Loading

0 comments on commit cfcf0e9

Please sign in to comment.