mirror of
https://github.com/FabricMC/fabric.git
synced 2025-05-21 10:40:40 -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> {
|
public final class FabricBlockEntityTypeBuilder<T extends BlockEntity> {
|
||||||
private final Factory<? extends T> factory;
|
private final Factory<? extends T> factory;
|
||||||
private final Set<Block> blocks = new HashSet<>();
|
private final Set<Block> blocks = new HashSet<>();
|
||||||
private boolean canPotentiallyExecuteCommands = false;
|
@Nullable
|
||||||
|
private Boolean canPotentiallyExecuteCommands = null;
|
||||||
|
|
||||||
private FabricBlockEntityTypeBuilder(Factory<? extends T> factory) {
|
private FabricBlockEntityTypeBuilder(Factory<? extends T> factory) {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
|
|
|
@ -18,22 +18,25 @@ package net.fabricmc.fabric.impl.object.builder;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
|
|
||||||
public class ExtendedBlockEntityType<T extends BlockEntity> extends BlockEntityType<T> {
|
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);
|
super(factory, blocks);
|
||||||
this.canPotentiallyExecuteCommands = canPotentiallyExecuteCommands;
|
this.canPotentiallyExecuteCommands = canPotentiallyExecuteCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPotentiallyExecuteCommands() {
|
public boolean canPotentiallyExecuteCommands() {
|
||||||
if (canPotentiallyExecuteCommands) {
|
if (canPotentiallyExecuteCommands != null) {
|
||||||
return true;
|
return canPotentiallyExecuteCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.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;
|
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType;
|
||||||
|
|
||||||
public interface FabricEntityTypeImpl {
|
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 {
|
interface Builder {
|
||||||
void fabric_setLivingEntityBuilder(Living<? extends LivingEntity> livingBuilder);
|
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);
|
public abstract EntityType<T> build(RegistryKey<EntityType<?>> registryKey);
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
|
@Nullable
|
||||||
private Boolean alwaysUpdateVelocity = null;
|
private Boolean alwaysUpdateVelocity = null;
|
||||||
@Unique
|
@Unique
|
||||||
|
@Nullable
|
||||||
private Boolean canPotentiallyExecuteCommands = null;
|
private Boolean canPotentiallyExecuteCommands = null;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package net.fabricmc.fabric.mixin.object.builder;
|
package net.fabricmc.fabric.mixin.object.builder;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -29,8 +30,10 @@ import net.fabricmc.fabric.impl.object.builder.FabricEntityTypeImpl;
|
||||||
@Mixin(EntityType.class)
|
@Mixin(EntityType.class)
|
||||||
public abstract class EntityTypeMixin implements FabricEntityTypeImpl {
|
public abstract class EntityTypeMixin implements FabricEntityTypeImpl {
|
||||||
@Unique
|
@Unique
|
||||||
|
@Nullable
|
||||||
private Boolean alwaysUpdateVelocity;
|
private Boolean alwaysUpdateVelocity;
|
||||||
@Unique
|
@Unique
|
||||||
|
@Nullable
|
||||||
private Boolean canPotentiallyExecuteCommands;
|
private Boolean canPotentiallyExecuteCommands;
|
||||||
|
|
||||||
@Inject(method = "alwaysUpdateVelocity", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "alwaysUpdateVelocity", at = @At("HEAD"), cancellable = true)
|
||||||
|
@ -48,12 +51,12 @@ public abstract class EntityTypeMixin implements FabricEntityTypeImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fabric_setAlwaysUpdateVelocity(Boolean alwaysUpdateVelocity) {
|
public void fabric_setAlwaysUpdateVelocity(@Nullable Boolean alwaysUpdateVelocity) {
|
||||||
this.alwaysUpdateVelocity = alwaysUpdateVelocity;
|
this.alwaysUpdateVelocity = alwaysUpdateVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fabric_setCanPotentiallyExecuteCommands(Boolean canPotentiallyExecuteCommands) {
|
public void fabric_setCanPotentiallyExecuteCommands(@Nullable Boolean canPotentiallyExecuteCommands) {
|
||||||
this.canPotentiallyExecuteCommands = canPotentiallyExecuteCommands;
|
this.canPotentiallyExecuteCommands = canPotentiallyExecuteCommands;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue