mirror of
https://github.com/FabricMC/fabric.git
synced 2025-05-09 12:50:36 -04:00
Port to 24w33a (#4033)
Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> Co-authored-by: hypherionmc <hypherionmc@gmail.com> (cherry picked from commit 952fb19a0df7354e8352ef0c993a956b2bed32c2)
This commit is contained in:
parent
343cdcb01b
commit
1bb677a646
287 changed files with 1262 additions and 1775 deletions
fabric-object-builder-api-v1/src
client
java/net/fabricmc/fabric/mixin/object/builder/client
resources
main
java/net/fabricmc/fabric
api/object/builder/v1/block/entity
mixin/object/builder
resources
test/java/net/fabricmc/fabric/test/object/builder
testmod/java/net/fabricmc/fabric/test/object/builder
|
@ -28,11 +28,19 @@ import net.minecraft.util.Identifier;
|
|||
|
||||
@Mixin(EntityModelLayers.class)
|
||||
public class EntityModelLayersMixin {
|
||||
@Inject(method = "createSign", at = @At("HEAD"), cancellable = true)
|
||||
private static void createSign(WoodType type, CallbackInfoReturnable<EntityModelLayer> cir) {
|
||||
@Inject(method = "createStandingSign", at = @At("HEAD"), cancellable = true)
|
||||
private static void createStandingSign(WoodType type, CallbackInfoReturnable<EntityModelLayer> cir) {
|
||||
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
|
||||
Identifier identifier = Identifier.of(type.name());
|
||||
cir.setReturnValue(new EntityModelLayer(identifier.withPrefixedPath("sign/"), "main"));
|
||||
cir.setReturnValue(new EntityModelLayer(identifier.withPrefixedPath("sign/standing/"), "main"));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "createWallSign", at = @At("HEAD"), cancellable = true)
|
||||
private static void createWallSign(WoodType type, CallbackInfoReturnable<EntityModelLayer> cir) {
|
||||
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
|
||||
Identifier identifier = Identifier.of(type.name());
|
||||
cir.setReturnValue(new EntityModelLayer(identifier.withPrefixedPath("sign/wall/"), "main"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.object.builder.client",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"client": [
|
||||
"EntityModelLayersMixin",
|
||||
"HangingSignEditScreenMixin",
|
||||
|
|
|
@ -16,10 +16,7 @@
|
|||
|
||||
package net.fabricmc.fabric.api.object.builder.v1.block.entity;
|
||||
|
||||
import com.mojang.datafixers.types.Type;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
/**
|
||||
|
@ -36,20 +33,4 @@ public interface FabricBlockEntityType {
|
|||
default void addSupportedBlock(Block block) {
|
||||
throw new AssertionError("Implemented in Mixin");
|
||||
}
|
||||
|
||||
/**
|
||||
* General-purpose Fabric-provided extensions for {@link BlockEntityType.Builder}.
|
||||
*
|
||||
* <p>Note: This interface is automatically implemented on {@link BlockEntityType.Builder} via Mixin and interface injection.
|
||||
*/
|
||||
interface Builder<T extends BlockEntity> {
|
||||
/**
|
||||
* Builds the {@link BlockEntityType}, see {@link BlockEntityType.Builder#build(Type)}.
|
||||
*
|
||||
* @return the built {@link BlockEntityType}
|
||||
*/
|
||||
default BlockEntityType<T> build() {
|
||||
throw new AssertionError("Implemented in Mixin");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package net.fabricmc.fabric.api.object.builder.v1.block.entity;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.datafixers.types.Type;
|
||||
|
@ -33,10 +34,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
*
|
||||
* <p>Alternatively, use the access widener for {@link BlockEntityType.BlockEntityFactory}
|
||||
* in Fabric Transitive Access Wideners (v1).
|
||||
*
|
||||
* @deprecated Use {@link BlockEntityType.Builder} directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class FabricBlockEntityTypeBuilder<T extends BlockEntity> {
|
||||
private final Factory<? extends T> factory;
|
||||
private final List<Block> blocks;
|
||||
|
@ -46,10 +44,6 @@ public final class FabricBlockEntityTypeBuilder<T extends BlockEntity> {
|
|||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link BlockEntityType.Builder#create(BlockEntityType.BlockEntityFactory, Block...)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T extends BlockEntity> FabricBlockEntityTypeBuilder<T> create(Factory<? extends T> factory, Block... blocks) {
|
||||
List<Block> blocksList = new ArrayList<>(blocks.length);
|
||||
Collections.addAll(blocksList, blocks);
|
||||
|
@ -62,9 +56,7 @@ public final class FabricBlockEntityTypeBuilder<T extends BlockEntity> {
|
|||
*
|
||||
* @param block the supported block
|
||||
* @return this builder
|
||||
* @deprecated Use {@link BlockEntityType.Builder#create(BlockEntityType.BlockEntityFactory, Block...)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public FabricBlockEntityTypeBuilder<T> addBlock(Block block) {
|
||||
this.blocks.add(block);
|
||||
return this;
|
||||
|
@ -75,36 +67,21 @@ public final class FabricBlockEntityTypeBuilder<T extends BlockEntity> {
|
|||
*
|
||||
* @param blocks the supported blocks
|
||||
* @return this builder
|
||||
* @deprecated Use {@link BlockEntityType.Builder#create(BlockEntityType.BlockEntityFactory, Block...)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public FabricBlockEntityTypeBuilder<T> addBlocks(Block... blocks) {
|
||||
Collections.addAll(this.blocks, blocks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link BlockEntityType.Builder#build()}.
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockEntityType<T> build() {
|
||||
return build(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link BlockEntityType.Builder#build(Type)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockEntityType<T> build(Type<?> type) {
|
||||
return BlockEntityType.Builder.<T>create(factory::create, blocks.toArray(new Block[0]))
|
||||
.build(type);
|
||||
return new BlockEntityType<T>(factory::create, new HashSet<>(blocks));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link BlockEntityType.BlockEntityFactory}.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated
|
||||
public interface Factory<T extends BlockEntity> {
|
||||
T create(BlockPos blockPos, BlockState blockState);
|
||||
}
|
||||
|
|
|
@ -1,37 +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.object.builder;
|
||||
|
||||
import com.mojang.datafixers.types.Type;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityType;
|
||||
|
||||
@Mixin(BlockEntityType.Builder.class)
|
||||
public abstract class BlockEntityTypeBuilderMixin<T extends BlockEntity> implements FabricBlockEntityType.Builder<T> {
|
||||
@Shadow
|
||||
public abstract BlockEntityType<T> build(Type<?> type);
|
||||
|
||||
@Override
|
||||
public BlockEntityType<T> build() {
|
||||
return build(null);
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ import java.util.HashSet;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mojang.datafixers.types.Type;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
|
@ -43,7 +42,7 @@ public class BlockEntityTypeMixin<T extends BlockEntity> implements FabricBlockE
|
|||
private Set<Block> blocks;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void mutableBlocks(BlockEntityType.BlockEntityFactory<? extends T> factory, Set<Block> blocks, Type<?> type, CallbackInfo ci) {
|
||||
private void mutableBlocks(BlockEntityType.BlockEntityFactory<? extends T> factory, Set<Block> blocks, CallbackInfo ci) {
|
||||
this.blocks = new HashSet<>(this.blocks);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ extendable method net/minecraft/block/AbstractBlock$Settings <init> ()V
|
|||
accessible method net/minecraft/world/poi/PointOfInterestTypes register (Lnet/minecraft/registry/Registry;Lnet/minecraft/registry/RegistryKey;Ljava/util/Set;II)Lnet/minecraft/world/poi/PointOfInterestType;
|
||||
|
||||
extendable class net/minecraft/block/entity/BlockEntityType$BlockEntityFactory
|
||||
accessible method net/minecraft/block/entity/BlockEntityType <init> (Lnet/minecraft/block/entity/BlockEntityType$BlockEntityFactory;Ljava/util/Set;)V
|
||||
accessible class net/minecraft/village/TradeOffers$TypeAwareBuyForOneEmeraldFactory
|
||||
mutable field net/minecraft/village/TradeOffers REBALANCED_PROFESSION_TO_LEVELED_TRADE Ljava/util/Map;
|
||||
mutable field net/minecraft/village/TradeOffers REBALANCED_WANDERING_TRADER_TRADES Ljava/util/List;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.object.builder",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"AbstractBlockAccessor",
|
||||
"AbstractBlockSettingsAccessor",
|
||||
"BlockEntityTypeBuilderMixin",
|
||||
"BlockEntityTypeMixin",
|
||||
"DefaultAttributeRegistryAccessor",
|
||||
"DefaultAttributeRegistryMixin",
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"FabricMC"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.15.11",
|
||||
"fabricloader": ">=0.16.2",
|
||||
"fabric-api-base": "*"
|
||||
},
|
||||
"description": "Builders for objects vanilla has locked down.",
|
||||
|
@ -32,8 +32,7 @@
|
|||
"fabric-api:module-lifecycle": "stable",
|
||||
"loom:injected_interfaces": {
|
||||
"net/minecraft/class_1299\u0024class_1300": ["net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityType\u0024Builder<TT;>"],
|
||||
"net/minecraft/class_2591": ["net/fabricmc/fabric/api/object/builder/v1/block/entity/FabricBlockEntityType"],
|
||||
"net/minecraft/class_2591\u0024class_2592": ["net/fabricmc/fabric/api/object/builder/v1/block/entity/FabricBlockEntityType\u0024Builder<TT;>"]
|
||||
"net/minecraft/class_2591": ["net/fabricmc/fabric/api/object/builder/v1/block/entity/FabricBlockEntityType"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class FabricEntityTypeTest {
|
|||
|
||||
private static DefaultAttributeContainer.Builder createAttributes() {
|
||||
return MobEntity.createMobAttributes()
|
||||
.add(EntityAttributes.GENERIC_MAX_HEALTH, 10.0)
|
||||
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.25);
|
||||
.add(EntityAttributes.MAX_HEALTH, 10.0)
|
||||
.add(EntityAttributes.MOVEMENT_SPEED, 0.25);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,10 +53,7 @@ public class BlockEntityTypeBuilderTest implements ModInitializer {
|
|||
static final Block SECOND_MULTI_BETRAYAL_BLOCK = new BetrayalBlock(MapColor.YELLOW);
|
||||
|
||||
private static final Identifier BLOCK_ENTITY_TYPE_ID = ObjectBuilderTestConstants.id("betrayal_block");
|
||||
public static final BlockEntityType<?> BLOCK_ENTITY_TYPE = FabricBlockEntityTypeBuilder.create(BetrayalBlockEntity::new, INITIAL_BETRAYAL_BLOCK)
|
||||
.addBlock(ADDED_BETRAYAL_BLOCK)
|
||||
.addBlocks(FIRST_MULTI_BETRAYAL_BLOCK, SECOND_MULTI_BETRAYAL_BLOCK)
|
||||
.build();
|
||||
public static final BlockEntityType<?> BLOCK_ENTITY_TYPE = FabricBlockEntityTypeBuilder.create(BetrayalBlockEntity::new, INITIAL_BETRAYAL_BLOCK, ADDED_BETRAYAL_BLOCK, FIRST_MULTI_BETRAYAL_BLOCK, SECOND_MULTI_BETRAYAL_BLOCK).build();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue