mirror of
https://github.com/FabricMC/fabric.git
synced 2025-05-08 04:10:47 -04:00
(Block)EntityType builders use @Nullable Booleans
This commit is contained in:
parent
ac4f4b07c0
commit
d70d2c06bb
5 changed files with 18 additions and 9 deletions
fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric
api/object/builder/v1/block/entity
impl/object/builder
mixin/object/builder
|
@ -38,7 +38,8 @@ import net.fabricmc.fabric.impl.object.builder.ExtendedBlockEntityType;
|
|||
public final class FabricBlockEntityTypeBuilder<T extends BlockEntity> {
|
||||
private final Factory<? extends T> factory;
|
||||
private final Set<Block> blocks = new HashSet<>();
|
||||
private boolean canPotentiallyExecuteCommands = false;
|
||||
@Nullable
|
||||
private Boolean canPotentiallyExecuteCommands = null;
|
||||
|
||||
private FabricBlockEntityTypeBuilder(Factory<? extends T> factory) {
|
||||
this.factory = factory;
|
||||
|
|
|
@ -18,22 +18,25 @@ package net.fabricmc.fabric.impl.object.builder;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
public class ExtendedBlockEntityType<T extends BlockEntity> extends BlockEntityType<T> {
|
||||
private final boolean canPotentiallyExecuteCommands;
|
||||
@Nullable
|
||||
private final Boolean canPotentiallyExecuteCommands;
|
||||
|
||||
public ExtendedBlockEntityType(BlockEntityFactory<? extends T> factory, Set<Block> blocks, boolean canPotentiallyExecuteCommands) {
|
||||
public ExtendedBlockEntityType(BlockEntityFactory<? extends T> factory, Set<Block> blocks, @Nullable Boolean canPotentiallyExecuteCommands) {
|
||||
super(factory, blocks);
|
||||
this.canPotentiallyExecuteCommands = canPotentiallyExecuteCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPotentiallyExecuteCommands() {
|
||||
if (canPotentiallyExecuteCommands) {
|
||||
return true;
|
||||
if (canPotentiallyExecuteCommands != null) {
|
||||
return canPotentiallyExecuteCommands;
|
||||
}
|
||||
|
||||
return super.canPotentiallyExecuteCommands();
|
||||
|
|
|
@ -35,9 +35,9 @@ import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRe
|
|||
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType;
|
||||
|
||||
public interface FabricEntityTypeImpl {
|
||||
void fabric_setAlwaysUpdateVelocity(Boolean alwaysUpdateVelocity);
|
||||
void fabric_setAlwaysUpdateVelocity(@Nullable Boolean alwaysUpdateVelocity);
|
||||
|
||||
void fabric_setCanPotentiallyExecuteCommands(Boolean canPotentiallyExecuteCommands);
|
||||
void fabric_setCanPotentiallyExecuteCommands(@Nullable Boolean canPotentiallyExecuteCommands);
|
||||
|
||||
interface Builder {
|
||||
void fabric_setLivingEntityBuilder(Living<? extends LivingEntity> livingBuilder);
|
||||
|
|
|
@ -47,8 +47,10 @@ public abstract class EntityTypeBuilderMixin<T extends Entity> implements Fabric
|
|||
public abstract EntityType<T> build(RegistryKey<EntityType<?>> registryKey);
|
||||
|
||||
@Unique
|
||||
@Nullable
|
||||
private Boolean alwaysUpdateVelocity = null;
|
||||
@Unique
|
||||
@Nullable
|
||||
private Boolean canPotentiallyExecuteCommands = null;
|
||||
|
||||
@Unique
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.object.builder;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -29,8 +30,10 @@ import net.fabricmc.fabric.impl.object.builder.FabricEntityTypeImpl;
|
|||
@Mixin(EntityType.class)
|
||||
public abstract class EntityTypeMixin implements FabricEntityTypeImpl {
|
||||
@Unique
|
||||
@Nullable
|
||||
private Boolean alwaysUpdateVelocity;
|
||||
@Unique
|
||||
@Nullable
|
||||
private Boolean canPotentiallyExecuteCommands;
|
||||
|
||||
@Inject(method = "alwaysUpdateVelocity", at = @At("HEAD"), cancellable = true)
|
||||
|
@ -48,12 +51,12 @@ public abstract class EntityTypeMixin implements FabricEntityTypeImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setAlwaysUpdateVelocity(Boolean alwaysUpdateVelocity) {
|
||||
public void fabric_setAlwaysUpdateVelocity(@Nullable Boolean alwaysUpdateVelocity) {
|
||||
this.alwaysUpdateVelocity = alwaysUpdateVelocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setCanPotentiallyExecuteCommands(Boolean canPotentiallyExecuteCommands) {
|
||||
public void fabric_setCanPotentiallyExecuteCommands(@Nullable Boolean canPotentiallyExecuteCommands) {
|
||||
this.canPotentiallyExecuteCommands = canPotentiallyExecuteCommands;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue