This commit is contained in:
modmuss50 2023-04-05 17:18:33 +01:00
parent 2ffbbd0726
commit 158c189089
12 changed files with 56 additions and 167 deletions
fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup
fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider
fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item
fabric-loot-api-v2/src/main/java/net/fabricmc/fabric/mixin/loot
fabric-networking-api-v1/src/client
java/net/fabricmc/fabric/mixin/networking/client
resources
fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block
fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame
gradle.properties

View file

@ -42,17 +42,17 @@ public class FabricApiLookupTest implements ModInitializer {
public static final String MOD_ID = "fabric-lookup-api-v1-testmod";
// Chute - Block without model that transfers item from the container above to the container below.
// It's meant to work with unsided containers: chests, dispensers, droppers and hoppers.
public static final ChuteBlock CHUTE_BLOCK = new ChuteBlock(FabricBlockSettings.of(Material.METAL));
public static final ChuteBlock CHUTE_BLOCK = new ChuteBlock(FabricBlockSettings.of(Material.field_44489));
public static final BlockItem CHUTE_ITEM = new BlockItem(CHUTE_BLOCK, new Item.Settings());
public static BlockEntityType<ChuteBlockEntity> CHUTE_BLOCK_ENTITY_TYPE;
// Cobble gen - Block without model that can generate infinite cobblestone when placed above a chute.
// It's meant to test BlockApiLookup#registerSelf.
public static final CobbleGenBlock COBBLE_GEN_BLOCK = new CobbleGenBlock(FabricBlockSettings.of(Material.METAL));
public static final CobbleGenBlock COBBLE_GEN_BLOCK = new CobbleGenBlock(FabricBlockSettings.of(Material.field_44489));
public static final BlockItem COBBLE_GEN_ITEM = new BlockItem(COBBLE_GEN_BLOCK, new Item.Settings());
public static BlockEntityType<CobbleGenBlockEntity> COBBLE_GEN_BLOCK_ENTITY_TYPE;
// Testing for item api lookups is done in the `item` package.
public static final InspectorBlock INSPECTOR_BLOCK = new InspectorBlock(FabricBlockSettings.of(Material.METAL));
public static final InspectorBlock INSPECTOR_BLOCK = new InspectorBlock(FabricBlockSettings.of(Material.field_44489));
public static final BlockItem INSPECTOR_ITEM = new BlockItem(INSPECTOR_BLOCK, new Item.Settings());
@Override

View file

@ -30,10 +30,10 @@ import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.class_8490;
import net.minecraft.data.DataOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.DataWriter;
import net.minecraft.loot.LootManager;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.context.LootContextType;
import net.minecraft.util.Identifier;
@ -87,7 +87,7 @@ public interface FabricLootTableProvider extends Consumer<BiConsumer<Identifier,
final List<CompletableFuture<?>> futures = new ArrayList<>();
for (Map.Entry<Identifier, LootTable> entry : builders.entrySet()) {
JsonObject tableJson = (JsonObject) LootManager.toJson(entry.getValue());
JsonObject tableJson = (JsonObject) class_8490.LOOT_TABLES.method_51203().toJsonTree(entry.getValue());
ConditionJsonProvider.write(tableJson, conditionMap.remove(entry.getKey()));
futures.add(DataProvider.writeToPath(writer, tableJson, getOutputPath(entry.getKey())));

View file

@ -51,7 +51,7 @@ import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
public final class EntityEventTests implements ModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(EntityEventTests.class);
public static final Block TEST_BED = new TestBedBlock(AbstractBlock.Settings.of(Material.WOOL).strength(1, 1));
public static final Block TEST_BED = new TestBedBlock(AbstractBlock.Settings.of(Material.field_44489).strength(1, 1));
public static final Item DIAMOND_ELYTRA = new DiamondElytraItem();
@Override

View file

@ -20,7 +20,6 @@ import java.util.function.Consumer;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
@ -37,10 +36,9 @@ import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.fabricmc.fabric.api.item.v1.FabricItemStack;
import net.fabricmc.fabric.api.item.v1.CustomDamageHandler;
import net.fabricmc.fabric.api.item.v1.FabricItemStack;
import net.fabricmc.fabric.api.item.v1.ModifyItemAttributeModifiersCallback;
import net.fabricmc.fabric.impl.item.ItemExtensions;
@ -102,22 +100,4 @@ public abstract class ItemStackMixin implements FabricItemStack {
public boolean hookIsSuitableFor(Item item, BlockState state) {
return item.isSuitableFor((ItemStack) (Object) this, state);
}
@Final
@Shadow
private Item item;
@Shadow
private int count;
@Shadow
private boolean empty;
/**
* Soft-overwrite updateEmptyState to fix <a href="https://bugs.mojang.com/projects/MC/issues/MC-258939">MC-258939</a>.
* Cannot hard-overwrite because Lithium contains a similar but insufficient inject.
*/
@Inject(method = "updateEmptyState", at = @At("HEAD"), cancellable = true)
private void updateEmptyState(CallbackInfo ci) {
this.empty = this.item == null || this.item == Items.AIR || this.count <= 0;
ci.cancel();
}
}

View file

@ -17,20 +17,22 @@
package net.fabricmc.fabric.mixin.loot;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonObject;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.class_8488;
import net.minecraft.loot.LootManager;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.minecraft.resource.ResourceReloader;
import net.minecraft.util.profiler.Profiler;
import net.fabricmc.fabric.api.loot.v2.FabricLootTableBuilder;
@ -44,27 +46,34 @@ import net.fabricmc.fabric.impl.loot.LootUtil;
@Mixin(LootManager.class)
abstract class LootManagerMixin {
@Shadow
private Map<Identifier, LootTable> tables;
private Map<class_8488<?>, ?> field_44492;
@Inject(method = "apply", at = @At("RETURN"))
private void apply(Map<Identifier, JsonObject> jsonMap, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) {
@Inject(method = "reload", at = @At("RETURN"), cancellable = true)
private void reload(ResourceReloader.Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
//noinspection DataFlowIssue
LootManager lootManager = (LootManager) (Object) this;
cir.setReturnValue(cir.getReturnValue().thenRun(() -> applyLootTableEvents(manager, lootManager)));
}
@Unique
private void applyLootTableEvents(ResourceManager resourceManager, LootManager lootManager) {
// The builder for the new LootManager.tables map with modified loot tables.
// We're using an immutable map to match vanilla.
ImmutableMap.Builder<Identifier, LootTable> newTables = ImmutableMap.builder();
ImmutableMap.Builder<class_8488<?>, Object> newTables = ImmutableMap.builder();
tables.forEach((id, table) -> {
if (id.equals(LootTables.EMPTY)) {
this.field_44492.forEach((id, entry) -> {
if (id == LootManager.field_44491) {
// This is a special table and cannot be modified.
// Vanilla also warns about that.
newTables.put(id, entry);
return;
}
// noinspection ConstantConditions
LootManager lootManager = (LootManager) (Object) this;
LootTableSource source = LootUtil.determineSource(id, resourceManager);
LootTable table = (LootTable) entry;
LootTableSource source = LootUtil.determineSource(id.location(), resourceManager);
// Invoke the REPLACE event for the current loot table.
LootTable replacement = LootTableEvents.REPLACE.invoker().replaceLootTable(resourceManager, lootManager, id, table, source);
LootTable replacement = LootTableEvents.REPLACE.invoker().replaceLootTable(resourceManager, lootManager, id.location(), table, source);
if (replacement != null) {
// Set the loot table to MODIFY to be the replacement loot table.
@ -75,13 +84,12 @@ abstract class LootManagerMixin {
// Turn the current table into a modifiable builder and invoke the MODIFY event.
LootTable.Builder builder = FabricLootTableBuilder.copyOf(table);
LootTableEvents.MODIFY.invoker().modifyLootTable(resourceManager, lootManager, id, builder, source);
LootTableEvents.MODIFY.invoker().modifyLootTable(resourceManager, lootManager, id.location(), builder, source);
// Turn the builder back into a loot table and store it in the new table.
newTables.put(id, builder.build());
});
// Finally, store the new loot table map in the field.
tables = newTables.build();
this.field_44492 = newTables.build();
}
}

View file

@ -1,93 +0,0 @@
/*
* 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.networking.client;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
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.CallbackInfo;
import net.minecraft.client.font.MultilineText;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
/**
* This mixin makes disconnect reason text scrollable.
*/
@Mixin(DisconnectedScreen.class)
public abstract class DisconnectedScreenMixin extends Screen {
@Shadow
private int reasonHeight;
@Unique
private int actualReasonHeight;
@Unique
private int scroll;
@Unique
private int maxScroll;
private DisconnectedScreenMixin() {
super(null);
}
// Inject to right after reasonHeight is stored, to make sure the back button have correct position.
@Inject(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/DisconnectedScreen;reasonHeight:I", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER))
private void init(CallbackInfo ci) {
actualReasonHeight = reasonHeight;
reasonHeight = Math.min(reasonHeight, height - 100);
scroll = 0;
maxScroll = actualReasonHeight - reasonHeight;
}
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/MultilineText;drawCenterWithShadow(Lnet/minecraft/client/util/math/MatrixStack;II)I"))
private int render(MultilineText instance, MatrixStack matrixStack, int x, int y) {
DrawableHelper.enableScissor(0, y, width, y + reasonHeight);
instance.drawCenterWithShadow(matrixStack, x, y - scroll);
DrawableHelper.disableScissor();
// Draw gradient at the top/bottom to indicate that the text is scrollable.
if (actualReasonHeight > reasonHeight) {
int startX = (width - instance.getMaxWidth()) / 2;
int endX = (width + instance.getMaxWidth()) / 2;
if (scroll > 0) {
fillGradient(matrixStack, startX, y, endX, y + 10, 0xFF000000, 0);
}
if (scroll < maxScroll) {
fillGradient(matrixStack, startX, y + reasonHeight - 10, endX, y + reasonHeight, 0, 0xFF000000);
}
}
return y + reasonHeight;
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
scroll = MathHelper.clamp(scroll - (MathHelper.sign(amount) * client.textRenderer.fontHeight * 10), 0, maxScroll);
return super.mouseScrolled(mouseX, mouseY, amount);
}
}

View file

@ -7,8 +7,7 @@
"accessor.ConnectScreenAccessor",
"accessor.MinecraftClientAccessor",
"ClientLoginNetworkHandlerMixin",
"ClientPlayNetworkHandlerMixin",
"DisconnectedScreenMixin"
"ClientPlayNetworkHandlerMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -42,12 +42,6 @@ public class FabricMaterialBuilder extends Material.Builder {
return this;
}
@Override
public FabricMaterialBuilder liquid() {
super.liquid();
return this;
}
@Override
public FabricMaterialBuilder notSolid() {
super.notSolid();

View file

@ -46,6 +46,7 @@ public final class BlockSetTypeRegistry {
* Creates and registers a {@link BlockSetType}.
*
* @param id the id of this {@link BlockSetType}
* @param canOpenByHand set to true to allow this block set's door's to be opened by hand
* @param soundType the {@link BlockSoundGroup} for this block set
* @param doorClose the {@link SoundEvent} for when this block set's door closes
* @param doorOpen the {@link SoundEvent} for when this block set's door opens
@ -57,7 +58,7 @@ public final class BlockSetTypeRegistry {
* @param buttonClickOn the {@link SoundEvent} for when this block set's button is pressed
* @return a new {@link BlockSetType}
*/
public static BlockSetType register(Identifier id, BlockSoundGroup soundType, SoundEvent doorClose, SoundEvent doorOpen, SoundEvent trapdoorClose, SoundEvent trapdoorOpen, SoundEvent pressurePlateClickOff, SoundEvent pressurePlateClickOn, SoundEvent buttonClickOff, SoundEvent buttonClickOn) {
return BlockSetType.register(new BlockSetType(id.toString(), soundType, doorClose, doorOpen, trapdoorClose, trapdoorOpen, pressurePlateClickOff, pressurePlateClickOn, buttonClickOff, buttonClickOn));
public static BlockSetType register(Identifier id, boolean canOpenByHand, BlockSoundGroup soundType, SoundEvent doorClose, SoundEvent doorOpen, SoundEvent trapdoorClose, SoundEvent trapdoorOpen, SoundEvent pressurePlateClickOff, SoundEvent pressurePlateClickOn, SoundEvent buttonClickOff, SoundEvent buttonClickOn) {
return BlockSetType.register(new BlockSetType(id.toString(), canOpenByHand, soundType, doorClose, doorOpen, trapdoorClose, trapdoorOpen, pressurePlateClickOff, pressurePlateClickOn, buttonClickOff, buttonClickOn));
}
}

View file

@ -42,7 +42,7 @@ import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes;
public class FluidChuteBlock extends Block implements BlockEntityProvider {
public FluidChuteBlock() {
super(Settings.of(Material.METAL));
super(Settings.of(Material.field_44489));
}
private static final VoxelShape SHAPE = VoxelShapes.cuboid(

View file

@ -35,8 +35,8 @@ import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage;
public class TransferTestInitializer implements ModInitializer {
public static final String MOD_ID = "fabric-transfer-api-v1-testmod";
private static final Block INFINITE_WATER_SOURCE = new Block(AbstractBlock.Settings.of(Material.METAL));
private static final Block INFINITE_LAVA_SOURCE = new Block(AbstractBlock.Settings.of(Material.METAL));
private static final Block INFINITE_WATER_SOURCE = new Block(AbstractBlock.Settings.of(Material.field_44483));
private static final Block INFINITE_LAVA_SOURCE = new Block(AbstractBlock.Settings.of(Material.field_44483));
private static final Block FLUID_CHUTE = new FluidChuteBlock();
private static final Item EXTRACT_STICK = new ExtractStickItem();
public static BlockEntityType<FluidChuteBlockEntity> FLUID_CHUTE_TYPE;

View file

@ -2,8 +2,8 @@ org.gradle.jvmargs=-Xmx2560M
org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true
version=0.77.0
minecraft_version=23w13a
version=0.77.1
minecraft_version=23w14a
yarn_version=+build.1
loader_version=0.14.18
installer_version=0.11.1
@ -12,39 +12,39 @@ prerelease=true
# Do not manually update, use the bumpversions task:
fabric-api-base-version=0.4.23
fabric-api-lookup-api-v1-version=1.6.24
fabric-api-lookup-api-v1-version=1.6.25
fabric-biome-api-v1-version=13.0.6
fabric-block-api-v1-version=1.0.5
fabric-blockrenderlayer-v1-version=1.1.33
fabric-command-api-v1-version=1.2.25
fabric-command-api-v2-version=2.2.4
fabric-commands-v0-version=0.2.42
fabric-containers-v0-version=0.1.53
fabric-containers-v0-version=0.1.54
fabric-content-registries-v0-version=3.5.7
fabric-crash-report-info-v1-version=0.2.14
fabric-data-generation-api-v1-version=11.3.8
fabric-data-generation-api-v1-version=11.3.9
fabric-dimensions-v1-version=2.1.44
fabric-entity-events-v1-version=1.5.12
fabric-entity-events-v1-version=1.5.13
fabric-events-interaction-v0-version=0.4.42
fabric-events-lifecycle-v0-version=0.2.51
fabric-events-lifecycle-v0-version=0.2.52
fabric-game-rule-api-v1-version=1.0.32
fabric-gametest-api-v1-version=1.2.2
fabric-item-api-v1-version=2.1.16
fabric-item-api-v1-version=2.1.17
fabric-item-group-api-v1-version=3.0.3
fabric-key-binding-api-v1-version=1.0.32
fabric-keybindings-v0-version=0.2.30
fabric-lifecycle-events-v1-version=2.2.14
fabric-loot-api-v2-version=1.1.25
fabric-loot-tables-v1-version=1.1.29
fabric-loot-api-v2-version=1.1.26
fabric-loot-tables-v1-version=1.1.30
fabric-message-api-v1-version=5.1.0
fabric-mining-level-api-v1-version=2.1.37
fabric-models-v0-version=0.3.29
fabric-networking-api-v1-version=1.3.0
fabric-networking-v0-version=0.3.40
fabric-object-builder-api-v1-version=8.0.0
fabric-networking-api-v1-version=1.3.1
fabric-networking-v0-version=0.3.41
fabric-object-builder-api-v1-version=9.0.0
fabric-particles-v1-version=1.0.22
fabric-recipe-api-v1-version=1.0.7
fabric-registry-sync-v0-version=2.1.3
fabric-recipe-api-v1-version=1.0.8
fabric-registry-sync-v0-version=2.1.4
fabric-renderer-api-v1-version=2.2.4
fabric-renderer-indigo-version=1.1.0
fabric-renderer-registries-v1-version=3.2.37
@ -55,9 +55,9 @@ fabric-rendering-v1-version=2.1.0
fabric-resource-conditions-api-v1-version=2.3.0
fabric-resource-loader-v0-version=0.11.0
fabric-screen-api-v1-version=1.0.44
fabric-screen-handler-api-v1-version=1.3.19
fabric-screen-handler-api-v1-version=1.3.20
fabric-sound-api-v1-version=1.0.8
fabric-transfer-api-v1-version=3.0.1
fabric-transfer-api-v1-version=3.0.2
fabric-transitive-access-wideners-v1-version=4.0.0
fabric-convention-tags-v1-version=1.4.0
fabric-client-tags-api-v1-version=1.0.14