mirror of
https://github.com/wisplite/crystalline-sky.git
synced 2026-10-30 13:32:18 -05:00
Multiloader VII
cleanup registration api
This commit is contained in:
+2
-2
@@ -8,7 +8,7 @@ public class RegistrationListeners<T> {
|
|||||||
private @Nullable T obj;
|
private @Nullable T obj;
|
||||||
private @Nullable Consumer<T> cons;
|
private @Nullable Consumer<T> cons;
|
||||||
|
|
||||||
public void registered(T obj) {
|
public synchronized void registered(T obj) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
if (cons != null) {
|
if (cons != null) {
|
||||||
cons.accept(obj);
|
cons.accept(obj);
|
||||||
@@ -16,7 +16,7 @@ public class RegistrationListeners<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(Consumer<? super T> consumer) {
|
public synchronized void addListener(Consumer<? super T> consumer) {
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
consumer.accept(obj);
|
consumer.accept(obj);
|
||||||
} else if (cons == null) {
|
} else if (cons == null) {
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceKey;
|
|||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class BlockHolder<T extends Block> extends ItemLikeHolder.NonItem<T> {
|
public class BlockHolder<T extends Block> extends ItemLikeHolder<T> {
|
||||||
public BlockHolder(HolderOwner<T> owner, ResourceKey<T> key) {
|
public BlockHolder(HolderOwner<T> owner, ResourceKey<T> key) {
|
||||||
super(owner, key);
|
super(owner, key);
|
||||||
}
|
}
|
||||||
|
|||||||
-5
@@ -8,9 +8,4 @@ public class ItemHolder<T extends Item> extends ItemLikeHolder<T> {
|
|||||||
public ItemHolder(HolderOwner<T> owner, ResourceKey<T> key) {
|
public ItemHolder(HolderOwner<T> owner, ResourceKey<T> key) {
|
||||||
super(owner, key);
|
super(owner, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(Item item) {
|
|
||||||
return asItem() == item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-12
@@ -23,21 +23,12 @@ abstract class ItemLikeHolder<T extends ItemLike> extends BaseHolder<T> implemen
|
|||||||
return is(stack.getItem());
|
return is(stack.getItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean is(Item item);
|
public boolean is(Item item) {
|
||||||
|
return asItem() == item;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item asItem() {
|
public Item asItem() {
|
||||||
return value().asItem();
|
return value().asItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NonItem<T extends ItemLike> extends ItemLikeHolder<T> {
|
|
||||||
protected NonItem(HolderOwner<T> owner, ResourceKey<T> key) {
|
|
||||||
super(owner, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(Item item) {
|
|
||||||
return asItem() == item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user