mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-17 23:48:00 +01:00
Update the thing for 1.20.4 changes
This commit is contained in:
parent
f091521e1b
commit
9bbbec3cf4
4 changed files with 47 additions and 18 deletions
|
@ -10,6 +10,7 @@ import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
|
|||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
||||
import net.minecraft.registry.tag.EntityTypeTags;
|
||||
|
||||
public class UEntityTypeTagProvider extends FabricTagProvider<EntityType<?>> {
|
||||
public UEntityTypeTagProvider(FabricDataOutput output, CompletableFuture<WrapperLookup> registriesFuture) {
|
||||
|
@ -40,5 +41,6 @@ public class UEntityTypeTagProvider extends FabricTagProvider<EntityType<?>> {
|
|||
EntityType.SALMON, EntityType.COD, EntityType.PUFFERFISH,
|
||||
EntityType.FROG
|
||||
);
|
||||
getOrCreateTagBuilder(EntityTypeTags.CAN_BREATHE_UNDER_WATER).add(UEntities.MIMIC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,11 +121,6 @@ public class MimicEntity extends PathAwareEntity {
|
|||
return isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreatheInWater() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack getPickBlockStack() {
|
||||
|
@ -262,7 +257,7 @@ public class MimicEntity extends PathAwareEntity {
|
|||
}
|
||||
|
||||
public ScreenHandler createScreenHandler(int syncId, PlayerInventory inv, PlayerEntity player) {
|
||||
chestData.checkLootInteraction(player);
|
||||
chestData.generateLoot(player);
|
||||
setChest(chestData);
|
||||
var inventory = InventoryUtil.copyInto(chestData, new SimpleInventory(chestData.size()) {
|
||||
@Override
|
||||
|
@ -399,5 +394,11 @@ public class MimicEntity extends PathAwareEntity {
|
|||
void setAllowMimics(boolean allowMimics);
|
||||
|
||||
void setMimic(boolean mimic);
|
||||
|
||||
void readMimicAttributes(NbtCompound nbt);
|
||||
|
||||
void writeMimicAttributes(NbtCompound nbt);
|
||||
|
||||
void configureMimic(@Nullable PlayerEntity player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.block.entity.LockableContainerBlockEntity;
|
|||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.LootableInventory;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -30,16 +31,23 @@ abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockE
|
|||
|
||||
MixinLootableContainerBlockEntity() { super(null, null, null); }
|
||||
|
||||
@Inject(method = "deserializeLootTable", at = @At("HEAD"))
|
||||
private void deserializeMimic(NbtCompound nbt, CallbackInfoReturnable<Boolean> info) {
|
||||
@Override
|
||||
public void readMimicAttributes(NbtCompound nbt) {
|
||||
isMimic = nbt.getBoolean("mimic");
|
||||
}
|
||||
|
||||
@Inject(method = "serializeLootTable", at = @At("HEAD"))
|
||||
private void serializeMimic(NbtCompound nbt, CallbackInfoReturnable<Boolean> info) {
|
||||
@Override
|
||||
public void writeMimicAttributes(NbtCompound nbt) {
|
||||
nbt.putBoolean("mimic", isMimic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureMimic(@Nullable PlayerEntity player) {
|
||||
if (player != null && allowMimics && lootTableId != null) {
|
||||
mimicLootTable = lootTableId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllowMimics(boolean allowMimics) {
|
||||
this.allowMimics = allowMimics;
|
||||
|
@ -53,18 +61,11 @@ abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockE
|
|||
markDirty();
|
||||
}
|
||||
|
||||
@Inject(method = "checkLootInteraction", at = @At("HEAD"))
|
||||
private void onCheckLootInteraction(@Nullable PlayerEntity player, CallbackInfo info) {
|
||||
if (player != null && allowMimics && lootTableId != null) {
|
||||
mimicLootTable = lootTableId;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "createMenu",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/block/entity/LootableContainerBlockEntity.checkLootInteraction(Lnet/minecraft/entity/player/PlayerEntity;)V",
|
||||
target = "net/minecraft/block/entity/LootableContainerBlockEntity.generateLoot(Lnet/minecraft/entity/player/PlayerEntity;)V",
|
||||
shift = Shift.AFTER
|
||||
), cancellable = true)
|
||||
private void onCreateMenu(int syncId, PlayerInventory playerInventory, PlayerEntity player, CallbackInfoReturnable<ScreenHandler> info) {
|
||||
|
@ -77,3 +78,27 @@ abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockE
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Mixin(LootableInventory.class)
|
||||
interface MixinLootableInventory {
|
||||
@Inject(method = "generateLoot", at = @At("HEAD"))
|
||||
default void onGenerateLoot(@Nullable PlayerEntity player, CallbackInfo info) {
|
||||
if (this instanceof MimicEntity.MimicGeneratable m) {
|
||||
m.configureMimic(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "readLootTable", at = @At("HEAD"))
|
||||
default void onReadLootTable(NbtCompound nbt, CallbackInfoReturnable<Boolean> info) {
|
||||
if (this instanceof MimicEntity.MimicGeneratable m) {
|
||||
m.readMimicAttributes(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "writeLootTable", at = @At("HEAD"))
|
||||
default void onWriteLootTable(NbtCompound nbt, CallbackInfoReturnable<Boolean> info) {
|
||||
if (this instanceof MimicEntity.MimicGeneratable m) {
|
||||
m.writeMimicAttributes(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
"MixinItemStack",
|
||||
"MixinLivingEntity",
|
||||
"MixinLootableContainerBlockEntity",
|
||||
"MixinLootableInventory",
|
||||
"MixinMilkBucketItem",
|
||||
"MixinMobEntity",
|
||||
"MixinPersistentProjectileEntity",
|
||||
|
|
Loading…
Reference in a new issue