From 9f80c32edb70c2dc5d0982c093dc06f29cffbd41 Mon Sep 17 00:00:00 2001 From: Kitteh6660 Date: Fri, 31 May 2024 22:45:28 -0400 Subject: [PATCH] Fix many errors in API files --- .../thebetweenlands/api/IBetweenlandsAPI.java | 34 ++------ .../thebetweenlands/api/aspect/Aspect.java | 23 +++--- .../api/aspect/AspectContainer.java | 46 +++++------ .../api/aspect/AspectItem.java | 2 +- .../api/aspect/DiscoveryContainer.java | 67 ++++++++-------- .../api/aspect/IAspectType.java | 10 +-- .../api/aspect/ItemAspectContainer.java | 18 ++--- .../api/audio/IEntitySound.java | 6 +- .../api/block/IAspectFogBlock.java | 8 +- .../thebetweenlands/api/block/ICenser.java | 8 +- .../api/block/IDungeonFogBlock.java | 8 +- .../api/block/IFarmablePlant.java | 29 +++---- .../api/block/ISickleHarvestable.java | 10 +-- .../api/capability/IBlessingCapability.java | 5 +- .../IEntityCustomCollisionsCapability.java | 16 ++-- .../api/capability/IEquipmentCapability.java | 19 +++-- .../api/capability/IFlightCapability.java | 16 ++-- .../capability/IFoodSicknessCapability.java | 2 +- .../api/capability/ILastKilledCapability.java | 2 +- .../api/capability/IPuppetCapability.java | 4 +- .../api/capability/IPuppeteerCapability.java | 2 +- .../capability/IRuneChainUserCapability.java | 67 ++++++++++++++++ .../capability/ISerializableCapability.java | 6 +- .../thebetweenlands/api/entity/IBLBoss.java | 6 +- .../api/entity/IEntityCameraOffset.java | 2 +- .../entity/IEntityCustomBlockCollisions.java | 4 +- .../api/entity/IEntityMusic.java | 28 +++---- .../api/entity/IEntityPreventUnmount.java | 8 +- .../api/entity/IEntityScreenShake.java | 2 +- .../api/entity/IEntityWithLootModifier.java | 2 +- .../api/entity/IPullerEntity.java | 2 +- .../api/entity/IPullerEntityProvider.java | 2 +- .../api/entity/IRingOfGatheringMinion.java | 18 ++--- .../entity/ProcessedEntityCollisionBox.java | 16 ++-- .../entity/spawning/ICustomSpawnEntry.java | 24 +++--- .../api/environment/IEnvironmentEvent.java | 16 ++-- .../IEnvironmentEventRegistry.java | 6 +- .../IPredictableEnvironmentEvent.java | 4 +- .../api/event/ArmSwingSpeedEvent.java | 6 +- .../api/event/EquipmentChangedEvent.java | 2 +- .../api/event/SplashPotionEvent.java | 18 ++--- .../api/event/UpdateFogEvent.java | 16 ++-- .../api/item/CorrosionHelper.java | 79 +++++++++---------- .../api/item/IAnimatorRepairable.java | 2 +- .../thebetweenlands/api/item/ICorrodible.java | 39 ++++----- .../thebetweenlands/api/item/IDecayFood.java | 18 ++--- .../thebetweenlands/api/item/IEquippable.java | 32 ++++---- .../api/item/IExtendedReach.java | 6 +- .../api/item/IFoodSicknessItem.java | 12 +-- .../api/item/IRenamableItem.java | 18 +++-- .../thebetweenlands/api/item/IRuneItem.java | 21 +++++ .../api/item/IRuneletItem.java | 8 ++ .../api/loot/ISharedLootCondition.java | 9 ++- .../api/loot/ISharedLootContainer.java | 15 ++-- .../api/loot/ISharedLootPool.java | 9 ++- .../api/loot/LootTableView.java | 15 ++-- .../thebetweenlands/api/misc/FogState.java | 42 +++++----- .../network/IGenericDataManagerAccess.java | 20 ++--- .../thebetweenlands/api/package-info.java | 5 +- .../api/recipes/IAnimatorRecipe.java | 26 +++--- .../api/recipes/ICenserRecipe.java | 20 ++--- .../api/recipes/ICompostBinRecipe.java | 2 +- .../api/recipes/IDruidAltarRecipe.java | 20 ++--- .../api/recipes/IPestleAndMortarRecipe.java | 2 +- .../api/recipes/IPurifierRecipe.java | 4 +- .../api/sky/IBetweenlandsSky.java | 14 ++-- .../api/sky/IRiftMaskRenderer.java | 18 ++--- .../api/sky/IRiftRenderer.java | 20 ++--- .../api/sky/IRiftSkyRenderer.java | 18 ++--- .../api/storage/IChunkStorage.java | 24 +++--- .../storage/IDeferredStorageOperation.java | 6 +- .../api/storage/ILocalStorage.java | 43 +++++----- .../api/storage/ILocalStorageHandler.java | 17 ++-- .../storage/IOfflinePlayerDataHandler.java | 8 +- .../api/storage/IWorldStorage.java | 32 ++++---- .../api/storage/LocalRegion.java | 14 ++-- .../api/storage/LocalStorageReference.java | 24 +++--- .../api/storage/StorageID.java | 12 +-- 78 files changed, 665 insertions(+), 599 deletions(-) create mode 100644 src/main/java/thebetweenlands/api/capability/IRuneChainUserCapability.java create mode 100644 src/main/java/thebetweenlands/api/item/IRuneItem.java create mode 100644 src/main/java/thebetweenlands/api/item/IRuneletItem.java diff --git a/src/main/java/thebetweenlands/api/IBetweenlandsAPI.java b/src/main/java/thebetweenlands/api/IBetweenlandsAPI.java index 04fd03b66a..a836e53d7c 100644 --- a/src/main/java/thebetweenlands/api/IBetweenlandsAPI.java +++ b/src/main/java/thebetweenlands/api/IBetweenlandsAPI.java @@ -3,15 +3,10 @@ import java.util.List; import java.util.function.Predicate; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; import thebetweenlands.api.aspect.IAspectType; -import thebetweenlands.api.entity.IEntityMusic; -import thebetweenlands.api.entity.IEntityMusicProvider; import thebetweenlands.api.recipes.IAnimatorRecipe; import thebetweenlands.api.recipes.ICompostBinRecipe; import thebetweenlands.api.recipes.IDruidAltarRecipe; @@ -110,13 +105,13 @@ public interface IBetweenlandsAPI { * Registers an entity to be equippable with amulets * @param entity */ - public void registerAmuletSupportingEntity(Class entity); + public void registerAmuletSupportingEntity(Class entity); /** * Unregisters an entity from being equippable with amulets * @param entity */ - public void unregisterAmuletSupportingEntity(Class entity); + public void unregisterAmuletSupportingEntity(Class entity); /** * Adds an item to the overworld item whitelist @@ -154,23 +149,4 @@ public interface IBetweenlandsAPI { * @param aspectCount */ public void addStaticAspectsToItem(ItemStack item, IItemStackMatcher matcher, int tier, int group, float amountMultiplier, float amountVariation, int aspectCount); - - /** - * Registers an entity music provider which allows playing music around an entity or to change - * the music of a mob implementing {@link IEntityMusic} - * @param entityCls - * @param musicProvider - * @return ture if successful. May be false if a music provider has already been registered for the specified entity class - */ - @SideOnly(Side.CLIENT) - public boolean registerEntityMusicProvider(Class entityCls, IEntityMusicProvider musicProvider); - - /** - * Unregisters an entity music provider - * @param entityCls - * @param musicProvider - * @return - */ - @SideOnly(Side.CLIENT) - public boolean unregisterEntityMusicProvider(Class entityCls, IEntityMusicProvider musicProvider); } diff --git a/src/main/java/thebetweenlands/api/aspect/Aspect.java b/src/main/java/thebetweenlands/api/aspect/Aspect.java index 2325ea35f3..98d23e079e 100644 --- a/src/main/java/thebetweenlands/api/aspect/Aspect.java +++ b/src/main/java/thebetweenlands/api/aspect/Aspect.java @@ -3,16 +3,17 @@ import java.math.RoundingMode; import java.text.DecimalFormat; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import thebetweenlands.common.registries.AspectRegistry; public final class Aspect implements Comparable { - public static final DecimalFormat ASPECT_AMOUNT_FORMAT = new DecimalFormat("#.##"); + public static final DecimalFormat ASPECT_AMOUNT_FORMAT = new DecimalFormat("#.##"); + static { ASPECT_AMOUNT_FORMAT.setRoundingMode(RoundingMode.CEILING); } - + /** * The type of this aspect */ @@ -28,24 +29,24 @@ public Aspect(IAspectType aspect, int amount) { this.type = aspect; this.amount = amount; } - + public float getDisplayAmount() { return this.amount / 1000.0F; } - + public String getRoundedDisplayAmount() { - return ASPECT_AMOUNT_FORMAT.format(this.getDisplayAmount()); + return ASPECT_AMOUNT_FORMAT.format(this.getDisplayAmount() - 0.00001f); } - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setString("aspect", this.type.getName()); - nbt.setInteger("amount", this.amount); + public CompoundTag save(CompoundTag nbt) { + nbt.putString("aspect", this.type.getName()); + nbt.putInt("amount", this.amount); return nbt; } - public static Aspect readFromNBT(NBTTagCompound nbt) { + public static Aspect load(CompoundTag nbt) { String aspectName = nbt.getString("aspect"); - int amount = nbt.getInteger("amount"); + int amount = nbt.getInt("amount"); IAspectType aspectType = AspectRegistry.getAspectTypeFromName(aspectName); if(aspectType != null) { return new Aspect(aspectType, amount); diff --git a/src/main/java/thebetweenlands/api/aspect/AspectContainer.java b/src/main/java/thebetweenlands/api/aspect/AspectContainer.java index 49aa3550b1..fdad42baf8 100644 --- a/src/main/java/thebetweenlands/api/aspect/AspectContainer.java +++ b/src/main/java/thebetweenlands/api/aspect/AspectContainer.java @@ -12,9 +12,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; import thebetweenlands.common.registries.AspectRegistry; /** @@ -45,10 +45,10 @@ private Storage(IAspectType type, AspectContainer container) { * @param nbt * @return */ - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setInteger("dynamic", this.dynamicAmount); - nbt.setInteger("storedStatic", this.storedStaticAmount); - nbt.setBoolean("hasStoredStatic", this.hasStoredStaticAmount); + public CompoundTag save(CompoundTag nbt) { + nbt.putInt("dynamic", this.dynamicAmount); + nbt.putInt("storedStatic", this.storedStaticAmount); + nbt.putBoolean("hasStoredStatic", this.hasStoredStaticAmount); return nbt; } @@ -57,9 +57,9 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { * @param nbt * @return */ - public Storage readFromNBT(NBTTagCompound nbt) { - this.dynamicAmount = nbt.getInteger("dynamic"); - this.storedStaticAmount = nbt.getInteger("storedStatic"); + public Storage load(CompoundTag nbt) { + this.dynamicAmount = nbt.getInt("dynamic"); + this.storedStaticAmount = nbt.getInt("storedStatic"); this.hasStoredStaticAmount = nbt.getBoolean("hasStoredStatic"); return this; } @@ -263,8 +263,8 @@ public final boolean isEmpty() { * @param nbt * @return */ - public NBTTagCompound save(NBTTagCompound nbt) { - NBTTagList typesList = new NBTTagList(); + public CompoundTag save(CompoundTag nbt) { + ListTag typesList = new ListTag(); for(Entry entry : this.storage.entrySet()) { IAspectType type = entry.getKey(); Storage storage = entry.getValue(); @@ -274,13 +274,13 @@ public NBTTagCompound save(NBTTagCompound nbt) { continue; } - NBTTagCompound storageNbt = new NBTTagCompound(); - storageNbt.setTag("aspect", type.writeToNBT(new NBTTagCompound())); - storageNbt.setTag("storage", storage.writeToNBT(new NBTTagCompound())); + CompoundTag storageNbt = new CompoundTag(); + storageNbt.put("aspect", type.save(new CompoundTag())); + storageNbt.put("storage", storage.save(new CompoundTag())); - typesList.appendTag(storageNbt); + typesList.add(storageNbt); } - nbt.setTag("container", typesList); + nbt.put("container", typesList); return nbt; } @@ -290,15 +290,15 @@ public NBTTagCompound save(NBTTagCompound nbt) { * @param staticAspects * @return */ - public AspectContainer read(NBTTagCompound nbt) { - NBTTagList typesList = nbt.getTagList("container", Constants.NBT.TAG_COMPOUND); - for(int i = 0; i < typesList.tagCount(); i++) { - NBTTagCompound storageNbt = typesList.getCompoundTagAt(i); - IAspectType type = IAspectType.readFromNBT(storageNbt.getCompoundTag("aspect")); + public AspectContainer read(CompoundTag nbt) { + ListTag typesList = nbt.getList("container", Tag.TAG_COMPOUND); + for(int i = 0; i < typesList.size(); i++) { + CompoundTag storageNbt = typesList.getCompound(i); + IAspectType type = IAspectType.load(storageNbt.getCompound("aspect")); if(type == null) continue; Storage storage = this.getStorage(type); - storage.readFromNBT(storageNbt.getCompoundTag("storage")); + storage.load(storageNbt.getCompound("storage")); } return this; } diff --git a/src/main/java/thebetweenlands/api/aspect/AspectItem.java b/src/main/java/thebetweenlands/api/aspect/AspectItem.java index 621ff668f6..e478caff78 100644 --- a/src/main/java/thebetweenlands/api/aspect/AspectItem.java +++ b/src/main/java/thebetweenlands/api/aspect/AspectItem.java @@ -1,6 +1,6 @@ package thebetweenlands.api.aspect; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; import thebetweenlands.common.herblore.aspect.AspectManager; import thebetweenlands.common.herblore.aspect.IItemStackMatcher; diff --git a/src/main/java/thebetweenlands/api/aspect/DiscoveryContainer.java b/src/main/java/thebetweenlands/api/aspect/DiscoveryContainer.java index 06e815ffe2..3d6a3a6a1b 100644 --- a/src/main/java/thebetweenlands/api/aspect/DiscoveryContainer.java +++ b/src/main/java/thebetweenlands/api/aspect/DiscoveryContainer.java @@ -7,12 +7,13 @@ import java.util.Map; import java.util.Map.Entry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; import thebetweenlands.api.aspect.DiscoveryContainer.AspectDiscovery.EnumDiscoveryResult; import thebetweenlands.api.item.IDiscoveryProvider; import thebetweenlands.common.herblore.aspect.AspectManager; @@ -47,7 +48,7 @@ public static DiscoveryContainer empty() { * @param nbt * @return */ - public static DiscoveryContainer readFromNBT(NBTTagCompound nbt) { + public static DiscoveryContainer load(BlockState state, CompoundTag nbt) { DiscoveryContainer container = empty(); container.updateFromNBT(nbt, false); return container; @@ -162,8 +163,8 @@ private Aspect getUndiscoveredAspect(List all, List discove * Writes this discovery container to an NBT * @param nbt */ - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - NBTTagList discoveryList = new NBTTagList(); + public CompoundTag save(CompoundTag nbt) { + ListTag discoveryList = new ListTag(); Iterator>> discoveryIT = this.discoveredStaticAspects.entrySet().iterator(); while(discoveryIT.hasNext()) { Entry> e = discoveryIT.next(); @@ -171,16 +172,16 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { discoveryIT.remove(); continue; } - NBTTagCompound discoveryEntry = new NBTTagCompound(); + CompoundTag discoveryEntry = new CompoundTag(); AspectManager.writeAspectItemToNbt(e.getKey(), discoveryEntry); - NBTTagList aspectListCompound = new NBTTagList(); + ListTag aspectListCompound = new ListTag(); for(IAspectType type : e.getValue()) { - aspectListCompound.appendTag(type.writeToNBT(new NBTTagCompound())); + aspectListCompound.add(type.save(new CompoundTag())); } - discoveryEntry.setTag("aspects", aspectListCompound); - discoveryList.appendTag(discoveryEntry); + discoveryEntry.put("aspects", aspectListCompound); + discoveryList.add(discoveryEntry); } - nbt.setTag("discoveries", discoveryList); + nbt.put("discoveries", discoveryList); return nbt; } @@ -189,18 +190,18 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { * @param nbt * @return */ - public DiscoveryContainer updateFromNBT(NBTTagCompound nbt, boolean save) { + public DiscoveryContainer updateFromNBT(CompoundTag nbt, boolean save) { this.discoveredStaticAspects.clear(); - NBTTagList discoveryList = nbt.getTagList("discoveries", Constants.NBT.TAG_COMPOUND); - int discoveryEntries = discoveryList.tagCount(); + ListTag discoveryList = nbt.getList("discoveries", Tag.TAG_COMPOUND); + int discoveryEntries = discoveryList.size(); for (int i = 0; i < discoveryEntries; i++) { - NBTTagCompound discoveryEntry = discoveryList.getCompoundTagAt(i); + CompoundTag discoveryEntry = discoveryList.getCompound(i); AspectItem item = AspectManager.readAspectItemFromNBT(discoveryEntry); List aspectTypeList = new ArrayList(); - NBTTagList aspectListCompound = discoveryEntry.getTagList("aspects", Constants.NBT.TAG_COMPOUND); - for (int c = 0; c < aspectListCompound.tagCount(); c++) { - NBTTagCompound aspectTypeCompound = aspectListCompound.getCompoundTagAt(c); - aspectTypeList.add(IAspectType.readFromNBT(aspectTypeCompound)); + ListTag aspectListCompound = discoveryEntry.getList("aspects", Tag.TAG_COMPOUND); + for (int c = 0; c < aspectListCompound.size(); c++) { + CompoundTag aspectTypeCompound = aspectListCompound.getCompound(c); + aspectTypeList.add(IAspectType.load(aspectTypeCompound)); } this.discoveredStaticAspects.put(item, aspectTypeList); } @@ -277,10 +278,10 @@ public static enum EnumDiscoveryResult { * @param player * @return */ - public static boolean hasDiscoveryProvider(EntityPlayer player) { - InventoryPlayer inventory = player.inventory; - for(int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); + public static boolean hasDiscoveryProvider(Player player) { + Inventory inventory = player.getInventory(); + for(int i = 0; i < inventory.getContainerSize(); i++) { + ItemStack stack = inventory.getItem(i); if(!stack.isEmpty() && stack.getItem() instanceof IDiscoveryProvider) return true; } @@ -292,11 +293,11 @@ public static boolean hasDiscoveryProvider(EntityPlayer player) { * @param player * @return */ - public static List> getWritableDiscoveryContainers(EntityPlayer player) { + public static List> getWritableDiscoveryContainers(Player player) { List> containerList = new ArrayList>(); - InventoryPlayer inventory = player.inventory; - for(int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); + Inventory inventory = player.getInventory(); + for(int i = 0; i < inventory.getContainerSize(); i++) { + ItemStack stack = inventory.getItem(i); if(!stack.isEmpty() && stack.getItem() instanceof IDiscoveryProvider) { @SuppressWarnings("unchecked") IDiscoveryProvider provider = (IDiscoveryProvider) stack.getItem(); @@ -314,7 +315,7 @@ public static List> getWritableDiscoveryContainers(EntityP * @param player * @return */ - public static DiscoveryContainer getMergedDiscoveryContainer(EntityPlayer player) { + public static DiscoveryContainer getMergedDiscoveryContainer(Player player) { List> containerList = getWritableDiscoveryContainers(player); DiscoveryContainer merged = DiscoveryContainer.empty(); for(DiscoveryContainer container : containerList) { @@ -330,7 +331,7 @@ public static DiscoveryContainer getMergedDiscoveryContainer(EntityPlayer pla * @param item * @param type */ - public static void addDiscoveryToContainers(EntityPlayer player, AspectItem item, IAspectType type) { + public static void addDiscoveryToContainers(Player player, AspectItem item, IAspectType type) { List> discoveryContainers = getWritableDiscoveryContainers(player); for(DiscoveryContainer container : discoveryContainers) container.addDiscovery(item, type); diff --git a/src/main/java/thebetweenlands/api/aspect/IAspectType.java b/src/main/java/thebetweenlands/api/aspect/IAspectType.java index 075b6c5635..9b30896042 100644 --- a/src/main/java/thebetweenlands/api/aspect/IAspectType.java +++ b/src/main/java/thebetweenlands/api/aspect/IAspectType.java @@ -2,8 +2,8 @@ import javax.annotation.Nullable; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import thebetweenlands.common.registries.AspectRegistry; public interface IAspectType { @@ -42,8 +42,8 @@ public interface IAspectType { * @param nbt * @return */ - public default NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setString("type", this.getName()); + public default CompoundTag save(CompoundTag nbt) { + nbt.putString("type", this.getName()); return nbt; } @@ -53,7 +53,7 @@ public default NBTTagCompound writeToNBT(NBTTagCompound nbt) { * @return */ @Nullable - public static IAspectType readFromNBT(NBTTagCompound nbt) { + public static IAspectType load(CompoundTag nbt) { return AspectRegistry.getAspectTypeFromName(nbt.getString("type")); } } diff --git a/src/main/java/thebetweenlands/api/aspect/ItemAspectContainer.java b/src/main/java/thebetweenlands/api/aspect/ItemAspectContainer.java index 921d846791..d29ed5b2eb 100644 --- a/src/main/java/thebetweenlands/api/aspect/ItemAspectContainer.java +++ b/src/main/java/thebetweenlands/api/aspect/ItemAspectContainer.java @@ -8,9 +8,9 @@ import com.google.common.collect.ImmutableList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import thebetweenlands.common.herblore.aspect.AspectManager; public final class ItemAspectContainer extends AspectContainer { @@ -41,7 +41,7 @@ private ItemAspectContainer(AspectManager manager, ItemStack stack) { */ public static ItemAspectContainer fromItem(ItemStack stack, @Nullable AspectManager manager) { ItemAspectContainer container = new ItemAspectContainer(manager, stack); - NBTTagCompound aspectNbt = stack.getTagCompound() != null ? stack.getTagCompound().getCompoundTag(ASPECTS_NBT_TAG) : null; + CompoundTag aspectNbt = stack.getTag() != null ? stack.getTag().getCompound(ASPECTS_NBT_TAG) : null; if(aspectNbt != null) container.read(aspectNbt); return container; @@ -55,7 +55,7 @@ public static ItemAspectContainer fromItem(ItemStack stack, @Nullable AspectMana */ public static ItemAspectContainer fromItem(ItemStack stack) { ItemAspectContainer container = new ItemAspectContainer(null, stack); - NBTTagCompound aspectNbt = stack.getTagCompound() != null ? stack.getTagCompound().getCompoundTag(ASPECTS_NBT_TAG) : null; + CompoundTag aspectNbt = stack.getTag() != null ? stack.getTag().getCompound(ASPECTS_NBT_TAG) : null; if(aspectNbt != null) container.read(aspectNbt); return container; @@ -63,10 +63,10 @@ public static ItemAspectContainer fromItem(ItemStack stack) { @Override protected void onChanged() { - NBTTagCompound nbt = this.itemStack.getTagCompound(); + CompoundTag nbt = this.itemStack.getTag(); if(nbt == null) - this.itemStack.setTagCompound(nbt = new NBTTagCompound()); - nbt.setTag(ASPECTS_NBT_TAG, this.save(new NBTTagCompound())); + this.itemStack.setTag(nbt = new CompoundTag()); + nbt.put(ASPECTS_NBT_TAG, this.save(new CompoundTag())); } /** @@ -105,7 +105,7 @@ public List getAspects(DiscoveryContainer discoveries) { * @param player * @return */ - public List getAspects(EntityPlayer player) { + public List getAspects(Player player) { return this.getAspects(DiscoveryContainer.getMergedDiscoveryContainer(player)); } diff --git a/src/main/java/thebetweenlands/api/audio/IEntitySound.java b/src/main/java/thebetweenlands/api/audio/IEntitySound.java index 3999cb348b..86eb99a5db 100644 --- a/src/main/java/thebetweenlands/api/audio/IEntitySound.java +++ b/src/main/java/thebetweenlands/api/audio/IEntitySound.java @@ -1,9 +1,9 @@ package thebetweenlands.api.audio; -import net.minecraft.client.audio.ISound; -import net.minecraft.entity.Entity; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.world.entity.Entity; -public interface IEntitySound extends ISound { +public interface IEntitySound extends SoundInstance { public Entity getMusicEntity(); public void stopEntityMusic(); diff --git a/src/main/java/thebetweenlands/api/block/IAspectFogBlock.java b/src/main/java/thebetweenlands/api/block/IAspectFogBlock.java index a8563ef86a..fa64b5669d 100644 --- a/src/main/java/thebetweenlands/api/block/IAspectFogBlock.java +++ b/src/main/java/thebetweenlands/api/block/IAspectFogBlock.java @@ -2,12 +2,12 @@ import javax.annotation.Nullable; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.state.BlockState; import thebetweenlands.api.aspect.IAspectType; public interface IAspectFogBlock { @Nullable - public IAspectType getAspectFogType(IBlockAccess world, BlockPos pos, IBlockState state); + public IAspectType getAspectFogType(LevelAccessor world, BlockPos pos, BlockState state); } diff --git a/src/main/java/thebetweenlands/api/block/ICenser.java b/src/main/java/thebetweenlands/api/block/ICenser.java index 5eabbe32ca..69ca8790fc 100644 --- a/src/main/java/thebetweenlands/api/block/ICenser.java +++ b/src/main/java/thebetweenlands/api/block/ICenser.java @@ -1,11 +1,11 @@ package thebetweenlands.api.block; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public interface ICenser { - public World getCenserWorld(); + public Level getCenserWorld(); public BlockPos getCenserPos(); diff --git a/src/main/java/thebetweenlands/api/block/IDungeonFogBlock.java b/src/main/java/thebetweenlands/api/block/IDungeonFogBlock.java index 6a4e900f87..7113b96330 100644 --- a/src/main/java/thebetweenlands/api/block/IDungeonFogBlock.java +++ b/src/main/java/thebetweenlands/api/block/IDungeonFogBlock.java @@ -1,9 +1,9 @@ package thebetweenlands.api.block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.state.BlockState; public interface IDungeonFogBlock { - public boolean isCreatingDungeonFog(IBlockAccess world, BlockPos pos, IBlockState state); + public boolean isCreatingDungeonFog(LevelAccessor world, BlockPos pos, BlockState state); } diff --git a/src/main/java/thebetweenlands/api/block/IFarmablePlant.java b/src/main/java/thebetweenlands/api/block/IFarmablePlant.java index d0158c6179..869be5b3b3 100644 --- a/src/main/java/thebetweenlands/api/block/IFarmablePlant.java +++ b/src/main/java/thebetweenlands/api/block/IFarmablePlant.java @@ -2,9 +2,9 @@ import java.util.Random; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; public interface IFarmablePlant { /** @@ -14,7 +14,7 @@ public interface IFarmablePlant { * @param state * @return */ - public boolean isFarmable(World world, BlockPos pos, IBlockState state); + public boolean isFarmable(Level world, BlockPos pos, BlockState state); /** * Returns whether this plant can spread to the target position @@ -25,7 +25,7 @@ public interface IFarmablePlant { * @param rand * @return */ - public boolean canSpreadTo(World world, BlockPos pos, IBlockState state, BlockPos targetPos, Random rand); + public boolean canSpreadTo(Level world, BlockPos pos, BlockState state, BlockPos targetPos, Random rand); /** * Returns the spreading chance between 0 and 1 @@ -36,7 +36,7 @@ public interface IFarmablePlant { * @param rand * @return */ - public default float getSpreadChance(World world, BlockPos pos, IBlockState state, BlockPos targetPos, Random rand) { + public default float getSpreadChance(Level world, BlockPos pos, BlockState state, BlockPos targetPos, Random rand) { return 1; } @@ -48,7 +48,7 @@ public default float getSpreadChance(World world, BlockPos pos, IBlockState stat * @param rand * @return */ - public int getCompostCost(World world, BlockPos pos, IBlockState state, Random rand); + public int getCompostCost(Level world, BlockPos pos, BlockState state, Random rand); /** * Called when the plant is decaying @@ -57,7 +57,7 @@ public default float getSpreadChance(World world, BlockPos pos, IBlockState stat * @param state * @param rand */ - public void decayPlant(World world, BlockPos pos, IBlockState state, Random rand); + public void decayPlant(Level world, BlockPos pos, BlockState state, Random rand); /** * Spreads this plant to the specified target position @@ -67,16 +67,5 @@ public default float getSpreadChance(World world, BlockPos pos, IBlockState stat * @param targetPos * @param rand */ - public void spreadTo(World world, BlockPos pos, IBlockState state, BlockPos targetPos, Random rand); - - /** - * Returns whether this plant can be destroyed by rain - * @param world - * @param pos - * @param state - * @return - */ - public default boolean canBeDestroyedByPuddles(World world, BlockPos pos, IBlockState state) { - return false; - } + public void spreadTo(Level world, BlockPos pos, BlockState state, BlockPos targetPos, Random rand); } diff --git a/src/main/java/thebetweenlands/api/block/ISickleHarvestable.java b/src/main/java/thebetweenlands/api/block/ISickleHarvestable.java index 597e0892a8..0bf6027a4d 100644 --- a/src/main/java/thebetweenlands/api/block/ISickleHarvestable.java +++ b/src/main/java/thebetweenlands/api/block/ISickleHarvestable.java @@ -2,9 +2,9 @@ import java.util.List; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.LevelAccessor; public interface ISickleHarvestable { /** @@ -14,7 +14,7 @@ public interface ISickleHarvestable { * @param pos * @return */ - public boolean isHarvestable(ItemStack item, IBlockAccess world, BlockPos pos); + public boolean isHarvestable(ItemStack item, LevelAccessor world, BlockPos pos); /** * Returns the drops from harvesting this block with a sickle @@ -24,5 +24,5 @@ public interface ISickleHarvestable { * @param fortune * @return */ - public List getHarvestableDrops(ItemStack item, IBlockAccess world, BlockPos pos, int fortune); + public List getHarvestableDrops(ItemStack item, LevelAccessor world, BlockPos pos, int fortune); } \ No newline at end of file diff --git a/src/main/java/thebetweenlands/api/capability/IBlessingCapability.java b/src/main/java/thebetweenlands/api/capability/IBlessingCapability.java index 00a0497a61..74fc205988 100644 --- a/src/main/java/thebetweenlands/api/capability/IBlessingCapability.java +++ b/src/main/java/thebetweenlands/api/capability/IBlessingCapability.java @@ -2,7 +2,8 @@ import javax.annotation.Nullable; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public interface IBlessingCapability { public boolean isBlessed(); @@ -10,7 +11,7 @@ public interface IBlessingCapability { @Nullable public BlockPos getBlessingLocation(); - public int getBlessingDimension(); + public Level getBlessingDimension(); public void setBlessed(int dimension, BlockPos location); diff --git a/src/main/java/thebetweenlands/api/capability/IEntityCustomCollisionsCapability.java b/src/main/java/thebetweenlands/api/capability/IEntityCustomCollisionsCapability.java index 109a0caa3c..9649b8effc 100644 --- a/src/main/java/thebetweenlands/api/capability/IEntityCustomCollisionsCapability.java +++ b/src/main/java/thebetweenlands/api/capability/IEntityCustomCollisionsCapability.java @@ -4,10 +4,10 @@ import javax.annotation.Nullable; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos.MutableBlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; public interface IEntityCustomCollisionsCapability { @FunctionalInterface @@ -15,7 +15,7 @@ public static interface EntityCollisionPredicate { public static EntityCollisionPredicate ALL = (entity, aabb, otherEntity, otherAabb) -> true; public static EntityCollisionPredicate NONE = (entity, aabb, otherEntity, otherAabb) -> false; - public boolean isColliding(Entity entity, AxisAlignedBB aabb, Entity otherEntity, AxisAlignedBB otherAabb); + public boolean isColliding(Entity entity, AABB aabb, Entity otherEntity, AABB otherAabb); } @FunctionalInterface @@ -23,15 +23,15 @@ public static interface BlockCollisionPredicate { public static EntityCollisionPredicate ALL = (entity, aabb, pos, state) -> true; public static EntityCollisionPredicate NONE = (entity, aabb, pos, state) -> false; - public boolean isColliding(Entity entity, AxisAlignedBB aabb, MutableBlockPos pos, IBlockState state, @Nullable AxisAlignedBB blockAabb); + public boolean isColliding(Entity entity, AABB aabb, MutableBlockPos pos, BlockState state, @Nullable AABB blockAabb); } @FunctionalInterface public static interface CollisionBoxHelper { - public void getCollisionBoxes(Entity entity, AxisAlignedBB aabb, EntityCollisionPredicate entityPredicate, BlockCollisionPredicate blockPredicate, List collisionBoxes); + public void getBlockCollisions(Entity entity, AABB aabb, EntityCollisionPredicate entityPredicate, BlockCollisionPredicate blockPredicate, List collisionBoxes); } - public void getCustomCollisionBoxes(CollisionBoxHelper collisionBoxHelper, AxisAlignedBB aabb, List collisionBoxes); + public void getCustomCollisionBoxes(CollisionBoxHelper collisionBoxHelper, AABB aabb, List collisionBoxes); public boolean isPhasing(); diff --git a/src/main/java/thebetweenlands/api/capability/IEquipmentCapability.java b/src/main/java/thebetweenlands/api/capability/IEquipmentCapability.java index e9350732e3..82d2321f4d 100644 --- a/src/main/java/thebetweenlands/api/capability/IEquipmentCapability.java +++ b/src/main/java/thebetweenlands/api/capability/IEquipmentCapability.java @@ -2,11 +2,10 @@ import javax.annotation.Nonnull; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ITickable; +import net.minecraft.world.Container; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import thebetweenlands.api.item.IEquippable; import thebetweenlands.common.capability.equipment.EnumEquipmentInventory; import thebetweenlands.common.capability.equipment.EquipmentHelper; @@ -21,14 +20,14 @@ public interface IEquipmentCapability { *
  • For any item that extends {@link IEquippable}: *
      *
    • If an item that extends {@link IEquippable} - * is added, {@link IEquippable#onEquip(ItemStack, Entity, IInventory)} should be invoked. + * is added, {@link IEquippable#onEquip(ItemStack, Entity, Container)} should be invoked. *
    • *
    • * If an item that extends {@link IEquippable} - * is removed, {@link IEquippable#onUnequip(ItemStack, Entity, IInventory)} should be invoked. + * is removed, {@link IEquippable#onUnequip(ItemStack, Entity, Container)} should be invoked. *
    • *
    • - * {@link IEquippable#onEquipmentTick(ItemStack, Entity, IInventory)} should be invoked every tick + * {@link IEquippable#onEquipmentTick(ItemStack, Entity, Container)} should be invoked every tick * for items in an equipment inventory. *
    • *
    @@ -36,13 +35,13 @@ public interface IEquipmentCapability { * *

    * {@link EquipmentHelper} provides some helper functions: - * {@link EquipmentHelper#equipItem(EntityPlayer, Entity, ItemStack)}, {@link EquipmentHelper#unequipItem(EntityPlayer, Entity)} and + * {@link EquipmentHelper#equipItem(Player, Entity, ItemStack)}, {@link EquipmentHelper#unequipItem(Player, Entity)} and * {@link EquipmentHelper#unequipItem(Entity, EnumEquipmentInventory, int)} * @param inventory * @return */ @Nonnull - public IInventory getInventory(EnumEquipmentInventory inventory); + public Container getInventory(EnumEquipmentInventory inventory); /** * Returns how many amulets can be equipped diff --git a/src/main/java/thebetweenlands/api/capability/IFlightCapability.java b/src/main/java/thebetweenlands/api/capability/IFlightCapability.java index b62353c32b..87eeaba4a6 100644 --- a/src/main/java/thebetweenlands/api/capability/IFlightCapability.java +++ b/src/main/java/thebetweenlands/api/capability/IFlightCapability.java @@ -1,7 +1,7 @@ package thebetweenlands.api.capability; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import thebetweenlands.common.item.equipment.ItemRing; public interface IFlightCapability { @@ -47,8 +47,8 @@ public interface IFlightCapability { * @param ring * @return */ - public default boolean canFlyWithRing(EntityPlayer player, ItemStack ring) { - return (player.experienceTotal > 0 || player.experience > 0 || player.experienceLevel > 0) && !player.isRiding(); + public default boolean canFlyWithRing(Player player, ItemStack ring) { + return (player.totalExperience > 0 || player.experienceProgress > 0 || player.experienceLevel > 0) && player.getVehicle() != null; } /** @@ -57,8 +57,8 @@ public default boolean canFlyWithRing(EntityPlayer player, ItemStack ring) { * @param stack * @return */ - public default boolean canFlyWithoutRing(EntityPlayer player) { - return player.capabilities.isCreativeMode || player.isSpectator(); + public default boolean canFlyWithoutRing(Player player) { + return player.isCreative() || player.isSpectator(); } /** @@ -66,8 +66,8 @@ public default boolean canFlyWithoutRing(EntityPlayer player) { * @param player * @param ring */ - public default void onFlightTick(EntityPlayer player, ItemStack ring, boolean firstTick) { - if(!player.world.isRemote && (firstTick || player.ticksExisted % 20 == 0)) { + public default void onFlightTick(Player player, ItemStack ring, boolean firstTick) { + if(!player.level().isClientSide() && (firstTick || player.tickCount % 20 == 0)) { ItemRing.removeXp(player, 2); } } diff --git a/src/main/java/thebetweenlands/api/capability/IFoodSicknessCapability.java b/src/main/java/thebetweenlands/api/capability/IFoodSicknessCapability.java index e28c02b99d..54996255f6 100644 --- a/src/main/java/thebetweenlands/api/capability/IFoodSicknessCapability.java +++ b/src/main/java/thebetweenlands/api/capability/IFoodSicknessCapability.java @@ -1,6 +1,6 @@ package thebetweenlands.api.capability; -import net.minecraft.item.Item; +import net.minecraft.world.item.Item; import thebetweenlands.common.capability.foodsickness.FoodSickness; public interface IFoodSicknessCapability { diff --git a/src/main/java/thebetweenlands/api/capability/ILastKilledCapability.java b/src/main/java/thebetweenlands/api/capability/ILastKilledCapability.java index cfbd40a885..b841db13b9 100644 --- a/src/main/java/thebetweenlands/api/capability/ILastKilledCapability.java +++ b/src/main/java/thebetweenlands/api/capability/ILastKilledCapability.java @@ -2,7 +2,7 @@ import javax.annotation.Nullable; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public interface ILastKilledCapability { public void setLastKilled(@Nullable ResourceLocation key); diff --git a/src/main/java/thebetweenlands/api/capability/IPuppetCapability.java b/src/main/java/thebetweenlands/api/capability/IPuppetCapability.java index a24e0b27ec..aeec51c92f 100644 --- a/src/main/java/thebetweenlands/api/capability/IPuppetCapability.java +++ b/src/main/java/thebetweenlands/api/capability/IPuppetCapability.java @@ -4,8 +4,8 @@ import javax.annotation.Nullable; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; public interface IPuppetCapability { /** diff --git a/src/main/java/thebetweenlands/api/capability/IPuppeteerCapability.java b/src/main/java/thebetweenlands/api/capability/IPuppeteerCapability.java index bed9291adf..edd4abb972 100644 --- a/src/main/java/thebetweenlands/api/capability/IPuppeteerCapability.java +++ b/src/main/java/thebetweenlands/api/capability/IPuppeteerCapability.java @@ -4,7 +4,7 @@ import javax.annotation.Nullable; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; public interface IPuppeteerCapability { /** diff --git a/src/main/java/thebetweenlands/api/capability/IRuneChainUserCapability.java b/src/main/java/thebetweenlands/api/capability/IRuneChainUserCapability.java new file mode 100644 index 0000000000..c144fcf2de --- /dev/null +++ b/src/main/java/thebetweenlands/api/capability/IRuneChainUserCapability.java @@ -0,0 +1,67 @@ +package thebetweenlands.api.capability; + +import javax.annotation.Nullable; + +import net.minecraft.world.level.block.entity.TickingBlockEntity; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import thebetweenlands.api.runechain.IRuneChainUser; +import thebetweenlands.api.runechain.chain.IRuneChain; +import thebetweenlands.api.runechain.chain.IRuneChainData; + +public interface IRuneChainUserCapability extends TickingBlockEntity { + /** + * Returns the rune chain user instance of the thing this capability is attached to + * @return Rune chain user instance of the thing this capability is attached to + */ + public IRuneChainUser getUser(); + + /** + * Adds a rune chain instance to this capability and assigns it a unique ID + * @param chain Data to create the rune chain from + * @return Unique ID assigned to the rune chain instance + */ + public int addRuneChain(IRuneChainData data); + + /** + * Adds a rune chain instance synced over the network to this capability + * @param chain Rune chain instance to add to this capability + * @param id Unique ID to be assigned to the rune chain instance + */ + @OnlyIn(Dist.CLIENT) + public void addRuneChain(IRuneChain chain, int id); + + /** + * Sets whether the rune chain should automatically be updated by the capability holder + * @param id ID that was assigned to the rune chain instance + * @param updating Whether the rune chain should automatically be updated + * @param removeOnFinish Whether the rune chain should automatically be removed from this capability once {@link IRuneChain#isRunning()} returns false. Only works if + * updating is true. The rune chain must already be running otherwise it will be removed immediately in the first update. + * @return True if updating was successfully set, false otherwise (i.e. when no rune chain instance exists with the specified ID) + */ + public boolean setUpdating(int id, boolean updating, boolean removeOnFinish); + + /** + * Updates all updating rune chains in this capability + */ + @Override + public void tick(); + + /** + * Removes the rune chain instance with the specified ID + * @param id ID that was assigned to the rune chain instance that is to be removed + * @return Rune chain instance that was removed, or null if this capability did not + * contain a rune chain instance with the specified ID + */ + @Nullable + public IRuneChain removeRuneChain(int id); + + /** + * Returns the rune chain instance with the specified ID + * @param id ID that was assigned to the rune chain instance + * @return Rune chain instance with the specified ID, or null if this capability does + * not contain a rune chain instance with the specified ID + */ + @Nullable + public IRuneChain getRuneChain(int id); +} diff --git a/src/main/java/thebetweenlands/api/capability/ISerializableCapability.java b/src/main/java/thebetweenlands/api/capability/ISerializableCapability.java index 88f378c1d9..cc675e4525 100644 --- a/src/main/java/thebetweenlands/api/capability/ISerializableCapability.java +++ b/src/main/java/thebetweenlands/api/capability/ISerializableCapability.java @@ -1,6 +1,6 @@ package thebetweenlands.api.capability; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; /** * Capabilities can implement this interface to save/load data to/from NBT @@ -10,11 +10,11 @@ public interface ISerializableCapability { * Writes the data to the nbt * @param nbt */ - public void writeToNBT(NBTTagCompound nbt); + public void save(CompoundTag nbt); /** * Reads the data from the nbt * @param nbt */ - public void readFromNBT(NBTTagCompound nbt); + public void load(CompoundTag nbt); } diff --git a/src/main/java/thebetweenlands/api/entity/IBLBoss.java b/src/main/java/thebetweenlands/api/entity/IBLBoss.java index 92ade59336..69082b2d37 100644 --- a/src/main/java/thebetweenlands/api/entity/IBLBoss.java +++ b/src/main/java/thebetweenlands/api/entity/IBLBoss.java @@ -2,7 +2,7 @@ import java.util.UUID; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.Vec3i; public interface IBLBoss { public UUID getBossInfoUuid(); @@ -15,7 +15,7 @@ public default float getMiniBossTagSize(float partialTicks) { return 0.5F; } - public default Vec3d getMiniBossTagOffset(float partialTicks) { - return Vec3d.ZERO; + public default Vec3i getMiniBossTagOffset(float partialTicks) { + return Vec3i.ZERO; } } diff --git a/src/main/java/thebetweenlands/api/entity/IEntityCameraOffset.java b/src/main/java/thebetweenlands/api/entity/IEntityCameraOffset.java index e5ddc73d5b..a10a74af6b 100644 --- a/src/main/java/thebetweenlands/api/entity/IEntityCameraOffset.java +++ b/src/main/java/thebetweenlands/api/entity/IEntityCameraOffset.java @@ -1,6 +1,6 @@ package thebetweenlands.api.entity; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; public interface IEntityCameraOffset { public boolean applyOffset(Entity view, float partialTicks); diff --git a/src/main/java/thebetweenlands/api/entity/IEntityCustomBlockCollisions.java b/src/main/java/thebetweenlands/api/entity/IEntityCustomBlockCollisions.java index 40e29f0aa1..1da52317bf 100644 --- a/src/main/java/thebetweenlands/api/entity/IEntityCustomBlockCollisions.java +++ b/src/main/java/thebetweenlands/api/entity/IEntityCustomBlockCollisions.java @@ -2,8 +2,8 @@ import java.util.List; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.phys.AABB; public interface IEntityCustomBlockCollisions { - public void getCustomCollisionBoxes(AxisAlignedBB aabb, List collisionBoxes); + public void getCustomCollisionBoxes(AABB aabb, List collisionBoxes); } diff --git a/src/main/java/thebetweenlands/api/entity/IEntityMusic.java b/src/main/java/thebetweenlands/api/entity/IEntityMusic.java index 21c632bc24..36e8ff7ae1 100644 --- a/src/main/java/thebetweenlands/api/entity/IEntityMusic.java +++ b/src/main/java/thebetweenlands/api/entity/IEntityMusic.java @@ -2,37 +2,31 @@ import javax.annotation.Nullable; -import net.minecraft.client.audio.ISound.AttenuationType; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import thebetweenlands.api.audio.IEntitySound; -import thebetweenlands.client.audio.EntityMusicSound; +import net.minecraft.world.entity.player.Player; import thebetweenlands.common.sound.BLSoundEvent; +//TODO: Determine if this need updating. public interface IEntityMusic { @Nullable @Deprecated - public BLSoundEvent getMusicFile(EntityPlayer listener); + public BLSoundEvent getMusicFile(Player listener); - public double getMusicRange(EntityPlayer listener); + public double getMusicRange(Player listener); - public boolean isMusicActive(EntityPlayer listener); + public boolean isMusicActive(Player listener); - @SideOnly(Side.CLIENT) + /*@OnlyIn(Dist.CLIENT) @Nullable - public default IEntitySound getMusicSound(EntityPlayer listener) { + public default IEntitySound getMusicSound(Player listener) { BLSoundEvent sound = this.getMusicFile(listener); - return new EntityMusicSound(sound, SoundCategory.MUSIC, (Entity) this, this, 1, AttenuationType.NONE); - } + return new EntityMusicSound>(sound, SoundSource.MUSIC, (Entity) this, 1, Attenuation.NONE); + }*/ - public default int getMusicLayer(EntityPlayer listener) { + public default int getMusicLayer(Player listener) { return 0; } - public default boolean canInterruptOtherEntityMusic(EntityPlayer listener) { + public default boolean canInterruptOtherEntityMusic(Player listener) { return true; } } diff --git a/src/main/java/thebetweenlands/api/entity/IEntityPreventUnmount.java b/src/main/java/thebetweenlands/api/entity/IEntityPreventUnmount.java index 683a01a9ab..bdf89c41b1 100644 --- a/src/main/java/thebetweenlands/api/entity/IEntityPreventUnmount.java +++ b/src/main/java/thebetweenlands/api/entity/IEntityPreventUnmount.java @@ -1,6 +1,6 @@ package thebetweenlands.api.entity; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.entity.player.Player; public interface IEntityPreventUnmount { /** @@ -8,14 +8,14 @@ public interface IEntityPreventUnmount { * @param rider * @return */ - public boolean isUnmountBlocked(EntityPlayer rider); + public boolean isUnmountBlocked(Player rider); /** * Returns whether the unmount status bar text should be prevented * @param rider * @return */ - public default boolean shouldPreventStatusBarText(EntityPlayer rider) { + public default boolean shouldPreventStatusBarText(Player rider) { return true; } @@ -24,7 +24,7 @@ public default boolean shouldPreventStatusBarText(EntityPlayer rider) { * This may not necessarily be called during the player's update. * @param rider */ - public default void onUnmountBlocked(EntityPlayer rider) { + public default void onUnmountBlocked(Player rider) { } } diff --git a/src/main/java/thebetweenlands/api/entity/IEntityScreenShake.java b/src/main/java/thebetweenlands/api/entity/IEntityScreenShake.java index 892b4f89a3..ff808e09a0 100644 --- a/src/main/java/thebetweenlands/api/entity/IEntityScreenShake.java +++ b/src/main/java/thebetweenlands/api/entity/IEntityScreenShake.java @@ -1,6 +1,6 @@ package thebetweenlands.api.entity; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; public interface IEntityScreenShake { @Deprecated diff --git a/src/main/java/thebetweenlands/api/entity/IEntityWithLootModifier.java b/src/main/java/thebetweenlands/api/entity/IEntityWithLootModifier.java index b8c4258e7b..da3a60fc49 100644 --- a/src/main/java/thebetweenlands/api/entity/IEntityWithLootModifier.java +++ b/src/main/java/thebetweenlands/api/entity/IEntityWithLootModifier.java @@ -4,7 +4,7 @@ import javax.annotation.Nullable; -import net.minecraft.world.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootContext; public interface IEntityWithLootModifier { /** diff --git a/src/main/java/thebetweenlands/api/entity/IPullerEntity.java b/src/main/java/thebetweenlands/api/entity/IPullerEntity.java index 6dd0becdf4..45e700636c 100644 --- a/src/main/java/thebetweenlands/api/entity/IPullerEntity.java +++ b/src/main/java/thebetweenlands/api/entity/IPullerEntity.java @@ -2,7 +2,7 @@ import javax.annotation.Nullable; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; import thebetweenlands.common.entity.draeton.DraetonPhysicsPart; import thebetweenlands.common.entity.draeton.EntityDraeton; diff --git a/src/main/java/thebetweenlands/api/entity/IPullerEntityProvider.java b/src/main/java/thebetweenlands/api/entity/IPullerEntityProvider.java index 1951d8a95a..05c5d828e4 100644 --- a/src/main/java/thebetweenlands/api/entity/IPullerEntityProvider.java +++ b/src/main/java/thebetweenlands/api/entity/IPullerEntityProvider.java @@ -2,7 +2,7 @@ import javax.annotation.Nullable; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; import thebetweenlands.common.entity.draeton.DraetonPhysicsPart; import thebetweenlands.common.entity.draeton.EntityDraeton; diff --git a/src/main/java/thebetweenlands/api/entity/IRingOfGatheringMinion.java b/src/main/java/thebetweenlands/api/entity/IRingOfGatheringMinion.java index 9c2ef79536..5ffa5e4a3a 100644 --- a/src/main/java/thebetweenlands/api/entity/IRingOfGatheringMinion.java +++ b/src/main/java/thebetweenlands/api/entity/IRingOfGatheringMinion.java @@ -4,9 +4,9 @@ import javax.annotation.Nullable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityTameable; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.TamableAnimal; public interface IRingOfGatheringMinion { /** @@ -17,7 +17,7 @@ public interface IRingOfGatheringMinion { * @param nbt NBT returned by {@link #returnToRing(UUID)} * @return */ - public boolean returnFromRing(Entity user, NBTTagCompound nbt); + public boolean returnFromRing(Entity user, CompoundTag nbt); /** * Called when the entity should be teleported back to the user @@ -25,7 +25,7 @@ public interface IRingOfGatheringMinion { * @return */ public default void returnToCall(Entity user) { - ((Entity) this).setPosition(user.posX, user.posY, user.posZ); + ((Entity) this).setPos(user.getX(), user.getY(), user.getZ()); } /** @@ -35,8 +35,8 @@ public default void returnToCall(Entity user) { * @param userId * @return */ - public default NBTTagCompound returnToRing(UUID userId) { - return new NBTTagCompound(); + public default CompoundTag returnToRing(UUID userId) { + return new CompoundTag(); } @Nullable @@ -52,7 +52,7 @@ public default boolean shouldReturnOnUnload(boolean isOwnerLoggedIn) { } public default boolean shouldReturnOnCall() { - if(this instanceof EntityTameable && ((EntityTameable)this).isSitting()) { + if(this instanceof TamableAnimal && ((TamableAnimal)this).isOrderedToSit()) { return false; } return true; @@ -64,7 +64,7 @@ public default boolean shouldReturnOnCall() { * @return */ public default boolean isRespawnedByAnimator() { - return !((Entity) this).isEntityAlive(); + return !((Entity) this).isAlive(); } public default int getAnimatorLifeCrystalCost() { diff --git a/src/main/java/thebetweenlands/api/entity/ProcessedEntityCollisionBox.java b/src/main/java/thebetweenlands/api/entity/ProcessedEntityCollisionBox.java index 8db5492493..9970401a4d 100644 --- a/src/main/java/thebetweenlands/api/entity/ProcessedEntityCollisionBox.java +++ b/src/main/java/thebetweenlands/api/entity/ProcessedEntityCollisionBox.java @@ -2,12 +2,12 @@ import javax.annotation.Nullable; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; -public abstract class ProcessedEntityCollisionBox extends AxisAlignedBB { +public abstract class ProcessedEntityCollisionBox extends AABB { private final T entity; public ProcessedEntityCollisionBox(T entity, BlockPos pos) { @@ -25,12 +25,12 @@ public ProcessedEntityCollisionBox(T entity, double x1, double y1, double z1, do this.entity = entity; } - public ProcessedEntityCollisionBox(T entity, Vec3d min, Vec3d max) { + public ProcessedEntityCollisionBox(T entity, Vec3 min, Vec3 max) { super(min, max); this.entity = entity; } - public ProcessedEntityCollisionBox(T entity, AxisAlignedBB other) { + public ProcessedEntityCollisionBox(T entity, AABB other) { super(other.minX, other.minY, other.minZ, other.maxX, other.maxY, other.maxZ); this.entity = entity; } @@ -40,5 +40,5 @@ public T getEntity() { } @Nullable - public abstract AxisAlignedBB process(@Nullable Entity other, AxisAlignedBB otherAabb); + public abstract AABB process(@Nullable Entity other, AABB otherAabb); } diff --git a/src/main/java/thebetweenlands/api/entity/spawning/ICustomSpawnEntry.java b/src/main/java/thebetweenlands/api/entity/spawning/ICustomSpawnEntry.java index 0941c8f115..37e9f70320 100644 --- a/src/main/java/thebetweenlands/api/entity/spawning/ICustomSpawnEntry.java +++ b/src/main/java/thebetweenlands/api/entity/spawning/ICustomSpawnEntry.java @@ -1,12 +1,12 @@ package thebetweenlands.api.entity.spawning; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.LevelChunk; public interface ICustomSpawnEntry extends IWeightProvider { /** @@ -28,7 +28,7 @@ public interface ICustomSpawnEntry extends IWeightProvider { * @param blockState The block where the entity will spawn * @param surfaceBlockState The block below where the entity will spawn */ - public boolean canSpawn(World world, Chunk chunk, BlockPos pos, IBlockState blockState, IBlockState surfaceBlockState); + public boolean canSpawn(Level world, LevelChunk chunk, BlockPos pos, BlockState blockState, BlockState surfaceBlockState); /** * Updates the spawning data based on the spawning position @@ -36,7 +36,7 @@ public interface ICustomSpawnEntry extends IWeightProvider { * @param pos * @return */ - public void update(World world, BlockPos pos); + public void update(Level world, BlockPos pos); /** * Returns the weight of this spawn entry @@ -194,17 +194,17 @@ public interface ICustomSpawnEntry extends IWeightProvider { * @param world * @return */ - public EntityLiving createEntity(World world); + public Mob createEntity(Level world); /** * Returns the entity type * @return */ - public Class getEntityType(); + public Class getEntityType(); /** * Called when the entity is spawned * @param entity */ - public void onSpawned(EntityLivingBase entity); + public void onSpawned(LivingEntity entity); } diff --git a/src/main/java/thebetweenlands/api/environment/IEnvironmentEvent.java b/src/main/java/thebetweenlands/api/environment/IEnvironmentEvent.java index 664d30f15a..388300cf7e 100644 --- a/src/main/java/thebetweenlands/api/environment/IEnvironmentEvent.java +++ b/src/main/java/thebetweenlands/api/environment/IEnvironmentEvent.java @@ -2,9 +2,9 @@ import javax.annotation.Nullable; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import thebetweenlands.api.network.IGenericDataManagerAccess; public interface IEnvironmentEvent { @@ -12,7 +12,7 @@ public interface IEnvironmentEvent { * Returns the world * @return */ - public World getWorld(); + public Level getLevel(); /** * Returns whether this event is currently active @@ -54,25 +54,25 @@ public interface IEnvironmentEvent { * Called every world tick. * @param rnd */ - public void update(World world); + public void update(Level world); /** * Returns the NBT data of this event. * @return */ - public NBTTagCompound getData(); + public CompoundTag getData(); /** * Saves the event data. * @param compound */ - public void writeToNBT(NBTTagCompound compound); + public void save(CompoundTag compound); /** * Loads the event data. * @param compound */ - public void readFromNBT(NBTTagCompound compound); + public void load(CompoundTag compound); /** * Sets the default values when the event is first loaded from the save file. diff --git a/src/main/java/thebetweenlands/api/environment/IEnvironmentEventRegistry.java b/src/main/java/thebetweenlands/api/environment/IEnvironmentEventRegistry.java index a602c145d2..83f157ecef 100644 --- a/src/main/java/thebetweenlands/api/environment/IEnvironmentEventRegistry.java +++ b/src/main/java/thebetweenlands/api/environment/IEnvironmentEventRegistry.java @@ -5,8 +5,8 @@ import javax.annotation.Nullable; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; public interface IEnvironmentEventRegistry { /** @@ -26,7 +26,7 @@ public interface IEnvironmentEventRegistry { * Returns the world this environment event registry belongs to * @return */ - public World getWorld(); + public Level getLevel(); /** * Returns an unmodifiable map of all registered environment events diff --git a/src/main/java/thebetweenlands/api/environment/IPredictableEnvironmentEvent.java b/src/main/java/thebetweenlands/api/environment/IPredictableEnvironmentEvent.java index 59bfc19cec..bae3c3396e 100644 --- a/src/main/java/thebetweenlands/api/environment/IPredictableEnvironmentEvent.java +++ b/src/main/java/thebetweenlands/api/environment/IPredictableEnvironmentEvent.java @@ -7,8 +7,8 @@ import com.google.common.collect.ImmutableList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; public interface IPredictableEnvironmentEvent extends IEnvironmentEvent { /** diff --git a/src/main/java/thebetweenlands/api/event/ArmSwingSpeedEvent.java b/src/main/java/thebetweenlands/api/event/ArmSwingSpeedEvent.java index 79361744fd..5644382d1a 100644 --- a/src/main/java/thebetweenlands/api/event/ArmSwingSpeedEvent.java +++ b/src/main/java/thebetweenlands/api/event/ArmSwingSpeedEvent.java @@ -1,14 +1,14 @@ package thebetweenlands.api.event; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; @Cancelable public class ArmSwingSpeedEvent extends LivingEvent { private float speed; - public ArmSwingSpeedEvent(EntityLivingBase living) { + public ArmSwingSpeedEvent(LivingEntity living) { super(living); this.speed = 1.0F; } diff --git a/src/main/java/thebetweenlands/api/event/EquipmentChangedEvent.java b/src/main/java/thebetweenlands/api/event/EquipmentChangedEvent.java index 5c4950ea0d..d6eff3e90d 100644 --- a/src/main/java/thebetweenlands/api/event/EquipmentChangedEvent.java +++ b/src/main/java/thebetweenlands/api/event/EquipmentChangedEvent.java @@ -1,6 +1,6 @@ package thebetweenlands.api.event; -import net.minecraft.entity.Entity; +import net.minecraft.world.entity.Entity; import net.minecraftforge.event.entity.EntityEvent; import thebetweenlands.api.capability.IEquipmentCapability; diff --git a/src/main/java/thebetweenlands/api/event/SplashPotionEvent.java b/src/main/java/thebetweenlands/api/event/SplashPotionEvent.java index a26e8e2ed0..a3f7cca8bf 100644 --- a/src/main/java/thebetweenlands/api/event/SplashPotionEvent.java +++ b/src/main/java/thebetweenlands/api/event/SplashPotionEvent.java @@ -1,10 +1,10 @@ package thebetweenlands.api.event; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.potion.PotionEffect; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * This event is fired when a splash potion tries to apply its splash potion effects to an entitiy @@ -12,11 +12,11 @@ @Cancelable public class SplashPotionEvent extends EntityEvent { private final Entity potion; - private final EntityLivingBase target; - private final PotionEffect effect; + private final LivingEntity target; + private final MobEffect effect; private final boolean instant; - public SplashPotionEvent(Entity potion, EntityLivingBase target, PotionEffect effect, boolean instant) { + public SplashPotionEvent(Entity potion, LivingEntity target, MobEffect effect, boolean instant) { super(potion); this.potion = potion; this.target = target; @@ -28,11 +28,11 @@ public Entity getSplashPotionEntity() { return this.potion; } - public EntityLivingBase getTarget() { + public LivingEntity getTarget() { return this.target; } - public PotionEffect getPotionEffect() { + public MobEffect getPotionEffect() { return this.effect; } diff --git a/src/main/java/thebetweenlands/api/event/UpdateFogEvent.java b/src/main/java/thebetweenlands/api/event/UpdateFogEvent.java index c55b068899..87fd1d0723 100644 --- a/src/main/java/thebetweenlands/api/event/UpdateFogEvent.java +++ b/src/main/java/thebetweenlands/api/event/UpdateFogEvent.java @@ -1,8 +1,8 @@ package thebetweenlands.api.event; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; +import net.minecraftforge.eventbus.api.Event; import thebetweenlands.api.misc.Fog; import thebetweenlands.api.misc.FogState; @@ -10,11 +10,11 @@ public class UpdateFogEvent extends Event { private FogState state; private Fog biomeFog; private Fog ambientFog; - private World world; - private Vec3d position; + private Level world; + private Vec3i position; private float farPlaneDistance; - public UpdateFogEvent(FogState state, Fog biomeFog, Fog ambientFog, Vec3d position, World world, float farPlaneDistance) { + public UpdateFogEvent(FogState state, Fog biomeFog, Fog ambientFog, Vec3i position, Level world, float farPlaneDistance) { this.state = state; this.biomeFog = biomeFog; this.ambientFog = ambientFog; @@ -35,7 +35,7 @@ public float getFarPlaneDistance() { * Returns the position * @return */ - public Vec3d getPosition() { + public Vec3i getPosition() { return this.position; } @@ -43,7 +43,7 @@ public Vec3d getPosition() { * Returns the world * @return */ - public World getWorld() { + public Level getLevel() { return this.world; } diff --git a/src/main/java/thebetweenlands/api/item/CorrosionHelper.java b/src/main/java/thebetweenlands/api/item/CorrosionHelper.java index 1f2aab50b2..961ce96eb4 100644 --- a/src/main/java/thebetweenlands/api/item/CorrosionHelper.java +++ b/src/main/java/thebetweenlands/api/item/CorrosionHelper.java @@ -6,21 +6,24 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.Entity; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; import thebetweenlands.api.capability.IDecayCapability; import thebetweenlands.common.config.BetweenlandsConfig; import thebetweenlands.common.registries.CapabilityRegistry; +import thebetweenlands.common.registries.DimensionRegistry; import thebetweenlands.common.registries.GameruleRegistry; import thebetweenlands.util.NBTHelper; @@ -72,7 +75,7 @@ public static float getModifier(ItemStack stack) { * @param blockState * @return */ - public static float getDestroySpeed(float normalStrength, ItemStack itemStack, IBlockState blockState) { + public static float getDestroySpeed(float normalStrength, ItemStack itemStack, BlockState blockState) { return normalStrength * getModifier(itemStack); } @@ -84,7 +87,7 @@ public static float getDestroySpeed(float normalStrength, ItemStack itemStack, I * @return */ public static boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { - return !(newStack.getItem() == oldStack.getItem() && areItemStackTagsEqual(newStack, oldStack) && (newStack.isItemStackDamageable() || newStack.getMetadata() == oldStack.getMetadata())); + return !(newStack.getItem() == oldStack.getItem() && areItemStackTagsEqual(newStack, oldStack) && (newStack.isDamageableItem() || newStack.getTag().equals(oldStack.getTag()))); } /** @@ -95,7 +98,7 @@ public static boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack n * @return */ public static boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { - return !(newStack.getItem() == oldStack.getItem() && areItemStackTagsEqual(newStack, oldStack) && (newStack.isItemStackDamageable() || newStack.getMetadata() == oldStack.getMetadata())); + return !(newStack.getItem() == oldStack.getItem() && areItemStackTagsEqual(newStack, oldStack) && (newStack.isDamageableItem() || newStack.getTag().equals(oldStack.getTag()))); } /** @@ -118,10 +121,10 @@ public static boolean areItemStackTagsEqual(ItemStack oldStack, ItemStack newSta * @param damageVsEntity * @return */ - public static Multimap getAttributeModifiers(Multimap map, EntityEquipmentSlot slot, ItemStack stack, UUID uuid, float damageVsEntity) { - if(slot == EntityEquipmentSlot.MAINHAND) { - map.removeAll(SharedMonsterAttributes.ATTACK_DAMAGE.getName()); - map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(uuid, "Tool modifier", damageVsEntity * getModifier(stack), 0)); + public static Multimap getAttributeModifiers(Multimap map, EquipmentSlot slot, ItemStack stack, UUID uuid, float damageVsEntity) { + if(slot == EquipmentSlot.MAINHAND) { + map.removeAll(Attributes.ATTACK_DAMAGE.getRegistryName()); + map.put(Attributes.ATTACK_DAMAGE.getRegistryName().toString(), new AttributeModifier(uuid, "Tool modifier", damageVsEntity * getModifier(stack), AttributeModifier.Operation.ADDITION)); } return map; } @@ -142,11 +145,11 @@ public static boolean isCorrosionEnabled() { * @param slot * @param isHeldItem */ - public static void updateCorrosion(ItemStack stack, World world, Entity holder, int slot, boolean isHeldItem) { - if (world.isRemote) { + public static void updateCorrosion(ItemStack stack, Level world, Entity holder, EquipmentSlot slot, boolean isHeldItem) { + if (world.isClientSide()) { return; } - if(!world.isRemote && holder.dimension == BetweenlandsConfig.WORLD_AND_DIMENSION.dimensionId && !(holder instanceof EntityPlayer && ((EntityPlayer)holder).isCreative())) { + if (!world.isClientSide() && holder.level().dimensionTypeId() == DimensionRegistry.BETWEENLANDS && !(holder instanceof Player && ((Player)holder).isCreative())) { if(!stack.isEmpty() && stack.getItem() instanceof ICorrodible) { ICorrodible corrodible = (ICorrodible) stack.getItem(); int corrosion = corrodible.getCorrosion(stack); @@ -156,16 +159,16 @@ public static void updateCorrosion(ItemStack stack, World world, Entity holder, } } else if (corrosion < corrodible.getMaxCorrosion(stack)) { float probability = holder.isInWater() ? 0.0014F : 0.0007F; - if (holder instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) holder; - probability *= (isHeldItem && !player.getActiveItemStack().isEmpty() ? 2.8F : 1.0F); - IDecayCapability cap = player.getCapability(CapabilityRegistry.CAPABILITY_DECAY, null); + if (holder instanceof Player) { + Player player = (Player) holder; + probability *= (isHeldItem && !player.getMainHandItem().isEmpty() ? 2.8F : 1.0F); + IDecayCapability cap = (IDecayCapability) player.getCapability(CapabilityRegistry.CAPABILITY_DECAY, null); if(cap != null) { float playerCorruption = cap.getDecayStats().getDecayLevel() / 20.0F; probability *= (1 - Math.pow(playerCorruption, 2) * 0.9F); } } - if (world.rand.nextFloat() < probability) { + if (world.random.nextFloat() < probability) { int coating = corrodible.getCoating(stack); if(coating > 0) { corrodible.setCoating(stack, coating - 1); @@ -184,33 +187,29 @@ public static void updateCorrosion(ItemStack stack, World world, Entity holder, * @param lines * @param advancedItemTooltips */ - public static void addCorrosionTooltips(ItemStack stack, List lines, boolean advancedItemTooltips) { + public static void addCorrosionTooltips(ItemStack stack, List lines, boolean advancedItemTooltips) { if(!stack.isEmpty() && stack.getItem() instanceof ICorrodible) { ICorrodible corrodible = (ICorrodible) stack.getItem(); if(isCorrosionEnabled()) { StringBuilder corrosionInfo = new StringBuilder("tooltip.bl.corrosion."); corrosionInfo.append(getCorrosionStage(stack)); - corrosionInfo.replace(0, corrosionInfo.length(), I18n.format(corrosionInfo.toString())); + corrosionInfo.replace(0, corrosionInfo.length(), I18n.get(corrosionInfo.toString())); + lines.add(Component.translatable(corrosionInfo.toString())); if (advancedItemTooltips) { - corrosionInfo.append(" ("); - corrosionInfo.append(corrodible.getCorrosion(stack)); - corrosionInfo.append("/" + corrodible.getMaxCorrosion(stack) + ")"); + lines.add(Component.literal(" (" + corrodible + "/" + corrodible.getMaxCorrosion(stack) + ")")); } - lines.add(corrosionInfo.toString()); } int coating = corrodible.getCoating(stack); if(coating > 0 || advancedItemTooltips) { StringBuilder coatingInfo = new StringBuilder("tooltip.bl.coated."); coatingInfo.append(getCoatingStage(stack)); - coatingInfo.replace(0, coatingInfo.length(), I18n.format(coatingInfo.toString())); + coatingInfo.replace(0, coatingInfo.length(), I18n.get(coatingInfo.toString())); + lines.add(Component.translatable(coatingInfo.toString())); if (advancedItemTooltips) { - coatingInfo.append(" ("); - coatingInfo.append(coating); - coatingInfo.append("/" + corrodible.getMaxCoating(stack) + ")"); + lines.add(Component.literal(" (" + coating + "/" + corrodible.getMaxCoating(stack) + ")")); } - lines.add(coatingInfo.toString()); } } } @@ -225,7 +224,7 @@ public static int getCorrosionStage(ItemStack stack) { ICorrodible corrodible = (ICorrodible) stack.getItem(); int maxCorrosion = corrodible.getMaxCorrosion(stack); int corrosion = corrodible.getCorrosion(stack); - return Math.min(5, MathHelper.floor(corrosion / (float)maxCorrosion * 6)); + return Math.min(5, Mth.floor(corrosion / (float)maxCorrosion * 6)); } return 0; } @@ -240,7 +239,7 @@ public static int getCoatingStage(ItemStack stack) { ICorrodible corrodible = (ICorrodible) stack.getItem(); int maxCoating = corrodible.getMaxCoating(stack); int coating = corrodible.getCoating(stack); - return Math.min(5, MathHelper.floor(coating / (float)maxCoating * 6)); + return Math.min(5, Mth.floor(coating / (float)maxCoating * 6)); } return 0; } diff --git a/src/main/java/thebetweenlands/api/item/IAnimatorRepairable.java b/src/main/java/thebetweenlands/api/item/IAnimatorRepairable.java index e0f2ed5c9b..b3ad1026d9 100644 --- a/src/main/java/thebetweenlands/api/item/IAnimatorRepairable.java +++ b/src/main/java/thebetweenlands/api/item/IAnimatorRepairable.java @@ -1,6 +1,6 @@ package thebetweenlands.api.item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; public interface IAnimatorRepairable { /** diff --git a/src/main/java/thebetweenlands/api/item/ICorrodible.java b/src/main/java/thebetweenlands/api/item/ICorrodible.java index 3b9610a8de..ea51b02a13 100644 --- a/src/main/java/thebetweenlands/api/item/ICorrodible.java +++ b/src/main/java/thebetweenlands/api/item/ICorrodible.java @@ -2,13 +2,14 @@ import javax.annotation.Nullable; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.registries.ForgeRegistries; import thebetweenlands.util.NBTHelper; public interface ICorrodible { @@ -16,7 +17,7 @@ public interface ICorrodible { * Returns an array of item variants that use a corroded texture * @return */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) @Nullable default ResourceLocation[] getCorrodibleVariants() { return null; @@ -31,7 +32,7 @@ default ResourceLocation[] getCorrodibleVariants() { public static ResourceLocation[] getItemCorrodibleVariants(I item) { ResourceLocation[] variants = item.getCorrodibleVariants(); if (variants == null) { - return new ResourceLocation[] { item.getRegistryName() }; + return new ResourceLocation[] { ForgeRegistries.ITEMS.getKey(item) }; } return variants; } @@ -60,9 +61,9 @@ default int getMaxCorrosion(ItemStack stack) { * @return */ default int getCoating(ItemStack stack) { - NBTTagCompound nbt = stack.getTagCompound(); - if(nbt != null && nbt.hasKey(CorrosionHelper.ITEM_COATING_NBT_TAG, Constants.NBT.TAG_INT)) { - return nbt.getInteger(CorrosionHelper.ITEM_COATING_NBT_TAG); + CompoundTag nbt = stack.getTag(); + if(nbt != null && nbt.contains(CorrosionHelper.ITEM_COATING_NBT_TAG, Tag.TAG_INT)) { + return nbt.getInt(CorrosionHelper.ITEM_COATING_NBT_TAG); } return 0; } @@ -73,9 +74,9 @@ default int getCoating(ItemStack stack) { * @return */ default int getCorrosion(ItemStack stack) { - NBTTagCompound nbt = stack.getTagCompound(); - if(nbt != null && nbt.hasKey(CorrosionHelper.ITEM_CORROSION_NBT_TAG, Constants.NBT.TAG_INT)) { - return nbt.getInteger(CorrosionHelper.ITEM_CORROSION_NBT_TAG); + CompoundTag nbt = stack.getTag(); + if(nbt != null && nbt.contains(CorrosionHelper.ITEM_CORROSION_NBT_TAG, Tag.TAG_INT)) { + return nbt.getInt(CorrosionHelper.ITEM_CORROSION_NBT_TAG); } return 0; } @@ -86,8 +87,8 @@ default int getCorrosion(ItemStack stack) { * @param coating */ default void setCoating(ItemStack stack, int coating) { - NBTTagCompound nbt = NBTHelper.getStackNBTSafe(stack); - nbt.setInteger(CorrosionHelper.ITEM_COATING_NBT_TAG, coating); + CompoundTag nbt = NBTHelper.getStackNBTSafe(stack); + nbt.putInt(CorrosionHelper.ITEM_COATING_NBT_TAG, coating); } /** @@ -96,7 +97,7 @@ default void setCoating(ItemStack stack, int coating) { * @param corrosion */ default void setCorrosion(ItemStack stack, int corrosion) { - NBTTagCompound nbt = NBTHelper.getStackNBTSafe(stack); - nbt.setInteger(CorrosionHelper.ITEM_CORROSION_NBT_TAG, corrosion); + CompoundTag nbt = NBTHelper.getStackNBTSafe(stack); + nbt.putInt(CorrosionHelper.ITEM_CORROSION_NBT_TAG, corrosion); } } diff --git a/src/main/java/thebetweenlands/api/item/IDecayFood.java b/src/main/java/thebetweenlands/api/item/IDecayFood.java index 9851f06d71..979b093825 100644 --- a/src/main/java/thebetweenlands/api/item/IDecayFood.java +++ b/src/main/java/thebetweenlands/api/item/IDecayFood.java @@ -4,12 +4,12 @@ import javax.annotation.Nullable; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.level.Level; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IDecayFood { /** @@ -35,8 +35,8 @@ default float getDecayHealSaturation(ItemStack stack) { * @param list * @param flag */ - @SideOnly(Side.CLIENT) - default void getDecayFoodTooltip(ItemStack stack, @Nullable World worldIn, List list, ITooltipFlag flag) { - list.add(I18n.format("tooltip.bl.decay_food", stack.getDisplayName())); + @OnlyIn(Dist.CLIENT) + default void getDecayFoodTooltip(ItemStack stack, @Nullable Level worldIn, List list, TooltipFlag flag) { + list.add(I18n.get("tooltip.bl.decay_food", stack.getDisplayName())); } } diff --git a/src/main/java/thebetweenlands/api/item/IEquippable.java b/src/main/java/thebetweenlands/api/item/IEquippable.java index 8474759378..1343e91e46 100644 --- a/src/main/java/thebetweenlands/api/item/IEquippable.java +++ b/src/main/java/thebetweenlands/api/item/IEquippable.java @@ -2,12 +2,12 @@ import javax.annotation.Nullable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import thebetweenlands.api.capability.IEquipmentCapability; import thebetweenlands.common.capability.equipment.EnumEquipmentInventory; import thebetweenlands.common.registries.CapabilityRegistry; @@ -27,7 +27,7 @@ public interface IEquippable { * @param target Entity that will be equipped * @return */ - public boolean canEquipOnRightClick(ItemStack stack, EntityPlayer player, Entity target); + public boolean canEquipOnRightClick(ItemStack stack, Player player, Entity target); /** * Returns whether this item can be equipped @@ -36,7 +36,7 @@ public interface IEquippable { * @param target Entity that will be equipped * @return */ - public boolean canEquip(ItemStack stack, @Nullable EntityPlayer player, Entity target); + public boolean canEquip(ItemStack stack, @Nullable Player player, Entity target); /** * Returns whether this item can be unequipped by a player @@ -46,7 +46,7 @@ public interface IEquippable { * @param inventory Equipment inventory * @return */ - public boolean canUnequip(ItemStack stack, @Nullable EntityPlayer player, Entity target, IInventory inventory); + public boolean canUnequip(ItemStack stack, @Nullable Player player, Entity target, Container inventory); /** * Returns whether this item can drop on death @@ -55,7 +55,7 @@ public interface IEquippable { * @param inventory Equipment inventory * @return */ - public boolean canDrop(ItemStack stack, Entity entity, IInventory inventory); + public boolean canDrop(ItemStack stack, Entity entity, Container inventory); /** * Called when an item is equipped @@ -63,7 +63,7 @@ public interface IEquippable { * @param entity Entity that is being equipped * @param inventory Equipment inventory */ - public void onEquip(ItemStack stack, Entity entity, IInventory inventory); + public void onEquip(ItemStack stack, Entity entity, Container inventory); /** * Called when an item is unequipped @@ -71,14 +71,14 @@ public interface IEquippable { * @param entity Entity that is being unequipped * @param inventory Equipment inventory */ - public void onUnequip(ItemStack stack, Entity entity, IInventory inventory); + public void onUnequip(ItemStack stack, Entity entity, Container inventory); /** * Called when the equipment is ticked * @param stack * @param entity */ - public void onEquipmentTick(ItemStack stack, Entity entity, IInventory inventory); + public void onEquipmentTick(ItemStack stack, Entity entity, Container inventory); /** * Adds the equipped property overrides to the specified item @@ -89,9 +89,9 @@ public static void addEquippedPropertyOverrides(Item item) { if(stack.getItem() instanceof IEquippable && entity != null) { IEquipmentCapability cap = entity.getCapability(CapabilityRegistry.CAPABILITY_EQUIPMENT, null); if (cap != null) { - IInventory inv = cap.getInventory(((IEquippable) stack.getItem()).getEquipmentCategory(stack)); - for (int i = 0; i < inv.getSizeInventory(); i++) { - if (stack == inv.getStackInSlot(i)) { + Container inv = cap.getInventory(((IEquippable) stack.getItem()).getEquipmentCategory(stack)); + for (int i = 0; i < inv.getContainerSize(); i++) { + if (stack == inv.getItem(i)) { return 1; } } diff --git a/src/main/java/thebetweenlands/api/item/IExtendedReach.java b/src/main/java/thebetweenlands/api/item/IExtendedReach.java index f9e0744326..fde572f903 100644 --- a/src/main/java/thebetweenlands/api/item/IExtendedReach.java +++ b/src/main/java/thebetweenlands/api/item/IExtendedReach.java @@ -1,7 +1,7 @@ package thebetweenlands.api.item; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; public interface IExtendedReach { @@ -11,7 +11,7 @@ public interface IExtendedReach { */ double getReach(); - default void onLeftClick(EntityPlayer player, ItemStack stack) { + default void onLeftClick(Player player, ItemStack stack) { } } diff --git a/src/main/java/thebetweenlands/api/item/IFoodSicknessItem.java b/src/main/java/thebetweenlands/api/item/IFoodSicknessItem.java index 9e457931df..ec02a5bfe0 100644 --- a/src/main/java/thebetweenlands/api/item/IFoodSicknessItem.java +++ b/src/main/java/thebetweenlands/api/item/IFoodSicknessItem.java @@ -4,9 +4,9 @@ import javax.annotation.Nullable; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import thebetweenlands.common.capability.foodsickness.FoodSickness; import thebetweenlands.common.handler.FoodSicknessHandler; @@ -17,8 +17,8 @@ public interface IFoodSicknessItem { * @param stack * @return */ - default boolean canGetSickOf(@Nullable EntityPlayer player, ItemStack stack) { - return player != null ? FoodSicknessHandler.isFoodSicknessEnabled(player.getEntityWorld()) : false; + default boolean canGetSickOf(@Nullable Player player, ItemStack stack) { + return player != null ? FoodSicknessHandler.isFoodSicknessEnabled(player.level()) : false; } /** @@ -35,6 +35,6 @@ default void getSicknessTooltip(ItemStack stack, FoodSickness sickness, int hatr if(advancedTooltips) { debug = " (" + hatred + "/" + sickness.maxHatred + ")"; } - toolTip.add(I18n.format("tooltip.bl.food_sickness.state." + sickness.name().toLowerCase()) + debug); + toolTip.add(I18n.get("tooltip.bl.food_sickness.state." + sickness.name().toLowerCase()) + debug); } } diff --git a/src/main/java/thebetweenlands/api/item/IRenamableItem.java b/src/main/java/thebetweenlands/api/item/IRenamableItem.java index 527e62ef34..39686f5af7 100644 --- a/src/main/java/thebetweenlands/api/item/IRenamableItem.java +++ b/src/main/java/thebetweenlands/api/item/IRenamableItem.java @@ -1,19 +1,21 @@ package thebetweenlands.api.item; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHand; +import net.minecraft.network.chat.Component; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; public interface IRenamableItem { - public default boolean canRename(EntityPlayer player, EnumHand hand, ItemStack stack, String name) { + + public default boolean canRename(Player player, InteractionHand hand, ItemStack stack, String name) { return true; } - public default void setRename(EntityPlayer player, EnumHand hand, ItemStack stack, String name) { - stack.setStackDisplayName(name); + public default void setRename(Player player, InteractionHand hand, ItemStack stack, String name) { + stack.setHoverName(Component.literal(name)); } - public default void clearRename(EntityPlayer player, EnumHand hand, ItemStack stack, String name) { - stack.clearCustomName(); + public default void clearRename(Player player, InteractionHand hand, ItemStack stack, String name) { + stack.resetHoverName(); } } diff --git a/src/main/java/thebetweenlands/api/item/IRuneItem.java b/src/main/java/thebetweenlands/api/item/IRuneItem.java new file mode 100644 index 0000000000..1f7c62427a --- /dev/null +++ b/src/main/java/thebetweenlands/api/item/IRuneItem.java @@ -0,0 +1,21 @@ +package thebetweenlands.api.item; + +import javax.annotation.Nullable; + +import net.minecraft.world.item.ItemStack; +import thebetweenlands.api.aspect.IAspectType; +import thebetweenlands.api.runechain.rune.RuneCategory; +import thebetweenlands.api.runechain.rune.RuneTier; + +public interface IRuneItem { + public RuneCategory getRuneCategory(ItemStack stack); + + public default int getInfusionCost(ItemStack stack, IAspectType type, RuneTier tier) { + return 100; + } + + public ItemStack infuse(ItemStack stack, IAspectType type, RuneTier tier); + + @Nullable + public IAspectType getInfusedAspect(ItemStack stack); +} diff --git a/src/main/java/thebetweenlands/api/item/IRuneletItem.java b/src/main/java/thebetweenlands/api/item/IRuneletItem.java new file mode 100644 index 0000000000..ab378cc565 --- /dev/null +++ b/src/main/java/thebetweenlands/api/item/IRuneletItem.java @@ -0,0 +1,8 @@ +package thebetweenlands.api.item; + +import net.minecraft.world.item.ItemStack; +import thebetweenlands.api.runechain.rune.RuneCategory; + +public interface IRuneletItem { + public ItemStack carve(ItemStack stack, RuneCategory category); +} diff --git a/src/main/java/thebetweenlands/api/loot/ISharedLootCondition.java b/src/main/java/thebetweenlands/api/loot/ISharedLootCondition.java index b991b5f2ec..24ebf5028b 100644 --- a/src/main/java/thebetweenlands/api/loot/ISharedLootCondition.java +++ b/src/main/java/thebetweenlands/api/loot/ISharedLootCondition.java @@ -2,11 +2,12 @@ import java.util.Random; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.conditions.LootCondition; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -public interface ISharedLootCondition extends LootCondition { +public interface ISharedLootCondition extends LootItemCondition { + public default boolean testCondition(Random rand, LootContext context, ISharedLootPool pool) { - return this.testCondition(rand, context); + return this.testCondition(rand, context, pool); } } diff --git a/src/main/java/thebetweenlands/api/loot/ISharedLootContainer.java b/src/main/java/thebetweenlands/api/loot/ISharedLootContainer.java index b890616d98..30d8ea68aa 100644 --- a/src/main/java/thebetweenlands/api/loot/ISharedLootContainer.java +++ b/src/main/java/thebetweenlands/api/loot/ISharedLootContainer.java @@ -2,14 +2,13 @@ import javax.annotation.Nullable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.ILootContainer; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.entity.player.Player; import thebetweenlands.api.storage.StorageID; -import thebetweenlands.common.world.storage.SharedLootPoolStorage; +import thebetweenlands.common.loot.shared.SharedLootPool; -public interface ISharedLootContainer extends ILootContainer, IInventory { +public interface ISharedLootContainer extends Container { @Nullable public StorageID getSharedLootPoolStorageID(); @@ -17,7 +16,7 @@ public interface ISharedLootContainer extends ILootContainer, IInventory { public void removeLootTable(); - public boolean fillInventoryWithLoot(@Nullable EntityPlayer player); + public boolean fillInventoryWithLoot(@Nullable Player player); /** * Sets the shared loot table of this loot container and registers/links it to the specified @@ -26,5 +25,5 @@ public interface ISharedLootContainer extends ILootContainer, IInventory { * @param lootTable * @param lootTableSeed */ - public void setSharedLootTable(SharedLootPoolStorage storage, ResourceLocation lootTable, long lootTableSeed); + public void setSharedLootTable(SharedLootPool storage, ResourceLocation lootTable, long lootTableSeed); } diff --git a/src/main/java/thebetweenlands/api/loot/ISharedLootPool.java b/src/main/java/thebetweenlands/api/loot/ISharedLootPool.java index 0290a4932d..72846e5071 100644 --- a/src/main/java/thebetweenlands/api/loot/ISharedLootPool.java +++ b/src/main/java/thebetweenlands/api/loot/ISharedLootPool.java @@ -4,8 +4,8 @@ import javax.annotation.Nullable; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.LootTable; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.loot.LootTable; public interface ISharedLootPool { /** @@ -27,7 +27,8 @@ public interface ISharedLootPool { * @return */ public long getLootTableSeed(); - + + //TODO: Determine if this should be re-added somehow. /** * Returns a loot table view of this shared loot pool * that allows retrieving items from the shared loot pool. @@ -37,7 +38,7 @@ public interface ISharedLootPool { * the shared pool! * @return */ - public LootTableView getLootTableView(); + //public LootTableView getLootTableView(); /** * Returns how many items of the specified loot entry in the diff --git a/src/main/java/thebetweenlands/api/loot/LootTableView.java b/src/main/java/thebetweenlands/api/loot/LootTableView.java index 63ae8a8eaf..b2436b3ca2 100644 --- a/src/main/java/thebetweenlands/api/loot/LootTableView.java +++ b/src/main/java/thebetweenlands/api/loot/LootTableView.java @@ -1,11 +1,15 @@ -package thebetweenlands.api.loot; +//TODO: Determine if this class should be removed. +/*package thebetweenlands.api.loot; -import net.minecraft.world.storage.loot.LootPool; -import net.minecraft.world.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.functions.LootItemFunction; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; public abstract class LootTableView extends LootTable { - public LootTableView() { - super(new LootPool[0]); + + public LootTableView(LootContextParamSet params, LootPool[] pool, LootItemFunction[] func) { + super(params, null, pool, func); } @Override @@ -13,3 +17,4 @@ public final boolean isFrozen() { return true; } } +*/ \ No newline at end of file diff --git a/src/main/java/thebetweenlands/api/misc/FogState.java b/src/main/java/thebetweenlands/api/misc/FogState.java index c93f31f6ad..6d7dede14d 100644 --- a/src/main/java/thebetweenlands/api/misc/FogState.java +++ b/src/main/java/thebetweenlands/api/misc/FogState.java @@ -3,17 +3,16 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; import net.minecraftforge.common.MinecraftForge; import thebetweenlands.api.event.UpdateFogEvent; import thebetweenlands.api.misc.Fog.FogType; import thebetweenlands.api.misc.Fog.MutableFog; import thebetweenlands.common.world.WorldProviderBetweenlands; -import thebetweenlands.common.world.biome.BiomeBetweenlands; public class FogState { private Fog targetFog; @@ -93,17 +92,18 @@ public Fog getFog() { * @param mode * @return */ - public Fog getBiomeFog(World world, Vec3d position, float farPlaneDistance, int mode) { + //TODO: Figure a way to make this work with new biomes. + public Fog getBiomeFog(Level world, Vec3i position, float farPlaneDistance, int mode) { MutableFog defaultBiomeFog = new MutableFog().setType(FogType.LINEAR).setDensity(0.0F).setColorIncrement(0.001F).setDistanceIncrementMultiplier(1.0F) .setRed(0.5F).setGreen(0.5F).setBlue(0.5F).setStart(farPlaneDistance).setEnd(farPlaneDistance).setColorMultiplier(1); - Biome biome = world.getBiome(new BlockPos(position)); + Biome biome = world.getBiome(new BlockPos(position)).get(); - if(biome instanceof BiomeBetweenlands) { - BiomeBetweenlands biomeBl = (BiomeBetweenlands) biome; - int[] fogColor = biomeBl.getFogRGB(); - defaultBiomeFog.setRed(fogColor[0] / 255.0F).setGreen(fogColor[1] / 255.0F).setBlue(fogColor[2] / 255.0F); - defaultBiomeFog.setStart(biomeBl.getFogStart(farPlaneDistance, mode)).setEnd(biomeBl.getFogEnd(farPlaneDistance, mode)); + if (biome instanceof Biome) { + Biome biomeBl = (Biome) biome; + int fogColor = biomeBl.getFogColor(); + defaultBiomeFog.setRed(fogColor % 65536 / 255.0F).setGreen(fogColor % 256 / 255.0F).setBlue(fogColor / 255.0F); + // defaultBiomeFog.setStart(biomeBl.getFogStart(farPlaneDistance, mode)).setEnd(biomeBl.getFogEnd(farPlaneDistance, mode)); //TODO: Make this work. } return defaultBiomeFog.toImmutable(); @@ -143,7 +143,7 @@ public float getLowDistanceFogReduction(float end) { * @param position * @return */ - public Fog getAmbientFog(Fog biomeFog, World world, Vec3d position) { + public Fog getAmbientFog(Fog biomeFog, Level world, Vec3i position) { MutableFog defaultAmbientFog = new MutableFog(biomeFog); //Reduced fog for those players with really low view distance @@ -153,18 +153,18 @@ public Fog getAmbientFog(Fog biomeFog, World world, Vec3d position) { float fixedFogStart = this.getFixedFogStart(defaultAmbientFog.getStart()); float fixedFogEnd = this.getFixedFogEnd(defaultAmbientFog.getEnd()); - if(position.y < WorldProviderBetweenlands.CAVE_START) { - float fogColorMultiplier = ((float)(WorldProviderBetweenlands.CAVE_START - position.y) / WorldProviderBetweenlands.CAVE_START); + if(position.getY() < WorldProviderBetweenlands.CAVE_START) { + float fogColorMultiplier = ((float)(WorldProviderBetweenlands.CAVE_START - position.getY()) / WorldProviderBetweenlands.CAVE_START); fogColorMultiplier = 1.0F - fogColorMultiplier; fogColorMultiplier *= Math.pow(fogColorMultiplier, 8.5); fogColorMultiplier = fogColorMultiplier * 0.95F + 0.05F; - if(position.y <= WorldProviderBetweenlands.PITSTONE_HEIGHT) { + if(position.getY() <= WorldProviderBetweenlands.PITSTONE_HEIGHT) { float targettedMultiplier = 0.3F; if(fogColorMultiplier < targettedMultiplier) { - fogColorMultiplier += Math.pow(((targettedMultiplier - fogColorMultiplier) / WorldProviderBetweenlands.PITSTONE_HEIGHT * (WorldProviderBetweenlands.PITSTONE_HEIGHT - position.y)), 0.85F); + fogColorMultiplier += Math.pow(((targettedMultiplier - fogColorMultiplier) / WorldProviderBetweenlands.PITSTONE_HEIGHT * (WorldProviderBetweenlands.PITSTONE_HEIGHT - position.getY())), 0.85F); } } - fogColorMultiplier = MathHelper.clamp(fogColorMultiplier, 0.1F, 1); + fogColorMultiplier = Mth.clamp(fogColorMultiplier, 0.1F, 1); fogColorMultiplier = Math.min(fogColorMultiplier, 1.0F); fogColorMultiplier = fogColorMultiplier + (1.0F - fogColorMultiplier) * (float)Math.pow(lowViewDistanceFogReduction, 2.25D); defaultAmbientFog.setStart(fixedFogStart * fogColorMultiplier); @@ -184,7 +184,7 @@ public Fog getAmbientFog(Fog biomeFog, World world, Vec3d position) { * @param mode * @return */ - public Fog getAmbientFog(World world, Vec3d position, float farPlaneDistance, int mode) { + public Fog getAmbientFog(Level world, Vec3i position, float farPlaneDistance, int mode) { return this.getAmbientFog(this.getBiomeFog(world, position, farPlaneDistance, mode), world, position); } @@ -195,7 +195,7 @@ public Fog getAmbientFog(World world, Vec3d position, float farPlaneDistance, in * @param farPlaneDistance * @param mode */ - public void update(World world, Vec3d position, float farPlaneDistance, int mode) { + public void update(Level world, Vec3i position, float farPlaneDistance, int mode) { Fog defaultBiomeFog = this.getBiomeFog(world, position, farPlaneDistance, mode); Fog defaultAmbientFog = this.getAmbientFog(defaultBiomeFog, world, position); diff --git a/src/main/java/thebetweenlands/api/network/IGenericDataManagerAccess.java b/src/main/java/thebetweenlands/api/network/IGenericDataManagerAccess.java index 2fc3addf64..ca6b257aa6 100644 --- a/src/main/java/thebetweenlands/api/network/IGenericDataManagerAccess.java +++ b/src/main/java/thebetweenlands/api/network/IGenericDataManagerAccess.java @@ -4,14 +4,14 @@ import javax.annotation.Nullable; -import net.minecraft.network.datasync.DataParameter; -import net.minecraft.util.ITickable; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.block.entity.TickingBlockEntity; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -public interface IGenericDataManagerAccess extends ITickable { +public interface IGenericDataManagerAccess extends TickingBlockEntity { public static interface IDataEntry { - public DataParameter getKey(); + public ResourceKey getKey(); public void setValue(T valueIn); @@ -32,12 +32,12 @@ public static interface IDataManagedObject { * @param fromPacket Whether the new value is from a packet * @return Return true if the change was handled and no further processing is required */ - public default boolean onParameterChange(DataParameter key, Object value, boolean fromPacket) { + public default boolean onParameterChange(ResourceKey key, Object value, boolean fromPacket) { return false; } } - public T get(DataParameter key); + public T get(ResourceKey key); public boolean isDirty(); @@ -47,7 +47,7 @@ public default boolean onParameterChange(DataParameter key, Object value, boo @Nullable public List> getAll(); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void setValuesFromPacket(List> newEntries); public boolean isEmpty(); @@ -55,5 +55,5 @@ public default boolean onParameterChange(DataParameter key, Object value, boo public void setClean(); @Override - public void update(); + public void tick(); } diff --git a/src/main/java/thebetweenlands/api/package-info.java b/src/main/java/thebetweenlands/api/package-info.java index 731e45b848..e2da9107a0 100644 --- a/src/main/java/thebetweenlands/api/package-info.java +++ b/src/main/java/thebetweenlands/api/package-info.java @@ -1,3 +1,4 @@ -@API(apiVersion = thebetweenlands.common.lib.ModInfo.API_VERSION, owner = thebetweenlands.common.lib.ModInfo.ID, provides = thebetweenlands.common.lib.ModInfo.API_NAME) +//TODO: Determine if this file should be removed. +/*@API(apiVersion = thebetweenlands.common.lib.ModInfo.API_VERSION, owner = thebetweenlands.common.lib.TheBetweenlands.MOD_ID, provides = thebetweenlands.common.lib.ModInfo.API_NAME) package thebetweenlands.api; -import net.minecraftforge.fml.common.API; \ No newline at end of file +import net.minecraftforge.fml.common.API*/ \ No newline at end of file diff --git a/src/main/java/thebetweenlands/api/recipes/IAnimatorRecipe.java b/src/main/java/thebetweenlands/api/recipes/IAnimatorRecipe.java index a194e8d5ed..17b4faac08 100644 --- a/src/main/java/thebetweenlands/api/recipes/IAnimatorRecipe.java +++ b/src/main/java/thebetweenlands/api/recipes/IAnimatorRecipe.java @@ -3,13 +3,13 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IAnimatorRecipe { /** @@ -39,7 +39,7 @@ public interface IAnimatorRecipe { * @return */ @Nullable - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public Entity getRenderEntity(ItemStack stack); /** @@ -67,13 +67,13 @@ public interface IAnimatorRecipe { * @return */ @Nonnull - public ItemStack onAnimated(World world, BlockPos pos, ItemStack stack); + public ItemStack onAnimated(Level world, BlockPos pos, ItemStack stack); /** - * Use {@link #onRetrieved(EntityPlayer, BlockPos, ItemStack)} instead + * Use {@link #onRetrieved(Player, BlockPos, ItemStack)} instead */ @Deprecated - public boolean onRetrieved(World world, BlockPos pos, ItemStack stack); + public boolean onRetrieved(Level world, BlockPos pos, ItemStack stack); /** * Called when the animator has finished animating and is right clicked. @@ -82,8 +82,8 @@ public interface IAnimatorRecipe { * @param pos * @param stack */ - public default boolean onRetrieved(EntityPlayer player, BlockPos pos, ItemStack stack) { - return this.onRetrieved(player.world, pos, stack); + public default boolean onRetrieved(Player player, BlockPos pos, ItemStack stack) { + return this.onRetrieved(player.level(), pos, stack); } /** diff --git a/src/main/java/thebetweenlands/api/recipes/ICenserRecipe.java b/src/main/java/thebetweenlands/api/recipes/ICenserRecipe.java index 4acdd13596..3f1137a22e 100644 --- a/src/main/java/thebetweenlands/api/recipes/ICenserRecipe.java +++ b/src/main/java/thebetweenlands/api/recipes/ICenserRecipe.java @@ -4,12 +4,12 @@ import javax.annotation.Nullable; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import thebetweenlands.api.aspect.IAspectType; import thebetweenlands.api.block.ICenser; @@ -97,7 +97,7 @@ public interface ICenserRecipe { * @param nbt * @param packet */ - public void save(Context context, NBTTagCompound nbt, boolean packet); + public void save(Context context, CompoundTag nbt, boolean packet); /** * Called when the censer reads its data and context is not null @@ -105,7 +105,7 @@ public interface ICenserRecipe { * @param nbt * @param packet */ - public void read(Context context, NBTTagCompound nbt, boolean packet); + public void read(Context context, CompoundTag nbt, boolean packet); /** * Called every tick while the recipe is running. @@ -140,7 +140,7 @@ public interface ICenserRecipe { * @param tooltip * @return */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void getLocalizedEffectText(@Nullable Context context, ICenser censer, List tooltip); public static enum EffectColorType { @@ -156,7 +156,7 @@ public static enum EffectColorType { * @param type * @return */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public int getEffectColor(@Nullable Context context, ICenser censer, EffectColorType type); /** @@ -168,7 +168,7 @@ public static enum EffectColorType { * @param z * @param partialTicks */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void render(@Nullable Context context, ICenser censer, double x, double y, double z, float partialTicks); /** diff --git a/src/main/java/thebetweenlands/api/recipes/ICompostBinRecipe.java b/src/main/java/thebetweenlands/api/recipes/ICompostBinRecipe.java index 324a72da17..272bb35ea5 100644 --- a/src/main/java/thebetweenlands/api/recipes/ICompostBinRecipe.java +++ b/src/main/java/thebetweenlands/api/recipes/ICompostBinRecipe.java @@ -1,6 +1,6 @@ package thebetweenlands.api.recipes; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; public interface ICompostBinRecipe { /** diff --git a/src/main/java/thebetweenlands/api/recipes/IDruidAltarRecipe.java b/src/main/java/thebetweenlands/api/recipes/IDruidAltarRecipe.java index f351dfa96b..733d9486c5 100644 --- a/src/main/java/thebetweenlands/api/recipes/IDruidAltarRecipe.java +++ b/src/main/java/thebetweenlands/api/recipes/IDruidAltarRecipe.java @@ -1,9 +1,8 @@ package thebetweenlands.api.recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import thebetweenlands.common.registries.BlockRegistry; +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public interface IDruidAltarRecipe { /** @@ -33,7 +32,7 @@ public interface IDruidAltarRecipe { * @param pos The position of the druid altar * @param input The input stacks */ - public default void onStartCrafting(World world, BlockPos pos, ItemStack[] input) { + public default void onStartCrafting(Level world, BlockPos pos, ItemStack[] input) { } @@ -43,7 +42,7 @@ public default void onStartCrafting(World world, BlockPos pos, ItemStack[] input * @param pos The position of the druid altar * @param input The input stacks */ - public default void onCrafting(World world, BlockPos pos, ItemStack[] input) { + public default void onCrafting(Level world, BlockPos pos, ItemStack[] input) { } @@ -55,9 +54,10 @@ public default void onCrafting(World world, BlockPos pos, ItemStack[] input) { * @param input The input stacks * @param output The output stack */ - public default void onCrafted(World world, BlockPos pos, ItemStack[] input, ItemStack output) { - if (world.getBlockState(pos.down()).getBlock() == BlockRegistry.MOB_SPAWNER) { - world.setBlockState(pos.down(), world.getBiome(pos).topBlock); - } + public default void onCrafted(Level world, BlockPos pos, ItemStack[] input, ItemStack output) { + //TODO: Figure out what to replace. + /*if (world.getBlockState(pos.below()).getBlock() == BlockRegistry.MOB_SPAWNER) { + world.setBlockState(pos.below(), world.getBiome(pos).topBlock); + }*/ } } diff --git a/src/main/java/thebetweenlands/api/recipes/IPestleAndMortarRecipe.java b/src/main/java/thebetweenlands/api/recipes/IPestleAndMortarRecipe.java index 4e673cb765..c03b2377ce 100644 --- a/src/main/java/thebetweenlands/api/recipes/IPestleAndMortarRecipe.java +++ b/src/main/java/thebetweenlands/api/recipes/IPestleAndMortarRecipe.java @@ -1,6 +1,6 @@ package thebetweenlands.api.recipes; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; public interface IPestleAndMortarRecipe { /** diff --git a/src/main/java/thebetweenlands/api/recipes/IPurifierRecipe.java b/src/main/java/thebetweenlands/api/recipes/IPurifierRecipe.java index 854de9a9f0..21ad4e297d 100644 --- a/src/main/java/thebetweenlands/api/recipes/IPurifierRecipe.java +++ b/src/main/java/thebetweenlands/api/recipes/IPurifierRecipe.java @@ -1,7 +1,7 @@ package thebetweenlands.api.recipes; -import mcp.MethodsReturnNonnullByDefault; -import net.minecraft.item.ItemStack; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.world.item.ItemStack; public interface IPurifierRecipe { /** diff --git a/src/main/java/thebetweenlands/api/sky/IBetweenlandsSky.java b/src/main/java/thebetweenlands/api/sky/IBetweenlandsSky.java index 500c8176d2..8b5cab8d06 100644 --- a/src/main/java/thebetweenlands/api/sky/IBetweenlandsSky.java +++ b/src/main/java/thebetweenlands/api/sky/IBetweenlandsSky.java @@ -1,25 +1,25 @@ package thebetweenlands.api.sky; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IBetweenlandsSky { - @SideOnly(Side.CLIENT) - public void render(float partialTicks, WorldClient world, Minecraft mc); + @OnlyIn(Dist.CLIENT) + public void render(float partialTicks, ClientLevel world, Minecraft mc); /** * Sets the rift renderer that renders the rift * @param maskRenderer */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void setRiftRenderer(IRiftRenderer renderer); /** * Returns the rift renderer * @return */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public IRiftRenderer getRiftRenderer(); } diff --git a/src/main/java/thebetweenlands/api/sky/IRiftMaskRenderer.java b/src/main/java/thebetweenlands/api/sky/IRiftMaskRenderer.java index 22512225ed..b2b091bae2 100644 --- a/src/main/java/thebetweenlands/api/sky/IRiftMaskRenderer.java +++ b/src/main/java/thebetweenlands/api/sky/IRiftMaskRenderer.java @@ -1,9 +1,9 @@ package thebetweenlands.api.sky; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IRiftMaskRenderer { /** @@ -13,8 +13,8 @@ public interface IRiftMaskRenderer { * @param mc * @param skyBrightness */ - @SideOnly(Side.CLIENT) - public void renderMask(float partialTicks, WorldClient world, Minecraft mc, float skyBrightness); + @OnlyIn(Dist.CLIENT) + public void renderMask(float partialTicks, ClientLevel world, Minecraft mc, float skyBrightness); /** * Renders the rift overlay @@ -23,8 +23,8 @@ public interface IRiftMaskRenderer { * @param mc * @param skyBrightness */ - @SideOnly(Side.CLIENT) - public void renderOverlay(float partialTicks, WorldClient world, Minecraft mc, float skyBrightness); + @OnlyIn(Dist.CLIENT) + public void renderOverlay(float partialTicks, ClientLevel world, Minecraft mc, float skyBrightness); /** * Renders the rift projection mesh @@ -33,6 +33,6 @@ public interface IRiftMaskRenderer { * @param mc * @param skyBrightness */ - @SideOnly(Side.CLIENT) - public void renderRiftProjection(float partialTicks, WorldClient world, Minecraft mc, float skyBrightness); + @OnlyIn(Dist.CLIENT) + public void renderRiftProjection(float partialTicks, ClientLevel world, Minecraft mc, float skyBrightness); } diff --git a/src/main/java/thebetweenlands/api/sky/IRiftRenderer.java b/src/main/java/thebetweenlands/api/sky/IRiftRenderer.java index 0472b59898..a63efd59a6 100644 --- a/src/main/java/thebetweenlands/api/sky/IRiftRenderer.java +++ b/src/main/java/thebetweenlands/api/sky/IRiftRenderer.java @@ -1,9 +1,11 @@ package thebetweenlands.api.sky; +import com.mojang.blaze3d.vertex.PoseStack; + import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IRiftRenderer { /** @@ -12,34 +14,34 @@ public interface IRiftRenderer { * @param world * @param mc */ - @SideOnly(Side.CLIENT) - public void render(float partialTicks, WorldClient world, Minecraft mc); + @OnlyIn(Dist.CLIENT) + public void render(PoseStack matrix, float partialTicks, ClientLevel world, Minecraft mc); /** * Sets the rift mask renderer that renders the rift mask and the overlay * @param maskRenderer */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void setRiftMaskRenderer(IRiftMaskRenderer maskRenderer); /** * Returns the rift mask renderer * @return */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public IRiftMaskRenderer getRiftMaskRenderer(); /** * Sets the rift sky renderer * @param skyRenderer */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void setRiftSkyRenderer(IRiftSkyRenderer skyRenderer); /** * Returns the rift sky renderer * @return */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public IRiftSkyRenderer getRiftSkyRenderer(); } diff --git a/src/main/java/thebetweenlands/api/sky/IRiftSkyRenderer.java b/src/main/java/thebetweenlands/api/sky/IRiftSkyRenderer.java index c232f357e7..525b43a1d3 100644 --- a/src/main/java/thebetweenlands/api/sky/IRiftSkyRenderer.java +++ b/src/main/java/thebetweenlands/api/sky/IRiftSkyRenderer.java @@ -1,9 +1,9 @@ package thebetweenlands.api.sky; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IRiftSkyRenderer { /** @@ -12,8 +12,8 @@ public interface IRiftSkyRenderer { * @param world * @param mc */ - @SideOnly(Side.CLIENT) - public void setClearColor(float partialTicks, WorldClient world, Minecraft mc); + @OnlyIn(Dist.CLIENT) + public void setClearColor(float partialTicks, ClientLevel world, Minecraft mc); /** * Renders the sky inside the rift @@ -21,8 +21,8 @@ public interface IRiftSkyRenderer { * @param world * @param mc */ - @SideOnly(Side.CLIENT) - public void render(float partialTicks, WorldClient world, Minecraft mc); + @OnlyIn(Dist.CLIENT) + public void render(float partialTicks, ClientLevel world, Minecraft mc); /** * Returns the sky's relative brightness between 0 and 1 @@ -31,6 +31,6 @@ public interface IRiftSkyRenderer { * @param mc * @return */ - @SideOnly(Side.CLIENT) - public float getSkyBrightness(float partialTicks, WorldClient world, Minecraft mc); + @OnlyIn(Dist.CLIENT) + public float getSkyBrightness(float partialTicks, ClientLevel world, Minecraft mc); } diff --git a/src/main/java/thebetweenlands/api/storage/IChunkStorage.java b/src/main/java/thebetweenlands/api/storage/IChunkStorage.java index d2d7bf7389..cdbe06f707 100644 --- a/src/main/java/thebetweenlands/api/storage/IChunkStorage.java +++ b/src/main/java/thebetweenlands/api/storage/IChunkStorage.java @@ -4,9 +4,9 @@ import javax.annotation.Nullable; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.capabilities.ICapabilityProvider; public interface IChunkStorage extends ICapabilityProvider { @@ -20,7 +20,7 @@ public interface IChunkStorage extends ICapabilityProvider { * Returns the chunk of this chunk storage * @return */ - public Chunk getChunk(); + public LevelChunk getChunk(); /** * Called when the chunk storage is initialized before any data is loaded @@ -42,14 +42,14 @@ public interface IChunkStorage extends ICapabilityProvider { * @param nbt NBT * @param packet Whether the NBT is being read from a packet */ - public void readFromNBT(NBTTagCompound nbt, boolean packet); + public void load(CompoundTag nbt, boolean packet); /** * Reads the local storage references from NBT * @param nbt * @return */ - public NBTTagCompound readLocalStorageReferences(NBTTagCompound nbt); + public CompoundTag readLocalStorageReferences(CompoundTag nbt); /** * Writes the chunk storage data to NBT @@ -57,39 +57,39 @@ public interface IChunkStorage extends ICapabilityProvider { * @param packet Whether the NBT is being written to a packet * @return */ - public NBTTagCompound writeToNBT(NBTTagCompound nbt, boolean packet); + public CompoundTag save(CompoundTag nbt, boolean packet); /** * Writes the local storage references to NBT * @param nbt * @return */ - public NBTTagCompound writeLocalStorageReferences(NBTTagCompound nbt); + public CompoundTag writeLocalStorageReferences(CompoundTag nbt); /** * Adds a watcher * @param player * @return True if the player wasn't watching yet */ - public boolean addWatcher(EntityPlayerMP player); + public boolean addWatcher(ServerPlayer player); /** * Removes a watcher * @param player * @return True if the player was watching */ - public boolean removeWatcher(EntityPlayerMP player); + public boolean removeWatcher(ServerPlayer player); /** * Returns an unmodifiable list of all current watching players * @return */ - public Collection getWatchers(); + public Collection getWatchers(); /** * Marks the chunk storage and the chunk as dirty */ - public void markDirty(); + public void setChanged(); /** * Sets whether the chunk storage is dirty. diff --git a/src/main/java/thebetweenlands/api/storage/IDeferredStorageOperation.java b/src/main/java/thebetweenlands/api/storage/IDeferredStorageOperation.java index f202d1d568..c687db5f44 100644 --- a/src/main/java/thebetweenlands/api/storage/IDeferredStorageOperation.java +++ b/src/main/java/thebetweenlands/api/storage/IDeferredStorageOperation.java @@ -1,6 +1,6 @@ package thebetweenlands.api.storage; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; public interface IDeferredStorageOperation { /** @@ -13,12 +13,12 @@ public interface IDeferredStorageOperation { * Reads the deferred storage operation data from NBT. * @param nbt */ - public void readFromNBT(NBTTagCompound nbt); + public void load(CompoundTag nbt); /** * Writes the deferred storage operation data to NBT. * @param nbt * @return */ - public NBTTagCompound writeToNBT(NBTTagCompound nbt); + public CompoundTag save(CompoundTag nbt); } diff --git a/src/main/java/thebetweenlands/api/storage/ILocalStorage.java b/src/main/java/thebetweenlands/api/storage/ILocalStorage.java index a6ebb84d28..3313f5b6cd 100644 --- a/src/main/java/thebetweenlands/api/storage/ILocalStorage.java +++ b/src/main/java/thebetweenlands/api/storage/ILocalStorage.java @@ -5,15 +5,14 @@ import javax.annotation.Nullable; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ITickable; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.phys.AABB; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import thebetweenlands.api.network.IGenericDataManagerAccess; public interface ILocalStorage extends ICapabilityProvider { @@ -28,7 +27,7 @@ public interface ILocalStorage extends ICapabilityProvider { * @return */ @Nullable - public AxisAlignedBB getBoundingBox(); + public AABB getBoundingBox(); /** * Returns whether the local storage is loaded @@ -54,7 +53,7 @@ public interface ILocalStorage extends ICapabilityProvider { * {@link #getID()} and {@link #getRegion()} are already read automatically * @param nbt */ - public void readFromNBT(NBTTagCompound nbt); + public void load(CompoundTag nbt); /** * Writes the local storage data to NBT. @@ -62,25 +61,25 @@ public interface ILocalStorage extends ICapabilityProvider { * @param nbt * @return */ - public NBTTagCompound writeToNBT(NBTTagCompound nbt); + public CompoundTag save(CompoundTag nbt); /** * Reads the initial data that is sent the first time * @param nbt */ - public void readInitialPacket(NBTTagCompound nbt); + public void readInitialPacket(CompoundTag nbt); /** * Writes the initial data that is sent the first time * @param nbt * @return */ - public NBTTagCompound writeInitialPacket(NBTTagCompound nbt); + public CompoundTag writeInitialPacket(CompoundTag nbt); /** * Marks the local storage as dirty */ - public void markDirty(); + public void setChanged(); /** * Sets whether the local storage is dirty @@ -104,7 +103,7 @@ public interface ILocalStorage extends ICapabilityProvider { * Sets the linked chunks. Only for use on client side for syncing * @param linkedChunks New linked chunks */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void setLinkedChunks(List linkedChunks); /** @@ -164,7 +163,7 @@ public default void onRemoving() { * @param player * @return True if the player wasn't watching yet */ - public boolean addWatcher(IChunkStorage chunkStorage, EntityPlayerMP player); + public boolean addWatcher(IChunkStorage chunkStorage, ServerPlayer player); /** * Removes a watcher of the specified chunk storage. @@ -174,13 +173,13 @@ public default void onRemoving() { * @param player * @return True if the player was watching */ - public boolean removeWatcher(IChunkStorage chunkStorage, EntityPlayerMP player); + public boolean removeWatcher(IChunkStorage chunkStorage, ServerPlayer player); /** * Returns an unmodifiable list of all current watching players * @return */ - public Collection getWatchers(); + public Collection getWatchers(); /** * Unlinks all chunks from this local storage. @@ -196,7 +195,7 @@ public default void onRemoving() { * @param chunk * @return True if the chunk was linked successfully */ - public boolean linkChunk(Chunk chunk); + public boolean linkChunk(LevelChunk chunk); /** * Links the specified chunk to this local storage using a deferred @@ -209,13 +208,13 @@ public default void linkChunkDeferred(ChunkPos chunk) { /** * Links the specified chunk to this local storage in a safe manner, - * i.e. calls {@link #linkChunk(Chunk)} if the chunk already exists and is loaded, + * i.e. calls {@link #linkChunk(LevelChunk)} if the chunk already exists and is loaded, * and {@link #linkChunkDeferred(ChunkPos)} if the chunk does not yet exist * or is not loaded. * @param chunk */ public default void linkChunkSafely(ChunkPos chunk) { - Chunk instance = this.getWorldStorage().getWorld().getChunkProvider().getLoadedChunk(chunk.x, chunk.z); + LevelChunk instance = this.getWorldStorage().getLevel().getChunkSource().getChunkNow(chunk.x, chunk.z); if(instance != null) { this.linkChunk(instance); } else { @@ -231,7 +230,7 @@ public default void linkChunkSafely(ChunkPos chunk) { * @param chunk * @return True if the chunk was unlinked successfully */ - public boolean unlinkChunk(Chunk chunk); + public boolean unlinkChunk(LevelChunk chunk); /** * Returns the data manager used to sync data.

    Only storages that implement {@link ITickable} diff --git a/src/main/java/thebetweenlands/api/storage/ILocalStorageHandler.java b/src/main/java/thebetweenlands/api/storage/ILocalStorageHandler.java index 9f110769c9..3bdbd5dba6 100644 --- a/src/main/java/thebetweenlands/api/storage/ILocalStorageHandler.java +++ b/src/main/java/thebetweenlands/api/storage/ILocalStorageHandler.java @@ -8,11 +8,10 @@ import com.google.common.base.Predicate; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ITickable; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.ChunkPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.phys.AABB; public interface ILocalStorageHandler { /** @@ -61,7 +60,7 @@ public interface ILocalStorageHandler { * @param type * @return */ - public List getLocalStorages(Class type, AxisAlignedBB aabb, @Nullable Predicate filter); + public List getLocalStorages(Class type, AABB aabb, @Nullable Predicate filter); /** * Deletes the file (or entry if in a region) of @@ -122,13 +121,13 @@ public interface ILocalStorageHandler { public File getLocalStorageDirectory(); /** - * Creates a local storage instance from the specified NBT, saved by {@link #saveLocalStorageToNBT(NBTTagCompound, ILocalStorage)} + * Creates a local storage instance from the specified NBT, saved by {@link #saveLocalStorageToNBT(CompoundTag, ILocalStorage)} * @param nbt * @param region * @param packet * @return */ - public ILocalStorage createLocalStorageFromNBT(NBTTagCompound nbt, LocalRegion region); + public ILocalStorage createLocalStorageFromNBT(CompoundTag nbt, LocalRegion region); /** * Creates a new local storage @@ -160,7 +159,7 @@ public interface ILocalStorageHandler { * @param packet * @return */ - public NBTTagCompound saveLocalStorageToNBT(NBTTagCompound nbt, ILocalStorage storage); + public CompoundTag saveLocalStorageToNBT(CompoundTag nbt, ILocalStorage storage); /** * Saves all local storages and regions diff --git a/src/main/java/thebetweenlands/api/storage/IOfflinePlayerDataHandler.java b/src/main/java/thebetweenlands/api/storage/IOfflinePlayerDataHandler.java index 854dad5935..8622ed68e3 100644 --- a/src/main/java/thebetweenlands/api/storage/IOfflinePlayerDataHandler.java +++ b/src/main/java/thebetweenlands/api/storage/IOfflinePlayerDataHandler.java @@ -4,7 +4,7 @@ import javax.annotation.Nullable; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; public interface IOfflinePlayerDataHandler { public void updateCache(); @@ -12,20 +12,20 @@ public interface IOfflinePlayerDataHandler { /** * Returns offline data specific to the player with the specified UUID. * This data is always available, regardless of whether the player is on- or offline. - * Use {@link #setOfflinePlayerData(UUID, NBTTagCompound)} after changing data to make sure it + * Use {@link #setOfflinePlayerData(UUID, CompoundTag)} after changing data to make sure it * is saved. * @param playerUuid * @return */ @Nullable - public NBTTagCompound getOfflinePlayerData(UUID playerUuid); + public CompoundTag getOfflinePlayerData(UUID playerUuid); /** * Sets the offline data of the player with the specified UUID. * @param playerUuid * @param nbt */ - public void setOfflinePlayerData(UUID playerUuid, NBTTagCompound nbt); + public void setOfflinePlayerData(UUID playerUuid, CompoundTag nbt); /** * Saves all offline player data to disk. diff --git a/src/main/java/thebetweenlands/api/storage/IWorldStorage.java b/src/main/java/thebetweenlands/api/storage/IWorldStorage.java index 331a52e2e1..5659ae6ebd 100644 --- a/src/main/java/thebetweenlands/api/storage/IWorldStorage.java +++ b/src/main/java/thebetweenlands/api/storage/IWorldStorage.java @@ -2,12 +2,12 @@ import javax.annotation.Nullable; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.LevelChunk; import thebetweenlands.api.entity.spawning.IBiomeSpawnEntriesData; public interface IWorldStorage { @@ -15,32 +15,32 @@ public interface IWorldStorage { * Writes the world data to the nbt * @param nbt */ - public void writeToNBT(NBTTagCompound nbt); + public void save(CompoundTag nbt); /** * Reads the world data from the nbt * @param nbt */ - public void readFromNBT(NBTTagCompound nbt); + public void load(CompoundTag nbt); /** * Returns the world instance * @return */ - public World getWorld(); + public Level getLevel(); /** * Called when a chunk storage needs to be read from the specified NBT and loaded * @param chunk * @param nbt */ - public void readAndLoadChunk(Chunk chunk, NBTTagCompound nbt); + public void readAndLoadChunk(LevelChunk chunk, CompoundTag nbt); /** * Called when a new chunk is loaded without any NBT data * @param chunk */ - public void loadChunk(Chunk chunk); + public void loadChunk(LevelChunk chunk); /** * Saves the chunk storage data to NBT. May return @@ -49,34 +49,34 @@ public interface IWorldStorage { * @return */ @Nullable - public NBTTagCompound saveChunk(Chunk chunk); + public CompoundTag saveChunk(LevelChunk chunk); /** * Called when a chunk is unloaded * @param chunk */ - public void unloadChunk(Chunk chunk); + public void unloadChunk(LevelChunk chunk); /** * Called when a player starts watching the specified chunk * @param pos * @param player */ - public void watchChunk(ChunkPos pos, EntityPlayerMP player); + public void watchChunk(ChunkPos pos, ServerPlayer player); /** * Called when a player stops watching the specified chunk * @param pos * @param player */ - public void unwatchChunk(ChunkPos pos, EntityPlayerMP player); + public void unwatchChunk(ChunkPos pos, ServerPlayer player); /** * Returns the chunk storage of the specified chunk * @param pos * @return */ - public IChunkStorage getChunkStorage(Chunk chunk); + public IChunkStorage getChunkStorage(LevelChunk chunk); /** * Returns the local storage handler responsible for loading and diff --git a/src/main/java/thebetweenlands/api/storage/LocalRegion.java b/src/main/java/thebetweenlands/api/storage/LocalRegion.java index 96f9b946b1..3747aec418 100644 --- a/src/main/java/thebetweenlands/api/storage/LocalRegion.java +++ b/src/main/java/thebetweenlands/api/storage/LocalRegion.java @@ -1,7 +1,7 @@ package thebetweenlands.api.storage; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; /** * One region spans over 32x32 chunks. Any {@link ILocalStorage} assigned to a region will be saved in that region file. @@ -66,9 +66,9 @@ public String getFileName() { * @param nbt * @return */ - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setInteger("x", this.x); - nbt.setInteger("z", this.z); + public CompoundTag save(CompoundTag nbt) { + nbt.putInt("x", this.x); + nbt.putInt("z", this.z); return nbt; } @@ -77,8 +77,8 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { * @param nbt * @return */ - public static LocalRegion readFromNBT(NBTTagCompound nbt) { - return new LocalRegion(nbt.getInteger("x"), nbt.getInteger("z")); + public static LocalRegion load(CompoundTag nbt) { + return new LocalRegion(nbt.getInt("x"), nbt.getInt("z")); } @Override diff --git a/src/main/java/thebetweenlands/api/storage/LocalStorageReference.java b/src/main/java/thebetweenlands/api/storage/LocalStorageReference.java index 764f654e97..956c6df60b 100644 --- a/src/main/java/thebetweenlands/api/storage/LocalStorageReference.java +++ b/src/main/java/thebetweenlands/api/storage/LocalStorageReference.java @@ -2,8 +2,8 @@ import javax.annotation.Nullable; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.ChunkPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.ChunkPos; public class LocalStorageReference { private final ChunkPos chunkPos; @@ -41,13 +41,13 @@ public LocalStorageReference(ILocalStorageHandle handle, StorageID id, @Nullable * @param nbt * @return */ - public static LocalStorageReference readFromNBT(NBTTagCompound nbt) { - ChunkPos pos = new ChunkPos(nbt.getInteger("x"), nbt.getInteger("z")); + public static LocalStorageReference load(CompoundTag nbt) { + ChunkPos pos = new ChunkPos(nbt.getInt("x"), nbt.getInt("z")); LocalRegion region = null; - if(nbt.hasKey("region")) { - region = LocalRegion.readFromNBT(nbt.getCompoundTag("region")); + if(nbt.contains("region")) { + region = LocalRegion.load(nbt.getCompound("region")); } - return new LocalStorageReference(pos, StorageID.readFromNBT(nbt), region); + return new LocalStorageReference(pos, StorageID.load(nbt), region); } /** @@ -55,12 +55,12 @@ public static LocalStorageReference readFromNBT(NBTTagCompound nbt) { * @param nbt * @return */ - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - this.id.writeToNBT(nbt); - nbt.setInteger("x", this.chunkPos.x); - nbt.setInteger("z", this.chunkPos.z); + public CompoundTag save(CompoundTag nbt) { + this.id.save(nbt); + nbt.putInt("x", this.chunkPos.x); + nbt.putInt("z", this.chunkPos.z); if(this.region != null) { - nbt.setTag("region", this.region.writeToNBT(new NBTTagCompound())); + nbt.put("region", this.region.save(new CompoundTag())); } return nbt; } diff --git a/src/main/java/thebetweenlands/api/storage/StorageID.java b/src/main/java/thebetweenlands/api/storage/StorageID.java index 6705e478a1..e05fa10b73 100644 --- a/src/main/java/thebetweenlands/api/storage/StorageID.java +++ b/src/main/java/thebetweenlands/api/storage/StorageID.java @@ -2,8 +2,8 @@ import javax.annotation.Nullable; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.Constants; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; public class StorageID { private final String strID; @@ -16,14 +16,14 @@ public static StorageID fromString(String id) { return new StorageID(id); } - public final NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setString("id", this.strID); + public final CompoundTag save(CompoundTag nbt) { + nbt.putString("id", this.strID); return nbt; } @Nullable - public static StorageID readFromNBT(NBTTagCompound nbt) { - if(nbt.hasKey("id", Constants.NBT.TAG_STRING)) { + public static StorageID load(CompoundTag nbt) { + if(nbt.contains("id", Tag.TAG_STRING)) { return new StorageID(nbt.getString("id")); } return null;